Joel Graff | 20 May 2012 06:06
Picon

Re: Problem using OSG GLSL uniforms and vertex attributes

Just as a followup, I did discover why OSG was adding the MVP and Vertex declarations to the vertex file.  I had
previously started with version 120 code that included the line

Code:

gl_Position = ftransform();

In my effort to carefully transition from 120 to 140+, I only commented out the ftransform() statement - I
didn't remove it.  

Thus, my transitioned code looked like:

Code:

gl_Position = osg_ModelViewProjectionMatrix * osg_Vetex; //ftransform(); 

The automatic conversion, then, saw the call to ftransform() and did what it was supposed to do - replaced
ftranform() with osg_MVP * osg_Vertex and declared both at the start of the file.  The end result would be
that osg_MVP and osg_Vertex get declared twice (once by me and once by the auto converter) and the
gl_Position statement ends up looking like:

Code:

gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; //osg_ModelViewProjectionMatrix * osg_Vertex;

I suppose that's a bug, which requires detecting commented code in the source string to fix, but I can't
imagine anyone else but me would go to the effort to create the condition that caused it...

Anyway, the moral of the story is: don't leave any commented out calls to ftransform() in legacy shader code!

Whoops. :)

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


Gmane