College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310...
-
Upload
sarah-tucker -
Category
Documents
-
view
218 -
download
0
Transcript of College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310...
![Page 1: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/1.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 1
CS5310Graduate Computer Graphics
Prof. Harriet FellSpring 2011
Lecture 7 – March 9, 2011
![Page 2: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/2.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 2
Today’s Topics
• Look at student images• About the final project• About the exam• Poly Mesh
Hidden Surface Removal Visible Surface Determination
---------------------------• Noise and Turbulence
Clouds Marble Other Effects
![Page 3: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/3.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 3
Rendering a Polymesh
• Scene is composed of triangles or other polygons.
• We want to view the scene from different view-points. Hidden Surface Removal
• Cull out surfaces or parts of surfaces that are not visible.
Visible Surface Determination• Head right for the surfaces that are visible.• Ray-Tracing is one way to do this.
![Page 4: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/4.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 4
Wireframe Rendering
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Hidden-Line Removal
Hidden-Face Removal
![Page 5: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/5.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 5
Convex Polyhedra
We can see a face if and only if its normal has a component toward us.
N·V > 0
V points from the face toward the viewer.
N point toward the outside of the polyhedra.
![Page 6: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/6.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 6
Hidden Surface Removal
• Backface culling Never show the back of a polygon.
• Viewing frustum culling Discard objects outside the camera’s view.
• Occlusion culling Determining when portions of objects are hidden.
• Painter’s Algorithm• Z-Buffer
• Contribution culling Discard objects that are too far away to be seen.
http://en.wikipedia.org/wiki/Hidden_face_removal
![Page 7: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/7.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 7
Painter’s Algorithm
![Page 8: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/8.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 8
Painter’s Algorithm
Sort objects back to front relative to the viewpoint.
for each object (in the above order) do
draw it on the screen
![Page 9: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/9.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 9
Painter’s Problem
![Page 10: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/10.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 10
Z-Buffer
This image is licensed under the Creative Commons Attribution License v. 2.0.
The Z-Buffer is usually part of graphics card hardware. It can also be implemented in software.
The depth of each pixel is stored in the z-buffer.
The Z-Buffer is a 2D array that holds one value for each pixel.
An object is rendered at a pixel only if its z-value is higher(lower) than the buffer value. The buffer is then updated.
![Page 11: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/11.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 11
Visible Surface Determination
• If surfaces are invisible, don’t render them. Ray Tracing
• We only render the nearest object.
Binary Space Partitioning (BSP)• Recursively cut up space into convex sets with
hyperplanes.• The scene is represented by a BSP-tree.
![Page 12: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/12.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 12
Sorting the Polygons
The first step of the Painter’s algorithm is:
Sort objects back to front relative to the viewpoint.
The relative order may not be well defined.
We have to reorder the objects when we change the viewpoint.
The BSP algorithm and BSP trees solve these problems.
![Page 13: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/13.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 13
Binary Space Partition
• Our scene is made of triangles. Other polygons can work too.
• Assume no triangle crosses the plane of any other triangle. We relax this condition later.
following Shirley et al.
![Page 14: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/14.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 14
BSP – Basics
• Let a plane in 3-space (or line in 2-space) be defined implicitly, i.e. f(P) = f(x, y, z) = 0 in 3-space f(P) = f(x, y) = 0 in 2-space
• All the points P such that f(P) > 0 lie on one side of the plane (line).
• All the points P such that f(P) < 0 lie on the other side of the plane (line).
• Since we have assumed that all vertices of a triangle lie on the same side of the plane (line), we can tell which side of a plane a triangle lies on.
![Page 15: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/15.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 15
BSP on a Simple Scene
Suppose scene has 2 triangles
T1 on the plane f(P) = 0 T2 on the f(P) < 0 side e is the eye.
if f(e) < 0 thendraw T1; draw T2
elsedraw T2; draw T1
![Page 16: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/16.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 16
The BSP Tree
Suppose scene has many triangles, T1, T2, … .We still assume no triangle crosses the plane of any other
triangle.
Let fi(P) = 0 be the equation of the plane containing Ti.The BSPTREE has a node for each triangle with T1 at the
root.At the node for Ti,
the minus subtree contains all the triangles whose vertices have fi(P) < 0the plus subtree contains all the triangles whose vertices have fi(P) > 0.
![Page 17: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/17.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 17
BSP on a non-Simple Scene
function draw(bsptree tree, point e)if (tree.empty) then
return
if (ftree.root(e) < 0) thendraw(tree.plus, e)render tree.triangledraw(tree.minus, e)
elsedraw(tree.minus, e)render tree.triangledraw(tree.plus, e)
![Page 18: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/18.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 18
2D BSP Trees Demo
http://www.symbolcraft.com/graphics/bsp/index.php
This is a demo in 2 dimensions.
The objects are line segments.
The dividing hyperplanes are lines.
![Page 19: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/19.jpg)
Building the BSP TreeWe still assume no triangle crosses the plane of another triangle.
tree = node(T1)for I in {2, …, N} do tree.add(Ti)
function add (triangle T)if (f(a) < 0 and f(b) < 0 and f(c) < 0) then
if (tree.minus.empty) then tree.minus = node(T)
else tree.minus.add(T)
else if (f(a) > 0 and f(b) > 0 and f(c) > 0) then if (tree.plus.empty) then
tree.plus = node(T)else
tree.plus.add(T)
![Page 20: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/20.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 20
Triangle Crossing a Plane
a
c
b
A
B
Two vertices, a and b, will be on one side and one, c, on the other side.
Find intercepts , A and B, of the plane with the 2 edges that cross it.
![Page 21: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/21.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 21
Cutting the Triangle
a
c
b
A
B
Cut the triangle into three triangles, none of which cross the cutting plane.
Be careful when one or more of a, b, and c is close to or on the cutting plane.
![Page 22: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/22.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 22
Binary Space Partitionof Polygons
by Fredrik (public domain)http://en.wikipedia.org/wiki/User:Fredrik
![Page 23: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/23.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 23
Scan-Line Algorithm
• Romney, G. W., G. S. Watkins, D. C. Evans, "Real-Time Display of Computer Generated Half-Tone Perspective Pictures", IFIP, 1968, 973-978.
• Scan Line Conversion of Polymesh - like Polyfill
• Edge Coherence / Scanline Coherence• 1) Most edges don’t hit a given scanline- keep track
of those that do.• 2) Use the last point on an edge to compute the next
one. xi+1 = xi + 1/m
![Page 24: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/24.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 24
ET – the Edge Table
The EdgeTable is for all nonhorizontal edges of all polygons.
ET has buckets based on edges smaller y-coordinate.Edge Data:
x-coordinate of smaller y-coordinate y-top 1/m = delta x polygon identification #: which polygons the edge
belongs to
![Page 25: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/25.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 25
Polygon Data Structure
edgesxmin ymax 1/m
1 6 8/4
(1, 2)
(9, 6)
xmin = x value at lowest y
ymax = highest y
![Page 26: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/26.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 26
Preprocessing the edges
count twice, once for each edge
chop lowest pixel to only count oncedelete
horizontal edges
For a closed polygon, there should be an even number of crossings at each scan line.
We fill between each successive pair.
![Page 27: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/27.jpg)
College of Computer and Information Science, Northeastern University
13
12
11
10 e6
9
8
7 e4 e5
6 e3 e7 e8
5
4
3
2
1 e2 e1 e11
0 e10 e9
e11
7 e3 e4 e5
6 e7 e8
11 e6
10
Polygon Data Structureafter preprocessing
Edge Table (ET) has a list of edges for each scan line.
e1
e2
e3e4
e5
e6
e7e8
e9
e10
e11
0
5
10
13
![Page 28: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/28.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 28
The Algorithm
1. Start with smallest nonempty y value in ET.
2. Initialize SLB (Scan Line Bucket) to nil.
3. While current y ≤ top y value:a. Merge y bucket from ET into SLB; sort on xmin.
b. Fill pixels between rounded pairs of x values in SLB.
c. Remove edges from SLB whose ytop = current y.
d. Increment xmin by 1/m for edges in SLB.
e. Increment y by 1.
![Page 29: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/29.jpg)
College of Computer and Information Science, Northeastern University
Running the Algorithm
e2
e3e4
e5
e6
e7e8
e9
e10
e11
0
5
10
13
ET1312
11 e61098
7 e3 e4 e56 e7 ve85432
1 e2 e110 e10 e9
xmin ymax 1/me2 2 6 -2/5e3 1/3 12 1/3e4 4 12 -2/5e5 4 13 0e6 6 2/3 13 -4/3e7 10 10 -1/2e8 10 8 2e9 11 8 3/8e10 11 4 -3/4e11 6 4 2/3
50 10 15
![Page 30: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/30.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 30
Running the Algorithm
e2
e3e4
e5
e6
e7e8
e9
e10
e11
0
5
10
13
50 10 15
y=0
SCB 11 4 -3/4
11 8 3/8 e9
e1010 1/4
11 3/8
![Page 31: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/31.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 31
Running the Algorithm
e2
e3e4
e5
e6
e7e8
e9
e10
e11
0
5
10
13
50 10 15
y=1
SLB 2 6 -2/5
6 4 2/3 e11
e21 3/5
10 1/4 4 -3/4
11 3/8 8 3/8 e9
e10
6 2/3
9 1/2
11 6/8
![Page 32: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/32.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 32
Running the Algorithm
e2
e3e4
e5
e6
e7e8
e9
e10
e11
0
5
10
13
50 10 15
y=2
SLB 1 3/5 6 -2/5
6 2/3 4 2/3 e11
e2
9 1/2 4 -3/4
11 6/8 8 3/8 e9
e10
12 1/8
8 3/4
7 1/3
1 1/5
![Page 33: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/33.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 33
Running the Algorithm
e3e4
e5
e6
e7e8
e9
e100
5
10
13
50 10 15
y=3
SLB 1 1/5 6 -2/5
7 1/3 4 2/3 e11
e2
8 3/4 4 -3/4
12 1/8 8 3/8 e9
e10
12 4/8
8
8
4/5
e11e2
![Page 34: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/34.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 34
Running the Algorithm
e3e4
e5
e6
e7e8
e100
5
10
13
50 10 15
y=4
SLB 4/5 6 -2/5
8 4 2/3 e11
e2
8 4 -3/4
12 4/8 8 3/8 e9
e10 e11e2e9
Remove these edges.
![Page 35: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/35.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 35
Running the Algorithm
e3e4
e5
e6
e7e8
0
5
10
13
50 10 15
y=4
SLB 4/5 6 -2/5 e2
12 4/8 8 3/8 e9
12 7/8
2/5
e2 e11
e10
e9e11 and e10 are removed.
![Page 36: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/36.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 36
Running the Algorithm
e3e4
e5
e6
e7e8
0
5
10
13
50 10 15
y=5
SLB 2/5 6 -2/5 e2
12 7/8 8 3/8 e9
13 2/8
0
e2 e11
e10
e9
![Page 37: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/37.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 37
Running the Algorithm
e3e4
e5
e6
e7e8
0
5
10
13
50 10 15
y=6
SLB 0 6 -2/5 e2
10 10 -1/2 e7
e2 e11
e10
e9
Remove this edge.
10 8 2 e8
13 2/8 8 3/8 e9
9 1/2
12
13 5/8
![Page 38: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/38.jpg)
College of Computer and Information Science, Northeastern University
Running the Algorithm
e3e4
e5
e6
e7e8
0
5
10
13
50 10 15
y=7
SLB
4 13 0 e5
9 1/2 10 -1/2 e7
e2 e11
e10
e9
12 8 2 e8
13 5/8 8 3/8 e9
Add these edges.
4 12 -2/5 e4
1/3 12 1/3 e3
![Page 39: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/39.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 39
Polygon Table
Polygon Table
A, B, C, D of the plane equation
shading or color info (e.g. color and N)
in (out) boolean
initialized to false (= out) at start of scanline
z – at lowest y, x
![Page 40: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/40.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 40
Coherence
• Non-penetrating polygons maintain their relative z values. If the polygons penetrate, add a false edge.
• If there is no change in edges from one scanline to the next, and no change in order wrt x, then no new computations of z are needed.
![Page 41: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/41.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 41
Active Edge Table
Keep in order of increasing x.
At (1) AET AB AC DF EF
A
B
CD
E
F1
2
1 2 3 4
1 2 3 4
![Page 42: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/42.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 42
Running the Algorithm 1
If more than one in is true, compute the z values at that point to see which polygon is furthest forward.
If only one in is true, use that polygon’s color and shading.
A
B
CD
E
F1
2
1 2 3 4
1 2 3 4
![Page 43: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/43.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 43
Running the Algorithm 2
On crossing an edgeset in of polygons with that edge to not in.
At (2) AET AB DF AC EF
If there is a third polygon, GHIJ behind the other two, after edge AC is passed at level (2) there is no need to evaluate z again - if the polygons do not pierce each other.
A
B
CD
E
F1
2
1 2 3 4
1 2 3 4
![Page 44: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/44.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 44
Time for a Break
![Page 45: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/45.jpg)
Perlin Noise
![Page 46: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/46.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 46
Noise Reference Links
• Perlin Noise by Ken Perlin
• Perlin Noise by Hugo Elias
• Paul Bourke Texture and Colour ala Perlin
![Page 47: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/47.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 47
The Oscar™
To Ken Perlin for the development of Perlin Noise, a technique used to produce natural appearing textures on computer generated surfaces for motion picture visual effects.
![Page 48: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/48.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 48
The Movies
• James Cameron Movies (Abyss,Titanic,...) • Animated Movies (Lion King, Moses,...) • Arnold Movies (T2, True Lies, ...) • Star Wars Episode I • Star Trek Movies • Batman Movies • and lots of others
In fact, after around 1990 or so, every Hollywood effects film has used it.
![Page 49: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/49.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 49
What is Noise?
• Noise is a mapping from Rn to R - you input an n-dimensional point with real coordinates, and it returns a real value.
• n=1 for animation
• n=2 cheap texture hacks
• n=3 less-cheap texture hacks
• n=4 time-varying solid textures
![Page 50: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/50.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 50
Noise is Smooth Randomness
![Page 51: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/51.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 51
Making Linear Noise
1. Generate random values at grid points.
2. Interpolate linearly between these values.
![Page 52: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/52.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 52
Making Splined Noise
1. Generate random values at grid points.
2. Interpolate smoothly between these values.
![Page 53: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/53.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 53
lerping
lerp(v1, v2, t) = (1 – t)v1 + tv2
P
Q
(1-t)P + tQ
t of the distance from P to Q
![Page 54: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/54.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 54
2D Linear Noise
253 45 3
145 68 37
50 5 241
228 154 219
199 57 20 139 80 230154 74 178
101 15 182
207 133 174
![Page 55: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/55.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 55
3D Linear Noise
![Page 56: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/56.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 56
Noise is Smooth Randomness
![Page 57: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/57.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 57
Perlin Noise Sphere
![Page 58: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/58.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 58
Noise Code
MATLAB Noise Code
Don’t click this.
![Page 59: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/59.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 59
Turbulence or Sum 1/fn(noise)
Perlin Noise and Turbulence by Baul Bourke
noise(p) + ½ noise(2p) + ¼ noise(4p) ...
![Page 60: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/60.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 60
Turbulence and Persistence
1
0
Noise
.
2.
0 1.
ni i
i
n
x p b x
n p
b
p p
Turbulence
where is the smallest integer such that size of a pixel
Usually
is the persistence,
See Perlin Noise by Hugo Elias for more about persistence.
![Page 61: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/61.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 61
Perlin Sum 1/f(noise) Sphere
![Page 62: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/62.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 62
Perlin Sum 1/f(|noise|) Sphere
![Page 63: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/63.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 63
2D Nornalized Turbulence
Just Noise
![Page 64: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/64.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 64
2D Turbulence
![Page 65: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/65.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 65
Turbulence Code
![Page 66: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/66.jpg)
function turb = LinearTurbulence2(u, v, noise, divisor)% double t, scale;% LN(u, v) +LN(2u, 2v)/2 + LN(4u, 4v)/4 + ...% Value is between between 0 and 2.
t = 0; scale = 1; while (scale >= 1/divisor) t = t + linearNoise2(u/scale, v/scale, noise) * scale; scale = scale/2; end
turb = t/2; % now value is between 0 and 1
![Page 67: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/67.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 67
Marble
factorG = sqrt(abs(sin(x + twist*turbulence(x, y, noise) color = (0, trunc(factorG*255), 255);
![Page 68: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/68.jpg)
Clouds
r = sqrt((x-200/d)*(x-200/d) + (y-200/d)*(y-200/d)); factorB = abs(cos(r + fluff*turbulence(x, y, noise)); color=(127 + 128*(1 - factorB), 127 + 128*(1 - factorB), 255);
![Page 69: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/69.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 69
Fire
![Page 70: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/70.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 70
Plane Flame Code(MATLAB)
w = 300; h = w + w/2; x=1:w; y=1:h;
flameColor = zeros(w,3); % Set a color for each xflameColor(x,:)=…
[1-2*abs(w/2-x)/w; max(0,1-4*abs(w/2-x)/w); zeros(1,w)]';
flame=zeros(h,w,3); % Set colors for whole flame% 1 <= x=j <= 300=h, 1 <= y=451-i <= 450=h+h/2for i = 1:h for j = 1:w flame(i,j,:)=(1-(h-i)/h)*flameColor(j,:); endend
![Page 71: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/71.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 71
Turbulent Flame Code(MATLAB)
for u = 1:450 for v = 1:300 x = round(u+80*Tarray(u,v,1)); x = max(x,2); x = min(x,449); y = round(v+80*Tarray(u,v,2)); y = max(y,2); y = min(y,299); flame2(u,v,:) = flame(x,y,:); endend
![Page 72: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/72.jpg)
function Tarray = turbulenceArray(m,n)noise1 = rand(39,39);noise2 = rand(39,39);noise3 = rand(39,39);divisor = 64;Tarray = zeros(m,n); for i = 1:m for j = 1:n Tarray(i,j,1) = LinearTurbulence2(i/divisor, j/divisor, noise1, divisor); Tarray(i,j,2) = LinearTurbulence2(i/divisor, j/divisor, noise2, divisor); Tarray(i,j,3) = LinearTurbulence2(i/divisor, j/divisor, noise3, divisor);
endend
![Page 73: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/73.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 73
Student Images
![Page 74: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/74.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 74
Student Images
![Page 75: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/75.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 75
Student Images
![Page 76: College of Computer and Information Science, Northeastern UniversitySeptember 5, 20151 CS5310 Graduate Computer Graphics Prof. Harriet Fell Spring 2011.](https://reader034.fdocuments.in/reader034/viewer/2022051315/56649e175503460f94b0252e/html5/thumbnails/76.jpg)
College of Computer and Information Science, Northeastern UniversityApril 19, 2023 76
Perlin’s Clouds and Corona