getDistBoxToPoint max, not length nets us hard edges instea of drounded, float3 extents = probe.boxMax; isn't neded, can use unit space for that and put box min/max back to controlling the reflected boxe's scale. divnull safety

This commit is contained in:
Azaezel 2019-03-18 17:07:43 -05:00
parent 04a6130df8
commit 3aac1421cc

View file

@ -65,7 +65,7 @@ float defineSphereSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeR
float getDistBoxToPoint(float3 pt, float3 extents)
{
float3 d = max(max(-extents - pt, 0), pt - extents);
return length(d);
return max(max(d.x,d.y),d.z);
}
float defineBoxSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeRay)
@ -74,7 +74,7 @@ float defineBoxSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeRay)
//float3 boxMinLS = mul(probe.worldToLocal, float4(probe.boxMin, 1.0)).xyz;
//float3 extents = mul(probe.worldToLocal, float4(probe.boxMax, 1.0)).xyz;
float3 extents = probe.boxMax;
float3 extents = float3(1,1,1);//probe.boxMax;
/*float3 boxOuterRange = boxMaxLS;
float3 boxInnerRange = boxOuterRange * 0.5;
@ -92,7 +92,7 @@ float defineBoxSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeRay)
float3 reducedExtents = extents - float3(transitionDistance, transitionDistance, transitionDistance);
float distToBox = getDistBoxToPoint(surfPosLS * extents, reducedExtents);
float normalizedDistance = distToBox / transitionDistance;
float normalizedDistance = distToBox / max(transitionDistance,0.0001);
// If closer than 70% to the probe radius, then full contribution is used.
// For the other 30% we smoothstep and return contribution lower than 1 so other
@ -376,4 +376,4 @@ float4 main( PFXVertToPix IN ) : SV_TARGET
return float4(cubeColor, 1);
#endif
}
}