Carsten Neumann wrote:
> Michael Babcock wrote:
>> I'm having a problem with a GLSL shader. It works fine for opaque
>> objects, but transparent objects don't look right. I tracked it down to
>> my use of the OpenSG uniforms OSGWorldMatrix and OSGTransInvWorldMatrix.
>> It appears these variables contain garbage or out-of-date values for
>> transparency sorted objects.
>>
>> If I setSortTrans(false) on the render action, the shader works
>> correctly, but of course transparency isn't rendered correctly in this case.
>>
>> Any ideas why this might be the case?
> 
> very strange, I just checked the code in the RenderAction that updates
> the matrices and it is the same for transparent and opaque objects. I
> don't know in what context you are using this and how much work it is,
> but would it be possible for you to create a small (like the testFoo.cpp
> ones) program that shows the behavior ?
> Alternatively, can you run your code in a debugger with a breakpoint
> being set on void RenderAction::updateShader(State *state) and see if it
> gets called before each object that is being rendered with your shader ?

I ran into this issue again and, unlike before, I could not workaround 
it by disabling frustum culling. I found a fix though: add a call to 
updateShader(pNewState) after line 2318 of OSGRenderAction.cpp (from 1.8 
cvs).

I do not know why the changeFrom call is not updating the uniform 
parameters, or why it only has the issue on transparency sorted 
geometry. All object materials in my scene point to a single SHLChunk, 
and each material has its own SHLParameterChunks to modify the 
appearance, if that provides any hints.

The relevant code in RenderAction looks like:

             pNewState = pRoot->getState();

             if(pNewState != NULL)
             {
                 if(_pActiveState != NULL)
                 {
                     // we need this cgfx test because for multipass 
cgfx materials
                     // the state doesn't change.
                     if(pNewState != _pActiveState ||
                        (_cgfxChunkId != -1 && 
pNewState->getChunk(_cgfxChunkId) != NULL) ||
                        pRoot->isNoStateSorting())
                     {
                         State *previous_state = _pActiveState;
                         _pActiveState = pNewState;
                         pNewState->changeFrom(this, previous_state);
                         updateShader(pNewState); //*** FIXME
                         _uiNumMaterialChanges++;
                     }
                     else
                     {
                         // even if the state didn't change we need to 
update
                         // the shaders to provide the right world matrix.
                         updateShader(pNewState);
                     }
                 }
                 else
                 {
                     _pActiveState = pRoot->getState();
                     _pActiveState->activate(this);
                     _uiNumMaterialChanges++;
                 }
             }
             else
             {
                 updateShader(_pActiveState);
             }



------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to