|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowContext shadowContext, uint shadowAlgorithm, ShadowData sd, uint texIdx, uint sampIdx, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowContext shadowContext, uint shadowAlgorithm, ShadowData sd, uint texIdx, uint sampIdx, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) |
|
|
|
{ |
|
|
|
real weight = 1.0; |
|
|
|
|
|
|
|
|
|
|
real3 pos = EvalShadow_ReceiverBiasWeightPos( positionWS, normalWS, L, EvalShadow_WorldTexelSize( sd, L_dist, perspProj ), sd.edgeTolerance, EvalShadow_ReceiverBiasWeightUseNormalFlag( sd.nrmlBias.w ) ); |
|
|
|
real3 tcs = EvalShadow_GetTexcoords( sd, pos, perspProj ); |
|
|
|
weight = SampleCompShadow_T2DA( shadowContext, texIdx, sampIdx, tcs, slice ).x; |
|
|
|
weight = SampleCompShadow_T2DA( shadowContext, texIdx, sampIdx, tcs, sd.slice ).x; |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerComparisonState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerComparisonState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) |
|
|
|
return lerp( 1.0, SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, samp, EvalShadow_GetTexcoords( sd, pos, perspProj ), slice ).x, EvalShadow_ReceiverBiasWeightFlag( sd.nrmlBias.w ) ); |
|
|
|
return lerp( 1.0, SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, samp, EvalShadow_GetTexcoords( sd, pos, perspProj ), sd.slice ).x, EvalShadow_ReceiverBiasWeightFlag( sd.nrmlBias.w ) ); |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowContext shadowContext, uint shadowAlgorithm, ShadowData sd, uint texIdx, uint sampIdx, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) { return 1.0; } |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerComparisonState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) { return 1.0; } |
|
|
|
real EvalShadow_ReceiverBiasWeight (ShadowData sd, Texture2DArray tex, SamplerState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, real slice, bool perspProj ) { return 1.0; } |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowContext shadowContext, uint shadowAlgorithm, ShadowData sd, uint texIdx, uint sampIdx, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) { return 1.0; } |
|
|
|
real EvalShadow_ReceiverBiasWeight( ShadowData sd, Texture2DArray tex, SamplerComparisonState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) { return 1.0; } |
|
|
|
real EvalShadow_ReceiverBiasWeight (ShadowData sd, Texture2DArray tex, SamplerState samp, real3 positionWS, real3 normalWS, real3 L, real L_dist, bool perspProj ) { return 1.0; } |
|
|
|
#endif // SHADOW_USE_VIEW_BIAS_SCALING != 0 |
|
|
|
|
|
|
|
// receiver bias either using the normal to weight normal and view biases, or just light view biasing |
|
|
|
|
|
|
float nrmlBiasMax = sd.nrmlBias.y; |
|
|
|
float nrmlBiasScale = sd.nrmlBias.z; |
|
|
|
|
|
|
|
float NdotL = saturate( dot( normalWS, L ) ); |
|
|
|
float NdotL = dot( normalWS, L ); |
|
|
|
float sine = sqrt( saturate( 1.0 - NdotL * NdotL ) ); |
|
|
|
float tangent = abs( NdotL ) > 0.0 ? (sine / NdotL) : 0.0; |
|
|
|
sine = clamp( sine * nrmlBiasScale, nrmlBiasMin, nrmlBiasMax ); |
|
|
|
|
|
|
UnpackShadowType( sd.shadowType, shadowType, shadowAlgorithm ); |
|
|
|
// get the texture |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
float recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, slice, true ); |
|
|
|
float recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, true ); |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); |
|
|
|
// get shadowmap texcoords |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
} |
|
|
|
|
|
|
|
#define EvalShadow_PointDepth_( _samplerType ) \ |
|
|
|
|
|
|
float slice; \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, slice, true ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, true ); \ |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); \ |
|
|
|
/* get shadowmap texcoords */ \ |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); \ |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, tex, samp ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, tex, samp ); \ |
|
|
|
} |
|
|
|
EvalShadow_PointDepth_( SamplerComparisonState ) |
|
|
|
EvalShadow_PointDepth_( SamplerState ) |
|
|
|
|
|
|
UnpackShadowType( sd.shadowType, shadowType, shadowAlgorithm ); |
|
|
|
// sample the texture according to the given algorithm |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, slice, true ); |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, true ); |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); |
|
|
|
// get shadowmap texcoords |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
} |
|
|
|
|
|
|
|
#define EvalShadow_SpotDepth_( _samplerType ) \ |
|
|
|
|
|
|
ShadowData sd = shadowContext.shadowDatas[index]; \ |
|
|
|
float slice; \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, slice, true ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, true ); \ |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); \ |
|
|
|
/* get shadowmap texcoords */ \ |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); \ |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, tex, samp ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, tex, samp ); \ |
|
|
|
} |
|
|
|
EvalShadow_SpotDepth_( SamplerComparisonState ) |
|
|
|
EvalShadow_SpotDepth_( SamplerState ) |
|
|
|
|
|
|
sd.worldToShadow = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].worldToShadow; |
|
|
|
sd.shadowToWorld = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].shadowToWorld; |
|
|
|
sd.scaleOffset.zw = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].scaleOffset.zw; |
|
|
|
sd.slice = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].slice; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
float recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, slice, true ); |
|
|
|
float recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, L_dist, true ); |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); |
|
|
|
// get shadowmap texcoords |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
} |
|
|
|
|
|
|
|
#define EvalShadow_PunctualDepth_( _samplerType ) \ |
|
|
|
|
|
|
sd.worldToShadow = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].worldToShadow; \ |
|
|
|
sd.shadowToWorld = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].shadowToWorld; \ |
|
|
|
sd.scaleOffset.zw = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].scaleOffset.zw; \ |
|
|
|
sd.slice = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].slice; \ |
|
|
|
float slice; \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, slice, true ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, L_dist, true ); \ |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, L_dist, recvBiasWeight, true ); \ |
|
|
|
/* get shadowmap texcoords */ \ |
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, true ); \ |
|
|
|
|
|
|
uint payloadOffset = GetPayloadOffset( sd ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, tex, samp ); \ |
|
|
|
return SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, tex, samp ); \ |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// Directional shadows (cascaded shadow map) |
|
|
|
|
|
|
|
|
|
|
// sample the texture |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
uint shadowType, shadowAlgorithm; |
|
|
|
UnpackShadowType( sd.shadowType, shadowType, shadowAlgorithm ); |
|
|
|
|
|
|
|
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, 1.0, slice, false ); |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, 1.0, false ); |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, 1.0, recvBiasWeight, false ); |
|
|
|
// Be careful of this code, we need it here before the if statement otherwise the compiler screws up optimizing dirShadowSplitSpheres VGPRs away |
|
|
|
real3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz; |
|
|
|
|
|
|
|
|
|
|
// evaluate the first cascade |
|
|
|
real2 sampleBias = EvalShadow_SampleBias_Ortho( sd, normalWS ); |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
real shadow1 = 1.0; |
|
|
|
|
|
|
|
shadowSplitIndex++; |
|
|
|
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, orig_pos, normalWS, L, 1.0, recvBiasWeight, false ); |
|
|
|
posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, false, false ); |
|
|
|
// sample the texture |
|
|
|
UnpackShadowmapId( sd.id, slice ); |
|
|
|
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
} |
|
|
|
} |
|
|
|
shadow = lerp( shadow, shadow1, alpha ); |
|
|
|
|
|
|
\ |
|
|
|
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \ |
|
|
|
\ |
|
|
|
/* sample the texture */ \ |
|
|
|
float slice; \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
\ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, 1.0, slice, false ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, 1.0, false ); \ |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, 1.0, recvBiasWeight, false ); \ |
|
|
|
/* Be careful of this code, we need it here before the if statement otherwise the compiler screws up optimizing dirShadowSplitSpheres VGPRs away */ \ |
|
|
|
real3 splitSphere = dirShadowSplitSpheres[shadowSplitIndex].xyz; \ |
|
|
|
|
|
|
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, true, false ); \ |
|
|
|
/* evalute the first cascade */ \ |
|
|
|
real2 sampleBias = EvalShadow_SampleBias_Ortho( sd, normalWS ); \ |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
real shadow1 = 1.0; \ |
|
|
|
\ |
|
|
|
shadowSplitIndex++; \ |
|
|
|
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, orig_pos, normalWS, L, 1.0, recvBiasWeight, false ); \ |
|
|
|
posTC = EvalShadow_GetTexcoords( sd, positionWS, posNDC, false, false ); \ |
|
|
|
/* sample the texture */ \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sampleBias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
shadow1 = SampleShadow_SelectAlgorithm( shadowContext, sd, orig_payloadOffset, posTC, sampleBias, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
shadow = lerp( shadow, shadow1, alpha ); \ |
|
|
|
|
|
|
|
|
|
|
// get texture description |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, 1.0, slice, false ); |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( shadowContext, shadowAlgorithm, sd, texIdx, sampIdx, positionWS, normalWS, L, 1.0, false ); |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, 1.0, recvBiasWeight, false ); |
|
|
|
// get shadowmap texcoords |
|
|
|
real3 posNDC; |
|
|
|
|
|
|
} |
|
|
|
// sample the texture |
|
|
|
real2 sampleBias = EvalShadow_SampleBias_Ortho( sd, normalWS ); |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithm, texIdx, sampIdx ); |
|
|
|
return shadowSplitIndex < (kMaxShadowCascades-1) ? shadow : lerp( shadow, 1.0, alpha ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
real alpha = border <= 0.0 ? 0.0 : saturate( (relDistance - (1.0 - border)) / border ); \ |
|
|
|
\ |
|
|
|
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \ |
|
|
|
\ |
|
|
|
/* get texture description */ \ |
|
|
|
float slice; \ |
|
|
|
UnpackShadowmapId( sd.id, slice ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, 1.0, slice, false ); \ |
|
|
|
real recvBiasWeight = EvalShadow_ReceiverBiasWeight( sd, tex, samp, positionWS, normalWS, L, 1.0, false ); \ |
|
|
|
positionWS = EvalShadow_ReceiverBias( sd, positionWS, normalWS, L, 1.0, recvBiasWeight, false ); \ |
|
|
|
/* get shadowmap texcoords */ \ |
|
|
|
real3 posNDC; \ |
|
|
|
|
|
|
} \ |
|
|
|
/* sample the texture */ \ |
|
|
|
real2 sampleBias = EvalShadow_SampleBias_Ortho( sd, normalWS ); \ |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, slice, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
real shadow = SampleShadow_SelectAlgorithm( shadowContext, sd, payloadOffset, posTC, sampleBias, shadowAlgorithms[shadowSplitIndex], tex, samp ); \ |
|
|
|
return shadowSplitIndex < (kMaxShadowCascades-1) ? shadow : lerp( shadow, 1.0, alpha ); \ |
|
|
|
} \ |
|
|
|
\ |
|
|
|
|
|
|
|
|
|
|
// load the texel |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, sd.slice ); |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
uint2 texelIdx = EvalShadow_GetTexcoords( sd, positionWS, closestNDC.xy, true ); |
|
|
|
|
|
|
|
// load the texel |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId(sd.id, slice); |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, slice, 0 ).x; |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, sd.slice, 0 ).x; |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
|
|
|
|
// load the texel |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, sd.slice ); |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
uint2 texelIdx = EvalShadow_GetTexcoords( sd, positionWS, closestNDC.xy, true ); |
|
|
|
|
|
|
|
// load the texel |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId(sd.id, slice); |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, slice, 0 ).x; |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, sd.slice, 0 ).x; |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
|
|
|
|
// load the texel |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, sd.slice ); |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
uint2 texelIdx = EvalShadow_GetTexcoords( sd, positionWS, closestNDC.xy, true ); |
|
|
|
|
|
|
|
// load the texel |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId(sd.id, slice); |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, slice, 0 ).x; |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, sd.slice, 0 ).x; |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
|
|
|
|
// load the texel |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, slice ); |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
closestNDC.z = LoadShadow_T2DA( shadowContext, texIdx, texelIdx, sd.slice ); |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |
|
|
|
|
|
|
|
|
|
|
// load the texel |
|
|
|
uint texIdx, sampIdx; |
|
|
|
float slice; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx, slice ); |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, slice, 0 ).x; |
|
|
|
UnpackShadowmapId( sd.id, texIdx, sampIdx ); |
|
|
|
closestNDC.z = LOAD_TEXTURE2D_ARRAY_LOD( tex, texelIdx, sd.slice, 0 ).x; |
|
|
|
|
|
|
|
// reconstruct depth position |
|
|
|
real4 closestWS = mul( closestNDC, sd.shadowToWorld ); |