Improvement of deferred rendering in klayge 4.0 (3): transparent troubles

Source: Internet
Author: User

Reprinted please indicate the source is klayge Game Engine

 

We have discussed how to squeeze information into a limited G-buffer, and the other problem in reality is how to render transparent objects.

Transparent object

Transparent objects are indispensable in the game. For deferred rendering, transparent objects are always painful. A common practice is to use forward shading to render transparent objects separately in the deferred Rendering scenario, but that means a complete set of forward shading pipelines must be implemented separately. This is very unfavorable for maintenance and expansion, and has a great impact on performance.

In klayge 4.0, the method I use is calledDeep G-Buffer. The basic process is to reproduce three copies of the deferred rendering pipeline described in the first article, opaque objects, the back of transparent objects, and the front of transparent objects have their own independent G-buffer, lighting pass, shading pass, and special shading pass. At last, three shading results will be generated, and then they will be mixed according to Alpha.

First, the G-buffer of the opaque object is created, which is the same as the original one:


Careful friends can find that the normal in G-buffer seems interesting because best fit for normals is used.

Then set cull as front, and only draw the back of the transparent object, which exists in the second G-buffer. Here, we also need to use a method similar to depth PEELING To clip a pixel farther than an opaque object. Because the vast majority of pixels are blocked by opaque objects, there are only a few on the back of transparent objects:

Similarly, we can store the front of a transparent object in the third G-buffer:

After lighting pass, shading pass, and special shading pass, the shading of an opaque object is obtained:

Shading on the back of a transparent object is hardly illuminated:

And shading on the front of a transparent object:

Note that all transparent objects provide the pixel Alpha value in the special shading pass. Next we just need to mix them together to get the desired results:

On the other side, we can see that the light of a transparent object and an opaque object can be smoothly transitioned continuously due to the same illumination mode.

This article presents a method for rendering transparent objects under the deferred framework, which can solve the problem simply and effectively. The disadvantage is three times the memory and bandwidth consumption. If the number of depth peeling layers increases, the consumption of memory and bandwidth will also increase. Here, we can also use other order independent transparency methods to replace depth PEELING To separate G-buffer. The next article will analyzeReal-time Gi.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.