Forward Rendering in Unity & checking render order with Frame Debugger

How does it work?

  • each object is rendered in a pass for each light that affects it.  
  • each object might be rendered multiple times depending upon how many lights are within range. 
  • lit objects are rendered in a separate passes.  
  • if it is possible to manage light counts in your game: Forward Rendering can be a very fast solution and helps to reduce hardware requirements.
  • Some objects might be rendered multiple times depending on: 
    • How many lights are in the Scene 
    • Do the lights affect the GameObject

Forward Rendering Pseudocode

Pass {   

    for(each primitive in this model){   

        for(each fragment coverd by this primitive){   

            if(failed in depth test){   




                float4 color = Shading(materialInfo,pos,normal,lightDir,viewDir);   






Advantages of Forward Rendering

  • Can handle transparency quickly.  
  • Allows for the use of hardware techniques like multi-sample anti-aliasing (MSAA) to improve image quality, which are not available in other alternatives like Deferred Rendering. 

Disadvantages of Forward Rendering

  • Must pay a render cost on a per-light basis: the more lights affecting each object within scene, the slower rendering performance will become.
  • HDR is not supported in Forward Rendering when using techniques such as multi-sample anti-aliasing (MSAA). 

Using Frame Debugger to check the lighting rendering process in forward rendering pipeline

  1. clear colour, depth and stencil buffer to prepare for the next rendering steps
  2. use the shader’s Base Pass to render the green directional light to the frame debugger 
  3. use the shader’s Additional Pass to render the Point lights (if they are in range of the object to render) for the final result

How does Unity process the render order for these lights?

It’s usually ordered by the importance of the lights. If all the light sources have the same colour and intensity: their importance depends on their distance to the object. The first point light to be rendered is the one that’s the closest to the object.

Note that if the colour and intensity are different for the light sources: distance is not the only criteria for determining rendering importance.

If the point light that’s closest to the object has the lowest intensity: the first light to be rendered is the second closest point light with higher intensity in the frame debugger.

If the object is not within the range of a light source: unity shader will not use the additional pass to process the light for that object.

if there are a lot of per-pixel lights: the additional pass will be called for multiple times which could impact performance.

Can set the light’s render mode to not important: this tells unity to not treat that light as a pixel light.

What would happen if you mark the directional light and the point lights’ render mode to not important? 

If the base pass does not calculate per-vertex lighting and Spherical Harmonics, then it would only show the results of the ambient light – those not-important lights will not have any effects on the object.

Using Frame Debugger to check the shadow rendering process in forward rendering pipeline

  1. UpdateDepthTexture: update the camera’s depth texture using the pass with “LightMode” = “ShadowCaster” (shader Fallback)
  2. RenderShadowmap: render the main directional light’s shadowmap
  3. CollectShadows: get the screen space shadowmap from depth map and shadow map
  4. Render the final results: render with shadows if the object’s shader includes the sampling of the screen space shadow map