Direct3d improvement: Using HLSL Programming to Implement Photoshop Filters-pseudo HDR/blow

Source: Internet
Author: User

The so-called HDR means a high dynamic range. In normal display and bitmap, each channel is 8-bit, that is, the RGB component range is 0-255, which indicates that the actual color is obviously far from enough. In reality, the dynamic range of images is much larger, so how can we maintain a larger dynamic range in the existing display devices as much as possible, in addition, making it more in line with human habits has become a hot topic in graphics research. Generally, the real HDR method uses a floating point texture. During the rendering operation, we use a 16-bit dynamic range to save the calculation results, and then analyze the calculation results, find the intermediate gray value of the image, and then adjust and map the image to the device of the LDR. HoweverAlgorithmThere are two resource-consuming processes, one of which is a floating point texture, and the other is to calculate the gray level in the middle of the image (usually the image is continuously rendered to the rendertarget, each rendering time, the image size is reduced by half until it reaches 1x1. A 1024 x image needs to be rendered 10 times !). Therefore, although HDR works very well, only a few products currently adopt this algorithm, most of which adopt the pseudo HDR + blow effect.

The pseudo-HDR effect is usually used to re-adjust the brightness curve of the image to make the brightness brighter and darker, while the blow effect is to spread the brightness of the image to produce a soft effect.

Here we use a quadratic curve to re-adjust the brightness of the image. The equation of this curve is

X [(2-4 K) x + 4k-1 ).

K value range: 0.5-2.0

After this formula is adjusted, the brightness area of the image will be brighter and the overall brightness willImprove. Then, how can we spread the brightness of an image? A feasible method is to make a downsample for the scene image. Turn it into the original 1/4 times, which is equal to the brightness that spreads out in a 4x4 pixel area.

The technical solutions are basically available. In rendermonkeyImplementationIt is different from the previous example. here we need to use the multi-pass rendering of rendermonkey:

For the first pass, we first perform the downsample operation on the image. First, add a new pass before the original pass and name it downsample pass. Create a render to texture node, set its size (1/4 of the original image size), and create a render target node in the new pass to point to it. In this way, the rendering result of this pass will be saved to the render to texture. The pixel shader of this pass only needs to use the shader with The Blur effect.

Next, name another pass as render pass and add a new texture object. Point the texture object to the added render to texture so that the downsample image can be used in the pass. Then add a float variable to indicate the K value mentioned in the above formula. The final workspace structure is as follows:

Next, edit the pixel shader of render pass.CodeAs follows:

The following is a comparison between the original image and the processed image:

Click to view the chart
Source image

 


K = 1.1


K = 1.6

Figure: Comparison between images processed by pseudo HDR + blow and original images

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.