Jump to content
  • Advertisement
Sign in to follow this  
LevyDee

Is my PCF implementation correct?

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


float samp1 = tex2D(ShadowMap, pixelUV);
float samp2 = tex2D(ShadowMap, float2(pixelUV.x + texelSizeU, pixelUV.y));
float samp3 = tex2D(ShadowMap, float2(pixelUV.x, pixelUV.y + texelSizeV));
float samp4 = tex2D(ShadowMap, float2(pixelUV.x + texelSizeU, pixelUV.y + texelSizeV));

float avgSample = (samp1 + samp2 + samp3 + samp4) / 4;

oColor = mapColor * (1 - avgSample);


oColor is my float4 color out.
mapColor I sample from a color buffer.

texelSizeU and texelSizeV I set from code, taking the shadow maps width and height.
1.0f/width 1.0f/height

I am asking because I seem to be getting a funky output.

Share this post


Link to post
Share on other sites
Advertisement
PCF seems fine to me, although i prefer to interpolate the samples based on the original texture sample, instead of just averaging them.

Did you make sure that you have set your sampler to point-sampling? Using linear filtering for shadowmapping can often cause weird artifacts.
A picture of the output would help.

Share this post


Link to post
Share on other sites
I apologize, I was just averaging the depth values, not taking into account my 1's and 0's(in shadow, not in shadow).

Silly mistake!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!