Jump to content
  • Advertisement
Sign in to follow this  

Shadow Mapping doesn't work in deferred renderer

This topic is 1442 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

Hey I have a problem implementing shadow mapping. For the shadow map I render a 512*512 pixel image from the view of the light. In the final shader I use the gbuffer and the shadow map to do these:

float2 projcoord;
	float mydepth;
	float lightdepth;
	float4 lightviewpos = mul(position,LightViewMatrix);
	lightviewpos = mul(lightviewpos,LightProjectionMatrix);

	projcoord.x = lightviewpos.x / lightviewpos.w / 2.0f + 0.5f;
	projcoord.y = -lightviewpos.y / lightviewpos.w / 2.0f + 0.5f;
	if( (saturate(projcoord.x) == projcoord.x) && (saturate(projcoord.y) == projcoord.y))
		mydepth = rsm_pos.Sample(pointSampler,projcoord).z / rsm_pos.Sample(pointSampler,projcoord).w; 
		lightdepth = lightviewpos.z / lightviewpos.w;
		lightdepth -= 0.001f;

		if( lightdepth < mydepth)
			return diffuse;

I don't know why it doesn't work, it seems to be right. Can somebody 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!