1 / 57

Attributes of Graphics Primitives

Attributes of Graphics Primitives. Sang Il Park Sejong University. OpenGL State variables:. Color Point attributes Line attributes Fill-Area attributes. Color in OpenGL. Color buffer Setting: Setting the color value: Ex). glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB). GLUT_RGBA

pete
Download Presentation

Attributes of Graphics Primitives

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. Attributes of Graphics Primitives Sang Il Park Sejong University

  2. OpenGL State variables: • Color • Point attributes • Line attributes • Fill-Area attributes

  3. Color in OpenGL • Color buffer Setting: • Setting the color value:Ex) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB) GLUT_RGBA GLUT_RGB GLUT_INDEX GLUT_SINGLE GLUT_DOUBLE glColor* (values); glColor3f (0.0, 1.0, 0.5); glColor3i ( 0, 255, 128);

  4. Point Attributes in OpenGL • Size: • Color : glPointSize ( size ); glColor* (values);

  5. Line Attributes in OpenGL • Width: • Line-Style :ex) • Line-Style On/Off: glLineWidth ( width ); glLineStipple (repeatFactor, pattern); glLineStipple (1, 0x00FF); glLineStipple (1, 0x0101); glEnable (GL_LINE_STIPPLE); glDisable (GL_LINE_STIPPLE);

  6. Other Line Attributes Not in OpenGL • Line Caps: • Connecting: Butt cap Round cap Projecting square cap Miter join Round join Bevel join

  7. Other Line Attributes Not in OpenGL • Pen and Brush Options:

  8. Color in OpenGL • Color buffer Setting: • Setting the color value:Ex) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB) GLUT_RGBA GLUT_RGB GLUT_INDEX GLUT_SINGLE GLUT_DOUBLE glColor* (values); glColor3f (0.0, 1.0, 0.5); glColor3i ( 0, 255, 128);

  9. Area Filling • Scan line approach • Seed Fill Algorithm

  10. Area Filling (Scan line Approach) • For each scan line (1) Find intersections (the extrema of spans) • Use Bresenham's line-scan algorithm (2) Sort intersections (increasing x order) (3) Fill in between pair of intersections

  11. Area Filling (Scan line Approach) • Take advantage of • Edge coherence: edges intersected by scan line i are also intersected by scan line i+1

  12. Area Filling (Scan line method)

  13. Area Filling (Seed Fill Algorithm) • basic idea • Start at a pixel interior to a polygon • Fill the others using connectivity seed

  14. Seed Fill Algorithm (Cont’) 4-connected 8-connected Need a stack. Why?

  15. Seed Fill Algorithm (Cont’) start position

  16. 8 8 6 6 4 4 2 2 0 2 4 6 8 10 0 2 4 6 8 10 Seed Fill Algorithm (Cont’) interior-defined boundary-defined flood fill algorithm boundary fill algorithm

  17. hole 7 7 6 6 5 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 4 4 3 3 boundary pixel interior pixel seed pixel 2 2 1 1 Seed Fill Algorithm (Cont’) The stack may contain duplicated or unnecessary information !!!

  18. Boundary Filling

  19. Flood Filling : Start a point inside the figure, replace a specified interior color only.

  20. Scan Line Seed Fill scan line conversion seed filling + Shani, U., “Filling Regions in Binary Raster Images: A Graph-Theoretic Approach”, Computer Graphics, 14, (1981), 321-327

  21. Boundary Filling • Efficiency in space! • finish the scan line containing the starting position • process all lines below the start line • process all lines above the start line

  22. Problems of Filling Algorithm • What happens if a vertex is shared by more than one polygon, e.g. three triangles? • What happens if the polygon intersects itself? • What happens for a “sliver”? • Solutions? • Redefine what it means to be inside of a triangle • Different routines for nasty little triangles

  23. OpenGL Fill-Area Function • Shade model: • Wire-frame or point: glShadeModel ( shadeModel ); GL_SMOOTH GL_FLAT glPolygonMode ( face, displayMode ); GL_LINE GL_POINT GL_FILL GL_FRONT GL_BACK GL_FRONT_AND_BACK

  24. Aliasing in CG Which is the better?

  25. Aliasing in CG • Digital technology can only approximate analog signals through a process known as sampling • The distortion of information due to low-frequency sampling (undersampling) • Choosing an appropriate sampling rate depends on data size restraints, need for accuracy, the cost per sample… • Errors caused by aliasing are called artefacts. Common aliasing artefacts in computer graphics include jagged profiles, disappearing or improperly rendered fine detail, and disintegrating textures.

  26. The Nyquist Theorem the sampling rate must be at least twice the frequency of the signal or aliasing occurs

  27. Aliasing Effects

  28. Artifacts - Jagged profiles • Jagged silhouettes are probably the most familiar effect caused by aliasing. • Jaggies are especially noticeable where there is a high contrast between the interior and the exterior of the silhouette

  29. Artefacts - Improperly rendered detail

  30. Artefacts - Disintegrating textures • The checkers should become smaller as the distance from the viewer increases.

  31. Antialiasing • Antialiasing methods were developed to combat the effects of aliasing. The two major categories of antialiasing techniques are prefiltering and postfiltering.

  32. Prefiltering • Eliminate high frequencies before sampling (Foley & van Dam p. 630) • Convert I(x) to F(u) • Apply a low-pass filter • A low-pass filter allows low frequencies through, but attenuates (or reduces) high frequencies • Then sample. Result: no aliasing!

  33. High Frequency

  34. Prefiltering

  35. Prefiltering

  36. Basis for Prefiltering Algorithms

  37. A2 A1 AB A3 Catmull’s Algorithm • Find fragment areas • Multiply by fragment colors • Sum for final pixel color

  38. Prefiltering Example

  39. Prefiltering • So what’s the problem? • Problem: most rendering algorithms generate sampled function directly • e.g., Z-buffer, ray tracing

  40. Supersampling • The simplest way to reduce aliasing artifacts is supersampling • Increase the resolution of the samples • Average the results down • Or sometimes, it is called “Postfiltering”.

  41. Supersampling • The process: • Create virtual image at higher resolution than the final image • Apply a low-pass filter • Resample filtered image

  42. Supersampling: Limitations • Q: What practical consideration hampers super-sampling? • A: Storage goes up quadratically • Q: What theoretical problem does supersampling suffer? • A: Doesn’t eliminate aliasing! Supersampling simply shifts the Nyquist limit higher

  43. Supersampling: Worst Case • Q: Give a simple scene containing infinite frequencies • A: A checkered ground plane receding into infinity • See next slide…

  44. Supersampling • Despite these limitations, people still use super-sampling (why?) • So how can we best perform it?

  45. Sampling in the Postfiltering method • Supersampling from a 4*3 image. • Sampling can be done randomly or regularly. The method of perturbing the sample positions is known as "jittering."

  46. Stochastic Sampling • Stochastic: involving or containing a random variable • Sampling theory tells us that with a regular sampling grid, frequencies higher than the Nyquist limit will alias • Q: What about irregular sampling? • A: High frequencies appear as noise, not aliases • This turns out to bother our visual system less!

  47. Stochastic Sampling • An intuitive argument: • In stochastic sampling, every region of the image has a finite probability of being sampled • Thus small features that fall between uniform sample points tend to be detected by non-uniform samples

  48. Stochastic Sampling • Idea: randomizing distribution of samples scatters aliases into noise • Problem: what type of random distribution to adopt? • Reason: type of randomness used affects spectral characteristics of noise into which high frequencies are converted

  49. Stochastic Sampling • Problem: given a pixel, how to distribute points (samples) within it? Grid Random Poisson Disc Jitter

More Related