Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Sampling a bluured shadow map

4: Adsense

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   

1419
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.


#2 MJP   Moderators   

19471
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.