cs130 : computer graphics - ucr · [wikipedia] color representation. alpha channel. graphics...
TRANSCRIPT
CS130 : Computer Graphics
Tamar ShinarComputer Science & Engineering
UC Riverside
Raster Devices and Images
Raster Devices
Raster Display
Hearn, Baker, Carithers
Transmissive vs. Emissive Display
[H&
B, Fig. 2-16]
+_
ON ONOFF
LEDs
anode
cathodes
LCD LED
Raster Display
red, green, blue subpixels
What is an image?
Continuous image
Raster Image
A raster image is 2D array storing pixel values at each pixel
What is an image?
Raster image
= number of columns
= number of rows
Each pixel value represents the average color of the image over that pixel’s area.
What is an image?
Raster image
= number of columns
= number of rows
Each pixel value represents the average color of the image over that pixel’s area.
RGB CMYK
Color Representation
sRGB color triangle comparison of color gamuts
[wikipedia]
Color Representation
Alpha Channel
Graphics Pipeline
Modern graphics system[A
ngel and Shreiner]
17
Z-buffer Rendering
•Z-buffering is very common approach, also often accelerated with hardware
•OpenGL is based on this approach
3D Polygons Image PixelsGRAPHICS PIPELINE
Choice of primitives
• Which primitives should an API contain?
• small set - supported by hardware, or
• lots of primitives - convenient for user
Choice of primitives
• Which primitives should an API contain?
➡small set - supported by hardware
• lots of primitives - convenient for user
Choice of primitives
• Which primitives should an API contain?
➡small set - supported by hardware
• lots of primitives - convenient for user
Performance is in 10s millions polygons/secportability, hardware support key
Choice of primitives
• Which primitives should an API contain?
➡small set - supported by hardware
• lots of primitives - convenient for user
GPUs are optimized for points, lines, and triangles
Choice of primitives
Other geometric shapes will be built out of these
• Which primitives should an API contain?
➡small set - supported by hardware
• lots of primitives - convenient for user
GPUs are optimized for points, lines, and triangles
Two classes of primitives [A
ngel and Shreiner]
Geometric : points, lines, polygonsImage : arrays of pixels
ff
Point and line segment types [A
ngel and Shreiner]
Polygons• Multi-sided planar element composed of edges and
vertices.• Vertices (singular: vertex) are represented by points • Edges connect vertices as line segments
E1
E3 E2
(x1,y1)
(x2,y2)
(x3,y3)
Valid polygons
• Simple
• Convex
• Flat
Valid polygons
• Simple
• Convex
• Flat
OpenGL polygons
• Only triangles are supported (in latest versions)
GL_POINTS GL_TRIANGLES
GL_TRIANGLE_STRIP
GL_TRIANGLE_FAN
Other polygons
triangulation
Graphics Pipeline[A
ngel and Shreiner]
ff
Pipelining operations
* +ba
c
An arithmetic pipeline that computes c+(a*b)
3D graphics pipeline
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Geometry: primitives - made of verticesVertex processing: coordinate transformations and colorClipping and primitive assembly: output is a set of primitivesRasterization: output is a set of fragments for each primitiveFragment processing: update pixels in the frame buffer
Graphics Pipeline (slides courtesy K. Fatahalian)
Vertex processing
v0
v1
v2
v3
v4
v5
Vertices
Vertices are transformed into “screen space”
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Vertex processing
v0
v1
v2
v3
v4
v5
Vertices
Vertices are transformed into “screen space”
EACH VERTEX IS TRANSFORMED
INDEPENDENTLY
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Primitive processing
v0
v1
v2
v3
v4
v5
Vertices
v0
v1
v2
v3
v4
v5
Primitives (triangles)
Then organized into primitives that are clipped and culled…
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Rasterization
Primitives are rasterized into “pixel fragments”
Fragments
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Rasterization
Primitives are rasterized into “pixel fragments”
EACH PRIMITIVE IS RASTERIZED INDEPENDENTLY
Fragment processing
Shaded fragments
Fragments are shaded to compute a color at each pixel
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Vertex processor
Clipper and primitive assembler
RasterizerFragment processor
Vertices Pixels
Fragment processing
EACH FRAGMENT IS PROCESSED INDEPENDENTLY
Fragments are shaded to compute a color at each pixel
Pixel operations
Pixels
Fragments are blended into the frame buffer at their pixel locations (z-buffer determines visibility)
Pipeline entities
v0
v1
v2
v3
v4
v5 v0
v1
v2
v3
v4
v5
Vertices Primitives Fragments
Pixels Fragments (shaded)
Graphics pipeline
Primitive Generation
Vertex Generation
Vertex Processing
Fragment Generation
Fragment Processing
Pixel Operations
Fixed-function
Programmable
Memory Buffers Vertex Data Buffers
Textures
Output image (pixels)
Textures
Textures
Primitive Processing
Vertex stream
Vertex stream
Primitive stream
Primitive stream
Fragment stream
Fragment stream
Vertices
Primitives
Fragments
Pixels