Hi, Mike, Robert, folks,

    Thanks for the help from this list, I've decided to use a 
uniform to solve the problem of switching lighting mode between 
fragments. My idea is to add the program and a LightingOn uniform 
to the stateset of the root node of the scenegraph, and set its 
value to 0 wherever the stateset of a node has GL_LIGHTING off, 
and to 1 wherever GL_LIGHTING is on. However, on a closer 
thought, here comes a problem. For the GL_LIGHTING mode in the 
stateset of a node, I can set it to whatever value and it won't 
affect that in the stateset of a different node, and individual
glEnable(GL_LIGHTING) and glDisable(GL_LIGHTING) will be called 
during the draw stage. But if I'm sharing a uniform, is it that 
during the draw stage only one call to glUniform() for that 
uniform will take place, and its value will be that of the last 
call to Uniform::Set() before the draw stage? How do I make 
multiple glUniform() calls to the same uniform take place during 
the draw stage alongside glEnable/glDisable(GL_LIGHTING)? I 
don't think it's correct to create a separate osg::Uniform for 
each node, which in the minimum will induce multiple   
glGetUniformLocation() calls? Can I use a callback? A draw 
callback? 

    A second approach is to create two sets of shaders and two 
programs, one for non lit fragments, and another for lit fragments. 
Then I just set the appropriate program to the stateset of each 
node in the scenegraph. Will this work? I imagine there may be 
thousands of glUseProgram() calls during each draw. I don't know 
how big an impact it will be on the performance. 

    Thanks!

    Yefei
    


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to