Hello Aashish,

I'll be using a bit of extra information from talking to you earlier for my answer ;)

Aashish Chaudhary wrote:
I ran into issue related to wrong OSG shader variables (OSGWorldMatrix etc) getting passed to the shaders for a geometry. What I found in my debugging that its related to the graph operators I am using (OSGGraphOpSeq, OSGGeometryMergeGraphOp, and OSGMaterialMergeGraphOp).

it is only related to the graph ops to some extent: the MaterialMergeGraphOp replaces two distinct copies of the same material with just one and that ...

Digging more into the issue its somehow related to SHLChunk (the way it handles updaing OSG parameters).

... inhibits an update to the OSG Parameters in SHLChunk::changeFrom which does an early out before updating the parameters if the old and new chunk are the same.

Any suggestions or ideas are most welcome.

please try the attached patch.

        Cheers,
                Carsten

Index: Source/System/State/SHL/OSGSHLChunk.cpp
===================================================================
--- Source/System/State/SHL/OSGSHLChunk.cpp	(revision 1926)
+++ Source/System/State/SHL/OSGSHLChunk.cpp	(working copy)
@@ -2162,6 +2162,7 @@
                           StateChunk *old_chunk,
                           UInt32 /*idx*/)
 {
+    Window   *win = pEnv->getWindow();
     SHLChunk *old = dynamic_cast<SHLChunk *>(old_chunk);
 
     if(old == NULL)
@@ -2170,53 +2171,41 @@
         return;
     }
 
-    // SHLChunk didn't change so do nothing.
-    if(old == this)
-        return;
+    GLuint progId = GLuint(win->getGLObjectId(getGLId()));
 
-    pEnv->getWindow()->validateGLObject(getGLId(), pEnv);
+    if(progId != pEnv->getActiveShader())
+    {
+        if(progId == 0)
+            return;
 
-    // get "glUseProgramObjectARB" function pointer
-    OSGGLUSEPROGRAMOBJECTARBPROC useProgramObject =
-        reinterpret_cast<OSGGLUSEPROGRAMOBJECTARBPROC>(
-            pEnv->getWindow()->getFunction(_funcUseProgramObject));
+        win ->validateGLObject(getGLId(), pEnv);
+        pEnv->incNumShaderChanges();
 
-    GLuint program = GLuint(pEnv->getWindow()->getGLObjectId(getGLId()));
+        // get "glUseProgramObjectARB" function pointer
+        OSGGLUSEPROGRAMOBJECTARBPROC useProgramObject =
+            reinterpret_cast<OSGGLUSEPROGRAMOBJECTARBPROC>(
+                win->getFunction(_funcUseProgramObject));
 
-    if(program != 0)
-    {
-        useProgramObject(program);
-        pEnv->setActiveShader(program);
+        useProgramObject     (progId);
+        pEnv->setActiveShader(progId);
 
-        updateOSGParameters(pEnv, program);
-#if 0
-        updateParameters(pEnv->getWindow(), getParameters(),
-                     false,  // don't use program
-                     false,  // don't force updates
-                     true);  // keep the program active
-#endif
-
-        if(getPointSize())
+        if(_sfPointSize.getValue() == true)
         {
-            if(!old->getPointSize())
+            if(old->getPointSize() == false)
+            {
                 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
+            }
         }
         else
         {
-            if(old->getPointSize())
+            if(old->getPointSize() == true)
+            {
                 glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
+            }
         }
     }
-    else
-    {
-        if(pEnv->getWindow()->getGLObjectId(old->getGLId()) != 0)
-        {
-            useProgramObject(0);
-            pEnv->setActiveShader(0);
-        }
-    }
 
-    pEnv->incNumShaderChanges();
+    updateOSGParameters(pEnv, progId);
 }
 
 
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to