graphics pipeline - cs.ucr.edu · clipping and primitive assembly: output is a set of primitives...

30
Graphics Pipeline

Upload: lequynh

Post on 27-Aug-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Graphics Pipeline

Page 2: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Rendering approaches

1. object-oriented

foreach object ...

2. image-oriented

foreach pixel ...

vertices image3D rendering

pipeline

Page 3: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Modern graphics system[A

ngel and Shreiner]

Page 4: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

4

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

Page 5: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Choice of primitives

• Which primitives should an API contain?

• small set - supported by hardware, or

• lots of primitives - convenient for user

Page 6: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Choice of primitives

• Which primitives should an API contain?

➡small set - supported by hardware

• lots of primitives - convenient for user

Page 7: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 8: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 9: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 10: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Two classes of primitives [A

ngel and Shreiner]

Geometric : points, lines, polygonsImage : arrays of pixels

ff

Page 11: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Point and line segment types [A

ngel and Shreiner]

Page 12: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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)

Page 13: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Valid polygons

• Simple

• Convex

• Flat

Page 14: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Valid polygons

• Simple

• Convex

• Flat

Page 15: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

OpenGL polygons

• Only triangles are supported (in latest versions)

GL_POINTS GL_TRIANGLES

GL_TRIANGLE_STRIP

GL_TRIANGLE_FAN

Page 16: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Other polygons

triangulation

Page 17: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Graphics Pipeline[A

ngel and Shreiner]

ff

Page 18: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Pipelining operations

* +ba

c

An arithmetic pipeline that computes c+(a*b)

Page 19: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 20: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Graphics Pipeline (slides courtesy K. Fatahalian)

Page 21: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 22: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 23: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 24: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Rasterization

Primitives are rasterized into “pixel fragments”

Fragments

Vertex processor

Clipper and primitive assembler

RasterizerFragment processor

Vertices Pixels

Page 25: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Vertex processor

Clipper and primitive assembler

RasterizerFragment processor

Vertices Pixels

Rasterization

Primitives are rasterized into “pixel fragments”

EACH PRIMITIVE IS RASTERIZED INDEPENDENTLY

Page 26: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Fragment processing

Shaded fragments

Fragments are shaded to compute a color at each pixel

Vertex processor

Clipper and primitive assembler

RasterizerFragment processor

Vertices Pixels

Page 27: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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

Page 28: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Pixel operations

Pixels

Fragments are blended into the frame buffer at their pixel locations (z-buffer determines visibility)

Page 29: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

Pipeline entities

v0

v1

v2

v3

v4

v5 v0

v1

v2

v3

v4

v5

Vertices Primitives Fragments

Pixels Fragments (shaded)

Page 30: Graphics Pipeline - cs.ucr.edu · Clipping and primitive assembly: output is a set of primitives Rasterization: output is a set of fragments for each primitive ... Graphics pipeline

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