lightshaft rendering update

This commit is contained in:
turanszkij
2017-11-08 11:36:09 +00:00
parent f6d64d302a
commit 0c4f0ba694
+17 -23
View File
@@ -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<NUM_SAMPLES; i++){
PSIn.tex.xy -= deltaTexCoord;
float3 sam = xTexture.SampleLevel(Sampler, PSIn.tex.xy, 0).rgb;
sam *= illuminationDecay*xPPParams0[1];
color.rgb += sam;
illuminationDecay *= xPPParams0[2];
}
color*= xPPParams0[3];
PSIn.tex.xy -= deltaTexCoord;
float3 sam = xTexture.SampleLevel(sampler_linear_clamp, PSIn.tex.xy, 0).rgb;
sam *= illuminationDecay*xPPParams0[1];
color.rgb += sam;
illuminationDecay *= xPPParams0[2];
}
return float4(color / numSampling, 1);
color*= xPPParams0[3];
return float4(color, 1);
}