After some hard searching on net(so hard),I found a entire tutorial http://thecansin.com/tag/exponential-shadow-maps/
(though it's mainly about deferred shading & on XNA),and though the author has written a very detailed tut,1st,I can't see ESM's effect(not the .fx file,just the effect...) from his example,I used his techniques in my codes,I can't find many superiority like VSM than the normal SMs...the author just encode depth to a form of exponential
Several ways about ESM
Several ways about ESM
Last edited by mengzhu on Wed Jun 29, 2011 6:47 pm, edited 6 times in total.
and,I found another guy's pixel shader codes on ESM http://www.truevision3d.com/forums/anno ... 293.0.html
you can see ,he 's done a PSSM+ESM and wrote
...
float shadow = saturate(exp(max(ESM_MIN, ESM_K * (occluder - receiver))));
...
his calculation is not much like that xna lessons author 's ,I wonder how he save the depth?
The final edit,I suddenly hate all SM,such as esm evsm ,i think many guys have already written things maybe named as PSEVSM ...
you can see ,he 's done a PSSM+ESM and wrote
...
float shadow = saturate(exp(max(ESM_MIN, ESM_K * (occluder - receiver))));
...
his calculation is not much like that xna lessons author 's ,I wonder how he save the depth?
The final edit,I suddenly hate all SM,such as esm evsm ,i think many guys have already written things maybe named as PSEVSM ...
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
It`s been a while since I tried ESM, so I may mislead you somehow and for some weird reason I cannot find my test app, may be in my old pc, but here are some things I still recall (still would be nice if someone else shares his/her opinion):
For ESM you do:
1) Store exponential depth. IIRC I`ve seen different ways doing so like a 0-1 depth, Z/W (clip spaced) and then storing its exponential or linearly with the viewPos.xyz/viewPos.w
2) Apply some logarithmic filtering on the shadowmap
3) Get the shadow value (with the occluder-receiver code)
For ESM you do:
1) Store exponential depth. IIRC I`ve seen different ways doing so like a 0-1 depth, Z/W (clip spaced) and then storing its exponential or linearly with the viewPos.xyz/viewPos.w
2) Apply some logarithmic filtering on the shadowmap
3) Get the shadow value (with the occluder-receiver code)
What exactly do you expect to see? It`s nothing but some gradient looking SM. The way it`s easily recognised is that the shadows it generates usually look darker with distance increase, but it basically depends on what you do.I can't see ESM's effect
What do you mean? It`s not looking as nice as VSM or what?! See, all SM techniques have their pros and cons, one have better performance, but more artifacts etc. Usually you decide and use one and that`s it.I can't find many superiority like VSM than the normal SMs
No, he needs to filter his shadowmap, or it will look bad (well, nonfiltered).the author just encode depth to a form of exponential,then I ask, it does the prefiltering?
As a last note I hate them too, but if I need to use some SM, I will get over it and use it. See, the SMs don`t care whether you love them or not, right?!The final edit,I suddenly hate all SM,such as esm evsm ,i think many guys have already written things maybe named as PSEVSM ...
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
I really thank you from my heart, yesterday I thought no one would answer my mumbling ; I won't beg you for the source now~,it 's not polite because you need to open your old PC;
But I still wonder how to save the depth for the example above?If you and other masters have time ,then give a reply or share a example :
...
#define ESM_K 50.0f // Range [0, 80]
#define ESM_MIN -0.5f // Range [0, -oo]
#define ESM_DIFFUSE_SCALE 1.79f // Range [1, 10]
....
float occluder = tex2D(depthMap, uv)[splitIndex]; // this is sure for PSSM
float shadow = saturate(exp(max(ESM_MIN, ESM_K * (occluder - receiver))));
return 1.0f - (ESM_DIFFUSE_SCALE * (1.0f - shadow)) ;
...
his way is likely from this famous man 's short blog http://pixelstoomany.wordpress.com/2008 ... mple-code/
that ESM theory use a limit calculation to make a approximation of PCF ,as a eternal newbie I feel it's a trick indeed,e.g. : exp( k(Oi-R) ) is lim to 0 ...
And I suddenly hate the author mentioned in 2nd floor ,I can't find his vertex shader on net,and when I save the depth as normal SMs do,I still can see a shadow~~~(just the color is not so black like normal SM's and of course can be scaled by ESM_DIFFUSE_SCALE ) , I feel funny,this let me remember the time I first touch VSM,that VSM source was wrong copied by a guy (he hasn't copied ddx() ddy() but just a Chebyshev inequality)
People say ESM is not that difficult to implement ,but most of them hide the codes~ Though I also find some guy's codes in their SVN trunk, their code is hard or need long time to analyse,and I got a EVSM source but written in DX11(my baby HD4850 not support),though dx11 is not the key problem,I will have to spend long time on reading its codes if I really want to know the secret.
But I still wonder how to save the depth for the example above?If you and other masters have time ,then give a reply or share a example :
...
#define ESM_K 50.0f // Range [0, 80]
#define ESM_MIN -0.5f // Range [0, -oo]
#define ESM_DIFFUSE_SCALE 1.79f // Range [1, 10]
....
float occluder = tex2D(depthMap, uv)[splitIndex]; // this is sure for PSSM
float shadow = saturate(exp(max(ESM_MIN, ESM_K * (occluder - receiver))));
return 1.0f - (ESM_DIFFUSE_SCALE * (1.0f - shadow)) ;
...
his way is likely from this famous man 's short blog http://pixelstoomany.wordpress.com/2008 ... mple-code/
that ESM theory use a limit calculation to make a approximation of PCF ,as a eternal newbie I feel it's a trick indeed,e.g. : exp( k(Oi-R) ) is lim to 0 ...
And I suddenly hate the author mentioned in 2nd floor ,I can't find his vertex shader on net,and when I save the depth as normal SMs do,I still can see a shadow~~~(just the color is not so black like normal SM's and of course can be scaled by ESM_DIFFUSE_SCALE ) , I feel funny,this let me remember the time I first touch VSM,that VSM source was wrong copied by a guy (he hasn't copied ddx() ddy() but just a Chebyshev inequality)
People say ESM is not that difficult to implement ,but most of them hide the codes~ Though I also find some guy's codes in their SVN trunk, their code is hard or need long time to analyse,and I got a EVSM source but written in DX11(my baby HD4850 not support),though dx11 is not the key problem,I will have to spend long time on reading its codes if I really want to know the secret.
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
No, it`s ok, as it`s quite dirty and nothing special and I definitely didn`t invented sth new. Problem is that my old pc`s in my basement and is missing a PSU (donated to a friend), so it`s my lazyness and lack of time more than anything else.I won't beg you for the source now~,it 's not polite because you need to open your old PC;
But, I googled it a bit and I found a topic I used some code from:
http://forum.quest3d.com/index.php?topic=66112.0
Note that it was when I was experimenting with a deferred pipeline, so it may be a bit different.
Haha! I`m really flattered, but I`m a forever-noob-type just like you, the only difference is that I`ve already tried this thingy. But I admit there are many graphics masters and excellent programmers in the shadows around us.If you and other masters have time
I don`t quite believe this to be true, probably you`re just not searching enough. I remember I found many articles about it, and even there was one comparing performance and quality in PCF, VSM, ESM...People say ESM is not that difficult to implement ,but most of them hide the codes
I believe you`ve taken some parallel split ESM or sth alike that`s making the things harder to get. Basically the code in the link I posted is the "heart" of ESM.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Glad to talk with you,you are a warm-hearted man indeed.
The page you give to me http://forum.quest3d.com/index.php?topic=66112.0 is a "famous ESM web page" I think,I did found it before,and another guy(seems like a master ) said dont use that code because it is "wrong wrong wrong",he just did a little change,if you are interested in it you may take a look at his page
http://nolimitsdesigns.com/tag/exponential-shadow-map/
Now,,I think I'll be quiet now,I ’ve said too much words and made you spend too much time on this
The page you give to me http://forum.quest3d.com/index.php?topic=66112.0 is a "famous ESM web page" I think,I did found it before,and another guy(seems like a master ) said dont use that code because it is "wrong wrong wrong",he just did a little change,if you are interested in it you may take a look at his page
http://nolimitsdesigns.com/tag/exponential-shadow-map/
Now,,I think I'll be quiet now,I ’ve said too much words and made you spend too much time on this
Re: Several ways about ESM
I am a big fan of this technique, and currently using it in irrlicht, however i dont understand which part isnt working for you, post code and some screenshots and i will be glad to help out, its a simple and very effcient technique compared to other shadow mapping schemes.
"Irrlicht is obese"
If you want modern rendering techniques learn how to make them or go to the engine next door =p
If you want modern rendering techniques learn how to make them or go to the engine next door =p
Re: Several ways about ESM
Thank you for your warm helping. Maybe you've seen,I 've tried the way mentioned in 2nd floor and see a shadow,but don't know if I'm right.Since every body says ESM is simple to implement,but why even ShaderX6 and above link 's codes are still buggy?so would you share your codes?It's seems no need to hide it ;However,then I can compare every versions and know things in those ESM white papers clearer ,and after some days,maybe other "eternal newbie"s would thank you too~ Allah bless youomaremad wrote:I am a big fan of this technique, and currently using it in irrlicht, however i dont understand which part isnt working for you, post code and some screenshots and i will be glad to help out, its a simple and very effcient technique compared to other shadow mapping schemes.
Re: Several ways about ESM
I'm not a fan of z warping techniques.. I am a firm believer in linear depth for shadow maps. cause its fine if you have exponential depth with a camera, so you get appropriate precision on near objects... but the frusta of the light and camera are independent so z quality has to be consistent unless you have a magical way of making the map exponential around any given target depth.
Re: Several ways about ESM
Hello again, masters,now I think I understand that XNA lessons author's esm codes and run out a good shadow.At first ,I did something wrong with translating something from deferred shading codes(the magic thing is,I can still get a shadow by that wrong way ,I 've said ,this situation is like the time I met a wrong vsm example).