What is the order of CommandBuffer CameraEvents in each render path and editor view?

We’ve run a couple of tests that indicate that the order of CameraEvents is very different in different contexts. For instance, in Deferred rendering in the Game Window, the AfterSkybox event is called after Skybox AND after geometry. However, under the same rendering path in the Scene View window, the AfterSkybox event is called after the Skybox but BEFORE Geometry. Attempting to access a Camera Texture at this point in the Scene View will show only Skybox, not Geometry.

So what is the order of these events under the various default configurations?

  • Game View Forward Rendering
  • Scene View Forward Rendering
  • Game View Deferred Rendering
  • Scene View Deferred Rendering

The order of the Skybox events between the Scene view and Game view should be the only oddity. I’m not sure why they don’t match, but the skybox being rendered first was how Unity’s forward renderer worked in all versions prior to Unity 5.0, after which they changed the default sky to the current procedural sky shader which is significantly more expensive than the old default six sided texture only skybox. The new skybox meant moving it to render later translated to a potentially significant performance increase over rendering it first. For some reason the Scene view was not updated use the same ordering.

Otherwise Game view forward and Scene and Game view deferred should match the documentation:

There are several passes in the scripting documentation that aren’t listed in the diagram on that page, like Before/AfterFinalPass, Before/AfterReflections, and Before/AfterHaloAndLensFlares. Reflections happens after GBuffer and before Lighting. FinalPass happens after Lighting and before Skybox. HaloAndLensFlares happens for both deferred and forward after “Transparencies” (ForwardAlpha) and before ImageEffects. There’s also AfterEverything, but that’s self explanatory.

3 Likes