Search Issue Tracker
By Design
Votes
0
Found in
2019.2.11f1
2019.3
2020.2
Issue ID
1250562
Regression
No
Instanced meshes are not drawn at certain camera angles when Graphics.DrawMeshInstanced method is used
How to reproduce:
1. Open the attached '1250562.zip' project
2. Open '10001_00' Scene
3. Enter Play Mode
4. Pan the viewport camera using left-click mouse in Game View
Expected result: Instanced meshes are shown irrespective from the camera angle
Actual result: Instanced meshes disappear at a certain camera angle
Reproducible with: 2019.3.15f1, 2020.1.0b10, 2020.2.0a12
Could not test: 2018.4.23f1 due to errors thrown in the Console
Notes:
- Video of reproduction attached in Edit
- Reproducible on macOS and Windows
- Mesh instances disappear in Game View (Draw Mesh (instanced) pass is not shown in Frame Debugger) while are present in Scene View
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- SpeedTree does not move when using WindZone
- "Undeclared identifier 'LinearToSRGB'" error is thrown when creating a color variable with HDR color mode and assigning a Custom Render Texture target in Shader Graph
- Input System package is missing when creating a new HDRP project
- Inconsistent behaviour when interacting with different dropdown types with pointer events on parent Visual Element
- Hidden GameObjects won't re-enable when they have call "DontDestroyOnLoad" function
Resolution Note:
The observed issue is caused by incorrect mesh bounds being generated in your MakeMesh method in TerrainTussock.cs.
The generated grass mesh is being assigned a bounding box of new Bounds(-Vector3.one* 50000, Vector3.one * 100000)
which means a bounding box centered on (-50000, -50000, -50000) of size (10000, 10000, 10000)
The vertices of the generated grass mesh are placed outside this bounding box, with positive coordinates.
When DrawMeshInstanced is called, if the camera is facing away from the negative axes, the incorrect bounding boxes of the grass meshes are causing them to be culled, resulting in the observed issue.
One solution would be to generate an accurate bounding box for your mesh when generating, from the actual vertices you are generating.
Alternatively, if you definitely want a very large bounding box then it should have the center positioned such that the bounds will actually cover the vertices of the mesh.
For example, using
mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 100000);
instead of
mesh.bounds = new Bounds(-Vector3.one* 50000, Vector3.one * 100000);