1 / 14

Frame Buffer Operations

Frame Buffer Operations. Obscure Tricks and Cool Visual Effects. Operations on Fragments. Depth Test Blending Scissor Test Alpha Test Stencil Test Dithering Logical Operations. Scissor Test. glEnable(GL_SCISSOR_TEST) glScissor ( x, y, width, height)

adamdaniel
Download Presentation

Frame Buffer Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Frame Buffer Operations Obscure Tricks and Cool Visual Effects

  2. Operations on Fragments • Depth Test • Blending • Scissor Test • Alpha Test • Stencil Test • Dithering • Logical Operations

  3. Scissor Test • glEnable(GL_SCISSOR_TEST) • glScissor ( x, y, width, height) • integer window coordinates to draw into • x,y = lower left corner ? Uses ?

  4. Alpha Test: syntax • glEnable (GL_ALPHATEST) • glAlphaFunc ( test, compare_value ) • compare_value is float 0 to 1 • test is function such as • GL_LESS - accept fragment if alpha < value • GL_EQUAL - accept fragment is alpha = value • GL_NOTEQUAL - accept fragment if alpha ≠ value • GL_LEQUAL - <= • GL_NEVER - never accept any fragment • GL_ALWAYS - always accept every fragment • etc

  5. Alpha Test: uses • Given our tree made up of a texture of leaves with various alpha values, make the leaves slowly disappear by • slowing changing the alpha values that are accepted. • If you always want something to show up, but still need to use the depth test • draw scene once with depth test on, • then turn depth test off, • turn on alpha test for a particular value, • redraw scene

  6. Alpha Test: uses Gets bigger and bigger • A star texture that changes • create a texture where every texel has the same RGB, • but vary the Alpha values • apply the texture (don't use blending) • during each drawing, use GL_LESS with different value, so that different areas appear Create a texture of wavy lines?

  7. Stenciling: uses Isn't this just the scissor test? • My animation is viewed through a kitchen window, so the window frame and curtains should always show up. • Draw the window pieces once. • Draw the window pieces into the stencil buffer. • Draw the backyard over and over (only the fragments that are on the stencil will so up) http://www.uweb.ucsb.edu/~crashnburnjess/For%20Jess/Kitchen-Window.jpg

  8. Stenciling: uses • Draw Tree and Box • Before drawing shadow, create a mask that matches the front of the box.

  9. Example • Draw a square in the stencil buffer. • The wireframe pink cord is drawn in that mask, so only it appears in the square. • The same pink cord is drawn filled on the scene with a different stencil test. http://www.sulaco.co.za/opengl4.htm#stencil

  10. How Stenciling Operates • for each pixel being drawn into the color buffer • compare a value to the corresponding pixel in stencil buffer • only draw pixels into color buffer that pass the test • perhaps change the stencil buffer pixel based on outcome of that test • programmer indicates the value, the compare test, and what to do if the test passes or fails

  11. Stencil Functions • glEnable ( GL_STENCIL_TEST ) • glStencilFunc(test, compare_value, mask) • glStencilOp (stencil_fail, stencil_pass_depth_fail, stencil_pass_depth_pass) • GL_KEEP, GL_REPLACE, GL_ZERO, GL_INVERT, GL_INCR, etc

  12. Stencil Pseudo-Code • fill stencil buffer with 0s • draw desired shape into stencil buffer with 1s • either use glDrawPixels to write straight into stencil buffer • or draw into the color buffer with polygon functions, using glStencilOp to change the stencil bits • set the reference value to 1 and the test function to equal (only draw pixels into color map where stencil is equal to 1)

  13. Accumulation Buffer Motion Blur - leave an image trail • redraw the scene over and over while moving an object • between each drawing slightly dim the previous scene, glAccum(GL_MULT, decay) • move the accumulation buffer into the color buffer using glAccum(GL_RETURN, 1.0)

  14. Accumulation Buffer Depth of Field - make distant objects a little blury • Draw the scene several times, each with a very slight change in projection. Hence, distant objects will move around a little more than near objects. This is "jittering". • Add each projected scene to the accumulation buffer. For example, draw the scene 10 times with glAccum(GL_ACCUM, 0.1) so that each projection makes up 10% of the final image. • Move the accumulation buffer into the color buffer.

More Related