hi,

I have managed to create a directional shadow map with decent results so i decided to go on and try implementing

shadows for spot lights.

From what I understand the basic principle is the same as directional lights but using a perspective projection

instead of an orthogonic projection.

So i use glm::perspective to create the new projection matrix..

glm::vec3 slPos = glm::vec3( 1.0f, 3.0f, 0.0f ); glm::vec3 slDir = glm::vec3( glm::normalize( glm::vec3( 0.0f, 0.0f, 0.0f ) - slPos ) ); glm::mat4 depthProjectionMatrix = glm::perspective<float>( 45.0f, 1.0f, 2.0f, 50.0f ); glm::mat4 depthViewMatrix = glm::lookAt( slPos, glm::vec3( 0.0f, 0.0f, 0.0f ), glm::vec3( 0.0f, 1.0f, 0.0f ) );

And this is the glsl code I use to access the depth value in the sampler2DShadow texture.

if( texture( shadowMap, vec3( ShadowCoord.xyz ) / ShadowCoord.w ) < ( ShadowCoord.z / ShadowCoord.w ) ) { shade = 0.3f; }

Applying these changes i get this result .. there is the correct shadow but also a long shadow that shouldn't be there and I really can't find

an obvious bug..

**Edited by Demx, 28 October 2013 - 06:21 AM.**