- Home /
Procedurally generated mesh disappears from certain camera angles
This issue is best explained with a gif, so:
Essentialy I have this procedurally generated mesh, and for some reason in both the editor and the scene view, looking at it from certain angles causes it to not render.
I know it's not a clipping plane problem - I have the near clipping plane set to the smallest possible value, and I've set both the near and far planes to various values to no avail. Also, if it were a clipping plane problem, it wouldn't be happening in the scene view.
It's also not an occlusion culling problem - I have that disabled on the camera.
What is going on here? Why is this mesh disappearing? Any help would be much appreciated!
I had this problem with a normal mesh (not generated), the vertices were about 2 units above the origin and as soon as the origin was out of the screen space the mesh didn't show up. I might try to remember tanoshimi's suggestion about checking if the bounds are correctly set up.
Answer by tanoshimi · Mar 17, 2015 at 12:59 PM
Given you've said this is procedurally-generated, my guess is that you are not correctly recalculating the bounds of the mesh, so Unity is culling the renderer because it considers to be out of the camera view.
Can you confirm that you call RecalculateBounds at the last stage of generating your mesh?
Thank you! I'm an idiot! I made some changes to the way the meshes were made and forgot to re-add the RecalculateBounds step!
Thank you ! i forgot this. and if you want to be sure your mesh is always visible (in case for example if it is dynamic) , you can set bounds to : mesh.bounds = new Bounds(transform.position, new Vector3(float.$$anonymous$$axValue, float.$$anonymous$$axValue, float.$$anonymous$$axValue));
You could, but that means it will never be culled even if it's completely outside the camera frustum, making it use up pointless rendering cycles.
Your answer
Follow this Question
Related Questions
Passing Underneath Section of a Mesh 0 Answers
Fill in mesh? 2 Answers
Prevent inner edges from being at front 0 Answers
Good Game by One Person, Is it Possible? 2 Answers
Mesh Decal System 0 Answers