- Home /
Why does Unity render everything twice ?
I used GPU Perf Studio to analyze Unity's draw calls under DirectX11.
Remarks : - everything gets drawn twice into a render target the size of the resolution as if transparency is enabled on everything. Once with FrontCounterClockwise = true, and then false. The first time the pixel shader doesn't sample any texture, the second time, it does. What is this ? It's definetely not occlusion culling as I turned that off and I get the same results. All objects are drawn reverse order both times btw. - terrains are rendered 2 times, twice, and this is even weirder, I see the same draw call with the same vertex/pixel shader being called twice, once with DepthMask on, DepthTest On, the other with DepthMask off,DepthTest On and Blend on as if it had 2 passes. Why would it blend together the same mesh if I just have 1 pass in my custom terrain shader ? And I only got 2( or 5 ) brush textures while my GPU can support up to 32+ sampled textures ?
EDIT : I added 2 screenshots of the same object with the 2 different draw states & shaders. You can also see how it tries to resolve 3 multisampled textures. Special effects don't use multisampling, so 1 is the color buffer, 1 is depth, what's the third one ? It definitely looks like deferred rendering of some sorts even though I checked "Forward" everywhere, even in Player Settings.
Additional lighting pass? What lighting model do you use?
I suppose you use deferred rendering path. The first draw call is for prepassbase, it just renders normal and specular. The second one is for prepassfinal, it renders albedo and emissive, as you said, with texture. But I have no idea about other behaviors.