From d6cc399813352bc68e58f28a058fbb751a565050 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 9 Jul 2014 18:06:31 -0500 Subject: [PATCH 1/2] col is a float4, LUMINANCE_VECTOR a float3. results seemed cleaner this end doing a dot of the rgb than padding the lum --- .../game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl | 2 +- .../game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl b/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl index 8769905f6..e8870b3c4 100644 --- a/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl +++ b/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl @@ -45,7 +45,7 @@ float4 main( PFXVertToPix IN ) : COLOR0 col = tex2D( backBuffer, IN.uv0 ); //col = 1 - exp(-120000 * col); - col += dot( col, LUMINANCE_VECTOR ) + 0.0001f; + col += dot( col.rgb, LUMINANCE_VECTOR ) + 0.0001f; col *= brightScalar; } diff --git a/Templates/Full/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl b/Templates/Full/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl index 8769905f6..e8870b3c4 100644 --- a/Templates/Full/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl +++ b/Templates/Full/game/shaders/common/postFx/lightRay/lightRayOccludeP.hlsl @@ -45,7 +45,7 @@ float4 main( PFXVertToPix IN ) : COLOR0 col = tex2D( backBuffer, IN.uv0 ); //col = 1 - exp(-120000 * col); - col += dot( col, LUMINANCE_VECTOR ) + 0.0001f; + col += dot( col.rgb, LUMINANCE_VECTOR ) + 0.0001f; col *= brightScalar; } From 4b3ede66749185ea167c5494930d83902cf1d0a3 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 9 Jul 2014 18:07:23 -0500 Subject: [PATCH 2/2] explicit downcasting for some halfs --- .../game/shaders/common/postFx/lightRay/lightRayP.hlsl | 6 +++--- .../Full/game/shaders/common/postFx/lightRay/lightRayP.hlsl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayP.hlsl b/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayP.hlsl index 7dd334607..ff44abfae 100644 --- a/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayP.hlsl +++ b/Templates/Empty/game/shaders/common/postFx/lightRay/lightRayP.hlsl @@ -59,7 +59,7 @@ float4 main( PFXVertToPix IN ) : COLOR0 half2 deltaTexCoord = (half2)( texCoord.xy - screenSunPos ); // Divide by number of samples and scale by control factor. - deltaTexCoord *= 1.0 / (half)samples * density; + deltaTexCoord *= (half)(1.0 / samples * density); // Evaluate summation from Equation 3 NUM_SAMPLES iterations. for ( int i = 0; i < samples; i++ ) @@ -71,13 +71,13 @@ float4 main( PFXVertToPix IN ) : COLOR0 half3 sample = (half3)tex2Dlod( frameSampler, texCoord ); // Apply sample attenuation scale/decay factors. - sample *= illuminationDecay * weight; + sample *= half(illuminationDecay * weight); // Accumulate combined color. color += sample; // Update exponential decay factor. - illuminationDecay *= decay; + illuminationDecay *= half(decay); } //return saturate( amount ) * color * Exposure; diff --git a/Templates/Full/game/shaders/common/postFx/lightRay/lightRayP.hlsl b/Templates/Full/game/shaders/common/postFx/lightRay/lightRayP.hlsl index 7dd334607..ff44abfae 100644 --- a/Templates/Full/game/shaders/common/postFx/lightRay/lightRayP.hlsl +++ b/Templates/Full/game/shaders/common/postFx/lightRay/lightRayP.hlsl @@ -59,7 +59,7 @@ float4 main( PFXVertToPix IN ) : COLOR0 half2 deltaTexCoord = (half2)( texCoord.xy - screenSunPos ); // Divide by number of samples and scale by control factor. - deltaTexCoord *= 1.0 / (half)samples * density; + deltaTexCoord *= (half)(1.0 / samples * density); // Evaluate summation from Equation 3 NUM_SAMPLES iterations. for ( int i = 0; i < samples; i++ ) @@ -71,13 +71,13 @@ float4 main( PFXVertToPix IN ) : COLOR0 half3 sample = (half3)tex2Dlod( frameSampler, texCoord ); // Apply sample attenuation scale/decay factors. - sample *= illuminationDecay * weight; + sample *= half(illuminationDecay * weight); // Accumulate combined color. color += sample; // Update exponential decay factor. - illuminationDecay *= decay; + illuminationDecay *= half(decay); } //return saturate( amount ) * color * Exposure;