How to override RenderBounds baking ?

my shader does some vertex change, but this can not be reflect in frustum culling since it’s using bounds.

my question is how to override the default RenderBounds baking to make culling correct ? thx!

Not entirely sure because haven’t tried, but you can try expanding the Mesh bounds (eg. at import time in an asset post-processor? or when the mesh is loaded at runtime) for no runtime cost:

i solve this by place my code in OnValidate:

    private void OnValidate()
    {
        if (GetComponent<MeshFilter>() != null)
        {
            var mf = GetComponent<MeshFilter>();
            mf.sharedMesh.RecalculateBounds();
            var bounds = mf.sharedMesh.bounds;
            bounds.size = // set bounds what you want;
            mf.sharedMesh.bounds = bounds;
        }
}

this will auto set the bounds before ECS baking.

1 Like