Code taken pretty much exactly from Marco Salvi's ESM_SHADERX6_DVD and modified to work with Ogre
http://pixelstoomany.wordpress.com/cate ... adow-maps/
Becuase I want to use ESM in deferred shading the code below is meant purely for testing, so its limited to a single spotlight, its not so hard to
create a material that does an ambient pass and iterates the different light types building up the scene light anyway.
Code below isn't an app as such its just the code you need to setup a test app.. also I used shared params for the shadow tweakables, I think shared param material files need to be parsed first so if you want to use this maybe put that in another folder and put it at the top of .conf.
There are number of shadow filters given in Marco Salvi's code (I just picked one) (for testing). I'm going to try this technieque on PSSM next if I can.
code http://www.pearsonp.force9.co.uk/ESM.zip
ESM
- duststorm
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
- Contact:
Re: ESM
Interesting.
I didn't know the technique, so I went looking around a bit. I found a discussion about it here: http://forum.beyond3d.com/showthread.php?t=47528
Basically it's another approach to smoothing or blurring the shadows at the edges (instead of PCF I suppose).
From what they tell it's hard to get it to work well with sunlight and far off cast shadows, is this a fact?
I didn't know the technique, so I went looking around a bit. I found a discussion about it here: http://forum.beyond3d.com/showthread.php?t=47528
Basically it's another approach to smoothing or blurring the shadows at the edges (instead of PCF I suppose).
From what they tell it's hard to get it to work well with sunlight and far off cast shadows, is this a fact?
Developer @ MakeHuman.org
-
- Gremlin
- Posts: 196
- Joined: Tue Aug 08, 2006 6:45 pm
- x 14
Re: ESM
Good questions... can't say I really know the answers.
I can say is its a little more than just a shadow blur.. and I think it might be a given that directional lights with near casters casting a long way will cause the most trouble, but don't they always? truely I'm no expert in this field. I've tried plenty of other shadow algo's tho and they have all been floored in one way or another. ESM is supposedly (from the little that I've read) less floored.
Edit I guess the trouble is far off casters and a blurred shadow map not giving accurate enough depth info when compared and near casters being to blurred to give proper shadow edging is the classic trouble, I think ESM is by taking logs and changing the scale and using "over_darkening_factor" somehow getting around these problems, I have to speak intuitively because I don't really understand the math, I don't have shaderX6 either. Found VSM and chebyshev upper bound prob limit easier to understand.
I can say is its a little more than just a shadow blur.. and I think it might be a given that directional lights with near casters casting a long way will cause the most trouble, but don't they always? truely I'm no expert in this field. I've tried plenty of other shadow algo's tho and they have all been floored in one way or another. ESM is supposedly (from the little that I've read) less floored.
Edit I guess the trouble is far off casters and a blurred shadow map not giving accurate enough depth info when compared and near casters being to blurred to give proper shadow edging is the classic trouble, I think ESM is by taking logs and changing the scale and using "over_darkening_factor" somehow getting around these problems, I have to speak intuitively because I don't really understand the math, I don't have shaderX6 either. Found VSM and chebyshev upper bound prob limit easier to understand.
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: ESM
ESM looks like just a fast way to approximate PCF over a larger sampling area. That is, 2x2-4x4 PCF is being used most of the time and it's quite limited in quality. I guess ESM can approximate something like 8x8 or 16x16 PCF with comparable quality but the speed of 2x2 PCF. But that's only an intelligent guess. Anyway using ESM is asking for troubles with self-shadowing.
-
- Gremlin
- Posts: 196
- Joined: Tue Aug 08, 2006 6:45 pm
- x 14
Re: ESM
Had a go at pssm and failed, I think due to the LiSPM projection, I don't know if its possible to cut that out, like is there a fallback technique I can use? *notes the class inheritance and something with light angle*, I did get it working for basic directional light and hence pic
I have to say at this point I'm feeling rather fond of esm.
I have to say at this point I'm feeling rather fond of esm.
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: ESM
The shadow borders look really good! Can you compare ESM performance against 2x2 and 4x4 PCF?
As for the PSSM <-> LiSPSM they are currently hardwired. You could try copying the current implementation and inheriting it from Ogre::ShadowCameraSetup instead of Ogre::LiSPSMShadowCameraSetup. Then update PSSMShadowCameraSetup::getShadowCamera() to invoke ShadowCameraSetup::getShadowCamera() instead of LiSPSMShadowCameraSetup::getShadowCamera(). Should work in theory.
If that works nicely then I think it will be a perfect call for templating the PSSM implementation in the next Ogre version, e.g.
My personal preference would be aggregation but otherwise that's the smallest change required.
As for the PSSM <-> LiSPSM they are currently hardwired. You could try copying the current implementation and inheriting it from Ogre::ShadowCameraSetup instead of Ogre::LiSPSMShadowCameraSetup. Then update PSSMShadowCameraSetup::getShadowCamera() to invoke ShadowCameraSetup::getShadowCamera() instead of LiSPSMShadowCameraSetup::getShadowCamera(). Should work in theory.
If that works nicely then I think it will be a perfect call for templating the PSSM implementation in the next Ogre version, e.g.
Code: Select all
template< class TBaseShadowCameraSetup = LiSPSMShadowCameraSetup >
class PSSMShadowCameraSetup : public TBaseShadowCameraSetup
{
...
};