ColinLeung-NiloCat / UnityURP-MobileDrawMeshInstancedIndirectExample

Example project to draw 1million grass instances on mobile
https://youtu.be/A7rav4tS88s
MIT License
1.56k stars 237 forks source link

Pink triangle when built in Unity 2022.3.6 #5

Closed Torgo13 closed 11 months ago

Torgo13 commented 1 year ago

In Unity 2022.3.5 and 2022.3.6 the grass renders in the editor, but in a built application only a single pink triangle is drawn. If you move the camera close to the triangle the framerate drops significantly. The triangle can only be seen from one side.

Editor: 2023-08-05

Standalone build: 2023-08-05 (1)

The same issues occurs on:

Note: Dynamic Resolution is broken in Unity 2022 so disable it on the camera before testing.

In the documentation for Graphics.DrawMeshInstancedIndirect, it says: This function is now obsolete. Use Graphics.RenderMeshIndirect instead. Draws the same mesh multiple times using GPU instancing.

However, I was able to get the sample code in Graphics.DrawMeshInstancedIndirect to render a mesh such as a plane or cube in both the editor and a built application. The mesh wasn't pink like the grass, but they were rendered in the same position so it appeared like a single object. The example script is supposed to assign random positions to each instance but this doesn't seem to be working.

woojehyun commented 11 months ago

Try changing the tag to "RenderPipeline" = "UniversalRenderPipeline" -> "RenderPipeline" = "UniversalPipeline".

Torgo13 commented 11 months ago

Thank you @woojehyun!