In view of the inefficiency of the traditional forward rendering for multi-light source rendering, various deferred rendering methods have been proposed and widely used. For example, deferred shading and the subsequent deferred lighting. The most important difference between the deferred method and the traditional forward rendering method is that it improves the efficiency of Multi-light source rendering. It is to convert the calculation of the light source to the screen space, in this case, no invalid light source coloring is wasted. The deferred rendering method has become the mainstream of game engines. However, deferred
Shading and deferred lighting are different: Deferred shadign is a brain to convert all shading to the deferred stage, while deferred lighting is to selectively only convert lighting to deferred, the difference between the two methods leads to different features of the algorithm and their respective advantages and disadvantages. I have not been very clear about this. I have recently collected materials for a while. I would like to summarize it here.
The traditional forward rendering usually requires a complexity that is closely related to the number of light sources and the number of objects to be drawn. This results in low efficiency. The deferred rendering is to transfer the computing related to the light source to the screen space, thus minimizing irrelevant computing waste. To transfer the traditional forward rendering to deferred, we need to analyze or modify the illumination equation and generate the necessary auxiliary buffer to complete the final coloring operation.
Deferred Shading
First, let's take a look at the common illumination coloring equation in the following form:
The
- BLK is the light density or color at the current pixel.
- LK is the ray vector at the current pixel.
- VIt is the line of sight at the current pixel.
- NIs the normal vector at the current pixel.
- CDiff is the diffuse color at the current pixel.
- CSpec is the specular color at the current pixel.
- M is the specular correlation coefficient at the current pixel.
For each pixel, use the above formula to calculate the influence of each light source on it and accumulate and obtain its final color. Therefore, if you have the necessary elements in the above formula, you can complete the correct coloring of the object to be rendered, the basic elements are the operations to be completed by the G-pass of the deferred shading. The G-buffer in DS generally contains the following basic information:
- Depth
- Normal & specular
- Diffuse Albedo
- Specular Albedo
- Emissive Albedo
Of course, these are basic information. The detailed details and detailed organization of G-buffer are closely related to the engine structure, but some basic information is required, such as depth, normal, diffuse, specular. With G-buffer, you can use the second deferred pass and use the information in G-buffer to complete the final coloring.
However, from the necessary information contained in the above G-buffer, we can see that the use of a render target which is afraid of being the largest space cannot contain all necessary information, but at least two. This means multiple passes without the support of the MRT hardware. In this case, the efficiency is not much higher than that of the traditional forward rendering, therefore, this method is used in real-time rendering before the emergence of MRT. Another problem with MRT is the space occupation caused by multiple buffers. This is also the deffered
One of the reasons why lighting occurs based on DS.
Deferred Lighting
It can be seen from the G-buffer in DS that two pieces of information need to occupy the corresponding RT space, diffuse albedo and specular albedo, the improvement of defferd lighting is to remove these two parts from the G-buffer of DS, and only perform the corresponding illumination calculation in the deferred stage, the calculation of the influence of diffuse and specular components is carried out in the final shading stage. Therefore, DL actually adds a final shading stage relative to DS. In DL, the original coloring equation needs to be adjusted as follows:
Of course, if a more complex coloring model is used in DS, you may need to make different changes to the formula based on the actual situation to facilitate the independence of each pass.
The main process of DL is:
- Prepare G-buffer (normal & depth)
- Perform deferred lighting and obtain the L-buffer.FDiff andFSPEC)
- Re-render the scenario based on the L-buffer and perform the final Shading
DS vs DL
The above description shows the main differences between DS and DL:
- DS requires a larger G-buffer to prepare for the deferred stage. In addition, the hardware must have the support of MRT, which can be said to have higher hardware requirements.
- DL requires the rendering process of two ry elements to complete the rendering operation: G-pass and shading pass. This is both a disadvantage and an advantage: Because the deffered phase in DS is carried out in the screen space of the completely basic g-buffer, this also leads to the lack of object material information, in this way, additional operations are required to deal with changing rendering styles, while DL can obtain the object's village information in the shading phase, making the processing of this problem easier.
- The above two methods can only complete the rendering of opaque objects, while transparent or translucent objects require additional traditional pass.
For a more detailed comparison of the two methods, here is an article on specific analysis, and Wolfgang participated in the discussion, you can check it out (but the author may be biased against dl ).
Inferred Lighting
In Siggraph in, a buddy proposed inferred lighting, which is actually an improvement on deferred lighting. Although the final performance is not better than DL, however, at least a new idea is proposed, which has the following features:
- In G-buffer, in addition to basic depth and normal, additional information called discountinuity sensitive filter (DSF) is added, this is actually an ID that identifies the objects in the scenario and combines the normal distribution of the objects for use in the final shading stage. The G-buffer here has a very important feature that it can be smaller than the normal screen space, so that in the deferred lighting stage, the number of pixels that require light will be reduced, but the impact is that the Shading
Make up-sampling in pass (DSF in G-buffer is used to solve some problems encountered in US ).
- Deferred lighting of the G-buffer-based screen space (smaller than the normal screen space) and obtain the L-buffer.
- DSF is used for up-samping In the shading pass to solve the gap between different objects. At the same time, with DSF combined with the stipple marking method of translucent objects in G-pass, you can render translucent objects in a normal way in the normal shading pass. I personally think this idea is good.
However, the efficiency of inferred lighting still needs to be improved (as mentioned in the previous article), but the details are not complex.
About DS and DL more detailed description can look at here: http://www.realtimerendering.com/blog/deferred-lighting-approaches/