Hi, Im using Graphics.DrawMeshInstanced and Graphics.DrawMeshInstancedIndirect without much problems, but at certain camera orientations the geometry disappears. It is very reliable, I can trigger the issue by rotating the camera back and forth a tiny amount. I am really struggling to understand how this is even possible, there is no culling going on when using these calls right?
Another, perhaps related question is why does Graphics.DrawMeshInstancedIndirect want a bounds as an argument?
You need to add a bounds that cover all the geometry for all the instances. The entire drawcall is culled against that bounds. If that is not visible in the camera nothing will draw.
Thanks, that works for Graphics.DrawMeshInstancedIndirect, my props are no longer disappearing \o/
Graphics.DrawMeshInstanced does not have an overload accepting a bounds, and I compute vertex positions in the shader so the mesh bounds were incorrect. I set it to a large number now which works:
{
...
bounds = new Bounds(Vector3.zero, new Vector3(1000000, 1000000, 1000000))
};```
I used float.Maxvalue previously which doesnt work :S I am also a bit puzzled by this line from the docs:
```Meshes are not further culled by the view frustum or baked occluders```
I guess they are trying to say _individual_ meshes are not culled, but the draw call as a whole is...
Cheers, Bas
I know this thread is old. But I want to recommend not to oversize the bounds. When I did this, my shadow quality was quite worse than setting the actual needed size. It might not happen to every project, since mine has a very special setting, like close fit shadows, an orthographic camera etc. But maybe to someone, this info is helpful.
It helped me alot, visualize the bounds (google “Draw Bounds with Debug.DrawLine” for a git example).
This way, I realized, the bounds draw from the center and I put in the wrong origin.