From 3afbdff87109b1e4895a845cda808ff2bb88027e Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 8 Mar 2019 06:34:51 -0600 Subject: [PATCH] changes a bit of the probecount logic to be based on probehit aka, how many probes specifically are hitting a given pixel. allows for attenuation-blended probe to probe, and full-override probe to skylight. --- .../advanced/reflectionProbeArrayP.hlsl | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl index a4834363d..17b2206c2 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl @@ -177,6 +177,7 @@ float4 main( PFXVertToPix IN ) : SV_TARGET float blendFacSum = 0; float invBlendSum = 0; int skyID = 0; + float probehits = 0; //Set up our struct data ProbeData probes[MAX_PROBES]; @@ -197,10 +198,12 @@ float4 main( PFXVertToPix IN ) : SV_TARGET if (probes[i].type == 0) //box { probes[i].contribution = defineBoxSpaceInfluence(surface, probes[i], IN.wsEyeRay); + probehits++; } else if (probes[i].type == 1) //sphere { probes[i].contribution = defineSphereSpaceInfluence(surface, probes[i], IN.wsEyeRay); + probehits++; } else //skylight { @@ -223,9 +226,9 @@ float4 main( PFXVertToPix IN ) : SV_TARGET // and respect constraint A. for (i = 0; i < numProbes; i++) { - if (numProbes>1) + if (probehits>1.0) { - blendFactor[i] = ((probes[i].contribution / blendSum)) / (numProbes - 1); + blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1); blendFactor[i] *= ((probes[i].contribution) / invBlendSum); blendFacSum += blendFactor[i]; } @@ -243,14 +246,15 @@ float4 main( PFXVertToPix IN ) : SV_TARGET blendFacSum = 1.0f; } #endif - - float invBlendSumWeighted = 1.0f / blendFacSum; - for (i = 0; i < numProbes; ++i) + if (probehits>1.0) { - blendFactor[i] *= invBlendSumWeighted; - probes[i].contribution = blendFactor[i]; + float invBlendSumWeighted = 1.0f / blendFacSum; + for (i = 0; i < numProbes; ++i) + { + blendFactor[i] *= invBlendSumWeighted; + probes[i].contribution = blendFactor[i]; + } } - #if DEBUGVIZ_ATTENUATION == 1 float attenVis = 0; for (i = 0; i < numProbes; ++i)