OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgShadow question (ATI related?)


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Rick Middelkoop
Guest





PostPosted: Tue Oct 28, 2008 6:13 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

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.





------------------
Post generated by Mail2Forum
Back to top
Wojciech Lewandowski
Guest





PostPosted: Tue Oct 28, 2008 8:27 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

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:
[mailto:]On Behalf Of Rick
Middelkoop
Sent: Tuesday, October 28, 2008 7:13 PM
To:
Subject: 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.







------------------
Post generated by Mail2Forum
Back to top
Wojciech Lewandowski
Guest





PostPosted: Tue Oct 28, 2008 8:40 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

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:
[mailto:]On Behalf Of Rick
Middelkoop
Sent: Tuesday, October 28, 2008 7:13 PM
To:
Subject: 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.









------------------
Post generated by Mail2Forum
Back to top
Rick Middelkoop
Guest





PostPosted: Wed Oct 29, 2008 6:05 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

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).

Quote:
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.


Quote:
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:
[mailto:]On Behalf Of Rick
Middelkoop
Sent: Tuesday, October 28, 2008 7:13 PM
To:
Subject: 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.















------------------
Post generated by Mail2Forum
Back to top
Wojciech Lewandowski
Guest





PostPosted: Wed Oct 29, 2008 11:07 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

Hi Rick,

I am afraid you are on your own - I will not be able to help much. Shadow
mapping issues could be really hard ;-( I would need to grab similar board,
roll up the sleeves and start debuging. But I don't have the time nor access
to such hardware.

Quote:
[..]

Quote:
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?)

Probably. I don't have another idea.

Quote:
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).

Quote:
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'.

Quote:
Any ideas?

It does not sound like easy one. Are you sure that ATI bug only affects
texture application ? Maybe render to texture is also flipped somehow. I
assume you have modified texgen matrix but not shadow camera projection
matrix (the one involved in computation of texgen matrix) ? If shadow
camera projection gets modified it could potentially affect rest of the
code.

Actually, one idea just came to my mind, MinimalDrawBoundsShadowMap does
rough depth map prerender to compute visible shadowed scene extents. I
suppose reverted vertical texture coordinates may also affect this code. You
may look at MinimaDrawBounds line 203 - its the place where matrix for
prerenderd image scan is computed - and you may need to make the fixes
there. As a alternative approach, you could try
LightSpacePerspectiveShadowMapCB and see if the problem is also present ?
LightSpacePerspectiveShadowMapCB variant computes shadowed volume by
scanning boxes around drawables in render bins and should avoid at least
this potential prerenderd image scanning issue.

Quote:
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.

Good luck. And let me know if you come up with some constructive conclusion,
possible fixes or workarounds.

Cheers,
Wojtek

RE PS:

Quote:
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.

Default setting may impact performance but should be safest. I am not 100%
sure that other options are completely bug free so I would suggest not
experimenting with this if you have other problems. Usage of these options
also heavily depends on the light type. Leave it at default if you use spot
or omnidirectional light.





------------------
Post generated by Mail2Forum
Back to top
Rick Middelkoop
Guest





PostPosted: Thu Oct 30, 2008 5:06 pm    Post subject:
osgShadow question (ATI related?)
Reply with quote

Hi Wojtek,

Thanks for helping out. Unfortunately I didn't have much time today
to further investigate the problem.
Quote:
Quote:
It does not sound like easy one. Are you sure that ATI bug only affects
texture application ? Maybe render to texture is also flipped somehow. I
assume you have modified texgen matrix but not shadow camera projection
matrix (the one involved in computation of texgen matrix) ? If shadow
camera projection gets modified it could potentially affect rest of the
code.
I don't know. I read on the mailing list that there is an issue with FBO textures on ATI, because
at some point, ATI inverted the 't coordinate' in their drivers.

http://archive.netbsd.se/?ml=openscenegraph-submissions&a=2008-02&m=6605417
Quote:
Quote:
Actually, one idea just came to my mind, MinimalDrawBoundsShadowMap does
rough depth map prerender to compute visible shadowed scene extents. I
suppose reverted vertical texture coordinates may also affect this code. You
may look at MinimaDrawBounds line 203 - its the place where matrix for
prerenderd image scan is computed - and you may need to make the fixes
there. As a alternative approach, you could try
LightSpacePerspectiveShadowMapCB and see if the problem is also present ?
LightSpacePerspectiveShadowMapCB variant computes shadowed volume by
scanning boxes around drawables in render bins and should avoid at least
this potential prerenderd image scanning issue.
OK, I quickly tried LightSpacePerspectiveShadowMapCB but the problem was still present.
Unfortunately I didn't have enough time to take a good look at the prerendered image scan computation.
Quote:
Quote:
Quote:
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.
Good luck. And let me know if you come up with some constructive conclusion,
possible fixes or workarounds.
Thanks, and I will certainly let you know if I find something!

Cheers, Rick.

------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osggeometryshaders example question mgreene General 3 Tue Sep 12, 2017 3:12 pm View latest post
No new posts 【NEWBIE】Question about osg::Matri... Jiechang Guo General 5 Fri May 05, 2017 11:54 am View latest post
No new posts Related to osg lines Rambabu General 5 Tue Apr 18, 2017 9:22 am View latest post
No new posts Related to memcpy Rambabu General 1 Mon Apr 17, 2017 4:17 am View latest post
No new posts osgShadow and gl3 wernerM General 1 Fri Feb 24, 2017 2:54 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP