Request: GLSL Shadow Mapping tutorial

Is there any tutorial for implementing shadow maps through GLSL? My google was unsuccessful…

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!

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

This example is very good starting point.
Thank you, BobVodka :slight_smile:

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.

Originally posted by gulgi:
[b]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.[/b]
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

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
[link]http://members.gamedev.net/uto/ShadowMap/PointDepthGradient.jpg[/link]

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

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

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.