Override a bounding box

Hello,

I have a mesh that is rendered with a vertex shader with custom matrices that completely modifies its position. The default bounding box of the object (renderer.bounds) no longer represent the resulting bounds of the object and it is frustum culled when rendered whereas it should be visible.

Is there a way to override the current bounding box of an object or disable the frustum culling for this object (tell Unity to always render this object) ? The renderer.bounds property is Read-Only.

Currenty I will have to render the mesh manually with Graphics.DrawMeshNow but this is not really convenient.

2 Answers

2

It looks like Mesh.bounds is writable. I’d guess Renderer.bounds is a pointer to that, which is why it’s read only. Docs suggest Mesh.bounds are only autocalced when you assign triangles (since you need to explicitly call Mesh.RecalculateBounds if you modify Mesh.verts.)

I’d think setting Mesh.bounds to to include the max displacements should solve it.

I’ve got the same problem.
RecalculateBounds doesn’t work to me.