Hi,
I am trying to get shadow mapping working …have exhausted my own ideas.
I am using this tutorial Tutorial 16 : Shadow mapping but failing to get it working in my own code.
I know the first pass is rendering data into the texture, as I have read it back using:
glReadPixels (0, 0, x, y, GL_DEPTH_COMPONENT, GL_FLOAT, pFloat.getPointer());
and if I create a new texture with this data in the red channel I can see the scene from the light pov. The depth buffer contains values ranging from 0.7 (which is my nearest object) to 1.0 for the background.
I think the problem I have is the reading the depth data back in the subsequent fragment shader.
The tutorial uses sampler2DShadow, and reads it using texture( shadowMap, vec3(ShadowCoord.xy, (ShadowCoord.z)/ShadowCoord.w) ); I have tried this & can’t see any shadows.
I have also tried substituting the shadow texture for regular textures - at this stage just to see if I can read the data. I use sampler2D in the fragment shader, and “texture ( Texture, tx).z” to read it. I have created the texture using :
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
I find the documentation really confusing. Just focusing on how to read the texture with the depth map in - which sampler & calls should I use to read the depth data?
Thanks for any ideas.