What the title says. Graphics.RenderMesh does absolutely nothing in URP/HDRP, however it works fine in the Built-in pipeline.
Graphics.DrawMesh however, seems to work fine in all pipelines.
Unity 2021.3.4f1, URP 12.1.7. Has anyone encountered this?
What the title says. Graphics.RenderMesh does absolutely nothing in URP/HDRP, however it works fine in the Built-in pipeline.
Graphics.DrawMesh however, seems to work fine in all pipelines.
Unity 2021.3.4f1, URP 12.1.7. Has anyone encountered this?
I think I found the culprit, here’s the solution for those that hit the same pitfall:
The default values for the RenderParams struct (that Graphics.RenderMesh takes as input) work for the built-in pipeline but don’t work at all for SRPs.
If you create a RenderParams instance using its constructor, the value of RenderParams.renderingLayerMask is initialized to a value other than 0. However if you create a RenderParams instance using the default constructor (which uses the default value of each type to initialize the struct’s members), renderingLayerMask gets the default value for unsigned ints (zero) so bitwise ‘&’ with any layer will always yield 0, ensuring nothing gets rendered.
So what if you want to create a RenderParams struct without passing a material to its constructor? then you need to explicitly set the value of renderingLayerMask to GraphicsSettings.defaultRenderingLayerMask, otherwise RenderMesh won’t render anything.
I’m reporting this as a bug since:
Stumbled upon the solution by mere chance, was ready to mark “RenderMesh” as broken and move on to DrawMesh instead.
Okay, I was going to tell you “thank you ever so much because I ran into this exact issue with an asset I’m using” … but you would know, because you are developing the asset. Anyway, enjoy my emails pointing you to your own post ![]()
This fixed my problem specifically the “renderingLayerMask = GraphicsSettings.defaultRenderingLayerMask”. Thank you very much and I hope you have a nice day! ![]()