mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
cleanups and perf: only need to subtract the alpha post-blending, not pre and post, contribution>1 shouldn't happen, so max(result,0) suffices, and no need for a for-all-probes-loop if we already know ya only got one probe hitting the pixel under examination.
This commit is contained in:
parent
5703618dc0
commit
1d36cf05b0
1 changed files with 10 additions and 14 deletions
|
|
@ -202,34 +202,30 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
probehits++;
|
probehits++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probes[i].contribution>1 || probes[i].contribution<0)
|
probes[i].contribution = max(probes[i].contribution,0);
|
||||||
probes[i].contribution = 0;
|
|
||||||
|
|
||||||
blendSum += probes[i].contribution;
|
blendSum += probes[i].contribution;
|
||||||
invBlendSum += (1.0f - probes[i].contribution);
|
invBlendSum += (1.0f - probes[i].contribution);
|
||||||
|
|
||||||
alpha -= probes[i].contribution;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
|
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
|
||||||
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
|
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
|
||||||
// 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.
|
||||||
for (i = 0; i < numProbes; i++)
|
if (probehits>1.0)
|
||||||
{
|
{
|
||||||
if (probehits>1.0)
|
for (i = 0; i < numProbes; i++)
|
||||||
{
|
{
|
||||||
blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1);
|
blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1);
|
||||||
blendFactor[i] *= ((probes[i].contribution) / invBlendSum);
|
blendFactor[i] *= ((probes[i].contribution) / invBlendSum);
|
||||||
blendFacSum += blendFactor[i];
|
blendFacSum += blendFactor[i];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
blendFactor[i] = probes[i].contribution;
|
|
||||||
blendFacSum = probes[i].contribution;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blendFactor[i] = probes[i].contribution;
|
||||||
|
blendFacSum = probes[i].contribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Normalize blendVal
|
// Normalize blendVal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue