Jump to content
  • Advertisement
Sign in to follow this  

can't apply shadow map

This topic is 2856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi !
I render into a shadow map and this step works well, i render it in ortho mode as camera with :

D3DXMatrixOrthoLH( &lightProjectionMatrix, 512.0f, 512.0f, 1.0f, 10000.0f );

Then, i compute this matrix :

float textureOffset = 0.5f + (0.5f / 512.0f);

D3DXMATRIX texMatrix( 0.5f, 0.0f, 0.0f, 0.0f,
0.0f, -0.5f, 0.0f, 0.0f,
0.0f, 0.0f, (powf(2.0f, 32.0f)-1.0f), 0.0f,
textureOffset, textureOffset, 0.0f, 1.0f );

shadowWarpMatrix = lightProjectionMatrix * texMatrix;

which i use in my pixel shader :

half shadowMapping( /*float4x4 ShadowWarpMatrix*/psIn IN )
float4 lightSpaceVertexPosition = mul( tex2D(positionMap, IN.texCoord), lightProjectionMatrix );
float4 texCoord = mul( lightSpaceVertexPosition, shadowWarpMatrix );
texCoord.xyz /= texCoord.w ;
half shadowed ;
tex2D( shadowMap, texCoord.xy ).r < texCoord.z ? (shadowed = 0) : (shadowed = 1) ; /*(length(lightPosition[1]- tex2D(positionMap, IN.texCoord).xyz)/10000)*/ /*(lightSpaceVertexPosition.z / lightSpaceVertexPosition.w)*/ //tex2Dproj(shadowMap, float4(pixel.xy + (1.0/512.0) * pixel.w, pixel.z, pixel.w));//tex2Dproj( shadowMap, pixel );
return shadowed;

what i finally get is a black quad in the upper left corner of my rendering window which hides the final image...
I have no quad, and therefore a rendering without shadow if use perspective mode and not ortho as camera.
Can you help me ?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!