1
\$\begingroup\$

the problem is with shadow mapping as you can see,

actually it works fine but in a certain condition that the Depth Map size must be equal to the size of rendering buffer, I use an infinite directional light

so if the window is 800x600 the depth map must be 800x600, and when i change the size of the shadow map to be 900x600 it starts to be shifted and when it's size be 1024x1024 it also shifts till it disappears

the GLSL shadow function

float calcShadow(sampler2D Dmap, vec4 coor){

vec4 sh = vec4((coor.xyz/coor.w),1);
sh.z *= 0.9;
return step(sh.z,texture2D(Dmap,sh.xy).r);
}

here's the result when it's the same size as the window

Colored result & Depth Map Colored resultDepth Map

and here's the shifted result, as you can notice the depth map is exactly as the previous one with the addition of white space to the right.

Colored result http://goo.gl/5lYIFV

Depth Map http://goo.gl/7320Dd

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

It looks like you are missing a call to glViewport before rendering to the shadow map. The viewport should be set whenever you render to a render target (or texture) of a different size.

\$\endgroup\$
1
  • \$\begingroup\$ If it worked, please mark it as accepted. \$\endgroup\$
    – Heckel
    Jun 3, 2014 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .