Unity5 's render path, the difference from 4 is the use of the new deferred rendering, the previous 4 of deferred rendering (actually light prepass) was also preserved.
Legacy Deferred Lighting Rendering Path (light prepass)The old deferred Rendering Path uses light prepass rendering. Because it is old (unity5 before the deferred Lighting, but Unity5 still keeps it in use), it does not support some new rendering features, such as Unity5 's new PBR shader standard shader, And the new reflection probes. Can be replaced by a new deferred Lighting.
The advantage is that there is no limit to the number of lights because it renders all the data needed for lighting calculations into the render target. All light is calculated per pixel and can interact correctly with normal maps. All the light has cookies and shadows. Because it calculates light per pixel, it is not as obvious as a vertex-shaded polygon, not true. Per-vertex illumination is the calculation of the light color in the vetext shader, where each vertex calculates a light and then interpolates. Per-pixel illumination is calculated for each pixel, calculated in fragement shader.
The overhead in light prepass rendering is positively correlated with the number of pixels found, independent of the complexity of the scene, and related to the volume range of the light, regardless of the number of objects illuminated. Therefore, to make the volume of light smaller can improve performance.
Light Prepass rendering does not support antialiasing, and can not handle translucent objects, translucent objects will be treated with forward rendering, mesh objects can not accept shadows, only with four camera culling masks, (Official document explanation: you can Only the use of up to four culling masks. That's, your culling layer mask must at least contain all layers minus four arbitrary layers, so from the The + layers must be set. Otherwise you'll get graphical artefacts.)
Use it must define shader Model 3.0 above, support depth render textures and two-sided stencil buffers. 2004 years later, most PCs support light Prepass
Light Prepass's consumption is all from the number of pixels that the object needs to render, and it doesn't depend on the complexity of the scene, so the small point light, and spot light, or the light is obscured, it consumes little (optimization can be done from here). Shading is also rendered several times in order to produce shadows, so there is some overhead.
Light Prepass requires 3 pass in Unity
1. Base Pass: First calculate screen space buffer information: depth, normal, and specular power
2. Lighting Pass: Use the buffer information above to calculate the light in other buffers
3. Final Pass: The object is rendered again, getting the light and map calculated above, plus ambient light/spontaneous light, and so on.
As shown in the process,
If the object's shader cannot be treated with light prepass, it will be treated with forward rendering.
Base Pass
In this pass first render the object, the view space's normal and specular power there is a ARGB32 Render texture, normal use AGB channel, specular use a channel.
The result of the Base Pass is that the scene information and a Render texture are populated in Z buffer.
Lighting Pass
Lighting Pass is the calculation of light through depth,normal and specular power. The illumination is calculated on screen space, so the time spent and required to calculate does not depend on the complexity of the scene. The illumination buffer information exists in a ARGB32 Render texture, which includes diffuse illumination in the RGB channel, high light intensity in a channel. Illumination values with logarithmic encode can have a better dynamic range. When the camera's HDR option is selected, the light buffer information is used in the argbhalf format and does not use the logarithmic encode.
Final Pass
All objects are rendered once again, capturing the light and blending with the map and ambient light. Lightmaps also in final pass
Used in the. The camera is closer to the spot for real-time illumination, baking only indirect lighting. Where the camera is far away, all the light is baked.
Deferred Lighting Rendering PathUnity5 the new deferred rendering.
The biggest benefit is not limiting the number of light sources. All light is calculated per pixel and can interact correctly with normal maps. All the light has cookies and shadows.
The premise of using G-buffer is that these data can be written to multiple Render target at once, i.e. Multiple-render-target (MRT).
The overhead in deferred rendering is positively correlated with the number of pixels found in the light, irrespective of the complexity of the scene, related to the volume range of the light, regardless of the number of objects illuminated. Therefore, to make the volume of light smaller can improve performance.
Deferred rendering does not support anti-aliasing, and can not handle translucent objects, translucent objects will be treated with forward rendering, mesh objects can not accept shadows, can only use four
Using it requires a graphics card that supports multiple render Targets (MRT), must define shader Model 3.0 above, support depth render textures and two-sided stencil buffers. Most of the PCs after 2005 years support deferred rendering.
The consumption of deferred rendering all comes from the number of pixels that the light shines to the object, and does not depend entirely on the complexity of the scene, so a small point light, and spot light, or light is obscured, is very little (optimization can be done from here). Shading is also rendered several times in order to produce shadows, so there is some overhead.
Pass two passes in the deferred rendering
1. G-buffer Pass: All objects are rendered once, calculated diffuse color,specular color, smoothness, world space normal,emission and depth, existing screen spa The CE buffer information.
2. Lighting Pass: Increase the light to the front of the emission buffer information.
Basically as shown (the information generated by unity in G-buffer is more specific than the figure 1)
If the object's shader cannot be treated with light prepass, it will be treated with forward rendering.
Default G-buffer layout, 4 render Targetrt0,rt1,rt2,rt3:
RT0, ARGB32 format: Diffuse color (RGB), not Used (A).
RT1, ARGB32 format: Specular color (RGB), roughness (A).
RT2, ARGB2101010 format: World Space Normal (RGB), do not use (A).
RT3, ARGB32 (NON-HDR) or argbhalf (HDR) format: Emission + lighting + Lightmaps + reflection probes buffer.
Depth+stencil buffer.
ARGB32:8-bit integer per channel
Argbhalf: 16-bit floating point for each channel (so storing light in camera HDR mode with this format allows for a greater dynamic range with more detailed illumination details.) However, some graphics cards do not support floating-point render texture, you can use the Systeminfo.supportsrendertextureformat check.
So g-buffer in the case of no HDR is 160bits/pixels, with HDR is 192/pixel.
G-buffer Pass
Each object is rendered once, diffuse, specular, surface smoothness, world space Normal, and emission+ambient+reflections+lightmaps are rendered into G-buffer map. G-buffer maps can be used as global parameters for a material (called CAMERAGBUFFERTEXTURE0. CAMERAGBUFFERTEXTURE3)
Light Pass
The light pass calculates the illumination through g-buffer and depth in screen space, so the time spent and required to calculate does not depend on the complexity of the scene. The illumination information is stored in the emission buffer.
Reference: http://docs.unity3d.com/Manual/RenderTech-DeferredShading.html
http://blog.csdn.net/xoyojank/article/details/4460953
-----by wolf96 http://blog.csdn.net/wolf96
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unity5 old and new deferred rendering deferred Lighting Rendering Path