Re: [osg-users] ShadowMap problem...

2009-11-20 Thread Wojciech Lewandowski
Hi Wyatt,

Yes,thats a good picture. What it tells me:

1. Light node has been found and direction seem to be computed correctly.
2. Shadow map seems correct. Only back faces from light perspective are 
rendered.  These are the faces that are casting shadows. This is exactly what 
Lispsm sets.

Since ShadowMap rendering seems correct you most probably have an issue with 
application of shadow map to final scene.

Here is a check list to iterate.

1: Check your texcoords and texstages and verify if there is no conflict of 
some other texture with shadow map stage/coords. 
2: Check your shaders if they compile and use the same shadow map uniforms 
/shadow coords correctly. Try turning shaders off. Lispsm shadows should work  
even with fixed pipeline. Usually shadows become almost black but they are 
visible.
3: If you use vertex shader check materials used for terrain and buildings. 
Vertex shaders do not work correctly with materials using COLOR_MATERIAL 
attribute ie some material components are defined through vertex colors. Your 
material should have COLOR_MATERIAL mode set to off and 
diffuse/ambient/specular components should be defined in material not in 
promitive colors. COLOR_MATERIAL mode is notorious for the problems with 
shadows.  Its not supported by shaders. Works with fixed pipeline only. Best 
solution is to convert (osgconv) your model file into text .osg format and 
examine states it uses in text editor.  

If this does not help, consider sending a piece of your code and models.

Cheers,
Wojtek

From: Wyatt Earp 
Sent: Friday, November 20, 2009 6:03 AM
To: 'OpenSceneGraph Users' 
Cc: 'Wojciech Lewandowski' 
Subject: RE: [osg-users] ShadowMap problem...


Is this what you meant?

Thanks,

W

 

 

 

From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Wojciech 
Lewandowski
Sent: Thursday, November 19, 2009 4:56 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] ShadowMap problem...

 

Hi Wyatt,

 

Buildings getting darker while light is moving can be a normal thing it is 
simply a result of normal diffuse shading. Can you move camera so close that 
view frustum contains a single building ?. Ideally make it look at 45 deg from 
a liitle above. Then make screenshot, with debugHUD. Its really important whats 
on debug hud display.  This will tell me alot. If you have problems with 300 kb 
OSG forum limit, just send this screenshot directly to my address. 

 

Cheers,

Wojtek Lewandowski

 

 

 

From: Wyatt Earp 

Sent: Thursday, November 19, 2009 10:45 PM

To: 'OpenSceneGraph Users' 

Subject: Re: [osg-users] ShadowMap problem...

 

Ok... so I did what you suggested mostly... I took the osgshadow example, add 
my geometry and it worked.  I added another shader on the root node of the 
scenegraph, because in my app, I do that.  I took the shaders from 
ShadowMap.cpp and put them into vert/frag files and loaded them into their 
respective shaders.  That worked too.

 

In my application, when I load those shaders from ShadowMap.cpp and use them, I 
see a change in the lighting but it isn't what I expect.  Rather than the 
objects casting shadows on the terrain, it looks like a shdow is being cast 
over the objects, but it isnt'being cast on the terrain.  The best way I can 
describe it is that it looks like the objects are in the sun then a cloud 
floats between the sun and the object...  I don't think a picture will show 
what I mean, but here are 3 pictures with the shadow moving progressively to 
the left over the object... note the white building in the front gets darker.  
But now shadows on the terrain.

 



 



 

 



 

W

 

 

 

 -Original Message-

 From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-

 boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay

 Sent: Thursday, November 12, 2009 1:45 PM

 To: OpenSceneGraph Users

 Subject: Re: [osg-users] ShadowMap problem...

 

 Hi Wyatt,

 

  Any suggestions?

 

 Not really. At this point you'll probably have to trace into OSG to

 make

 sure the shadow map traversal is getting to the right objects (i.e.

 your

 masks are set correctly), and check your shaders (perhaps even try with

 the basic shaders that LISPSM uses by default for starters). Also, try

 to start with the osgShadow example, and work up progressively to

 something similar to what you have in your app, and perhaps in the

 process you'll find out what's not working. If not, then at least

 you'll

 have a small app that can demonstrate the problem, which we might be

 able to help with.

 

 Hope this helps,

 

 J-S

 --

 __

 Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com

 http://www.cm-labs.com/

  http://whitestar02.webhop.org/

 ___

 osg-users mailing list

 osg-users

Re: [osg-users] ShadowMap problem...

2009-11-19 Thread Wyatt Earp
Ok... so I did what you suggested mostly... I took the osgshadow example,
add my geometry and it worked.  I added another shader on the root node of
the scenegraph, because in my app, I do that.  I took the shaders from
ShadowMap.cpp and put them into vert/frag files and loaded them into their
respective shaders.  That worked too.

 

In my application, when I load those shaders from ShadowMap.cpp and use
them, I see a change in the lighting but it isn’t what I expect.  Rather
than the objects casting shadows on the terrain, it looks like a shdow is
being cast over the objects, but it isnt'being cast on the terrain.  The
best way I can describe it is that it looks like the objects are in the sun
then a cloud floats between the sun and the object...  I don’t think a
picture will show what I mean, but here are 3 pictures with the shadow
moving progressively to the left over the object... note the white building
in the front gets darker.  But now shadows on the terrain.

 

cid:image001.png@01CA692E.7A38B7F0

 

cid:image002.png@01CA692E.7A38B7F0

 

 

cid:image003.png@01CA692E.7A38B7F0

 

W

 

 

 

 -Original Message-

 From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-

 boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay

 Sent: Thursday, November 12, 2009 1:45 PM

 To: OpenSceneGraph Users

 Subject: Re: [osg-users] ShadowMap problem...

 

 Hi Wyatt,

 

  Any suggestions?

 

 Not really. At this point you'll probably have to trace into OSG to

 make

 sure the shadow map traversal is getting to the right objects (i.e.

 your

 masks are set correctly), and check your shaders (perhaps even try with

 the basic shaders that LISPSM uses by default for starters). Also, try

 to start with the osgShadow example, and work up progressively to

 something similar to what you have in your app, and perhaps in the

 process you'll find out what's not working. If not, then at least

 you'll

 have a small app that can demonstrate the problem, which we might be

 able to help with.

 

 Hope this helps,

 

 J-S

 --

 __

 Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com

 http://www.cm-labs.com/

  http://whitestar02.webhop.org/

 ___

 osg-users mailing list

 osg-users@lists.openscenegraph.org

 http://lists.openscenegraph.org/listinfo.cgi/osg-users-

 openscenegraph.org

image001.jpgimage002.jpgimage003.jpg___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-19 Thread Wojciech Lewandowski
Hi Wyatt,

Buildings getting darker while light is moving can be a normal thing it is 
simply a result of normal diffuse shading. Can you move camera so close that 
view frustum contains a single building ?. Ideally make it look at 45 deg from 
a liitle above. Then make screenshot, with debugHUD. Its really important whats 
on debug hud display.  This will tell me alot. If you have problems with 300 kb 
OSG forum limit, just send this screenshot directly to my address. 

Cheers,
Wojtek Lewandowski




From: Wyatt Earp 
Sent: Thursday, November 19, 2009 10:45 PM
To: 'OpenSceneGraph Users' 
Subject: Re: [osg-users] ShadowMap problem...


Ok... so I did what you suggested mostly... I took the osgshadow example, add 
my geometry and it worked.  I added another shader on the root node of the 
scenegraph, because in my app, I do that.  I took the shaders from 
ShadowMap.cpp and put them into vert/frag files and loaded them into their 
respective shaders.  That worked too.

 

In my application, when I load those shaders from ShadowMap.cpp and use them, I 
see a change in the lighting but it isn't what I expect.  Rather than the 
objects casting shadows on the terrain, it looks like a shdow is being cast 
over the objects, but it isnt'being cast on the terrain.  The best way I can 
describe it is that it looks like the objects are in the sun then a cloud 
floats between the sun and the object...  I don't think a picture will show 
what I mean, but here are 3 pictures with the shadow moving progressively to 
the left over the object... note the white building in the front gets darker.  
But now shadows on the terrain.

 



 



 

 



 

W

 

 

 

 -Original Message-

 From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-

 boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay

 Sent: Thursday, November 12, 2009 1:45 PM

 To: OpenSceneGraph Users

 Subject: Re: [osg-users] ShadowMap problem...

 

 Hi Wyatt,

 

  Any suggestions?

 

 Not really. At this point you'll probably have to trace into OSG to

 make

 sure the shadow map traversal is getting to the right objects (i.e.

 your

 masks are set correctly), and check your shaders (perhaps even try with

 the basic shaders that LISPSM uses by default for starters). Also, try

 to start with the osgShadow example, and work up progressively to

 something similar to what you have in your app, and perhaps in the

 process you'll find out what's not working. If not, then at least

 you'll

 have a small app that can demonstrate the problem, which we might be

 able to help with.

 

 Hope this helps,

 

 J-S

 --

 __

 Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com

 http://www.cm-labs.com/

  http://whitestar02.webhop.org/

 ___

 osg-users mailing list

 osg-users@lists.openscenegraph.org

 http://lists.openscenegraph.org/listinfo.cgi/osg-users-

 openscenegraph.org






___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
image001.jpgimage002.jpgimage003.jpg___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-19 Thread Wyatt Earp
Thanks for the reply... I'll do that and post result Thanks,
W

On Thu, Nov 19, 2009 at 4:56 PM, Wojciech Lewandowski lewandow...@ai.com.pl
 wrote:

  Hi Wyatt,

 Buildings getting darker while light is moving can be a normal thing it is
 simply a result of normal diffuse shading. Can you move camera so close
 that view frustum contains a single building ?. Ideally make it look at 45
 deg from a liitle above. Then make screenshot, with debugHUD. Its really
 important whats on debug hud display.  This will tell me alot. If you have
 problems with 300 kb OSG forum limit, just send this screenshot directly to
 my address.

 Cheers,
 Wojtek Lewandowski



  *From:* Wyatt Earp wyattbsearp1...@gmail.com
 *Sent:* Thursday, November 19, 2009 10:45 PM
 *To:* 'OpenSceneGraph Users' osg-users@lists.openscenegraph.org
 *Subject:* Re: [osg-users] ShadowMap problem...

  Ok... so I did what you suggested mostly... I took the osgshadow example,
 add my geometry and it worked.  I added another shader on the root node of
 the scenegraph, because in my app, I do that.  I took the shaders from
 ShadowMap.cpp and put them into vert/frag files and loaded them into their
 respective shaders.  That worked too.



 In my application, when I load those shaders from ShadowMap.cpp and use
 them, I see a change in the lighting but it isn’t what I expect.  Rather
 than the objects casting shadows on the terrain, it looks like a shdow is
 being cast over the objects, but it isnt'being cast on the terrain.  The
 best way I can describe it is that it looks like the objects are in the sun
 then a cloud floats between the sun and the object...  I don’t think a
 picture will show what I mean, but here are 3 pictures with the shadow
 moving progressively to the left over the object... note the white building
 in the front gets darker.  But now shadows on the terrain.



 [image: cid:image001.png@01CA692E.7A38B7F0]



 [image: cid:image002.png@01CA692E.7A38B7F0]





 [image: cid:image003.png@01CA692E.7A38B7F0]



 W







  -Original Message-

  From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-

  boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay

  Sent: Thursday, November 12, 2009 1:45 PM

  To: OpenSceneGraph Users

  Subject: Re: [osg-users] ShadowMap problem...

 

  Hi Wyatt,

 

   Any suggestions?

 

  Not really. At this point you'll probably have to trace into OSG to

  make

  sure the shadow map traversal is getting to the right objects (i.e.

  your

  masks are set correctly), and check your shaders (perhaps even try with

  the basic shaders that LISPSM uses by default for starters). Also, try

  to start with the osgShadow example, and work up progressively to

  something similar to what you have in your app, and perhaps in the

  process you'll find out what's not working. If not, then at least

  you'll

  have a small app that can demonstrate the problem, which we might be

  able to help with.

 

  Hope this helps,

 

  J-S

  --

  __

  Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com

  http://www.cm-labs.com/

   http://whitestar02.webhop.org/

  ___

  osg-users mailing list

  osg-users@lists.openscenegraph.org

  http://lists.openscenegraph.org/listinfo.cgi/osg-users-

  openscenegraph.org

 --

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-12 Thread Wyatt Earp
I think I am about to get this straightened out...

I have implemented the LiSPPSM shadow code in my app.  My scene consists of
two vehicles and a terrain.  If I don't add the terrain, I can see the
shadows on the base test geometry and it looks pretty good.  The base
geometry just happens to be sitting below my two vehicles.  If I do add the
terrain, most of the terrain is covered by a big black square, and I no
longer see the shadows on the base geometry (I can descend below the
geometry of the terrain and see the base geometry).  Is something possibly
casting a large shadow on the terrain to cause the big black square?  I am
not sure what it could be since I only have the terrain, two vehicles and
the base geometry.  Any suggestions?

Thx
W



 -Original Message-
 From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-
 boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay
 Sent: Wednesday, November 11, 2009 2:33 PM
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] ShadowMap problem...
 
 Hi Wyatt,
 
  With the debugHUD in the ShadowMap example, there was just
  a window which appeared to display the shadow map in gray-scale, but
 in the
  LISPSM example, there appears to be two sub-windows in the debughud
 window
  (not in gray-scale). What are these displaying?
 
 The left side is the shadow map itself, and the right side is a render
 of the bounds analysis render pass (the
 LightSpacePerspectiveShadowMapDB
 technique - Draw Bounds - makes a 64x64 render pass before the actual
 shadow pass to see if the shadow map bounds can be further reduced -
 Wojtek can tell you more about it, or search the archives for details).
 
  Am I supposed to, basically, copy the shader code from StandardShader
 map
  and add it to my shaders and turn off the LISPSM shaders?
 
 You only need to use some parts, those that relate to the shadow test.
 The rest of your shader can be what you want - most of the shader code
 in StandardShadowMap.cpp is just standard lighting, which you might be
 doing differently. You should copy the DynamicShadow function for both
 vertex and fragment shader (whether you want to keep it in a function
 or
 not, up to you) and then look at the place where it's used and do
 something similar.
 
 Read the shaders, you should understand.
 
 J-S
 --
 __
 Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
 http://www.cm-labs.com/
  http://whitestar02.webhop.org/
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-
 openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-12 Thread Wyatt B. S. Earp
I also noticed that the vehicles are all black without the terrain... i.e. just 
the base test texture, as though they are shadowed completely.

W



WyattEarp wrote:
 I think I am about to get this straightened out...
 
 I have implemented the LiSPPSM shadow code in my app.  My scene consists 
 of
 two vehicles and a terrain.  If I don't add the terrain, I can see the
 shadows on the base test geometry and it looks pretty good.  The base
 geometry just happens to be sitting below my two vehicles.  If I do add the
 terrain, most of the terrain is covered by a big black square, and I no
 longer see the shadows on the base geometry (I can descend below the
 geometry of the terrain and see the base geometry).  Is something possibly
 casting a large shadow on the terrain to cause the big black square?  I am
 not sure what it could be since I only have the terrain, two vehicles and
 the base geometry.  Any suggestions?
 
 Thx
 W
 
 
 
 
  -Original Message-
  From:  [mailto:osg-users-
  ] On Behalf Of Jean-Sébastien Guay
  Sent: Wednesday, November 11, 2009 2:33 PM
  To: OpenSceneGraph Users
  Subject: Re:  ShadowMap problem...
  
  Hi Wyatt,
  
  
   With the debugHUD in the ShadowMap example, there was just
   a window which appeared to display the shadow map in gray-scale, but
   
  in the
  
   LISPSM example, there appears to be two sub-windows in the debughud
   
  window
  
   (not in gray-scale). What are these displaying?
   
  
  The left side is the shadow map itself, and the right side is a render
  of the bounds analysis render pass (the
  LightSpacePerspectiveShadowMapDB
  technique - Draw Bounds - makes a 64x64 render pass before the actual
  shadow pass to see if the shadow map bounds can be further reduced -
  Wojtek can tell you more about it, or search the archives for details).
  
  
   Am I supposed to, basically, copy the shader code from StandardShader
   
  map
  
   and add it to my shaders and turn off the LISPSM shaders?
   
  
  You only need to use some parts, those that relate to the shadow test.
  The rest of your shader can be what you want - most of the shader code
  in StandardShadowMap.cpp is just standard lighting, which you might be
  doing differently. You should copy the DynamicShadow function for both
  vertex and fragment shader (whether you want to keep it in a function
  or
  not, up to you) and then look at the place where it's used and do
  something similar.
  
  Read the shaders, you should understand.
  
  J-S
  --
  __
  Jean-Sebastien Guay
  http://www.cm-labs.com/
  http://whitestar02.webhop.org/
  ___
  osg-users mailing list
  
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-
  openscenegraph.org
  
 
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-12 Thread Jean-Sébastien Guay

Hi Wyatt,


Any suggestions?


Not really. At this point you'll probably have to trace into OSG to make 
sure the shadow map traversal is getting to the right objects (i.e. your 
masks are set correctly), and check your shaders (perhaps even try with 
the basic shaders that LISPSM uses by default for starters). Also, try 
to start with the osgShadow example, and work up progressively to 
something similar to what you have in your app, and perhaps in the 
process you'll find out what's not working. If not, then at least you'll 
have a small app that can demonstrate the problem, which we might be 
able to help with.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-12 Thread Wojciech Lewandowski
I agree with J-S, just try loading your scene into osgshadow and see if it 
works there. All black may mean anything btw, can you post a screenshot 
sometimes ? You seem to be this unique type who tend to prefer thousands 
words than one picture


Wojtek


--
From: Jean-Sébastien Guay jean-sebastien.g...@cm-labs.com
Sent: Thursday, November 12, 2009 8:45 PM
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] ShadowMap problem...


Hi Wyatt,


Any suggestions?


Not really. At this point you'll probably have to trace into OSG to make 
sure the shadow map traversal is getting to the right objects (i.e. your 
masks are set correctly), and check your shaders (perhaps even try with 
the basic shaders that LISPSM uses by default for starters). Also, try to 
start with the osgShadow example, and work up progressively to something 
similar to what you have in your app, and perhaps in the process you'll 
find out what's not working. If not, then at least you'll have a small app 
that can demonstrate the problem, which we might be able to help with.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Jean-Sébastien Guay

Hi Wyatt,


When I have one or two objects, say the size of a car, or truck, only.  The
shadow map looks correct. But when I add my terrain which is approximately x
= 5100 by y = 5100, I no longer see the car/truck shadows on the shadow map.

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 
trade-off.



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 bound
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 seeing
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 
osgShadow::LightSpacePerspectiveShadowMap.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Wyatt Earp
Yes this all helps greatly.. I really appreciate the help you have provided.
Thanks,
W

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Wednesday, November 11, 2009 8:04 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...

Hi Wyatt,

 When I have one or two objects, say the size of a car, or truck, only.
The
 shadow map looks correct. But when I add my terrain which is approximately
x
 = 5100 by y = 5100, I no longer see the car/truck shadows on the shadow
map.
 
 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 
trade-off.

 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
bound
 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
seeing
 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 
osgShadow::LightSpacePerspectiveShadowMap.

Hope this helps,

J-S
-- 
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Wyatt Earp
BTW, 2 more questions 

1.  Is there a way I can query the number of texture units available on my
GPU via an OSG call?
2.  Is there a list, other than the osgShadow programming guide of shadowmap
techniques, specifically ViewDependentShadow techniques?

W


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Wednesday, November 11, 2009 8:04 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...

Hi Wyatt,

 When I have one or two objects, say the size of a car, or truck, only.
The
 shadow map looks correct. But when I add my terrain which is approximately
x
 = 5100 by y = 5100, I no longer see the car/truck shadows on the shadow
map.
 
 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 
trade-off.

 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
bound
 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
seeing
 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 
osgShadow::LightSpacePerspectiveShadowMap.

Hope this helps,

J-S
-- 
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Jean-Sébastien Guay

Hi Wyatt,


1.  Is there a way I can query the number of texture units available on my
GPU via an OSG call?


A Google search turned up glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB). Also 
searching the OSG headers, I found 
osg::Texture::Extensions::numTextureUnits() which returns a GLint (int). 
Look at the source to find out where the value will be initialized or 
how to initialize it yourself.


I generally don't bother to query and use 8 (0-7) as a number that's 
supported pretty much everywhere.



2.  Is there a list, other than the osgShadow programming guide of shadowmap
techniques, specifically ViewDependentShadow techniques?


The source/headers... And the mailing list archives.

The three usable types are:

class   LightSpacePerspectiveShadowMapDB /*...*/ {};
class   LightSpacePerspectiveShadowMapCB /*...*/ {};
class   LightSpacePerspectiveShadowMapVB /*...*/ {};

And LightSpacePerspectiveShadowMap is an alias for 
LightSpacePerspectiveShadowMapDB :


typedef LightSpacePerspectiveShadowMapDB LightSpacePerspectiveShadowMap;

And also StandardShadowMap is usable, but it's not view-dependent, so 
it's pretty much a direct replacement for osgShadow::ShadowMap but in 
the same class hierarchy as the LightSpace* classes.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Jean-Sébastien Guay

Hi Wyatt,


I have changed to a LISPSM shadow technique.


OK.


I have removed the cast bit from my terrain.
The only two objects I have set cast shadow are close together.


This should not need to be done when using LISPSM. It's view-dependent, 
so you don't need to make sure that the shadow map is applied to a small 
part of the scene as you did with the normal ShadowMap. Still, it 
doesn't hurt if you don't need shadows cast by your terrain anyways.



My texture size is 2048 x 2048.
Not seeing shadows on the terrain from my objects.


Did you check the debugHUD (with LISPSM it's as easy as 
shadowTechnique-setDebugDraw(true) )? Does it show something that looks 
valid?


Note that LISPSM's shaders are different than ShadowMap's shaders that 
your used before. It uses a different name for the shadow map sampler, 
and by default it separates the shaders into main and shadow parts, 
though you can still disable the shaders that LISPSM adds and use your 
own (make sure to use the right sampler and uniform names in your 
shader). Check the source in StandardShadowMap.cpp to see what the 
shaders look like.



Changed shadowTexture unit to 7.
Should basetexture be 0 still?  


The base texture unit is just used by the shaders that LISPSM sets by 
default. If you're disabling those and using your own (which you surely 
do if you're using units 0-3 for some effects), then don't worry about it.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Wyatt Earp

 Did you check the debugHUD (with LISPSM it's as easy as
 shadowTechnique-setDebugDraw(true) )? Does it show something that
 looks valid?

I am not sure... With the debugHUD in the ShadowMap example, there was just
a window which appeared to display the shadow map in gray-scale, but in the
LISPSM example, there appears to be two sub-windows in the debughud window
(not in gray-scale). What are these displaying?

 
 Note that LISPSM's shaders are different than ShadowMap's shaders that
 your used before. It uses a different name for the shadow map sampler,
 and by default it separates the shaders into main and shadow parts,
 though you can still disable the shaders that LISPSM adds and use your
 own (make sure to use the right sampler and uniform names in your
 shader). Check the source in StandardShadowMap.cpp to see what the
 shaders look like.

I found the shader source, in StandardShadowMap::StandardShadowMap.  I am a
bit confused about how to use the osgShadow in my app if I already have
shaders in my app.


The osgShadow programmers guide says 

 What if my objects already have a shader applied to them?
* That shader also needs to implement shadow mapping. See the top of
src/osgShadow/ShadowMap.cpp for the basic shader, and use that in your
shader (keep the same names for the variables too).


Am I supposed to, basically, copy the shader code from StandardShader map
and add it to my shaders and turn off the LISPSM shaders?

W

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Wojciech Lewandowski

Hi Wyatt,


Did you check the debugHUD (with LISPSM it's as easy as
shadowTechnique-setDebugDraw(true) )? Does it show something that
looks valid?


I am not sure... With the debugHUD in the ShadowMap example, there was 
just
a window which appeared to display the shadow map in gray-scale, but in 
the

LISPSM example, there appears to be two sub-windows in the debughud window
(not in gray-scale). What are these displaying?


First square displays shadow map using pseudo coloring (if you interested 
why see the comment above the shader in DebugShadowMap.cpp) second  square 
contains dump from predraw of you scene to very small depth texture, this 
extra pre render step is used to compute visible part of scene and optimize 
shadow volume. This second square is only drawn for LispsmDB   
MinimalDrawBoundsShadowMap.




Note that LISPSM's shaders are different than ShadowMap's shaders that
your used before. It uses a different name for the shadow map sampler,
and by default it separates the shaders into main and shadow parts,
though you can still disable the shaders that LISPSM adds and use your
own (make sure to use the right sampler and uniform names in your
shader). Check the source in StandardShadowMap.cpp to see what the
shaders look like.


[..]

Am I supposed to, basically, copy the shader code from StandardShader map
and add it to my shaders and turn off the LISPSM shaders?


Generally yes, But don't turn them off but rather alter them with your 
modified shaders.


WL 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Jean-Sébastien Guay

Hi Wojtek,

Generally yes, But don't turn them off but rather alter them with your 
modified shaders.


That's useful when the ShadowedScene is the root of the scene, and your 
entire scene can be rendered with a single shader (or uber-shader with 
uniforms to select different code paths). But in some cases that might 
not be the case.


I find it more convenient to disable the ShadowTechnique's shaders and 
just place my own shaders at the root of the scene. Also others may 
customize the way their shaders are applied to individual nodes. 
Eventually I intend to start using VirtualProgram too... :-)


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-11 Thread Wojciech Lewandowski



Generally yes, But don't turn them off but rather alter them with your
modified shaders.


That's useful when the ShadowedScene is the root of the scene, and your 
entire scene can be rendered with a single shader (or uber-shader with 
uniforms to select different code paths). But in some cases that might not 
be the case.


I see, that would work too.

I find it more convenient to disable the ShadowTechnique's shaders and 
just place my own shaders at the root of the scene. Also others may 
customize the way their shaders are applied to individual nodes. 
Eventually I intend to start using VirtualProgram too... :-)


I really recommend it. We developed VirtualProgram for this particular 
purpose ie to free user from creating all in one shader.


Wojtek


__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Wyatt Earp
Thanks, That seem to make some change, instead of a grayish circle, I now
see a moving roundish object... 
W


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Tuesday, November 10, 2009 1:31 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...

Hi Wyatt,

 Any suggestions? 

I haven't tried your code, but I don't see you calling 
ShadowMap::setLight() anywhere... Try to add this once your light source 
is initialized:

sm-setLight(ls-getLight());

Other than that, at first glance your code seems OK.

Hope this helps,

J-S
-- 
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Jean-Sébastien Guay

Hi Wyatt,


Thanks, That seem to make some change, instead of a grayish circle, I now
see a moving roundish object... 


Sounds familiar...

Han Solo: [flying across the deserts of Tatooine] I think my eyes are 
getting better. Instead of a big dark blur, I see a big bright blur.


http://www.imdb.com/character/ch002/quotes

/goofing off

Give me a minute, I'll try it out and see.

Just have to ask, if you try with only one object and a ground plane (a 
really simple scene) do you get the same results?


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Jean-Sébastien Guay

Hi Wyatt,

Just have to ask, if you try with only one object and a ground plane (a 
really simple scene) do you get the same results?


I just tested, and your code seems to work. I've attached a source file 
which is the osgshadow example, with the main() commented out and your 
code in its place. Have a look, the only changes were to put the 
ModelThree scene as child of your m_World group and to make sure I had a 
manipulator, and make everything compile...


You seem to be using a skydome (based on a variable called SKYDOME_RANGE 
in the code). You did set your skydome's node mask to ~cast right? 
Otherwise what you're seeing is probably your skydome's shadow being 
cast over everything... That's one thing about using osgShadow, you need 
to make sure things that you don't want to cast shadows don't have the 
cast shadow bit in their node mask. Also HUDs should be set that way. 
Keep an iron grip on your node masks or you'll have unpleasant 
surprises... :-)


The receive shadow node mask is not used for ShadowMap classes, but you 
can implement a node that doesn't receive shadows by adding a case in 
your shader (a test on a boolean uniform that skips the shadow test) and 
set that uniform to true at your scene's root and false for each node 
that you don't want to receive shadows.


And btw, osgShadow::ShadowMap is not really designed for positional 
lights, because they're omnidirectional and would need 6 full-scene RTT 
passes (like a cube map) to be totally accurate. I think (IIRC) 
osgShadow::ShadowMap and the ViewDependentShadow classes try to 
approximate a directional in that case, but the approximation breaks 
down if the light source is positioned inside the bounding box of the 
scene... You're better off either approximating the sun with a 
directional, or using a spot light for an interior scene.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
/* OpenSceneGraph example, osgshadow.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the Software), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

#include osg/ArgumentParser
#include osg/ComputeBoundsVisitor
#include osg/Texture2D
#include osg/ShapeDrawable
#include osg/MatrixTransform
#include osg/Geometry

#include osgGA/TrackballManipulator
#include osgGA/FlightManipulator
#include osgGA/DriveManipulator
#include osgGA/KeySwitchMatrixManipulator
#include osgGA/AnimationPathManipulator
#include osgGA/TerrainManipulator
#include osgGA/AnimationPathManipulator
#include osgGA/StateSetManipulator

#include osgViewer/CompositeViewer
#include osgViewer/ViewerEventHandlers

#include osgShadow/ShadowedScene
#include osgShadow/ShadowVolume
#include osgShadow/ShadowTexture
#include osgShadow/ShadowMap
#include osgShadow/SoftShadowMap
#include osgShadow/ParallelSplitShadowMap
#include osgShadow/LightSpacePerspectiveShadowMap
#include osgShadow/StandardShadowMap

#include osgDB/ReadFile
#include osgDB/WriteFile

#include iostream


// for the grid data..
#include terrain_coords.h
// for the model number four - island scene
#include IslandScene.h


static int ReceivesShadowTraversalMask = 0x1;
static int CastsShadowTraversalMask = 0x2;
/*
namespace ModelOne
{

enum Faces
{
FRONT_FACE = 1,
BACK_FACE = 2,
LEFT_FACE = 4,
RIGHT_FACE = 8,
TOP_FACE = 16,
BOTTOM_FACE = 32
};

osg::Node* createCube(unsigned int mask)
{
osg::Geode* geode = new osg::Geode;

osg::Geometry* geometry = new osg::Geometry;
geode-addDrawable(geometry);

osg::Vec3Array* vertices = new osg::Vec3Array;
geometry-setVertexArray(vertices);

osg::Vec3Array* normals = new osg::Vec3Array;
geometry-setNormalArray(normals);
geometry-setNormalBinding(osg::Geometry::BIND_PER_VERTEX);

osg::Vec4Array* colours = new osg::Vec4Array;
geometry-setColorArray(colours);
geometry-setColorBinding(osg::Geometry::BIND_OVERALL);

Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Wyatt Earp
No but I'll try it...


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Tuesday, November 10, 2009 2:11 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...


Just have to ask, if you try with only one object and a ground plane (a 
really simple scene) do you get the same results?

J-S
-- 
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Wyatt Earp
Getting closer to having this working like I think it should, but I have
noticed something.

When I have one or two objects, say the size of a car, or truck, only.  The
shadow map looks correct. But when I add my terrain which is approximately x
= 5100 by y = 5100, I no longer see the car/truck shadows on the shadow map.

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?

Tnanks,
W


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Tuesday, November 10, 2009 3:08 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...

Hi Wyatt,

 Just have to ask, if you try with only one object and a ground plane 
 (a really simple scene) do you get the same results?

I just tested, and your code seems to work. I've attached a source file
which is the osgshadow example, with the main() commented out and your code
in its place. Have a look, the only changes were to put the ModelThree scene
as child of your m_World group and to make sure I had a manipulator, and
make everything compile...

You seem to be using a skydome (based on a variable called SKYDOME_RANGE in
the code). You did set your skydome's node mask to ~cast right? 
Otherwise what you're seeing is probably your skydome's shadow being cast
over everything... That's one thing about using osgShadow, you need to make
sure things that you don't want to cast shadows don't have the cast shadow
bit in their node mask. Also HUDs should be set that way. 
Keep an iron grip on your node masks or you'll have unpleasant surprises...
:-)

The receive shadow node mask is not used for ShadowMap classes, but you can
implement a node that doesn't receive shadows by adding a case in your
shader (a test on a boolean uniform that skips the shadow test) and set that
uniform to true at your scene's root and false for each node that you don't
want to receive shadows.

And btw, osgShadow::ShadowMap is not really designed for positional lights,
because they're omnidirectional and would need 6 full-scene RTT passes (like
a cube map) to be totally accurate. I think (IIRC) osgShadow::ShadowMap and
the ViewDependentShadow classes try to approximate a directional in that
case, but the approximation breaks down if the light source is positioned
inside the bounding box of the scene... You're better off either
approximating the sun with a directional, or using a spot light for an
interior scene.

Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ShadowMap problem...

2009-11-10 Thread Wyatt Earp
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 bound
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 seeing
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?

W


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Jean-Sébastien Guay
Sent: Tuesday, November 10, 2009 3:08 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] ShadowMap problem...

Hi Wyatt,

 Just have to ask, if you try with only one object and a ground plane 
 (a really simple scene) do you get the same results?

I just tested, and your code seems to work. I've attached a source file
which is the osgshadow example, with the main() commented out and your code
in its place. Have a look, the only changes were to put the ModelThree scene
as child of your m_World group and to make sure I had a manipulator, and
make everything compile...

You seem to be using a skydome (based on a variable called SKYDOME_RANGE in
the code). You did set your skydome's node mask to ~cast right? 
Otherwise what you're seeing is probably your skydome's shadow being cast
over everything... That's one thing about using osgShadow, you need to make
sure things that you don't want to cast shadows don't have the cast shadow
bit in their node mask. Also HUDs should be set that way. 
Keep an iron grip on your node masks or you'll have unpleasant surprises...
:-)

The receive shadow node mask is not used for ShadowMap classes, but you can
implement a node that doesn't receive shadows by adding a case in your
shader (a test on a boolean uniform that skips the shadow test) and set that
uniform to true at your scene's root and false for each node that you don't
want to receive shadows.

And btw, osgShadow::ShadowMap is not really designed for positional lights,
because they're omnidirectional and would need 6 full-scene RTT passes (like
a cube map) to be totally accurate. I think (IIRC) osgShadow::ShadowMap and
the ViewDependentShadow classes try to approximate a directional in that
case, but the approximation breaks down if the light source is positioned
inside the bounding box of the scene... You're better off either
approximating the sun with a directional, or using a spot light for an
interior scene.

Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
 http://whitestar02.webhop.org/

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org