Re: [osg-users] Autoshadow aliasing in shadow maps

2011-09-27 Thread Justo Ureña
Hi all, 

Thanks for your posts, and sorry for my very late response. I´ve been on 
holidays and working in another things, so I left this issue abandoned.

But finally, I could get rid of these artifacts, and therefore, solve my 
problem. Although the filters mitigated the effect, they were still noticeable 
and the performance was affected. But the solution that Robert proposed works 
almost perfectly for me! As Robert said, the key was to do the lighting 
calculations in the fragment shader, and multiply the shadow factor by the 
diffuse light component. After that, I can add the ambient light factor to 
achieve a well lighted surface. This solution is so easy conceptually and to 
implement that I´m mad at myself because I didn´t think about it ;)

Thank you very much for your help, I think that this thread can be marked as 
solved.

Cheers,
Justo

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





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


Re: [osg-users] Autoshadow aliasing in shadow maps

2011-08-30 Thread Robert Osfield
Hi Sergey,

On Mon, Aug 29, 2011 at 10:55 PM, Sergey Polischuk pol...@yandex.ru wrote:
 All shadowmapping techniques have problems with such aliasing problems. You 
 can try use shadow volumes technique as it dont suffer from this problem and 
 generates correct shadows in any case, but it have other drawbacks. IIRC this 
 algo also implemented in osgShadows.

Shadow volumes will have problems with vertical surfaces that cast
their own shadow as well as numerical precision issues will mean that
some areas will classified in and other areas classified as out of the
shadow.

The matching of the vertex and fragment shaders handling of ambient
light is solution in both cases.

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


Re: [osg-users] Autoshadow aliasing in shadow maps

2011-08-29 Thread Sergey Polischuk
Hi, Justo

All shadowmapping techniques have problems with such aliasing problems. You can 
try use shadow volumes technique as it dont suffer from this problem and 
generates correct shadows in any case, but it have other drawbacks. IIRC this 
algo also implemented in osgShadows.

Cheers,
Sergey.

25.08.2011, 22:12, Justo Ureña chil...@hotmail.com:
 Hi,

 I´m testing diferent shadows techniques for my scene, and after some adjusts, 
 I got them working fine... Except for very big aliasing that appears in some 
 surfaces that are parallel to the light direction. It happens in all the 
 shadow maps techniques (ShadowMap, StandardShadowMap, LISPSM)... and I´ve 
 tried all the things that I could imagine to get rid of them without 
 success... Please, anyone can help me with that?

 From my investigation I got that the problem is that the depth map calculated 
 by the shadow camera does not fit exactly with the curved shape in the scene. 
 In the attachment you can see a render of the scene (that only includes the 
 cessna and a vertical directional light that produces the shadow) coloured 
 with the depth map. As you can see, in the laterals of the cessna appear 
 these withe stiches that means that the depth calculated in these texels of 
 the map is infinite, what is obviously wrong. There is any way to avoid this 
 annoying effect?

 Thank you very much!

 Cheers,
 Justo

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

 ___
 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] Autoshadow aliasing in shadow maps

2011-08-27 Thread Robert Osfield
Hi Justo,

On Sat, Aug 27, 2011 at 12:17 AM, Justo Ureña chil...@hotmail.com wrote:

 I´ve tried the ViewDependentShadowMap and although it works great, I still 
 have the same problem with the stiching due to the missing tessels...

Good to hear it's work well for you.  The aliasing artifact you are
still seeing is expected, it's a trait that all shadow technique will
have, but if the vertex and fragment shaders are properly setup this
issue will disappear, you can still still the artifact with
ViewDepententShadowMap as the shaders have been kept deliberately
simple.


 Robert, you´re right about that in a normal illumination, these surfaces 
 should be set to the ambient colour, cause their normals are pendicular with 
 the light direction. But as my scene is an outside static scene, and I don´t 
 want to illuminate a big portion of the scene with the ambient light because 
 it looks flat, I´m trying to implement some kind of hemispheric lighting 
 (from the glsl orange book), but without renouncing to the shadow effect. So, 
 I need this perpendicular surfaces to be lit, and to show the shadows...

There is no reason why you can't use different lighting models when
doing shadow mapping.  The key element to solve the artifact you are
seeing is computing the the diffuse+specular element  of lighting
separate the ambient component and not combining them until you've
take the result from the shadow map.  Typically the ambient  and
diffuse+specular components are all combined in the vertex shaders and
passed as a single colour to the fragment shader, but instead you'll
want to pass these as two colours to the fragment shader and have the
fragment shader do the shadow map test, then if you the fragment is
the shadow you'll want to just use the ambient contribution, but if
it's not in shadow you'll want to add the diffuse+specular component.

If this is done correctly then when the normal is perpendicular to the
light source the diffuse+specular component will be zero so the end
result will be the equal to the ambient component whether you are in
the shadow or not.

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


Re: [osg-users] Autoshadow aliasing in shadow maps

2011-08-26 Thread David Callu
Hi Justo,


Take a look to the Variante Shadow Map
algorithmhttp://developer.nvidia.com/node/165 to
apply shadow on the scene.
Instead of use default OpenGL ShadowMap comparaison technique, this
algorithm
provide a different way to capture and apply shadow.
This technique take more resource but with a better result.

HTH
David Callu



2011/8/25 Robert Osfield robert.osfi...@gmail.com

 Hi Justo,

 Surfaces that are parallel to the light source will be subject to
 numerical aliasing issues that will mean that either the fragment is
 inside or outside that shadow map.  You can't avoid these aliasing
 issues completely but if the vertex and fragment shaders are set up
 correctly then the parallel surfaces should in theory have the same
 ambient lighting regardless of being in the shadow or not so you
 shouldn't see the aliasing artifact.

 I have just developed a new shadow technique that you'll find checked
 into svn/trunk, look for the ViewDependentShadowMap, use the --vdsm
 option in osgshadow example.  All going well this will replace the
 collection of other shadow techniques.  I would recommend testing
 against this new technique.

 Robert.

 On Thu, Aug 25, 2011 at 7:12 PM, Justo Ureña chil...@hotmail.com wrote:
  Hi,
 
  I´m testing diferent shadows techniques for my scene, and after some
 adjusts, I got them working fine... Except for very big aliasing that
 appears in some surfaces that are parallel to the light direction. It
 happens in all the shadow maps techniques (ShadowMap, StandardShadowMap,
 LISPSM)... and I´ve tried all the things that I could imagine to get rid of
 them without success... Please, anyone can help me with that?
 
  From my investigation I got that the problem is that the depth map
 calculated by the shadow camera does not fit exactly with the curved shape
 in the scene. In the attachment you can see a render of the scene (that only
 includes the cessna and a vertical directional light that produces the
 shadow) coloured with the depth map. As you can see, in the laterals of the
 cessna appear these withe stiches that means that the depth calculated in
 these texels of the map is infinite, what is obviously wrong. There is any
 way to avoid this annoying effect?
 
  Thank you very much!
 
  Cheers,
  Justo
 
  --
  Read this topic online here:
  http://forum.openscenegraph.org/viewtopic.php?p=42241#42241
 
 
 
 
  ___
  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] Autoshadow aliasing in shadow maps

2011-08-26 Thread Justo Ureña
Hi,

thank you Robert and David for your answers, I really appreciate them.


 I have just developed a new shadow technique that you'll find checked 
 into svn/trunk, look for the ViewDependentShadowMap, use the --vdsm 
 option in osgshadow example. All going well this will replace the 
 collection of other shadow techniques. I would recommend testing 
 against this new technique. 
 

I´ve tried the ViewDependentShadowMap and although it works great, I still have 
the same problem with the stiching due to the missing tessels... Robert, 
you´re right about that in a normal illumination, these surfaces should be 
set to the ambient colour, cause their normals are pendicular with the light 
direction. But as my scene is an outside static scene, and I don´t want to 
illuminate a big portion of the scene with the ambient light because it looks 
flat, I´m trying to implement some kind of hemispheric lighting (from the 
glsl orange book), but without renouncing to the shadow effect. So, I need this 
perpendicular surfaces to be lit, and to show the shadows... 


 Take a look to the Variante Shadow Map algorithm to apply shadow on the 
 scene. 
 Instead of use default OpenGL ShadowMap comparaison technique, this algorithm 
 provide a different way to capture and apply shadow. 
 This technique take more resource but with a better result. 


I´ve already tested another filters as PCF, but the results weren´t so good and 
it consumed a lot of resources. I´ve read about the VSM algorithm, and I was 
doubting about implementing it. I think that I´m gonna try it, and I´ll let you 
know the results. Hopefully it will get rid of the problem. Hopefully!


Thank you very much guys!

PS: Anyway, I´m still curious with the missing texels problem. I´ve been 
investigating about it and I couldn´t get anything... Isn´t there any way to 
make the RTT camera to set the depth of this texel to the fragments one? Do you 
have any hint about it?
Thanks again.

Cheers,
Justo

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





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


Re: [osg-users] Autoshadow aliasing in shadow maps

2011-08-26 Thread Jean-Sébastien Guay

Hi Justo,


PS: Anyway, I´m still curious with the missing texels problem. I´ve been 
investigating about it and I couldn´t get anything... Isn´t there any way to make the RTT 
camera to set the depth of this texel to the fragments one? Do you have any hint about it?


There aren't any missing texels as you seem to think. In shadow map 
space, that area simply maps nowhere (it falls between 2 texels). You 
have 2 options: higher shadow map resolution so that the area where this 
happens is smaller, or do some filtering to hide the effect.


We had a similar effect where we would get a kind of moiré pattern 
over surfaces. It was most visible on very white surfaces and when the 
shadow map was stretched over a large area. Zoomed up close, the 
appearance was identical to what you have.


In our case simple PCF filtering worked for us, but you say you've tried 
it and rejected it. You could try some other type of filtering, or 
increase your shadow map resolution, though I doubt you'll get to a 
point where the artifact is not visible while keeping a reasonable 
resolution... For us it was still visible at 4096^2 resolution, so 
filtering was the best we could do.


Unfortunately this is the kind of thing (like z-buffer precision leading 
to z-fighting) where you just have to know what the artifacts could be, 
and manage all your options so you minimize the appearance of the 
artifacts. There is no perfect solution.


Hope this helps,

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


Re: [osg-users] Autoshadow aliasing in shadow maps

2011-08-25 Thread Robert Osfield
Hi Justo,

Surfaces that are parallel to the light source will be subject to
numerical aliasing issues that will mean that either the fragment is
inside or outside that shadow map.  You can't avoid these aliasing
issues completely but if the vertex and fragment shaders are set up
correctly then the parallel surfaces should in theory have the same
ambient lighting regardless of being in the shadow or not so you
shouldn't see the aliasing artifact.

I have just developed a new shadow technique that you'll find checked
into svn/trunk, look for the ViewDependentShadowMap, use the --vdsm
option in osgshadow example.  All going well this will replace the
collection of other shadow techniques.  I would recommend testing
against this new technique.

Robert.

On Thu, Aug 25, 2011 at 7:12 PM, Justo Ureña chil...@hotmail.com wrote:
 Hi,

 I´m testing diferent shadows techniques for my scene, and after some adjusts, 
 I got them working fine... Except for very big aliasing that appears in some 
 surfaces that are parallel to the light direction. It happens in all the 
 shadow maps techniques (ShadowMap, StandardShadowMap, LISPSM)... and I´ve 
 tried all the things that I could imagine to get rid of them without 
 success... Please, anyone can help me with that?

 From my investigation I got that the problem is that the depth map calculated 
 by the shadow camera does not fit exactly with the curved shape in the scene. 
 In the attachment you can see a render of the scene (that only includes the 
 cessna and a vertical directional light that produces the shadow) coloured 
 with the depth map. As you can see, in the laterals of the cessna appear 
 these withe stiches that means that the depth calculated in these texels of 
 the map is infinite, what is obviously wrong. There is any way to avoid this 
 annoying effect?

 Thank you very much!

 Cheers,
 Justo

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




 ___
 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