Accumulation buffer (cumulative cache)

Source: Internet
Author: User

Accumulation buffer (cumulative cache)

 

The cumulative cache is designed to synthesize multiple images. Instead of simply introducing pixel elements instead of pixel values, it scales the elements and adds them to the existing pixel values. To maintain accuracy after a series of mixed operations, the number of bits in each color component in the cumulative cache is more than that in a general visualization system. We can clear the cumulative cache like other caches. We can use glclearaccum () to set the clear values of the red, green, and blue components, clear the cumulative cache in bits or call glclear () with gl_accum_buffer_bit () command. Instead of rendering it directly into the cumulative cache, you should render it to a selected cache, and then use glaccum () to accumulate the current image in that cache into the cumulative cache. Glaccum () is copied using the selected read cache. You can use glreadbuffer () to set the cache you want to read. Glaccum () has two parameters: op and value. The OP value can be one of the following: OP value of glaccum () in table 1

OP Value Action
Gl_accum Reads pixels from the selected cache (this cache is selected for reading with glreadbuffer (), and uses values to multiply R, G, B, And a values, then add the result to the cumulative cache.
Gl_load The operation is similar to the gl_accum operation, but it replaces the value in the cumulative cache with the result value instead of the sum.
Gl_return Multiply the value from the accumulated cache by the value, and then put the result into the color cache activated for the write operation.
Gl_add Add the value to the R, G, B, And A values of each pixel in the cumulative cache.
Gl_mult Truncate the value between [-] and multiply the R, G, B, And A values of each pixel in the cumulative cache.
Because you must render the image to another cache before it is accumulated, a typical method of accumulating images is to render the image several times after it is cached, and accumulate each image to the cumulative cache, when the number of required images has been accumulated, copy the content back to the cache, and then swap the cache before and after. In this way, the accumulated image is displayed only at the end. The following is an example program for accumulating n images: 1. Call gldrawbuffer (gl_back) to render the cache only;
2. Call glreadbuffer (gl_back) so that the accumulated cache will be read from the back cache.
Note: The first two steps are only required when the application has changed the selected write and read cache. If the visualization system is dual-cache, these options are default.
3. Call glclear (bitfield) to clear the cache and then render the 1st images;
4. Call glaccum (gl_load, 1.f/ N); this allows you to avoid using separate steps to clear the cumulative cache;
5. Change the parameters of your image and re-paint it;
6. Call glaccum (gl_accum, 1.f/ N) to add 2nd images to 1st images;
7. Repeat the previous two steps ≥ N-2 ......
8. Call glaccum (gl_return, 1.f) to copy the completed image to the cache;
9. Call gluswapbuffers () (if glut is used) or swapbuffers () (if Win32 is used) to exchange the front and back cache. The cumulative cache provides a method to achieve "multiple exposures" in the scenario with a well-maintained color resolution. Using the cumulative cache can produce a lot of image effects to improve the authenticity of the image, including: Anti-sample, motion blur, soft shadow, depth field (depth of field) and convolution. To produce these effects, the image must be rendered multiple times, the scene location (or the selected object) must be slightly changed, incrementally changed, and then the results are accumulated.

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.