Skip to content

Conversation

@kenamis
Copy link

@kenamis kenamis commented Nov 27, 2025

The skirting mesh can get frustum culled in VR due to using the obsolete Graphics.DrawMesh function. This pull request changes to use the newer Graphics.RenderMesh function.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 27, 2025
Copy link
Contributor

@jasonmeisel jasonmeisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

}
RenderParams rp = new RenderParams(Material);
rp.camera = camera;
//rp.worldBounds //Let Graphics.RenderMesh use the mesh local bounds transformed to world space
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you get rid of the //rp.worldBounds and write a comment clarifying why using RenderMesh eliminates the frustum culling?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that line and added a comment about using Graphics.RenderMesh instead of Graphics.DrawMesh because the latter is obsolete.
I thought I remember official Unity post that one of the reason for Graphics.RenderMesh change was because Graphics.DrawMesh didn't handle XR stereo frustum calculation correctly. I couldn't find it again though.
In my project, the skirting would sometimes disappear, while in view, and I narrowed it down to them getting incorrectly frustum culled. After confirming the mesh bounds were correct, I remembered about the API change and that fixed it.

I supposed a few lines above for the matrix mesh pairs, the Graphics.DrawMeshInstanced should be updated as well.

Graphics.DrawMesh(m_skirtingMesh, matrix, Material, gameObject.layer, camera, 0, propertyBlock, ShadowCastingMode.Off, false, null, LightProbeUsage.Off);
}
}
RenderParams rp = new RenderParams(Material);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RenderParams rp = new RenderParams(Material);
var rp = new RenderParams(Material);

@kenamis kenamis requested a review from jasonmeisel December 7, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants