Per vertex static color and dynamic alpha

Hello Folks

I have a situation where I render a mesh with per vertex colors using glDrawElements() where I pass the per vertex colors as RGBA color array with the same initial alpha (A) set for each vertex but with different RGB values for each vertex

It works well in all situations except when I need to change the alpha for the entire mesh, where I end up going through the RGBA color array and change the alpha for each vertex to the current alpha.

Is there an easier way by which I can change the alpha for the entire mesh at the same time apply per vertex colors, without going through the color array changing alpha values for each vertex during a alpha value change.

Considering the color array is arranged like this RGBARGBARGBA…Is there a C language specific memory or buffer intialization function that I can depend on to change the values of all alpha components to the same value in a simpler way.

Thanks in advance!
-Binoy

I would suggest removing alpha from the vertex array and deriving it from the texture environment constant color (GL_TEXTURE_ENV_COLOR) instead. You can do this using ARB_texture_env_combine: set the last active texture unit’s alpha combine mode to GL_REPLACE, using GL_CONSTANT as the source.

– Tom

Or you can use material properties, or you can use lighting properties … this is all the same.

You could use programs and pass your alpha value as a constant, …

SeskaPeel.

Any extensions are out of limits to me as this app is meant to work even on the software renderer. So ARB_texture_env_combine may not be good for me.

And regarding material properties to get alpha, it works, but then it distorts the per vertex color. In this app, per vertex color conveys some quanditative data and material/lighting will distort what the vertex color is trying to convey.

BTW, Is there a way to specify separate color and alpha arrays while using vertex arrays?

Hello Folks,

I managed to solve this problem by maintaining a 1D texture of width 1 in GL_LUMINANCE_ALPHA format, where I decided to keep the dynamic alpha value with a luminance value of 1.0.

And then applied this texture to all vertices with per vertex colors applied. The result, static vertex colors, with dynamic alpha. And I need to update only one single float value rather than alpha components of all vertex colors.
Thanks to everybody who helped me out.
Specially TOM, for making me think of textures as an option to solve this issue.

-3dguy

Sounds like you want SUN_global_alpha . Too bad it’s almost universally unsupported. :frowning:

Hey,

It’s good to hear that an OGL extension exist to do the same.

Thanks
3dguy