Hi Roger,

Not even. As I said, uniforms can be set anywhere you need them in your scene graph (in the stateset of any node/drawable).

I should add: it's your responsibility to make sure that the uniforms that your shaders expect actually exist and have the correct values at the right points. Meaning that if the shader needs a uniform called "shadows_enabled", OSG will not check if a uniform with that name actually exists in your scene graph at the correct point(s). If it doesn't, or if it does but only for some objects in the scene graph, then the value will probably be garbage in the shader at some point, and the results will be wrong (perhaps in subtle ways).

I think you're expecting this to be more "automatic" or "rigid" (at least based on the assumptions you make), but it's pretty free-form. There are many ways to make subtle mistakes, but also lots of flexibility. The coupling between shaders and uniforms is very loose (at least at the OSG level).

The same for vertex attributes... You set these in your geometry objects and then if your shader needs them it finds them, but if it needs them and can't find them then errors arise, and there's no formal mechanism to verify that they exist where they should.

I'm just rambling here, but I once had a lighting problem that was pretty hard to track down. It turned up that in certain conditions (i.e. a given combination of if-then-else branches), I had forgotten to set the value of a varying variable in the vertex shader, which the fragment shader then used to calculate the lighting. So in those cases, the varying was garbage when it came time to use it in the fragment shader. That's another case where there's no validation. In that case, that could have been detected by static analysis of the vertex/fragment shader pair. We're pretty spoiled with the strong checking compilers have now (for example, "variable used before it was initialized"), and this just isn't the case for shaders (yet?).

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to