Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Red Vertex Color in CopperCube

olprint
Registered User
Quote
2023-09-08 15:29:54

When I get a vertex color that is red, the value -12648448 is returned. How is that number obtained?


Dieter
Guest
Quote
2023-09-08 16:04:30

If you print this as 32 bt hexadecimal, then it reads:

FF3F0000

Which is a bit weird but basically: each two digits are a 8 bit channel: alpha, red green blue.

This is 255, 63,0,0

So red is 63. You see if you'd go higher, you can make it brighter than the original. That's why I said weird, as i ^n the past we use 0 to 255 for red green blue.

Here's js, returning HEX$:
a=-12648448;
b=a.toString(16);
alert(b);


Dieter
Guest
Quote
2023-09-08 16:19:31

While we're on the topic, I may add:

This is how you extract the channel values

a=-12648448;
alpha=(a & 0xFF000000)>>>24;
red=(a & 0xFF0000)>>>16;
green=(a & 0xFF00)>>>8;
blue=(a & 0xFF);

So these are now values from 0 to 255.

Assemble it back, maybe after altering them:

a=(alpha<<24) | (red<<16) | (green <<8) | blue;


But if I'm not mistaken, there is even a function in CC that does the converting for you. Either way it's good to know I guess.


olprint
Registered User
Quote
2023-09-08 16:59:26

Thank you Dieter. I learnt new things from your answer.
Further, I used Blender to assign the red color, and exported as .dae, I don't know if that's the problem.


Dieter
Guest
Quote
2023-09-08 18:07:03

If it looks ok in CC then I'd say there is no problem.
Sometimes CC has problems with the vertex colors, then you see like dark triangles mixed with bright ones. It usually helps then to go: edit> modify scenenode> set vertex colors, and set them to 63,63,63.


olprint
Registered User
Quote
2023-09-08 19:02:54

I wanted to place interactive objects on a spiral mesh (1 object), where 365 colors will be something unique to mark those interactive objects.
Thanks again. I might run a loop and create a map for corresponding values.


Guest
Guest
Quote
2023-09-08 23:02:18

Maybe this might help you, this was on his old site, this guy is a goat when it comes to CC. But most of his work is underrated.

https://vazahat.github.io/CS_col...


olprint
Registered User
Quote
2023-09-09 01:04:14

Wonderful! Thanks for the link. Many other things to explore there.
About the problem: Red remained red when I used Blender python scripting to add vertex colors.
I guess there is a big difference between adding the colors directly (scripting) and adding a color as material.
I'm new to all these things.


Dieter
Guest
Quote
2023-09-09 19:41:22

Vertex color really has nothing to do with the material, except for one flag that defines whether vertex color should have an impact at all. See it as an additional filter, that's interpolating the vertex colors on the model surface, between vertices of varing colors.

So make sure your export settings enable vertex color, not ust by adding the color data, but also by the respective material settings.

I can only speak in regards to the B3D format, however if you're interested, I have released a socalled "tree tweaking utility" as part of the fancy terrain generator project.
It loads an alpha-mask-textured mesh, sets some vertex colors and then saves it as B3D, that loads in CC.
It comes with sourcecode, which is blitzbasic, so you could convert the mesh saving code with relative ease, I would guess - depending on your coding skills, but as you work with python, you may be a coder.
https://jfkeo1010etc.itch.io/fancy-procedural-terrain/devlog/348566/trees-tweaking-utility-released
It was for me very valuable to have the entire export code for B3D (well, static at least).
For example I wrote that terrain generator for windows, it makes a lot of use of vertex color (eg. sea ground, tree shadows, shading of grass), which was nice in its own, but to be able to save it as B3D and load it in CC just rocks.


olprint
Registered User
Quote
2023-09-10 08:26:22

Cool. Thanks for the link. I will see what I can do with those.
Thanks for the explanation. I am starting to/have realized that.


just_in_case
Moderator
Quote
2023-09-11 06:55:55

If you want your models to have vertex color data then you can also simply export your model in .Dae format using blender (work for static mesh only) and then import that .dae model in CC, and it will have all the color data as well. B3D also works great, and that Terrian tool by @dieter was great.


okeoke
Registered User
Quote
2023-09-11 08:50:28

O_O

It just works. You don't have to use any workarounds or shaders, just convert to dae and import. I wish it was documented somewhere, could save some time for me.


olprint
Registered User
Quote
2023-09-11 09:47:21

Thank you just_in_case.
Thank you okeoke.
But... the problem was:
Give the default cube in blender red, and import into CopperCube and see if the red will remain red.

Now... the problem is no longer a problem for me.


olprint
Registered User
Quote
2023-09-11 09:53:15

I am referring to vertex colors.
The one returned by CopperCube's ccbGetMeshBufferVertexColor(node, meshbufferindex, vertexindex).


okeoke
Registered User
Quote
2023-09-11 10:48:39

So, it works for me:
🔎︎


I also had to add a material which takes vertex color as an input.
When creating color attributes, I pick face corner/byte color.

Are you looking for something more specific?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact