frame buffer operations n.
Skip this Video
Loading SlideShow in 5 Seconds..
Frame Buffer Operations PowerPoint Presentation
Download Presentation
Frame Buffer Operations

Loading in 2 Seconds...

play fullscreen
1 / 14

Frame Buffer Operations - PowerPoint PPT Presentation

  • Uploaded on

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)

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Frame Buffer Operations' - adamdaniel

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
frame buffer operations

Frame Buffer Operations

Obscure Tricks

and Cool Visual Effects

operations on fragments
Operations on Fragments
  • Depth Test
  • Blending
  • Scissor Test
  • Alpha Test
  • Stencil Test
  • Dithering
  • Logical Operations
scissor test
Scissor Test
  • glEnable(GL_SCISSOR_TEST)
  • glScissor ( x, y, width, height)
    • integer window coordinates to draw into
    • x,y = lower left corner




alpha test syntax
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
alpha test uses
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
alpha test uses1
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?

stenciling uses
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)

stenciling uses1
Stenciling: uses
  • Draw Tree and Box
  • Before drawing shadow, create a mask that matches the front of the box.
  • 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.

how stenciling operates
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
stencil functions
Stencil Functions
  • glEnable ( GL_STENCIL_TEST )
  • glStencilFunc(test, compare_value, mask)
  • glStencilOp (stencil_fail, stencil_pass_depth_fail, stencil_pass_depth_pass)
stencil pseudo code
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)
accumulation buffer
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)

accumulation buffer1
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.