Jump to content
  • Advertisement
Sign in to follow this  

Shadowmapping & Graphical Errors

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

i've now implemented shadow mapping into my project and i'm not that impressed by it. this has several reasons: 1. to self shadow the terrain, i must check wether the pixel is the front of the mesh or the back ( from pos of the light ) this results in that crappy effect, that a triangle is shadowed or not ( and the in between state looks much more ****** ) you can see it here. it's in wireframe mode, because you can clearly see that type of "bug" 2. i've encountered some other graphical errors as well, it can't describe it well, so just look here or a here on the screens you can also see the Shadowmap, wich has been drawed to a quad. this is the shader code ( perhaps there are some errors (?)
// these are the shadow values, set in the project
Effect->SetFloat("ShadowOffset", 0.015f);
Effect->SetFloat("AmbientShadowValue", 0.1f);
Effect->SetFloat("ShadowIntensity", 0.4f);

// vertexshader
VS_OUTPUT VS(float4 Pos: POSITION, float3 Normal: NORMAL, float2 Tex0 : TEXCOORD0)
	N = mul(Normal, matRotation);
	tempFloat = saturate(dot(N, (float3)vecLightDir));
      Out.Pos	 = mul(Pos, matWorldViewProjection);
	Out.Tex0 = Tex0; 
	// Shadow stuff
	LightViewPortCoordinates = mul(Pos, matWorldLightViewProjection);
	Out.ShadowTex.x = 0.5f*LightViewPortCoordinates.x + 0.5f;
	Out.ShadowTex.y = 0.5f  - 0.5f*LightViewPortCoordinates.y;
	Out.LightSpacePixelDepth.x = tempFloat;
	Out.LightSpacePixelDepth.y = LightViewPortCoordinates.z - ShadowOffset;

	return Out;

// sampler
sampler LightDepthMapSampler = sampler_state
	texture = (LightDepthMapTexture);

// Pixelshader
float4 PS(float2 Tex0 : TEXCOORD0, float2 ShadowTex : TEXCOORD1, float2 LightSpacePixelDepth : TEXCOORD2) : COLOR 
    tempFloat = step(0.0f, tex2D(LightDepthMapSampler, ShadowTex).z - LightSpacePixelDepth.y);

    tempFloat *= ShadowIntensity*LightSpacePixelDepth.x;
    tempFloat += AmbientShadowValue;

    return tempFloat*tex2D(SkinSampler, Tex0);

i'm now playing with the shadow values, perhaps i find a setting wich eliminates or dimmers the graphic errors. but if you have any more tipps, i would be very gratefull if you share them with 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!