I am tweaking the rendering performance of our game.
I noticed that some objects are taking considerably longer to render than expected because they have roughly equal time spent rendering in the “Opaque” section as the “Deferred PrePass” section. Some objects contribute to the Deferred PrePass time while others do not.
I was wondering if someone could explain what the “Deferred PrePass” actually is, and how it’s role differs from that of “Opaque”.
Is the same object being rendered twice to two different render targets? Does Unity not support multiple render textures in one draw call? (Might switching to dx11 fix this?)
False.
From my experience in DirectX, at least, there is a feature which allows multiple render textures to be written to in one pass, in one pixel shader. There was a specific syntax for it in HLSL.
What that means is that it is possible in a graphics engine for the normal, diffuse, specular, glossiness, emissive, etc. to be output by one pixel shader, simply by using multiple out parameters, instead of returning one value. I seem to remember that you can return a struct as well, with multiple outputs.
(Funny enough, at the bottom of this page you’ll read: “Deferred Shading, a shading process that relies heavily on MRT to perform in real-time”)
If Unity did this, there wouldn’t be a problem here.
With all this being said, I’d have to beg the Unity guys to implement this, I presume? I’ll have to check to see if this plays out differently on DirectX 11 (although I could swear that DX9 supported MRT).
You’re talking about a completely different rendering algorithm though. Unity uses deferred lighting, not deferred shading. It has it’s advantages and disadvantages. It’s not an easy task to implement a custom rendering path, by the way. I’ve actually been working on a deferred shading renderer for the past two months or so. See this thread: http://forum.unity3d.com/threads/198539-The-Wish-for-an-Alternative-Rendering-Path
With deferred lighting renderer, you can’t render the two passes in one go, because there are dependencies. The second pass relies on the lighting pass, which relies on the first pass.