properly determine probehits via sub-zero values form attenuation returns, skip out on blendings entirely when determining we're only applying 1 or fewer probes to a pixel. apply alpha subtraction in either case in keeping with the countdown notion.

This commit is contained in:
Azaezel 2019-03-27 10:25:09 -05:00
parent 9b2b87c569
commit 6350e4240b

View file

@ -194,12 +194,14 @@ float4 main(PFXVertToPix IN) : SV_TARGET
if (probes[i].type == 0) //box if (probes[i].type == 0) //box
{ {
probes[i].contribution = defineBoxSpaceInfluence(surface, probes[i], IN.wsEyeRay); probes[i].contribution = defineBoxSpaceInfluence(surface, probes[i], IN.wsEyeRay);
probehits++; if (probes[i].contribution>0.0)
probehits++;
} }
else if (probes[i].type == 1) //sphere else if (probes[i].type == 1) //sphere
{ {
probes[i].contribution = defineSphereSpaceInfluence(surface, probes[i], IN.wsEyeRay); probes[i].contribution = defineSphereSpaceInfluence(surface, probes[i], IN.wsEyeRay);
probehits++; if (probes[i].contribution>0.0)
probehits++;
} }
probes[i].contribution = max(probes[i].contribution,0); probes[i].contribution = max(probes[i].contribution,0);
@ -212,21 +214,16 @@ float4 main(PFXVertToPix IN) : SV_TARGET
// respect constraint B. // respect constraint B.
// Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary // Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary
// and respect constraint A. // and respect constraint A.
if (probehits>1.0) if (probehits>1.0)
{ {
for (i = 0; i < numProbes; i++) for (i = 0; i < numProbes; i++)
{ {
blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1); blendFactor[i] = ((probes[i].contribution / blendSum)) / probehits;
blendFactor[i] *= ((probes[i].contribution) / invBlendSum); blendFactor[i] *= ((probes[i].contribution) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i]; blendFacSum += blendFactor[i];
} }
}
else
{
blendFactor[i] = probes[i].contribution;
blendFacSum = probes[i].contribution;
}
// Normalize blendVal // Normalize blendVal
#if DEBUGVIZ_ATTENUATION == 0 //this can likely be removed when we fix the above normalization behavior #if DEBUGVIZ_ATTENUATION == 0 //this can likely be removed when we fix the above normalization behavior
@ -236,17 +233,16 @@ float4 main(PFXVertToPix IN) : SV_TARGET
} }
#endif #endif
if (probehits>1.0)
{
float invBlendSumWeighted = 1.0f / blendFacSum; float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i) for (i = 0; i < numProbes; ++i)
{ {
blendFactor[i] *= invBlendSumWeighted; blendFactor[i] *= invBlendSumWeighted;
probes[i].contribution = saturate(blendFactor[i]); probes[i].contribution *= blendFactor[i];
alpha -= probes[i].contribution;
alpha -= probes[i].contribution;
} }
} }
else
alpha -= blendSum;
#if DEBUGVIZ_ATTENUATION == 1 #if DEBUGVIZ_ATTENUATION == 1
float attenVis = 0; float attenVis = 0;