[osg-users] Secondary Color not working?

umesh ramesh mailpm01 at yahoo.co.in
Tue Feb 14 02:37:32 PST 2017


Hi,

There seems to be a bug in OSG related to accessing secondary colors in vertex shader. I am using OSG 3.2.1. The same issue might also exist in OSG 3.4 too.
Here’s how I found out the issue:
I want to pass 8 attributes from my osg App to the shader. Then I need to retrieve those 8 attributes in vertex shader & perform my operations on them.
Note: In Italics are Pseudo code, not actual syntax.

I use primary color as…

geometry.setColorArray(colors); 
geometry.setColorBinding(BIND_PER_VERTEX);

…in my osg App to pass the first 4 parameters. 

I use secondary color…

geometry.setSecondaryColorArray(secondcolors);
geometry.setSecondaryColorBinding(BIND_PER_VERTEX);

… to pass rest 4 parameters to shader.

In shader, I access…
	texWeight[0] = gl_Color[0];
	...
	texWeight[4] = gl_SecondaryColor[0];
	...
…to do my operations. But all (or some) of the 4 secondary color values are not proper or invalid.
So as a work around, I am using …

geometry.setTexCoordArray(0, secondcolors);

..and in shader
…
texWeight[8] = gl_MultiTexCoord0.s;   or    gl_TexCoord[0].

The above is working fine.

To cross verify, I wrote the exact code in OpenGL and used:

glSecondaryColorPointer( 4, GL_FLOAT, 0, &SecColorBuffer[0] );

In shader…

texWeight[4] = gl_SecondaryColor[0];.

This worked perfectly. I am using Nvidia GPU.
Thus, I concluded that there’s maybe a bug in using SecondaryColor method in OSG.


Thank you!

Cheers,
umesh

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70183#70183








More information about the osg-users mailing list