How render a specific set of renderers again with a different material?

Hey everyone,

for the 1000x I’ve come across this issue in our project and multiple times I haven’t found a satisfying solution so I hope some one can really help and answer me this.

I have a bunch of MeshRenderers and SkinnedMeshRenderers in URP. Each of those goes through the default rendering path (forward+ if you care) and everything is fine. Now I’d like the render these renderers a second time with a set of different materials. Lets we have 30 renderers and 14 materials.

I can’t do this through the regular render objects feature, there are not enough rendering layers left to filter out which object should get which material and managing so many renderer features is crazy.
The real bottleneck here is FilteringSettings because that is the only way to get the context to render the already culled renderers. If I could I would like to just iterate over a list and keep track of that myself, but with the material override of RenderObjects. (Unity - Scripting API: Rendering.ScriptableRenderContext.DrawRenderers)

There is Unity - Scripting API: Rendering.CommandBuffer.DrawRenderer which nearly allows me to do all that I need even though with some detours but that function internally calls SetPass() and breaks SRP batches for every single call. Not nice, no fun, how can I get this with SRP batches?

There is also Unity - Scripting API: Rendering.CommandBuffer.DrawRendererList
Which does create a srp batch! but again it takes a RendererList / RendererListDesc which can only filter by layer?!

Why not duplicate the renderer? That would mean more game objects but okay, but it would also force the skinned meshes to be recalculated one more time for each skinned mesh renderer… nothing really gained here, not even sure what I would rather avoid the unbatched srp calls or the additional skinning calls.

Hooow HHHHOOOOOWW! is it possible to schedule a specific renderer to be renderer compatibly with the SRP batcher?

i know that on birp at least you can just apply two materials to a mesh renderer, and it renders twice.

One idea, but it could be a lot of work. You could have a specific pass added to the shaders that all your materials are using. Then when rendering a second time, you override to that pass. Presumably, that pass would reference different properties but on the same material still.

That only works if your object has exactly one material to begin with. The additional material slots ever only target the first submesh.

True, but that prevents using shadergraph and in the end it forces one to use the same material as on the base layer which removes a lot of the flexibility.