HDR & Bloom

I did not write a blog one week ( feeling in the water every day ), OpenGL worse Deferred Shading and SSAO, and did not learn the contents of PBR, plans next month to around number ten initial completion, and then into the practical aspects (before the end of New Year's Day) As for how science behind the graphics have not formally identified (the direction is probably more familiar with OpenGL, then write a rasterizer renderer and the like, if there is time, you may even try to attempt UE4, Unity engine and the like).

Followed by CSAPP, and the current plan is to use 3-4 months time to slowly learn (while doing lab, specific plans look), from the beginning of December, taking into account the progress during home after January will slow down, so the time can be relaxed. Data structures and algorithms are planning a half months time to relearn a month. Computer networks and then start preparing for the next semester. Winter also intends to do is to translate (and perhaps also may build a website), ready to Learn OpenGL CN re-translation of some articles again, and then mention PR.

Well, nonsense comes here almost over.

This blog intends to study some of the problems in the process of HDR and Bloom to ask.


The first is the HDR (Height Dynamic Range) high dynamic range. As the name suggests, it is a larger range of colors.

First we need to know, the display is limited to displaying only the color value of 0.0 - 1.0, even if the scene color values ​​higher than 1.0 fragments, will only display up to 1.0. This makes a lot of detail loss, many fragments exceeds 1.0 color value is also displayed (constrained) was 1.0, the performance of large white.

In this regard, we propose a solution that transforms the color values ​​correspond to the lighting equations in the interval [0.0, 1.0] in order to prevent loss of detail (small details still lose a little more or less).

When the frame buffer (frame buffer non-default) uses a standardized fixed point format (e.g. GL_RGB) for its internal format color buffer, (after rendering) will be constrained to the OpenGL [0.0, 1.0 Before these values stored in the frame buffer ], so we need to first internal format buffer changed its color GL_RGB16F (GL_RGBA16F, GL_RGB32F, GL_RGBA32F) , so that the sub-frame buffer can store the color values exceeding 1.0. This frame buffer is called the floating-point frame buffer.

After the buffer to give a color value is not restricted (stored inside the color annex) from the floating-point frame, we need to default to the frame buffer. But not directly (if the direct use value of more than 1.0 will be constrained to 1.0), we need floating point HDR color values ​​through a color map (Tone Mapping) will be converted to LDR [0.0, 1.0]. Tone mapping algorithm will not say here, Reinhard commonly used mapping. Of course, I remember gamma correction.

Reinhard mapping so that we will not be part of the loss in the brightness of the HDR to LDR transformation when too much detail, but for the dark portions are not so friendly and not-so-dark portion of the fine, then there is no discrimination.

In this regard, we can consider the introduction of exposure (Exposure), high exposure value will make a dark portion more detail (detail while brightness is reduced), and low exposure value is reduced so that the detail in the dark, increasing the brightness of the detail .

In photography, we can take exposure to multiple colors details different times, after the synthesis of different levels of exposure so that the color value of a great part has the details.


Then talk about Bloom flood (also known as Glow Glow)

Floodlight in this section that is difficult is difficult, that simple and easy. The main applications for the frame buffer, and a fragment shader MRT (Multiple Render Targets).

First, some of the bloom for the light source (illumination area), so that the light source emits light, thus creating a more realistic effect. The effect is as follows (Source LearnOpenGL )

 

 Implementation floodlight as follows:

[1] The HDR rendering of the scene to a color annex (let's call it "Annex 0"), and the extracted scenes HDR certain brightness, put another color to the annex ( "Annex 1" hereinafter referred to) .

[2] Annex 1 will be blurred.

[Annex 3] The results allow the attachment 1 is added to 0, and finally to the default output frame buffer.

Learn OpenGL-based below the relevant sections do some reading:

The first is the problem of the color of accessories, we can take the MRT technology, so that the two textures annex a fragment shader output to a frame buffer (non-default) is, of course, we also need to explicitly inform OpenGL that we are rendering to multiple colors by glDrawBuffers buffer (Annex 1 and Annex 0), only the default output to the color buffer (annex 0).

After getting Annex 1 and Annex 0, we need to blur in Annex 1. Here is two frame buffers, each a form of attachment for cross color blur ( to save the number of operations ). We need to start annex 1 as a frame buffer where the texture passed (actually passed shader fragment in operation), then the Gaussian blur, then the results obtained would be stored in the frame buffer attached to this color; then we the color then a further attachment incoming frame buffer (same as the way incoming texture shader fragment), and Gaussian blur based on the color of the attachment. So alternately go to. About Gaussian blur, reference may be made known on issues related to the peace: what is the principle of Gaussian blur Shi .

Finally, ambiguous results obtained and the original HDR mixing (operating in the default shader fragment in frame buffer), output to the default frame buffer on the line.

When was beginning to look for the two layout shader fragment and two frame buffer is very puzzling. Traced back, step by step according to a result derived from the code to the original number of the rendering process, the process and understand the principles of the bloom.

 

the above.

 

 

 

Guess you like

Origin www.cnblogs.com/zhlabcd/p/11950537.html