Skip to content

Commit 2364a32

Browse files
authored
Merge pull request #1 from kenamis/fix/incorrect-skirting-frustum
Fix for skirting being incorrectly frustum culled in VR
2 parents 85e9c82 + 31943d8 commit 2364a32

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

com.meta.utilities.environment/Runtime/Scripts/Water/QuadtreeRenderer.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ public void BeginContextRendering(List<Camera> cameras, MaterialPropertyBlock pr
132132
// If a skirting range is required
133133
if (m_skirtingSize > m_size)
134134
{
135-
using (ListPool<Matrix4x4>.Get(out var skirtingMatrices))
136-
{
137-
var offsetMatrix = Matrix4x4.Translate(m_currentGridCenter);
138-
skirtingMatrices.Add(offsetMatrix * Matrix4x4.LookAt(Vector3.zero, new Vector3(0f, 0f, 1f), Vector3.up));
139-
skirtingMatrices.Add(offsetMatrix * Matrix4x4.LookAt(Vector3.zero, new Vector3(1f, 0f, 0f), Vector3.up));
140-
skirtingMatrices.Add(offsetMatrix * Matrix4x4.LookAt(Vector3.zero, new Vector3(0f, 0f, -1f), Vector3.up));
141-
skirtingMatrices.Add(offsetMatrix * Matrix4x4.LookAt(Vector3.zero, new Vector3(-1f, 0f, 0f), Vector3.up));
142-
foreach (var matrix in skirtingMatrices)
143-
{
144-
// These are drawn with DrawMesh so that they can cull individually and be depth sorted correctly
145-
Graphics.DrawMesh(m_skirtingMesh, matrix, Material, gameObject.layer, camera, 0, propertyBlock, ShadowCastingMode.Off, false, null, LightProbeUsage.Off);
146-
}
147-
}
135+
var rp = new RenderParams(Material);
136+
rp.camera = camera;
137+
rp.matProps = propertyBlock;
138+
rp.shadowCastingMode = ShadowCastingMode.Off;
139+
rp.layer = gameObject.layer;
140+
rp.receiveShadows = false;
141+
rp.lightProbeUsage = LightProbeUsage.Off;
142+
143+
//Updated Graphics.DrawMesh to newer Graphics.RenderMesh. Graphics.DrawMesh is obsolete per the Unity documentation
144+
Graphics.RenderMesh(rp, m_skirtingMesh, 0, Matrix4x4.TRS(m_currentGridCenter, Quaternion.Euler(0f, 0f, 0f), Vector3.one));
145+
Graphics.RenderMesh(rp, m_skirtingMesh, 0, Matrix4x4.TRS(m_currentGridCenter, Quaternion.Euler(0f, 90f, 0f), Vector3.one));
146+
Graphics.RenderMesh(rp, m_skirtingMesh, 0, Matrix4x4.TRS(m_currentGridCenter, Quaternion.Euler(0f, 180f, 0f), Vector3.one));
147+
Graphics.RenderMesh(rp, m_skirtingMesh, 0, Matrix4x4.TRS(m_currentGridCenter, Quaternion.Euler(0f, 270f, 0f), Vector3.one));
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)