basics of rendering pipeline based rendering –objects in the scene are rendered in a sequence of...
TRANSCRIPT
![Page 1: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/1.jpg)
Basics of Rendering
• Pipeline Based Rendering– Objects in the scene are rendered in a sequence
of steps that form the Rendering Pipeline.
• Ray-Tracing– A series of rays are projected thru the view
plane and the view plane is colored based on the object that the ray strikes
![Page 2: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/2.jpg)
Scene Definitions
Camera
View Plane
Objects/Models
View Frustrum
![Page 3: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/3.jpg)
Pipeline Rendering
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
![Page 4: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/4.jpg)
Rendering: Transformations
• So far, discussion has been in screen space
• But model is stored in model space(a.k.a. object space or world space)
• Three sets of geometric transformations:– Modeling transforms– Viewing transforms– Projection transforms
![Page 5: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/5.jpg)
The Rendering Pipeline: 3-D
Scene graphObject geometry
LightingCalculations
Clipping
ModelingTransforms
ViewingTransform
ProjectionTransform
![Page 6: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/6.jpg)
The Rendering Pipeline: 3-D
ModelingTransforms
Scene graphObject geometry
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
Result:Result:
• All vertices of scene in shared 3-D “world” coordinate All vertices of scene in shared 3-D “world” coordinate systemsystem
![Page 7: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/7.jpg)
Rendering: Transformations
• Modeling transforms– Size, place, scale, and rotate objects and parts
of the model w.r.t. each other– Object coordinates world coordinates
Z
X
Y
X
Z
Y
![Page 8: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/8.jpg)
ModelingTransforms
Scene graphObject geometry
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
Result:Result:
• Scene vertices in 3-D “view” or “camera” coordinate Scene vertices in 3-D “view” or “camera” coordinate systemsystem
The Rendering Pipeline: 3-D
![Page 9: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/9.jpg)
Rendering: Transformations
• Viewing transform– Rotate & translate the world to lie directly in
front of the camera• Typically place camera at origin
• Typically looking down -Z axis
– World coordinates view coordinates
![Page 10: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/10.jpg)
ModelingTransforms
Scene graphObject geometry
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
Result:Result:
• 2-D screen coordinates of clipped vertices2-D screen coordinates of clipped vertices
The Rendering Pipeline: 3-D
![Page 11: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/11.jpg)
Rendering: Transformations
• Projection transform– Apply perspective foreshortening
• Distant = small: the pinhole camera model
– View coordinates screen coordinates
![Page 12: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/12.jpg)
• Perspective Camera
• Orthographic Camera
Rendering: Transformations
![Page 13: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/13.jpg)
Rendering: Transformations
• All these transformations involve shifting coordinate systems (i.e., basis sets)
• That’s what matrices do…• Represent coordinates as vectors, transforms as
matrices
• Multiply matrices = concatenate transforms!
Y
X
Y
X
cossin
sincos
![Page 14: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/14.jpg)
Rendering: Transformations
Example: Rotate point [1,0]T by 90 degrees CCW (Counter-clockwise)
1
0
'
'
0
1
01
10
'
'
0
1
)90cos()90sin(
)90sin()90cos(
'
'
y
x
y
x
y
x
x
y
(1,0)
x
(0,1)y
![Page 15: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/15.jpg)
Pipeline Rasterization
• Take a collection of 2D Polygonal Objects and draw them onto a framebuffer.
• Rasterization of Polygons is very efficient.
• All Models are eventually converted into polygons for rasterization.
• So why use other models? – Next class.
![Page 16: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/16.jpg)
Rasterizing Polygons• In interactive graphics, polygons rule the world• Two main reasons:
– Lowest common denominator for surfaces• Can represent any surface with arbitrary accuracy
• Splines, mathematical functions, volumetric isosurfaces…
– Mathematical simplicity lends itself to simple, regular rendering algorithms
• Like those we’re about to discuss…
• Such algorithms embed well in hardware
![Page 17: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/17.jpg)
Rasterizing Polygons
• Triangle is the minimal unit of a polygon– All polygons can be broken up into triangles
• Convex, concave, complex
– Triangles are guaranteed to be:• Planar
• Convex
– What exactly does it mean to be convex?
![Page 18: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/18.jpg)
Convex Shapes
• A two-dimensional shape is convex if and only if every line segment connecting two points on the boundary is entirely contained.
![Page 19: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/19.jpg)
Triangularization
• Convex polygons easily triangulated
• Concave polygons present a challenge
![Page 20: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/20.jpg)
Rasterizing Triangles
• Interactive graphics hardware commonly uses edge walking or edge equation techniques for rasterizing triangles
![Page 21: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/21.jpg)
Edge Walking
• Basic idea: – Draw edges vertically
• Interpolate colors down edges
– Fill in horizontal spans for each scanline• At each scanline, interpolate
edge colors across span
![Page 22: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/22.jpg)
Edge Walking: Notes
• Order three triangle vertices in x and y– Find middle point in y dimension and compute if it is to the
left or right of polygon. Also could be flat top or flat bottom triangle
• We know where left and right edges are.– Proceed from top scanline downwards– Fill each span– Until breakpoint or bottom vertex is reached
• Advantage: can be made very fast• Disadvantages:
– Lots of finicky special cases
![Page 23: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/23.jpg)
Edge Walking: Disadvantages
• Fractional offsets:
• Be careful when interpolating color values!• Beware of gaps between adjacent edges• Beware of duplicating shared edges
![Page 24: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/24.jpg)
General Polygon Rasterization
• Now that we can rasterize triangles, what about general polygons?
• We’ll take an edge-walking approach
![Page 25: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/25.jpg)
General Polygon Rasterization
• Consider the following polygon:
• How do we know whether a given pixel on the scanline is inside or outside the polygon?
A
B
C
D
E
F
![Page 26: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/26.jpg)
Polygon Rasterization
• Inside-Outside Points
![Page 27: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/27.jpg)
Polygon Rasterization
• Inside-Outside Points
![Page 28: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/28.jpg)
General Polygon Rasterization• Basic idea: use a parity test
for each scanline edgeCnt = 0; for each pixel on scanline (l to r) if (oldpixel->newpixel crosses edge)
edgeCnt ++; // draw the pixel if edgeCnt odd if (edgeCnt % 2) setPixel(pixel);
![Page 29: Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A](https://reader036.vdocuments.site/reader036/viewer/2022062408/56649e2b5503460f94b18ec3/html5/thumbnails/29.jpg)
General Polygon Rasterization
• Count your vertices carefully– Details…
B
CD
E
FG
I H
J
A