View Full Version : Request: GLSL Shadow Mapping tutorial
01-05-2005, 04:22 AM
Is there any tutorial for implementing shadow maps through GLSL? My google was unsuccessful...
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...
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;
01-06-2005, 04:40 AM
This example is very good starting point.
Thank you, BobVodka :)
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 * 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.
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
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.
3D point depth variation in the light space
Shadow depth variation
Difference between the two (cause of the artifacts)
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.