[osg-users] Problems implementing Cascaded Shadow Maps

Dima Trepnau dietrich.trepnau at st.ovgu.de
Tue Jul 26 01:36:36 PDT 2016


Hi all,

I'm currently trying to implement cascading shadow maps into an old (OSG 2.81) Simulation Project of another Student. I already managed to create the correct shadow maps, but it seems I have a few strange Problems with uploading the textures to the shaders and transforming the Vertices into shadow space.

1. Problem:
When I upload the shadow maps to the shaders I always end up with values clamped to [0,64]. I already tried different internal formats, Pixel formats and Pixel types.
I also seem to be unable to use uniform Arrays. 

2. Problem:
To transform a vertex into shadow projection space I just need to multiply it by the modelViewProjection Matrix of the "sun" and do the perspective division right? 

The shadow maps generated by this cams definitely look correct, however I get strange results if I try to use the projection matrix myself.

I use a uniform object to upload the modelViewProjection Matrix of the first sun to the shader by using

Code:

stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4 , "shadowMat1"));
stateset->getUniform("shadowMat1")->set(sunView->getCamera()->getViewMatrix() * sunView->getCamera()->getProjectionMatrix()) 




First I tries to use the shaders to color the vertices differently for each frustum split, but everthing had the same color.  
I then used a vertex that clearly is inside the Clip space of the first sun to test it.
When I transform a vertex into the view space by using the view matrix, I get the expected result, but after then transforming the view space coordinates with the projection matrix I end up with values like (-1666, 280, -13, 1). I expected values between [-1,1] since it's an orthographic camera.

Does anyone know what could cause this Problems?

Thank you!

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








More information about the osg-users mailing list