PCF is nothing more than adding the surrounding pixels, and then taking an average value. the smoothness of the result is directly related to the kernel size.
Next we will give you a hand for the Sawtooth teapot PCF with the stroke:
2x2:
3x3:
4x4:
Of course, the larger the kernel, the better the effect. however, the effect is not obvious to a certain extent, and performance issues must be considered. After all, texture sampling is slow for multiple times. in fact, through jitter, a small amount of sampling can be used to achieve an approximate larger kernel effect. here we use 4 sampling times to simulate the effect of 4x4 PCF. The sample template is as follows:
A register VPOs is added in ps3.0 to take the screen coordinates of the current pixel directly and determine the sampling position based on the parity of the coordinates:
Sampler2d texture0; <br/> float2 finverseviewportdimensions; </P> <p> struct ps_input <br/>{< br/> float2 texcoord: texcoord0; <br/> float2 screenpos: VPOs; <br/>}; </P> <p> float4 ps_main (ps_input input): color0 <br/>{< br/> float2 offset = fmod (input. screenpos, 2.0); </P> <p> float4 color = 0; <br/> color + = tex2d (texture0, input. texcoord + (float2 (-1.5,-1.5) + offset) * finverseviewportdimensions); <br/> color + = tex2d (texture0, input. texcoord + (float2 (-0.5, 0.5) + offset) * finverseviewportdimensions); <br/> color + = tex2d (texture0, input. texcoord + (float2 (-1.5, 0.5) + offset) * finverseviewportdimensions); <br/> color + = tex2d (texture0, input. texcoord + (float2 (-0.5, 1.5) + offset) * finverseviewportdimensions); <br/> color * = 0.25; </P> <p> return color; <br/>}< br/>
The final effect is a very efficient solution used in shadow blur: