Making SkinnedMeshRenderer update when it thinks it's not visible

I’ve hidden a SkinnedMeshRenderer with the camera culling mask, so I can render it myself with CommandBuffer.DrawRenderer to assign a second color output to an MRT. However, the renderer thinks it’s not visible to any cameras, and decides not to update the mesh. This happens even if “Update when offscreen” is checked.

(This wasn’t happening for the last couple days where I was working on this shader. I’m guessing I had the scene view pointing at the mesh the whole time, which triggers an update and hides the problem.)

How can I prevent a renderer from drawing, so I can do it, without it deciding not to update the mesh as a result?

(The usual “post to forums, figure it out immediately afterwards” strategy…)

I’ve hacked around this by hiding the mesh from primary rendering by calling material.SetShaderPassEnabled(“Always”, false), which disables the shader in a way that the renderer doesn’t notice. That seems to work, and fixes some other problems, like the mesh not appearing in the camera preview and not being included in the depth pass.

It’s definitely a hack, though–is there a proper way to override mesh rendering? Hopefully the answer isn’t “wait for ScriptableRenderLoop and roll it yourself”, this seems like a basic thing…

1 Like