Download presentation
Presentation is loading. Please wait.
Published byLee Joseph Modified over 8 years ago
1
Chapter 6. Blending, Antialiasing, Fog, and Polygon Offset Computer Graphics (spring, 2009) School of Computer Science University of Seoul
2
Topics ● Blending ● Antialiasing ● Fog ● Point Parameters ● Polygon Offset
3
Blending
4
● Final color = blend_eq ( C s S, C d D ) ● C s & C d : source & destination colors, resp. ● S & D are set by glBlendFunc*(). – GL_SRC_ALPHA, GL_DST_ALPHA,... ● blend_eq is set by glBlendEquation*(). – Supported by OpenGL ver 1.2 or higher. – GL_FUNC_ADD, GL_LOGIC_OP, … ● In most cases... ● S := GL_SRC_ALPHA, D := GL_ONE_MINUS_SRC_ALPHA ● blend_eq := GL_FUNC_ADD
5
Examples ● Transparent objects ● Modulating colors ● Matting / compositing Matting / compositing ● Billboarding Billboarding ● Antialiasing
6
3D Blending ● The “order” of rendering matters! ● Example: alpha3D.calpha3D.c ● How to render both opaque and transparent objects in a scene at the same time?
7
Antialiasing
8
● Aliasing = “jaggedness” ● Why? Since we're approximating the ideal line by a series of discrete pixels. ● Antialiasing: to use the “coverage fraction” as the alpha value. (Fig. 6-3)Fig. 6-3 ● The way to compute “coverage” depends on the platform. ● glHint() : controls quality vs. speed.
9
Antialiasing ● Example: aargb.caargb.c ● GL_ALIASED ( SMOOTH ) _LINE_WIDTH_RANGE, GL_SMOOTH_LINE_WIDTH_GRANULARITY : supported line width & size difference between supported widths. ( glLineWidth() ) glLineWidth()
10
Multisampling ● OpenGL ver 1.3 or higher ● Antialiasing technique for points, lines, polygons, bitmaps, and images. ● Each fragment with multiple colors, depths, and texcoords. ● No alpha blending (no sorting needed) ● Works well for the cases of intersecting or adjacent polygons. ● GL_POINT ( LINE, POLYGON ) _SMOOTH are ignored. ● Example: multisamp.c
11
Antialiasing Polygons ● How to handle overlapping edges of different polygons? ● Using accumulation buffer(Ch.10) is expensive! ● Example: aapoly.c
12
Fog
13
● To render objects fade depending on the distance from the viewpoint. ● Applied after matrix transformations, lighting, and texturing are performed. ● Can improve performance in large simulation...why? ● “depth-cuing”: for points & lines ● Fog color & (density) equation can be set. ● Example: fog.cfog.c
14
Fog Density Functions ● Fog density functions ● GL_EXP : f=e^(-density*z) ● GL_EXP2 : f=e^-(density*z)^2 ● GL_LINEAR : f=(end-z)/(end-start) ● Fig 6-4 Fig 6-4 ● Final fogged color: C = fC i +(1-f)C f ● Explicit per-vertex fog coordinates (ver 1.4) ● ex) “ground-based” fog ● Example: fogcoord.c
15
Point Parameters
16
● OpenGL ver 1.4 or higher ● Useful for rendering particle systems without polygons. ● To change the size & brightness of points depending on the distance from the viewpoint. ● Example: pointp.c
17
Polygon Offset
18
● To avoid “stitching” artifact when rendering a solid object both in GL_FILL and GL_LINE modes. ● Depth value for a fragment is modified before depth test. ● Also can be done using stencil buffer, but it's more expensive. ● Fig 6-5 Fig 6-5 ● Example: polyoff.cpolyoff.c
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.