[osg-users] ShadowMap problem...
wyattbsearp1881 at gmail.com
Wed Nov 11 10:36:51 PST 2009
I have changed to a LISPSM shadow technique.
I have removed the cast bit from my terrain.
The only two objects I have set cast shadow are close together.
My texture size is 2048 x 2048.
Not seeing shadows on the terrain from my objects.
Changed shadowTexture unit to 7.
Should basetexture be 0 still?
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
Sent: Wednesday, November 11, 2009 8:04 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...
> When I have one or two objects, say the size of a car, or truck, only.
> shadow map looks correct. But when I add my terrain which is approximately
> = 5100 by y = 5100, I no longer see the car/truck shadows on the shadow
> Similarly, if I increase the length and width of the bottom box in the
> osgShadow example, I no longer see the other objects in the shadow map.
> I assume I am running into some shadow map texture resolution limit or
> something. What is going on?
Yep, Most probable. osgShadow::ShadowMap can't help you there, but there
are a few things you can do to mitigate the problem.
* First, don't set your terrain to cast shadow (if it's mostly flat
you'd never see its shadow anyways)
* Second, make sure all the objects you set to cast shadow are in a
small area. If an object leaves the area of focus, remove its cast
shadow bit from its node mask.
* Third, increase the shadow map resolution as much as you can (on some
cards, 4096x4096 is the biggest you can go, on some others it's 2048x2048)
But if you want better results, switch to one of the ViewDependentShadow
techniques that are in OSG 2.8+ (for example
osgShadow::LightSpacePerspectiveShadowMap). These will consider the
camera's view volume and only calculate shadows for this area
automatically, so if you're looking at a relatively small portion of
your scene it will give much better results. Though they have some
artifacts in some situations too... Nothing is perfect, it's always a
> My shadow map is looking mostly correct now after making changes to light
> type, position etc. However shadows are not appearing in the final
> rendering. The app I am trying to add shadow mapping to uses textures
> to tex units 0-3. I noticed in the ShadowMap class there were methods for
> setting the texture unit and wondered if this possibly why I am not
> the shadows. That is, is my use of tex units 0-3 conflicting with
> ShadowMaps use of texture units and should I reassign one or the others
> texture units?
Most probably, ShadowMap uses texture unit 1 by default for the shadow
map. Call osgShadow::ShadowMap::setTextureUnit() to set the texture unit
you want the shadow map to use (for example 4, or 7 to give yourself
some breathing room), and use that same texture unit in your shadow
shaders when you get to the point of generating texture coordinates and
doing the shadow lookup too. There's a similar method in
Hope this helps,
Jean-Sebastien Guay jean-sebastien.guay at cm-labs.com
osg-users mailing list
osg-users at lists.openscenegraph.org
More information about the osg-users