mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
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:
parent
9b2b87c569
commit
6350e4240b
1 changed files with 13 additions and 17 deletions
|
|
@ -194,11 +194,13 @@ 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);
|
||||||
|
if (probes[i].contribution>0.0)
|
||||||
probehits++;
|
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);
|
||||||
|
if (probes[i].contribution>0.0)
|
||||||
probehits++;
|
probehits++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue