Buffers and Blending Outline Course Map Buffer in
Buffers and Blending
Outline Course Map Buffer in Open. GL Accumulation buffer Stencil buffer Blending 2
Fixed Pipeline Vertex pipeline Per-Vertex Operations Primitive assembly Viewport culling & clipping Rasterize Fragment Processing Per Fragment operations Pixel pipeline Frame Buffer operations Framebuffer 3
Course Map Vertex pipeline Transformation & Lighting Texture blending Primitive assembly Viewport culling & clipping Rasterize We are here! Per Fragment operations Pixel pipeline Frame Buffer operations Framebuffer 4
Buffer in Open. GL Color Buffer Store the color value(RGBA) to be seen on the screen. Depth Buffer Store the depth value for each pixel. Accumulation Buffer Stencil Buffer 5
Accumulation Buffer (1 / 10) The accumulation buffer holds RGBA color data just like the color buffers do in RGBA mode. It's typically used for accumulating a series of images into a final, composite image. Open. GL graphics operations don't write directly into the accumulation buffer. 6
Accumulation Buffer (2 / 10) GL_ACCUM GL_LOAD Accumulation buffer Color buffer GL_RETURN 7
Accumulation Buffer (3 / 10) 8
Accumulation Buffer (4 / 10) 9
Accumulation Buffer (5 / 10) 10
Accumulation Buffer (6 / 10) 11
Accumulation Buffer (7 / 10) 12
Accumulation Buffer (8 / 10) 13
Accumulation Buffer (9 / 10) void gl. Accum(GLenum op, Glfloat value); op: specifies the accumulation buffer operation. See the following page value: specifies a value used in the operation 14
Accumulation Buffer(10 / 10) op Meaning GL_ACCUM Read each pixel from the color buffer, multiplies the R, G, B, and alpha values by value, then add the result to the accumulation buffer. GL_LOAD The same as GL_ACCUM, but replace the value in the accumulation buffer rather than add. GL_RETURN Read values from the accumulation buffer, multiplies them by value, and places the result in the color buffers. GL_ADD / GL_MULT Simply add / multiply the values of each pixel in the accumulation buffer by value, and return to the accumulation buffer. 15
Stencil Buffer (1 / 9) void gl. Stencil. Func(GLenum func, GLint ref, GLuint mask); Sets the function and reference value for stencil testing. func: test function, see next page ref: reference value mask: a bitwise AND operation is performed on the stencil value and reference value with this mask value before comparing them(The size of stencil buffer is 8 bits) 16
Stencil Buffer (2 / 9) param GL_NEVER Meaning Always fails. GL_LESS Passes if ( ref & mask ) < ( stencil & mask ). GL_LEQUAL Passes if ( ref & mask ) ≤ ( stencil & mask ). GL_GEQUAL Passes if ( ref & mask ) ≥ ( stencil & mask ). GL_NOTEQUAL Passes if ( ref & mask ) != ( stencil & mask ). GL_ALWAYS Always passes. 17
Stencil Buffer (3 / 9) 18
Stencil Buffer (4 / 9) void gl. Stencil. Op(GLenum fail, GLenum zpass); Sets the stencil test actions. fail: the action to take when the stencil test fails zfail: stencil action when the stencil test passes, but the depth test fails zpass: both the stencil test and the depth test pass 19
Stencil Buffer (5 / 9) gl. Stencil. Op fail zpass 21
Stencil Buffer (6 / 9) param Meaning GL_KEEP Keeps the current value. GL_ZERO Sets the stencil buffer value to 0. GL_REPLACE Sets the stencil buffer value to ref, as specified by gl. Stencil. Func. GL_INCR Increments the current stencil buffer value. GL_DECR Decrements the current stencil buffer value. GL_INVERT Bitwise inverts the current stencil buffer value. 22
Stencil Buffer (7 / 9) 23
Stencil Buffer (8 / 9) 24
Stencil Buffer (9 / 9) 25
Blending (1 / 7) 26
Blending (2 / 7) 27
Blending (3 / 7) 28
Blending (4 / 7) 29
Blending (5 / 7) void gl. Blend. Func(GLenum sfactor, GLenum dfactor); sfactor: specifies how the red, green, blue, and alpha source blending factors are computed dfactor: specifies how the red, green, blue, and alpha destination blending factors are computed Source color is which you prepare to draw after setting blend. Destination color is the color on the current color buffer Color = source_color * sfactor + destination_color * dfactor 30
Blending (6 / 7) param GL_ZERO (0, 0, 0, 0) GL_ONE (1, 1, 1, 1) GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR 31
Blending (7 / 7) param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA 32
Thanks for listening! Any questions?
- Slides: 32