From 75d6e89876f74406e75a3aa5575148dfdd6e3b0d Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 14 May 2014 18:57:53 +0200 Subject: [PATCH] Made interactionSM shader sampler loop to use r_shadowMapSamples many iterations --- base/renderprogs/interactionSM.pixel | 41 +++++----------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/base/renderprogs/interactionSM.pixel b/base/renderprogs/interactionSM.pixel index c8c1d5b7..2e6b18c9 100644 --- a/base/renderprogs/interactionSM.pixel +++ b/base/renderprogs/interactionSM.pixel @@ -202,46 +202,19 @@ void main( PS_IN fragment, out PS_OUT result ) // multiple taps -#if 0 - const float2 poissonDisk2[12] = float2[]( - float2(-0.326,-0.406), - float2(-0.840,-0.074), - float2(-0.696, 0.457), - float2(-0.203, 0.621), - float2( 0.962,-0.195), - float2( 0.473,-0.480), - float2( 0.519, 0.767), - float2( 0.185,-0.893), - float2( 0.507, 0.064), - float2( 0.896, 0.412), - float2(-0.322,-0.933), - float2(-0.792,-0.598) - ); - float shadow = 0.0; - - float shadowTexelSize = ( 1.0 / 1024.0 ) * 0.5; - for( int i = 0; i < 12; i++ ) - { - int index = int( rand( shadowTexcoord.xy * 1.0 ) * 12 ); - - float4 shadowTexcoordOffset = float4( shadowTexcoord.xy + poissonDisk2[index] * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w ); - - shadow += texture( samp5, shadowTexcoordOffset.xywz); - } - - shadow *= ( 1.0 / 12.0 ); - -#elif 1 +#if 1 float4 base = shadowTexcoord; base.xy += rpJitterTexScale.xy * -0.5; float shadow = 0.0; - float stepSize = 1.0 / 16.0; + //float stepSize = 1.0 / 16.0; + float numSamples = rpScreenCorrectionFactor.w; + float stepSize = 1.0 / numSamples; float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset; - for( int i = 0; i < 16; i++ ) + for( float i = 0.0; i < numSamples; i += 1.0 ) { float4 jitter = base + tex2D( samp6, jitterTC.xy ) * rpJitterTexScale; jitter.zw = shadowTexcoord.zw; @@ -250,8 +223,8 @@ void main( PS_IN fragment, out PS_OUT result ) jitterTC.x += stepSize; } - shadow *= ( 1.0 / 16.0 ); -#else + shadow *= stepSize; +#else float shadow = texture( samp5, shadowTexcoord.xywz ); #endif