PDA

View Full Version : Request: GLSL Shadow Mapping tutorial



nik_bg
01-05-2005, 04:22 AM
Is there any tutorial for implementing shadow maps through GLSL? My google was unsuccessful...

gulgi
01-05-2005, 03:09 PM
Originally posted by nik_bg:
Is there any tutorial for implementing shadow maps through GLSL? My google was unsuccessful...Not that I know of...
I started out with Paul's Project, learning standard shadow mapping, then I just converted it into GLSL.... I answered a few questions about it on gamedev.net some time ago...

Good luck!

bobvodka
01-05-2005, 04:48 PM
ah, I knew I wasnt going crazy, there is infact one out there, which is where I started from, its probably not the most optimal route (not convinced about doing all the mulitplies to remap the vertex possition per fragment!!) however it works;

http://www.ampoff.org/modules.php?name=F...d0715f0c825aadb (http://www.ampoff.org/modules.php?name=Forums&file=viewtopic&t=15&sid=929e2d5849cd4501bd0715f0c825aadb)

nik_bg
01-06-2005, 04:40 AM
This example is very good starting point.
Thank you, BobVodka :)

gulgi
01-06-2005, 12:35 PM
That example uses a sampler2D instead of a sampler2DShadow. But he binds a depth-texture to it. Looks weird to me..

The important line in my vertex shader is:

ProjShadow = gl_TextureMatrix[1] * gl_Vertex;and then in my fragment shader:

color *= shadow2DProj(ShadowMap, ProjShadow).r;But for that to work you have to enable GL_COMPARE_R_TO_TEXTURE_ARB, and set up the texture matrix correctly.

bobvodka
01-06-2005, 04:59 PM
Originally posted by gulgi:
then in my fragment shader:

color *= shadow2DProj(ShadowMap, ProjShadow).r;But for that to work you have to enable GL_COMPARE_R_TO_TEXTURE_ARB, and set up the texture matrix correctly.hmmm I wonder if that would explain my problems, I swapped some code over to using that instead of working out the projective matrix myself in the texture matrix and I picked up alot of artifacts

uto
01-12-2005, 02:18 PM
There is two reason for the artifact.
First if might be because of the "z-fighting" because the depth value are the same on the "lighted" area. Those are easy to remove with an epsilon.
The other is the shadow map resolution, you can check that on the following link that speak more than my english.

-uto-

3D point depth variation in the light space
http://members.gamedev.net/uto/ShadowMap/PointDepthGradient.jpg

Shadow depth variation
http://members.gamedev.net/uto/ShadowMap/shadowDepthGradient.jpg

Difference between the two (cause of the artifacts)
http://members.gamedev.net/uto/ShadowMap/DepthError.jpg