-
Notifications
You must be signed in to change notification settings - Fork 4
Fix for skirting being incorrectly frustum culled in VR #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
jasonmeisel
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| RenderParams rp = new RenderParams(Material); | |
| var rp = new RenderParams(Material); |
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.