Hi Wojtek, Thanks for your hints!
I have made the adjustment to StandardShadowMap and MinimalDrawBoundsShadowMap like for ShadowMap. With the LightSpacePerspectiveShadowMap I then get almost-correct shadows when looking straight down along the Z axis (at a shadow-casting object), with the viewpoint coordinate system aligned to the world coordinate system. The shadows move away from the objects that cast them when I move/aim the viewpoint. When I just use StandardShadowMap (with the ShadowMap adjustment), the shadows are correct. (However, there is a small gap between the (shadow-casting) objects and their shadow, possibly polygon offset-related?) When I just use MinimalShadowMap or MinimalDrawBoundsShadowMap, the shadows are correct, but only when the bounding box (displayed when using setDebugDraw) of the shadow-casting objects is completely within view. When the bounding box is partially outside the viewing frustum, the shadows are correct only from certain viewpoint positions/orientations. If I then move/aim the viewpoint, the shadows move away from the objects that cast them (and eventually disappear in some cases). >From just looking at the debug HUD, you could say that the shadows get 'more correct' when the (shadow-casting objects) bounding box is less 'deformed'. Any ideas? I will keep looking into tomorrow, starting at the MinimalShadowMap level as this seems to be the lowest level at which the problem occurs on my system. Cheers, Rick. PS: I also experimented with the MinimalDrawBoundsShadowMap, calling setShadowReceivingCoarseBoundAccuracy with EMPTY_BOX and BOUNDING_SPHERE, giving the following results: EMPTY_BOX: no shadows are visible, debug HUD shows an empty shadow map BOUNDING_SPHERE: shadows visible from certain viewpoint positions/orientations, but not in the correct place. The debug HUD shows shadow map with projected bounding box etc. > Hi Again Rick, > > Small errata: I forgot to add .cpp suffixes to the files I suggest to > modify. So fixes should be done in > > MinimalDrawBoundShadowMap.cpp line 225 > and > StandardShadowMap.cpp line 753 > > Let us know if this helps, if it does, I will be smarter next time when this > question appears again. > > Cheers, > Wojtek > > > Rick, > > I don't know how to help you with your particular problem. But I hope these > 2 hints could be useful: > > I suppose it would be fairly simple to make similar adjustment for LisPSM as > you did for ShadowMap. Texgen matrix for LispSM is set in > MinimalDrawBoundShadowMap line 225. For safety you should also adjust > StandardShadowMap line 753. Second code path is used when you select LispSM > variant based on MinimalCullBoundsShadowMap or MinimalShadowMap. > > Maybe when you activate debug HUD ( call DebugShadowMap::setDebugDraw( > true ) ) it will be easier to see and fix the problem. > > Cheers, > Wojtek > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Rick > Middelkoop > Sent: Tuesday, October 28, 2008 7:13 PM > To: [email protected] > Subject: [osg-users] osgShadow question (ATI related?) > > > Hello, > > I'm trying to add shadows to the application I'm working on, and encountered > two issues which seems to be ATI card/driver related. > > The first issue is, that shadows generated using the ShadowMap technique > are in the > wrong location, both in the application I'm working on and the > 'osgshadow' example. > Only the ShadowTexture technique gives correct results. > > For example, in the 'aircraft above terrain' example scene with the > ShadowMap > technique (osgshadow --sm -2), there is a shadow on the ground below the > aircraft, > but it is turning in the opposite direction to the aircraft. > A colleague who is using an Nvidia card is seeing correct shadows in the > example. > > After searching the osg mailing list I found a few clues towards solving > the problem, > one was that ATI had inverted a coordinate of the FBO-texture in their > drivers: > http://archive.netbsd.se/?ml=openscenegraph-submissions&a=2008-02&m=6605417 > > The solution was to mirror the shadow map along the Y axis in the > ShadowMap::cull() > function: > > _texgen->setPlanesFromMatrix( osg::Matrix::scale(1.0, -1.0, 1.0) * > _camera->getProjectionMatrix() * > osg::Matrix::translate(1.0,1.0,1.0) * > osg::Matrix::scale(0.5f,0.5f,0.5f) ); > > (I am using a Radeon X1800 series card with the Catalyst 8.9 drivers, > and the osg2.7.3 > developer release. However, the effect also occurs with the osg2.2 > stable release.) > > Now for the second, still unsolved issue: > > At the moment, I am looking at using the LightSpacePerspectiveShadowMap > technique > in the application. However, the problem here is that when changing the > viewpoint position > or orientation, the shadows also move or rotate! It is very difficult > to see what is going on > from the position or movements of the shadows in this case. However, > when I mirror the > shadow map (like in the code above), the shadows seem to be correct in > one special case. > This is when the viewpoint is looking down along the Z axis, and the > viewpoint viewx/vup > axes are parallel to the world X/Y-axes. > > Does anyone have an idea on how this might be solved? > > Thanks + Best Regards, > > Rick. > > > > _______________________________________________ > 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 > > _______________________________________________ > 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

