Hi Phil,

Its a blind shot but try setting up empty osg::Program at scene root.

There is a chance that somehow your first encountered shader was assumed to be stage default by OSG. And since you don't set anything at the root it may leak on second frame render. Its just a guess. This is a weak hypothesis and don't ask me about solid proof ;-)

Wojtek


--------------------------------------------------
From: "Phil Fugue" <[email protected]>
Sent: Tuesday, June 22, 2010 9:42 PM
To: <[email protected]>
Subject: [osg-users] OpenGL Shader application problem

Hi,

An odd problem, and not sure quite how to describe. But here goes....

The quick summary is: When I cull certain geometry from my scene, an openGL shader seems to get applied to the root node (and thus the whole scene) rather than just the geometry it belongs on, but ONLY at the start up of the app. When those same conditions are in place later, it works just fine. Whats happening at start up?

More detailed: I have two pieces of geometry (geom1, geom2), they both have individual shaders applied to them respectively (shad1, shad2). I have keyboard controls to toggle the geometry on and off in the scene. My first hacky attempt at toggling (for quickness, and lack of knowledge of other mechanisms), I just translated the geometry out of view to toggle them 'off'. So on start up both geoms were 'off' out of view. But having geom2 out of view at startup resulted in shad1 being applied to the root node. When I toggled it (or anything else) 'on', all the sudden all shaders were applied appropriately. And remained correct for all toggling off and on. I.e, the startup error was not reproducable once into the app. And geom1 and geom2 are totally unrelated. Both are children of the root.

After finding the osgSwitch node, I reworked the code so that the toggling was done with SetAllChildrenOff/On() of a switch node parenting each of the geoms. If at startup, I set them on initially, all is well. But when I set them off for startup (desired), then it starts up with shad1 applied to the root again and shading the whole scene. Then if I toggle anything (geom1 or geom2), everyting snaps into working order and all is well.

So there's just something at startup when shader geometry is culled initially that is confusing the application of the shader, but is fine later. What is going on here? I dont even know what code to post here, as the shader code seems to be ok, since it works in all cases other than startup.

Hope I articulated this clearly. Any ideas?


Thank you!

Cheers,
Phil

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





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

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

Reply via email to