Skip to content

Commit bb7362d

Browse files
author
runes
committed
Fixed bug where probes with scaling in their transform would render incorrectly
1 parent 7860f21 commit bb7362d

File tree

1 file changed

+9
-6
lines changed
  • Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass

1 file changed

+9
-6
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -771,17 +771,20 @@ public void GetEnvLightVolumeDataAndBound(VisibleReflectionProbe probe, LightVol
771771

772772
var mat = probe.localToWorld;
773773

774+
Vector3 vx = mat.GetColumn(0);
775+
Vector3 vy = mat.GetColumn(1);
776+
Vector3 vz = mat.GetColumn(2);
777+
Vector3 vw = mat.GetColumn(3);
778+
vx.Normalize(); // Scale shouldn't affect the probe or its bounds
779+
vy.Normalize();
780+
vz.Normalize();
781+
774782
// C is reflection volume center in world space (NOT same as cube map capture point)
775783
var e = bnds.extents; // 0.5f * Vector3.Max(-boxSizes[p], boxSizes[p]);
776-
//Vector3 C = bnds.center; // P + boxOffset;
777-
var C = mat.MultiplyPoint(boxOffset); // same as commented out line above when rot is identity
784+
var C = vx * boxOffset.x + vy * boxOffset.y + vz * boxOffset.z + vw;
778785

779786
var combinedExtent = e + new Vector3(blendDistance, blendDistance, blendDistance);
780787

781-
Vector3 vx = mat.GetColumn(0);
782-
Vector3 vy = mat.GetColumn(1);
783-
Vector3 vz = mat.GetColumn(2);
784-
785788
// transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
786789
vx = worldToView.MultiplyVector(vx);
787790
vy = worldToView.MultiplyVector(vy);

0 commit comments

Comments
 (0)