From 0c4f0ba694c09911dcd6484c57016c6108c8d766 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Wed, 8 Nov 2017 11:36:09 +0000 Subject: [PATCH] lightshaft rendering update --- WickedEngine/lightShaftPS.hlsl | 40 +++++++++++++++------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/WickedEngine/lightShaftPS.hlsl b/WickedEngine/lightShaftPS.hlsl index 4e6ab4391..94ccb932b 100644 --- a/WickedEngine/lightShaftPS.hlsl +++ b/WickedEngine/lightShaftPS.hlsl @@ -1,34 +1,28 @@ #include "imageHF.hlsli" -static const int NUM_SAMPLES = 35; +static const uint NUM_SAMPLES = 35; float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET { - float3 color = float3(0,0,0); - float numSampling = 0.0f; + float3 color = xTexture.Sample(Sampler,PSIn.tex).rgb; - color += xTexture.Sample(Sampler,PSIn.tex).rgb; - numSampling++; - - [branch]if(xPPParams1[0] || xPPParams1[1]) //LIGHTSHAFTS + float2 lightPos = float2(xPPParams1[0] / GetInternalResolution().x, xPPParams1[1] / GetInternalResolution().y); + float2 deltaTexCoord = PSIn.tex - lightPos; + deltaTexCoord *= xPPParams0[0] / NUM_SAMPLES; + float illuminationDecay = 1.0f; + + [unroll] + for (uint i = 0; i < NUM_SAMPLES; i++) { - - float2 lightPos = float2(xPPParams1[0] / GetInternalResolution().x, xPPParams1[1] / GetInternalResolution().y); - float2 deltaTexCoord = PSIn.tex - lightPos; - deltaTexCoord *= 1.0f/NUM_SAMPLES * xPPParams0[0]; - float illuminationDecay = 1.0f; - - for( int i=0; i