diff --git a/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h b/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h index f9256a595..f043cb5ff 100644 --- a/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h +++ b/sp/src/materialsystem/stdshaders/common_flashlight_fxc.h @@ -10,6 +10,7 @@ #include "common_ps_fxc.h" +#define NEW_SHADOW_FILTERS // Comment if you want to enable retail shadow filter. // JasonM - TODO: remove this simpleton version float DoShadow( sampler DepthSampler, float4 texCoord ) @@ -138,13 +139,28 @@ float DoShadowNvidiaPCF3x3Box( sampler DepthSampler, const float4 shadowMapPos ) // 4 20 33 20 4 // 1 4 7 4 1 // +#if defined( NEW_SHADOW_FILTERS ) +float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float3 shadowMapPos ) +#else float DoShadowNvidiaPCF5x5Gaussian( sampler DepthSampler, const float4 shadowMapPos ) +#endif { +#if defined( NEW_SHADOW_FILTERS ) + // TODO: Set resolution from flashlight's state. + float fEpsilon = 1.0f / 1024.0f; +#else float fEpsilon = 1.0f / 512.0f; +#endif float fTwoEpsilon = 2.0f * fEpsilon; +#if defined( NEW_SHADOW_FILTERS ) + // I guess we don't need this one. + // float ooW = 1.0f / shadowMapPos.w; // 1 / w + float3 shadowMapCenter_objDepth = shadowMapPos; // Do both projections at once +#else float ooW = 1.0f / shadowMapPos.w; // 1 / w float3 shadowMapCenter_objDepth = shadowMapPos.xyz * ooW; // Do both projections at once +#endif float2 shadowMapCenter = shadowMapCenter_objDepth.xy; // Center of shadow filter float objDepth = shadowMapCenter_objDepth.z; // Object depth in shadow space @@ -601,7 +617,12 @@ float DoFlashlightShadow( sampler DepthSampler, sampler RandomRotationSampler, f #if !defined( _X360 ) //PC if( nShadowLevel == NVIDIA_PCF_POISSON ) +#if defined( NEW_SHADOW_FILTERS ) + // Let's replace noise filter with gaussian blur, like in Portal 2. + flShadow = DoShadowNvidiaPCF5x5Gaussian( DepthSampler, vProjCoords ); +#else flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, true, false ); +#endif else if( nShadowLevel == ATI_NOPCF ) flShadow = DoShadowPoisson16Sample( DepthSampler, RandomRotationSampler, vProjCoords, vScreenPos, vShadowTweaks, false, false ); else if( nShadowLevel == ATI_NO_PCF_FETCH4 ) @@ -818,4 +839,4 @@ float3 DoFlashlight( float3 flashlightPos, float3 worldPos, float4 flashlightSpa return diffuseLighting; } -#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ +#endif //#ifndef COMMON_FLASHLIGHT_FXC_H_ \ No newline at end of file