}
#include "PCSS.hlsl"
real SampleShadow_PCSS(ShadowContext shadowContext, inout uint payloadOffset, real3 coord, real4 scaleOffset, float slice, Texture2DArray tex, SamplerComparisonState compSamp, SamplerState samp)
real SampleShadow_PCSS( ShadowContext shadowContext, inout uint payloadOffset, real3 tcs, real4 scaleOffset, real2 sampleBias, float slice, uint texIdx, uint sampIdx )
return 1;
real LightArea = (params.x / 255.0); //TODO: Floats through payload.
real MinimumFilterSize = (params.y / 255.0);
real shadowSoftnesss = params.x;
int sampleCount = params.y;
real2 SampleBias = real2(sin(GenerateHashedRandomFloat(asuint(coord.x))),
cos(GenerateHashedRandomFloat(asuint(coord.y))));
real2 SampleBias = real2(sin(GenerateHashedRandomFloat(asuint(tcs.x))),
cos(GenerateHashedRandomFloat(asuint(tcs.y))));
if (!BlockerSearch(AverageBlockerDepth, NumBlockers, LightArea + MinimumFilterSize, coord, slice, SampleBias, tex, samp))
if (!BlockerSearch(AverageBlockerDepth, NumBlockers, shadowSoftnesss + 0.001, tcs, sampleBias, shadowContext, slice, texIdx, sampIdx, sampleCount))
real FilterSize = LightArea * PenumbraSize(coord.z, AverageBlockerDepth);
FilterSize = max(FilterSize, MinimumFilterSize);
real FilterSize = shadowSoftnesss * PenumbraSize(tcs.z, AverageBlockerDepth);
FilterSize = max(FilterSize, 0.001);
//3) Filter
return PCSS(tcs, FilterSize, scaleOffset, slice, SampleBias, shadowContext, texIdx, sampIdx, sampleCount);
}
real SampleShadow_PCSS( ShadowContext shadowContext, inout uint payloadOffset, real3 tcs, real4 scaleOffset, float slice, Texture2DArray tex, SamplerComparisonState compSamp, SamplerState samp )
{
return 1;
real2 params = asfloat(shadowContext.payloads[payloadOffset].xy);
real shadowSoftnesss = params.x;
int sampleCount = params.y;
payloadOffset++;
real2 SampleBias = real2(sin(GenerateHashedRandomFloat(asuint(tcs.x))),
cos(GenerateHashedRandomFloat(asuint(tcs.y))));
//1) Blocker Search
real AverageBlockerDepth = 0.0;
real NumBlockers = 0.0;
// if (!BlockerSearch(AverageBlockerDepth, NumBlockers, shadowSoftnesss + 0.001, tcs, slice, SampleBias, tex, samp, sampleCount))
// return 1.0;
//2) Penumbra Estimation
real FilterSize = shadowSoftnesss * PenumbraSize(tcs.z, AverageBlockerDepth);
FilterSize = max(FilterSize, 0.001);
return PCSS(coord, FilterSize, scaleOffset, slice, SampleBias, tex, compSamp);
return PCSS(tcs, FilterSize, scaleOffset, slice, SampleBias, tex, compSamp, sampleCount);
//-----------------------------------------------------------------------------------------------------
// helper function to dispatch a specific shadow algorithm
real SampleShadow_SelectAlgorithm( ShadowContext shadowContext, ShadowData shadowData, inout uint payloadOffset, real3 posTC, real2 sampleBias, uint algorithm, uint texIdx, uint sampIdx )
case GPUSHADOWALGORITHM_PCF_TENT_3X3 : return SampleShadow_PCF_Tent_3x3( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, texIdx, sampIdx );
case GPUSHADOWALGORITHM_PCF_TENT_5X5 : return SampleShadow_PCF_Tent_5x5( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, texIdx, sampIdx );
case GPUSHADOWALGORITHM_PCF_TENT_7X7 : return SampleShadow_PCF_Tent_7x7( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, texIdx, sampIdx );
case GPUSHADOWALGORITHM_PCSS : return SampleShadow_PCSS( shadowContext, payloadOffset, posTC, shadowData.scaleOffset, sampleBias, shadowData.slice, texIdx, sampIdx );
case GPUSHADOWALGORITHM_VSM : return SampleShadow_VSM_1tap( shadowContext, payloadOffset, posTC, shadowData.slice, texIdx, sampIdx );
case GPUSHADOWALGORITHM_EVSM_2 : return SampleShadow_EVSM_1tap( shadowContext, payloadOffset, posTC, shadowData.slice, texIdx, sampIdx, false );
case GPUSHADOWALGORITHM_EVSM_4 : return SampleShadow_EVSM_1tap( shadowContext, payloadOffset, posTC, shadowData.slice, texIdx, sampIdx, true );
case GPUSHADOWALGORITHM_PCF_TENT_3X3 : return SampleShadow_PCF_Tent_3x3( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, tex, compSamp );
case GPUSHADOWALGORITHM_PCF_TENT_5X5 : return SampleShadow_PCF_Tent_5x5( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, tex, compSamp );
case GPUSHADOWALGORITHM_PCF_TENT_7X7 : return SampleShadow_PCF_Tent_7x7( shadowContext, payloadOffset, shadowData.textureSize, shadowData.texelSizeRcp, posTC, sampleBias, shadowData.slice, tex, compSamp );
case GPUSHADOWALGORITHM_PCSS : return SampleShadow_PCSS(shadowContext, payloadOffset, posTC, shadowData.scaleOffset, shadowData.slice, tex, compSamp, s_point_clamp_sampler);
case GPUSHADOWALGORITHM_PCSS : return SampleShadow_PCSS( shadowContext, payloadOffset, posTC, shadowData.scaleOffset, shadowData.slice, tex, compSamp, s_point_clamp_sampler );
default: return 1.0;
}