Jaap van den Bosch | 3 Oct 2011 11:31
Picon

Re: OSG Shadow debugging

I already was suspicious of the empty right square. Looks like the shaders are not functioning somehow.
Here are some more results:

ShadowMap: Overall dimming, empty DebugHUD camera. See picture below
PSSM: Application crash...
ShadowVolume: Shadow pointing down: Blank screen. Other light direction: overblown colors. See picture below
SoftShadowMap: Light from above: no change. Light from an angle: Noise pattern as shadow. See picture below
Shadowtexture: blank screen. Primitives amount: 0 (somehow they have disappeared).

Wojciech, do you suspect a culprit responsible for these problems?

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=43159#43159

Attachments: 
http://forum.openscenegraph.org//files/softshadowmap_770.jpg
http://forum.openscenegraph.org//files/shadowvolume_532.jpg
http://forum.openscenegraph.org//files/shadowmap_183.jpg

Wojciech Lewandowski | 4 Oct 2011 13:50
Picon

Re: OSG Shadow debugging

Hi,

You will probably need to dive into osgShadow code with debugger. I would 
recommend using osgShadow::ShadowMap for this purpose. Its probably simplest 
from depth shadow mapping  techniques. I would put the breakpoint at start 
of void ShadowMap::cull(osgUtil::CullVisitor& cv) method and would step it 
line by line to check if all steps are performed correctly. This methods 
first culls main camera scene where shadows will be applied. Later finds the 
light source used to cast shadows, then computes shadow camera projection 
and view matrices based on light source and culls the scene for shadow 
camera,  finally sets the texgen for applying shadows for main camera scene. 
This order of operations may sound strange but you have to remember that 
scenes per cameras can be culled in any order. Its Cameras Render Order that 
decides that shadow map will be rendered before main scene in Render 
traversals. So shadow map will be ready for use when main camera scene will 
be rendered.

Imho most probable problem here is your code does not find the light source 
and then succesive operations are bound to fail because shadow camera 
projection is incorrectly computed and scene for shadow map culled out.  If 
the light is found and reasonable view and projection matrices for shadow 
camera are set then it probably means that shadow camera cull/render does 
not render the scene for some unknown reason ( I would check Casts Shadow 
masks on this occasion).

And I have no more ideas. I hope this problem is one of the above, if not 
you are on your own to dig further.  But thats really good opprtunity to 
learn how OSG works ;-)

Cheers,
(Continue reading)


Gmane