gpu-curtains
    Preparing search index...
    getPCFBaseShadowContribution: "\n// Interleaved Gradient Noise for randomizing sampling patterns\nfn interleavedGradientNoise(position: vec2f) -> f32 {\n return fract(52.9829189 * fract(dot(position, vec2(0.06711056, 0.00583715))));\n}\n\n// Vogel disk sampling for uniform circular distribution\nfn vogelDiskSample(sampleIndex: i32, samplesCount: i32, phi: f32) -> vec2f {\n let goldenAngle: f32 = 2.399963229728653;\n let r: f32 = sqrt((f32(sampleIndex) + 0.5) / f32(samplesCount));\n let theta: f32 = f32(sampleIndex) * goldenAngle + phi;\n return vec2(cos(theta), sin(theta)) * r;\n}\n\nfn getPCFBaseShadowContribution(\n shadowCoords: vec3f,\n fragmentPosition: vec2f,\n pcfSamples: i32,\n shadowRadius: f32,\n bias: f32,\n intensity: f32,\n depthTexture: texture_depth_2d\n) -> f32 { \n let inFrustum: bool = shadowCoords.x >= 0.0 && shadowCoords.x <= 1.0 && shadowCoords.y >= 0.0 && shadowCoords.y <= 1.0;\n let frustumTest: bool = inFrustum && shadowCoords.z <= 1.0;\n\n if(!frustumTest) {\n return 1.0;\n }\n\n var visibility = 0.0;\n \n // Percentage-closer filtering. Sample texels in the region\n // to smooth the result.\n let size: vec2f = vec2f(textureDimensions(depthTexture).xy);\n\n let texelSize: vec2f = 1.0 / size;\n\n // Hardware PCF with LinearFilter gives us 4-tap filtering per sample\n // 5 samples using Vogel disk + IGN = effectively 20 filtered taps with better distribution\n let radius: f32 = shadowRadius * texelSize.x;\n\n // Use IGN to rotate sampling pattern per pixel\n let phi: f32 = interleavedGradientNoise(fragmentPosition.xy) * PI2;\n\n for(var i: i32 = 0; i < pcfSamples; i++) {\n let offset: vec2f = vogelDiskSample(i, pcfSamples, phi) * radius;\n\n visibility += textureSampleCompareLevel(\n depthTexture,\n depthComparisonSampler,\n shadowCoords.xy + offset,\n shadowCoords.z - bias\n );\n }\n\n visibility /= f32(pcfSamples);\n \n return mix(1.0, visibility, saturate(intensity)); \n}\n" = ...

    Helper chunk to compute the shadow visibility of a fragment using shadowCoords, a 2D depthTexture and shadow properties using PCF. Returns 1 when fully visible and 0 when fully shadowed.