# Sampling a bluured shadow map

This topic is 1436 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 everyone,

I'm working on a program which uses an external pre-rendered shadow map to create static shadows. I want to create soft-edged shadows so I have applied a Gaussian blur to the shadow map using Paint.net. However, I'm not really sure how to use this to create soft shadows in my program. Here's my code for sampling the shadow map in HLSL:

if ((saturate(shadowProjectedTexCoords.x) == shadowProjectedTexCoords.x) && (saturate(shadowProjectedTexCoords.y) == shadowProjectedTexCoords.y))
{
if ((PSIn.Pos2DAsSeenByLight.z - f_ShadowEpsilon) > tex2D(ShadowMapSampler, shadowProjectedTexCoords).r && (PSIn.Pos2DAsSeenByLight.z - f_ShadowEpsilon) <= f_ShadowFarClip)
{
diffuseLightingFactor = 0;
specularLightingFactor = 0;
}
}


How do I convert this to take advantage of the blurred shadow map and get soft shadows?

Thanks!

Edited by george7378

#### Share this post

##### Share on other sites

You can't just blur a shadow map, it won't give you the results you want. Instead the standard procedure is to take multiple samples from the shadow map, compare with each one, and then filter the results. It's known as Percentage Closer Filtering, or PCF for short. There are also more advanced shadow map techniques like variance shadow maps or exponential shadow maps that allow filtering the shadow map directly, but they require using different techniques when rendering and sampling the shadow map.