Hi,
Curious question: Why is auto-instancing not enabled for custom depth rendering? EMeshPassFlags::CachedMeshCommands is not passed when registering the custom depth pass: https://github.com/EpicGames/UnrealEngine/blob/4e018926ddbe13c44857b6897afbc74291295b89/Engine/Source/Runtime/Renderer/Private/CustomDepthRendering.cpp\#L797 Basically all other main view passes except the translucent passes use auto-instancing. It makes sense that the translucent passes don’t use auto-instancing to maintain alpha blend order, but I don’t understand why it’s not used for custom depth rendering. Maybe I’m just missing something? Is there anything that prohibits the custom depth pass from using auto-instancing?
All the best,
Marcus
Hi,
thanks for reaching out. I believe the reason why the custom depth pass can not make use of auto-instancing is similar to the fact that early-Z rejection is disabled when the pixel shader modifies the depth value (in which case the renderer can not know the pixel’s depth beforehand and has to execute the pixel shader). I believe the renderer can not predict which meshes will be written to the custom depth pass, since any mesh can take part, and thus cannot optimize for it with auto-instancing.
I will pass on your question to Epic so someone with subject matter knowledge can answer.
Thanks,
Sam
Hi Sam,
I don’t see how early-Z would affect instancing. Early-Z can be disabled in other passes, like BasePass and DepthPass, where auto-instancing is enabled. But I guess you’re using some kind of analogy here? What makes the custom depth pass different from other main view passes that prevents it from using auto-instancing?
All the best,
Marcus
Hi,
yes, I used early-Z as an analogy, I apologize if that wasn’t clear.
I have passed your question on to Epic, since I’m not very familiar with this part of the engine.
Best regards,
Sam
Hi Marcus,
I have asked internally why we do not enable auto-instancing for our translucent passes, and I could not get a definitive answer. The last changes committed to that code were around 2019, and a long time has passed, so unfortunately, it is not clear why this was done. Have you already tried to enable auto-instancing for those particular passes? You should be fine if you do not experience side effects from doing this. Feel free to let me know if you have any more questions.
Hi Tim,
It makes sense not to enable auto-instancing for translucent passes as it would break the back-to-front draw order, which would cause visual blend issues. I don’t see why you would not want to enable auto-instancing for the custom depth pass though. That shouldn’t be dependent on draw order at least. I haven’t dared to try enabling it yet. I wanted to check here first to make sure I didn’t step on any mines.
All the best,
Marcus
Hi Marcus,
Thanks for letting me know. Unfortunately, there is not enough historical context to explain why we have not enabled auto-instancing in the custom depth pass. If you feel like trying it out, you could definitely make that change. If it ends up working for you without any negative side effects, we would be happy to take on a pull request to integrate that change. That’s the best advice I can give you now, but if you still have any questions, please let me know.
Best,
Tim