Custom Bounding Box not working

Hi, I’m using a custom vertex shader on an object that deforms the vertices a bit, so I need to expand the bounding box for proper frustum culling. I thought I could just do it script like
renderer.bounds.Expand() … but this doesn’t seem to have any effect…what’s the proper way to change the bounding box for an object? thanks…

Using the renderer.bounds property is frequently confusing and/or surprising:

I’m not sure what the right way is vis-a-vis vertex deformation, but perhaps putting some degenerate zero-surface-area triangles a little ways outside of your object’s natural bounds could help you increase the effective area? You might need to turn off mesh optimization on import, depending on if mesh optimization removes zero-area triangles…

Thanks. What I am doing in specific is using a shader to make sprite objects face the camera rather to doing it in script, so there is no geometry to access per se. It should be a straightforward thing to enlarge the bounding box… this is weird

You should not mess with renderer.bounds as doing so will disable any auto update of the bounding box since this is a worldspace bounding box. So moving the object would have no effect on the bounds. You usually want to change the localBounds if the Renderer or the Mesh (in case of a MeshRenderer).

1 Like