RGB as Uint32 in Mesh ColorBuffer

Is there an easy way to have the color Buffer of mesh as a Uint32Array so that there is only 32 bits per vertex instead of 86 bits (3 x float 32 bits) ?

I did not fin any PG doing that, but I might have missed it.

Thanks
Julien

They are uint8 array at the moment so it should already be the case :slight_smile:

1 Like

Thanks for you answer @sebavan

Typescript does not really like the assignement of a Uint8Array to a FloatArray… But at least I could “force it” to accept it.

Still, is it a world where I can be put RGBA value between 0 and 255 instead of just 0 or 1 ? Is there an example of a fragment shader that do the job of converting this 4 [0-255] values into a vec4 ?

You need to use normalized values for this. This is achievable by providing your own buffer https://playground.babylonjs.com/#VKBJN#3642

3 Likes

Wow, I did not know you can tell WebGL to normalize the values ! Thanks a lot!