Garrett Cope | 17 Aug 2012 14:30
Gravatar

[osgPlugins] osgShadow LiSPSM culling problem

Hi,

I'm working with the osgShadow LiSPSM implementation as that seems to be the one that people have had the
most success with. The shadows are great, but are being clipped vertically as the shadowing object moves
near the left or right edge of the window.

I've seen similar issues in other threads, but have tried the following previously suggested solutions
with no result:

- Using one directional light angled at the geometry
- Tried various values for minLightMargin
- Set distant MaxFarPlane

If I comment out the clipping function in MinimalShadowMap everything works as expected, but of course I
need to clip the shadows for it to be feasible. 

The problem seems to be with the calculation of the CullVisitor's projection matrix used for clipping, but
I have yet to find out where this is being calculated so I can see what the problem might be. I'm hoping Wojtek
or someone more familiar with this plugin can point me in the right direction.
... 

Thank you!

Cheers,
Garrett

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

(Continue reading)

Wojciech Lewandowski | 17 Aug 2012 21:30
Picon

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Garret,


I have not worked on Lispsm for long time but description of your problem may suggest that my method of obtaining main camera and its projection matrix may not work as it used to or your setup uses unusual multi channel master / slave configuration that was not tested so far. I am obtaining main view camera in several places in the code using this construct:

_cv->getRenderStage()->getCamera()

you may check if its still returning the right camera by adding asserts checking its projection matrix (getProjectionMatrixAsFrustum and check if near/far/left/right/top/bottom values are correct). 

One of the older problems with main camera was use of COMPUTE_NEAR_FAR flag. You may try turning it off and see if it affects your results.

If above does not help, I will ask you to create simple applet to show your problem and I may try to debug it in spare time.

Cheers,
Wojtek Lewandowski






2012/8/17 Garrett Cope <garrett.cope.ctr-V57KVV444psrI1il2JP8mg@public.gmane.orgs.edu>
Hi,

I'm working with the osgShadow LiSPSM implementation as that seems to be the one that people have had the most success with. The shadows are great, but are being clipped vertically as the shadowing object moves near the left or right edge of the window.

I've seen similar issues in other threads, but have tried the following previously suggested solutions with no result:

- Using one directional light angled at the geometry
- Tried various values for minLightMargin
- Set distant MaxFarPlane

If I comment out the clipping function in MinimalShadowMap everything works as expected, but of course I need to clip the shadows for it to be feasible.

The problem seems to be with the calculation of the CullVisitor's projection matrix used for clipping, but I have yet to find out where this is being calculated so I can see what the problem might be. I'm hoping Wojtek or someone more familiar with this plugin can point me in the right direction.
...

Thank you!

Cheers,
Garrett

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





_______________________________________________
osg-users mailing list
osg-users-ZwoEplunGu08BSWDSat3fA@public.gmane.orgcenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

<div>
<p>Hi Garret,</p>
<div><br></div>
<div>I have not worked on Lispsm for long time but description of your problem may suggest that my method of obtaining main camera and its projection matrix may not work as it used to or your setup uses unusual multi channel master / slave configuration that was not tested so far. I am obtaining main view camera in several places in the code using this construct:</div>

<div><br></div>
<div>_cv-&gt;getRenderStage()-&gt;getCamera()</div>
<div><br></div>
<div>you may check if its still returning the right camera by adding asserts checking its projection matrix (getProjectionMatrixAsFrustum and check if near/far/left/right/top/bottom values are correct).&nbsp;</div>

<div><br></div>
<div>One of the older problems with main camera was use of COMPUTE_NEAR_FAR flag. You may try turning it off and see if it affects your results.</div>
<div><br></div>
<div>If above does not help, I will ask you to create simple applet to show your problem and I may try to debug it in spare time.</div>

<div><br></div>
<div>Cheers,</div>
<div>Wojtek Lewandowski</div>
<div><br></div>
<div>
<br><div><br></div>
<div><br></div>
<div>
<br><br><div class="gmail_quote">2012/8/17 Garrett Cope <span dir="ltr">&lt;<a href="mailto:garrett.cope.ctr@..." target="_blank">garrett.cope.ctr@...s.edu</a>&gt;</span><br><blockquote class="gmail_quote">Hi,<br><br>
I'm working with the osgShadow LiSPSM implementation as that seems to be the one that people have had the most success with. The shadows are great, but are being clipped vertically as the shadowing object moves near the left or right edge of the window.<br><br>
I've seen similar issues in other threads, but have tried the following previously suggested solutions with no result:<br><br>
- Using one directional light angled at the geometry<br>
- Tried various values for minLightMargin<br>
- Set distant MaxFarPlane<br><br>
If I comment out the clipping function in MinimalShadowMap everything works as expected, but of course I need to clip the shadows for it to be feasible.<br><br>
The problem seems to be with the calculation of the CullVisitor's projection matrix used for clipping, but I have yet to find out where this is being calculated so I can see what the problem might be. I'm hoping Wojtek or someone more familiar with this plugin can point me in the right direction.<br>

...<br><br>
Thank you!<br><br>
Cheers,<br>
Garrett<br><br>
------------------<br>
Read this topic online here:<br><a href="http://forum.openscenegraph.org/viewtopic.php?p=49305#49305" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=49305#49305</a><br><br><br><br><br><br>
_______________________________________________<br>
osg-users mailing list<br><a href="mailto:osg-users@...">osg-users@...cenegraph.org</a><br><a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
Garrett Cope | 20 Aug 2012 20:10
Gravatar

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Wojtek, 

Thanks for replying.

The projection matrix at the points you mention matches what it is in my main app. I also set do_not_compute
for the near/far planes on the main camera but didn't find any difference.

If I understand the clipping correctly, it's just a polytope representing the bounds of the shadow cut by a
unit bounding box transformed by the main camera projection matrix. This means that either the shadow
bounds calculation is wrong or my fundamental projection matrix is wrong... Does this sound right? 

I will try to come up with a simpler example to see which is the culprit.

Thanks again for your help.

... 

Thank you!

Cheers,
Garrett

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

Robert Osfield | 23 Aug 2012 13:09
Picon

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Garret,

Could I suggest that you try out the new
osgShadow::ViewDependentShadowMap found in svn/trunk of the OSG, it's
more robust and flexible than the old LispSM implementation.

Robert.
Garrett Cope | 23 Aug 2012 19:18
Gravatar

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Robert,

Thanks for the suggestion! VDSM is nice and concise - nice work! 

But unfortunately I still get the same clipping problem with it, so I'm sure it's something wrong on my end.
I'll keep plugging away and see what I can come up with.

Thanks again,
Garrett 
...

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

Robert Osfield | 23 Aug 2012 20:10
Picon

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Garret,

On 23 August 2012 18:18, Garrett Cope <garrett.cope.ctr@...> wrote:
> Thanks for the suggestion! VDSM is nice and concise - nice work!
>
> But unfortunately I still get the same clipping problem with it, so I'm sure it's something wrong on my end.
I'll keep plugging away and see what I can come up with.

You'll need to post screen shots so can get an idea of what is
happening at your end.  If it's possible to recreate using the
osgshadow example then it'd be really useful.

Robert.
Garrett Cope | 23 Aug 2012 20:28
Gravatar

Re: [osgPlugins] osgShadow LiSPSM culling problem

Robert,

Attached are two screen shots. 'shadow_before' is the base state with a box casting a perfectly fine
shadow. 'shadow_after' is where I have rotated the camera such that the box has moved out of view to the
right. In this image you can see another clipping edge beginning at the bottom of the shadow that moves
relatively vertically as the box continues to rotate to the right of the viewing window.

As with the LiSPSM implementation, if I comment out the clipping section (here in
adjustPerspectiveShadowMapCameraSettings(..) function), it looks fine but of course is then not
clipped at all.

Thanks again,
Garrett
... [/img]

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

Attachments: 
http://forum.openscenegraph.org//files/shadow_after_115.png
http://forum.openscenegraph.org//files/shadow_before_410.png

Robert Osfield | 24 Aug 2012 12:58
Picon

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Garret,

On 23 August 2012 19:28, Garrett Cope <garrett.cope.ctr@...> wrote:
> Attached are two screen shots. 'shadow_before' is the base state with a box casting a perfectly fine
shadow. 'shadow_after' is where I have rotated the camera such that the box has moved out of view to the
right. In this image you can see another clipping edge beginning at the bottom of the shadow that moves
relatively vertically as the box continues to rotate to the right of the viewing window.

Thanks for the screenshots, unfortunately it doesn't quite provide
enough clues to know what might be amiss.

Could you output a small model that using the osgshadow example can be
used to recreate the issue?

You can record a camera path with osgshadow by pressing 'z' to start
and 'Z' to finish, this then writes out a file saved_animation.path,
you can then replay this in osgviewer/osgshadow using the command line
option -p saved_animation.path.

> As with the LiSPSM implementation, if I comment out the clipping section (here in
adjustPerspectiveShadowMapCameraSettings(..) function), it looks fine but of course is then not
clipped at all.

It sounds like the light space extents isn't being fitted properly, or
there is an error in the adjustment of the shadow map projection
matrix for the light space extents.  Debugging these issues requires
models that can recreate the issue though, there isn't really anything
I can do without being able to reproduce the problem.

Robert.
Garrett Cope | 24 Aug 2012 15:38
Gravatar

Re: [osgPlugins] osgShadow LiSPSM culling problem

Hi Robert,

I haven't been able to reproduce my specific problem with the osgshadow example, but I have been able to
reproduce all kinds of weird clipping planes. Just none that are resolved by commenting out the
aforementioned section.

For instance, if I set the default light direction in the example to pretty much anything other than 0,0,1
(for instance: 0,-1,1) and then rotate the model around with the manipulator, the shadows get clipped
along strange lines. 

I will keep trying to reproduce my specific instance of the issue.

Thanks again for the help,
Garrett

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


Gmane