In part of my stage, I’ve shadows close to the digital camera the place an excellent blur is necessary. I’ve at present applied a 4×4 PCF, which requires 16 texture samples.
I’m making an attempt to see if the equal could be achieved with solely 4 assortment calls.
My code is under and the end result within the picture for PCF (left) and gathered (proper). If the Reth protocol may very well be effective for distant shadows, it’s clearly not for the close by, not less than in the best way I did.
My code:
#outline INV1080 1.0/1080.0 //my shadow map has the dimensions of the display
#outline INV1920 1.0/1920.0
#outline INV1920HALF INV1920*0.5 //I believe we want 0.5 offset for gathering
#outline INV1080HALF INV1080*0.5
//precalculated offset for PCF for the dimensions of my shadowmap. Made for as much as 5x5 sampling
static const float2 OffSetPCF(5)(5) = {
{-2*INV1920, -2*INV1080 },{-INV1920, -2*INV1080 },{0, -2*INV1080 },{INV1920, -2*INV1080 },{2*INV1920, -2*INV1080 },
{-2*INV1920, -INV1080 },{-INV1920, -INV1080 },{0, -INV1080 },{INV1920, -INV1080 },{2*INV1920, -INV1080 },
{-2*INV1920, 0 },{-INV1920, 0 },{0, 0 },{INV1920, 0},{2*INV1920, 0 },
{-2*INV1920, INV1080 },{-INV1920, INV1080 },{0, INV1080 },{INV1920, INV1080 }, {2*INV1920, INV1080 },
{-2*INV1920, 2*INV1080 },{-INV1920, 2*INV1080 },{0, 2*INV1080 },{INV1920, 2*INV1080 },{2*INV1920, 2*INV1080 }
};
//precalculated offset for collect requires the dimensions of my shadowmap
static const float2 OffSetGather(5)(5) = {
{-2*INV1920+INV1920HALF, -2*INV1080+INV1080HALF },{-INV1920+INV1920HALF, -2*INV1080+INV1080HALF },{0+INV1920HALF, -2*INV1080+INV1080HALF },{INV1920+INV1920HALF, -2*INV1080+INV1080HALF },{2*INV1920+INV1920HALF, -2*INV1080+INV1080HALF },
{-2*INV1920+INV1920HALF, -INV1080+INV1080HALF },{-INV1920+INV1920HALF, -INV1080+INV1080HALF },{0+INV1920HALF, -INV1080+INV1080HALF },{INV1920+INV1920HALF, -INV1080+INV1080HALF },{2*INV1920+INV1920HALF, -INV1080+INV1080HALF },
{-2*INV1920+INV1920HALF, 0+INV1080HALF },{-INV1920+INV1920HALF, 0+INV1080HALF },{0+INV1920HALF, 0+INV1080HALF },{INV1920+INV1920HALF, 0+INV1080HALF },{2*INV1920+INV1920HALF, 0+INV1080HALF },
{-2*INV1920+INV1920HALF, INV1080+INV1080HALF },{-INV1920+INV1920HALF, INV1080+INV1080HALF },{0+INV1920HALF, INV1080+INV1080HALF },{INV1920+INV1920HALF, INV1080+INV1080HALF },{2*INV1920+INV1920HALF, INV1080+INV1080HALF },
{-2*INV1920+INV1920HALF, 2*INV1080+INV1080HALF },{-INV1920+INV1920HALF, 2*INV1080+INV1080HALF },{0+INV1920HALF, 2*INV1080 +INV1080HALF },{INV1920+INV1920HALF, 2*INV1080+INV1080HALF },{2*INV1920+INV1920HALF, 2*INV1080+INV1080HALF }
};
float SI = 0;//shadow depth
#ifdef SM_PCF4x4
for (int x=0;x
Can anybody give me recommendation on this feature and find out how to enhance it if attainable? You’ll discover that in compilecmpred, there’s a displacement within the UV and with INT2 as properly. Get rid of extra int2 displacement offers much less blur. I suppose we will mix the 2 varieties of compensation in a single.