Deferred shading of ssao + HDR demo

Source: Internet
Author: User

I have been learning some rendering knowledge some time ago. I hereby sort it out in this article for future reference. I also hope that it will play a leading role, let the majority of colleagues and fans do not hesitate to enlighten me ......

Deferred shading is used to filter out the quad with the same size as the screen through the pipeline. The quad records the final information, such as the position, normal, and material information, and then colors the information. Why? Compared with the traditional forward coloring method, this method has its own characteristics. On the SPOT Scene, objects in the scene are largely blocked from each other, and when the calculation of these objects is very complicated, we will see that, the complex coloring Calculation of most objects will not be displayed on the screen due to occlusion, which wastes a lot of time for useless work ...... Unless these objects are transparent ......, In addition, in the case of multiple light sources, deferredshading can greatly reduce the complexity of illumination computing. This article does not discuss the advantages and disadvantages of deferredshading too much, but only applies it to technologies.

Ssao should say that it was born to be a good friend with deferred shading. Because the position and normal information required by ssao can be easily obtained through the intermediate results of deferredshading. Let's talk about the basic principles of ssao:

 

(Figure 1)

1. For each pixel on the screen, find the location of the surrounding pixel, and then check whether the neighboring pixel is on the top of the current pixel. The more it is on the top, the larger the contribution of pixels in the surface area to the current pixel occlusion, the same distance between them is also considered. If the two pixels are closer, the larger the occlusion contribution will be, in this way, after checking all the neighboring pixels, you will get a final occlusion value of the current pixel. You can use this occlusion value at will. I use this value to influence ambientlight. This article about ssao is a good introduction. I simply and uniformly query 9 neighboring points for detection. The pixel spacing is an adjustable threshold value when the neighboring 9 points are detected. This threshold value affects the ssao effect. Below are the effects of different thresholds:


 

 

(From left to right is the threshold values 1, 5, 10)

We can see that when the threshold value is 1, the effect is not good, and halo and 5 will appear at 10.

After adding the ssao effect, we get a color quad. The color of this quad may not be in the range of (0, 1). We can use HDR to open the color hierarchy. I will not talk much about the principle of HDR. There are a lot of related information on the Internet. Many articles tend to sample 1/8 or 1/16 of the image size and then blur or sample the brightness. However, in practice, I think it is more appropriate to sample to 1/4. After obtaining the quad color of 1/4, on the one hand, calculate the average brightness value, on the other hand, first filter out the particularly bright part, then perform Gaussian blur, and finally use the average brightness value for tonemapping, combine the blurred image with the original image to form the bloom effect. Tone introduced in some articles on the Internet
Mapping cannot simulate the HDR effect well, and the brightness of an object changes dramatically with the scene. This seems strange, so I finally adopted the simplest tonemapping method.

Final Effect


(Figure 4: HDR)

 

The demo is included. The first demo is written by OpenGL. Some low-end graphics cards OpenGL may not support 8 Rt, so the demo cannot run.

Http://download.csdn.net/source/3288673

So the following is a demo written with DX9. The content is the same, but it is implemented with DX9.

Http://download.csdn.net/source/3513516

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.