What I know for certain is this: all shadow techniques stemming from
ViewDependentShadowTechnique (StandardShadowMap, MinimalShadowMap, LispSM)
are not compatible with nested cameras. And its a design flaw. Basically all
these techniques allocate resources per View and views are recognized and
indexed by cull visitor pointer. Unfortunately cull visitor of the view
main camera also traverses nested cameras, so this means these nested
cameras will use the same resources as main view camera. Since the shadow
map depends on the camera view/projection, obiously shadowmaps, projection
and texgen settings will not work correctly for nested cams. So I always
recommended using Slaves cameras instead of Nested cams because they have
their own CullVisitors. If I would design this today, instead of CullVisitor
I would probably use RenderStage to index view resources.
I am however, not sure if I agree with your diagnosis on basic ShadowMap
problem. Even if shadow map was rendered only once it should work well for
both main and nested camera. Thats because ShadowMap projection does not
depend on parent camera view or projection.
Instead I suspect that shadow tex coord Texgen may be the problem. This is
the only view dependent resouce here. Shadow texgen produces EYE_LINEAR
coords. These coords depend on current model view matrix. I guess in Felix
case main camera view matrix differs from nested camera view matrix. So
texgen working for the main cam, does not produce correct coords for nested
These however are only theoretical deliberations. I have never tested or
debuged such problem in practice, and I may be wrong.
From: Paul Martz
Sent: Friday, May 13, 2011 11:55 PM
To: OpenSceneGraph Users
Subject: Re: osgShadow and nested RTT-cams
Hi all -- While digging into an issue with multiple nested Camera nodes in
2.8.x, I came across this old thread in the archives and wanted to follow
it appears no one ever solved the mystery. I imagine there is more
information, or possibly even fixes on trunk? If so, please let me know.
Camera nodes have a 1-to-1 mapping with RenderStage objects, and the first
that happens in RenderStage::draw() is a check to ensure that the
only draws once per frame. (This is necessary because the RenderStage is
inserted twice into the render graph: Once as a pre-render RenderStage, then
once again as a regular child of the top-level Camera.) See RenderStage.cpp
1109 on trunk.
That's almost always what you want, except in Felix's case (see quoted
his situation, he has a scene that uses osgShadow (which uses a child Camera
implement the pre-render pass). Because a RenderStage can only draw once per
frame, there is no way to render an osgShadow scene twice per frame: once to
texture (using an RTT Camera) and once again to some other framebuffer.
On Aug 6 2009, 8:32 am, "Felix Heide" <>
A scenegraph as illustrated in the following image works fine:
i have a problem with using theosgShadownodekit together with
The FBO is used as a texture which is put on a simple quad-geode. The
But problems arise, when i use anRTT-Cam to render this scenegraph to an
is then rendered by the Viewers-Camera with orthogonal projection. In fact
this stuff is done to apply warping in the fragment shader pass. The
scenegraph is illustrated in the following figure:
theRTT-Cameras viewpoint. In addition sometimes flickering in the shadows
The results are strange shadow artifacts. The shadows move with
noticed. Except the shadows, the whole scene is rendered as it should be.
Line 192 in ShadowMap.cpp (osg 2.8.0) is
At first, i thought it would have something to do with the shadowMap's
shadowMaps cam inherit its viewpoint from the viewers cam and not the
If i understand the Reference Frame concept right, this line makes the
nestedrtt-cam, which would be the right one. So i tried to set the Referende
Frame to ABSOLUTE_RF by accessing the current camera in a cull-callback
to the ShadowScene node. That did not help.
Hope someone has a tip for me.
Read this topic online
osg-users mailing list
Post generated by Mail2Forum