Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sampling a bluured shadow map


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 11 February 2014 - 11:54 AM

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, 11 February 2014 - 11:54 AM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 10143

Like
1Likes
Like

Posted 11 February 2014 - 06:23 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS