Hi all, I've done a project in the past where I rendered thousands of meshes efficiently using Graphics.RenderMeshIndirect(). This worked great, but I thought that running my rendering behaviours in Update() isn't how URP is 'meant' to work. Unity's Render Graph system seems to provide a solution here, where meshes can be drawn in a way that nestles nicely within URP's frameworks.
The problem:
I can easily render a mesh with a material (left), but that material doesn't respond to any lights. It can take metallic/smoothness data to respond to the skybox, but it does not receive light or cast shadows.
The mesh on the left is rendered using my custom ScriptableRendererFeature, which contains a ScriptableRenderPass which calls DrawMesh(mesh, trs, material, 0, forwardLitShaderPass).
The mesh on the right is a simple GameObject with a Mesh Filter and Renderer. Both use the same material.
Unity's documentation does tell you not to expect lighting data out of DrawMesh(), but for the life of me I can't figure out how you're meant to include it yourself.
My Question:
-
Is there a way to render this mesh with correct lighting? I feel like I'm missing something obvious. Drawing the mesh was so simple with Render Graph, I'm baffled that lighting doesn't work out of the box, or that Unity's documentation can't point me towards any docs or samples that can enable lighting, explain why lighting doesn't work, or offer an alternative.
-
Is Render Graph even an appropriate tool for my situation? I want to render thousands of mesh instances that are built from a compute shader, exactly how I did so with
RenderMeshIndirect(). I can see that Render Graph has a lot of these features I need, but if I can't draw one mesh directly I don't know how I'll go with drawing multiple indirectly.
More Info
Unity: 6000.3.10f1; OpenGL
URP: 17.3.0
Thanks for any help in advance!