Hello Wojtek,

I hope you don't mind I address you directly for this question, but as you implemented the view-dependent shadow techniques, you are best placed to answer it.

I am currently investigating a problem that seems to be caused by the ordering of RTT passes. I have a scene that uses osgOcean and osgShadow, and the shadow INSIDE the refraction (which is an RTT effect) is late compared to the shadows OUTSIDE the refraction (i.e. above the water level). What I mean by late is that the shadow moves away from the casting object if I move the eye around, but stops moving and is in the right place as soon as I stop moving the eye. So the refraction pass seems to be happening before the shadow pass.

The nodes are ordered like this:

    root
ShadowedScene
  OceanScene
 <the scene>

And in the OceanScene traverse() method, there is a check if the current camera is the shadow pass camera or analysis camera (for DrawBounds techniques) and just do a regular traversal in that case. My expectation was that the first traversal of the OceanScene would be the shadow pass, then the main pass, and so when we do the refraction RTT (during the main pass), the shadow map would already be correct for the current frame.

But while debugging, I noticed that it's the opposite. And looking at StandardShadowMap.cpp I have the confirmation:

void StandardShadowMap::ViewData::cull()
{
    // step 1:
    // cull shadowed scene ie put into render bins and states into
    // stage graphs
    cullShadowReceivingScene( );

    // ...

    // step 4:
    // cull scene casting shadow and generate render
    cullShadowCastingScene( );

    // ...
}

So the main pass is done (culled) before the shadow pass. I can understand that the bounds calculation needs to cull the shadow receiving scene first, or else we won't know where the shadow map should lie. However, I wonder how this even works.

My understanding is that when the cull visitor traverses a scene graph, it accumulates the drawables and state into a list. It does this in the order it visits notes, and might reorder based on state or other criteria (distance to camera for the transparent bin, for example).

So given the code above, how does the cullShadowCastingScene() manage to place the drawables for the shadow pass before the ones for the main pass, even though the cullShadowReceivingScene() (culling the main pass) is before?

I think for osgOcean's refraction pass to contain correct shadows, I would need to do something similar, i.e. place the drawables for that pass after the shadow pass, but before the main pass, in the render list. I'm actually surprised that's not what happens already, since the sequence should be:

cullShadowReceivingScene()
  --> eventually calls OceanScene::traverse()
    --> does cull for refraction RTT camera
    --> then does cull for main pass
cullShadowCastingScene()
--> does shadow pass, somehow placing results before main pass, which for all it knows should contain the refraction pass

Another possible solution might be to disable shadows for the whole refraction RTT pass, but that would be less interesting visually as shadows would stop at the ocean surface and not go under (when looking through the surface).

Thanks in advance,

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

Reply via email to