CS530 - Spring 2020
Introduction to Scientific Visualization
Lecture
Graphics Primer
January 14, 2020
Graphics Primer Lecture 2 January 14, 2020 Introduction Computer - - PowerPoint PPT Presentation
CS530 - Spring 2020 Introduction to Scientific Visualization Graphics Primer Lecture 2 January 14, 2020 Introduction Computer Graphics vs. Visualization Visualization methods transform data into primitives that are rendered using CG
CS530 - Spring 2020
Introduction to Scientific Visualization
January 14, 2020
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
“Visualization methods transform data into primitives that are rendered using CG techniques”
2
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
3
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Points
4
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Lines
piecewise linear
5
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Lines
(e.g., splines)
6
P : t 2 I 7! P(t) 2 I Rn P(t)
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Surfaces
Triangle mesh (piecewise linear)
7
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Surfaces
bi-quadratic, bi-cubic, Bezier, splines, NURBS...
8
P : (u, v) ⇤ I J ⌅⇥ P(u, v) ⇤ I Rn
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
9
Color Normal Texture coordinates Opacity
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
10
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
11
Black 0,0,0 White 1,1,1 Red 1,0,0 Green 0,1,0 Blue 0,0,1 Yellow 1,1,0 Cyan 0,1,1 Magenta 1,0,1 Sky Blue 1/2,1/2, 1
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
12
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
13
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Shading reveals the shape of 3D objects through their interaction with light Shading creates colors as a function of:
surface properties surface normals lights
Only covering basics here Surfaces show information, lights show surfaces, shading controls how
14
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model (1975): Light reflected by
surface is combination of:
Specular reflection Diffuse reflection Ambient reflection
15
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model (1975): Light reflected by
surface is combination of:
Specular reflection Diffuse reflection Ambient reflection
15
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model (1975): Light reflected by
surface is combination of:
Specular reflection Diffuse reflection Ambient reflection
15
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model (1975): Light reflected by
surface is combination of:
Specular reflection Diffuse reflection Ambient reflection
15
http://en.wikipedia.org/wiki/Phong_shading
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Ambient reflection
16
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Ambient reflection
I = ksIs + kdId + kaIa
Light intensity per light source and per color channel
16
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Ambient reflection
I = ksIs + kdId + kaIa
Light intensity per light source and per color channel
16
relative contributions (material specific)
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Ambient reflection
I = ksIs + kdId + kaIa
Light intensity per light source and per color channel
16
relative contributions (material specific)
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Specular Reflection
mirror-like surfaces Specular reflection depends on position of the observer relative to light source and surface normal
17
⇥ l
⇥ n ⇥ r
⇥ v
θ θ
γ
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Specular Reflection
⇥ l
⇥ n ⇥ r
⇥ v
θ θ
γ
Is = Ii cosn = Ii cosn < r, v >
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Diffuse Reflection
Non-shiny surfaces Diffuse reflection depends only on relative position of light source and surface normal.
19
⇥ l
⇥ n
θ
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model: Diffuse Reflection
20
Id = Ii cos = Ii cos < l, n >
⇥ l
⇥ n
θ
Id = Ii cos ✓ = Ii (~ l · ~ n)
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong lighting model
21
⇥ l
⇥ n ⇥ r
⇥ v
θ θ
γ
sum over all light sources ambient light
per color channel
I = kaIa +
N
X
i=1
Ii (kd cos(θ) + ks cosn(γ))
diffuse specular
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
22
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
Bresenham, midpoint algorithms
23
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
Bresenham, midpoint algorithms
23
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
Bresenham, midpoint algorithms
23
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
Bresenham, midpoint algorithms
23
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
Bresenham, midpoint algorithms
23
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Transform geometric primitives into pixels
24
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Flat shading
25
(Color constant per polygon)
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Gouraud shading (1971)
26
(*) More on interpolation in the coming weeks...
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Phong shading
Note: Phong lighting model ≠ Phong shading
27
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
28
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Perspective projection
29
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
30
View angle Front clipping plane Back clipping plane Focal point Camera position View up Direction of projection Image plane
Only primitives located between front and back clipping planes will be rendered.
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
31
Roll Focal Point Azimuth Elevation Direction of projection
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Graphics Primitives Colors Shading Rasterization Cameras Fundamental Techniques
32
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Backface culling Z-buffer Alpha blending Depth peeling
33
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Back-face culling
34
< ⌃ v,⌃ n >> 0?
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Back-face culling
34
< ⌃ v,⌃ n >> 0?
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Back-face culling
34
< ⌃ v,⌃ n >> 0?
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Back-face culling
34
< ⌃ v,⌃ n >> 0?
If some objects do not show up/are black in your visualization: check your normals!
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Z-buffer algorithm
35
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Z-buffer algorithm
36
gray value indicates distance to image plane
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Alpha blending / compositing
37
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Alpha blending / compositing
37
cb = (1,0,0) ab = 0.9 cf = (0,1,0) af = 0.4 c = af*cf + (1 - af)*ab*cb a = af + (1 - af)*ab c = (0.54,0.4,0) a = 0.94
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Alpha blending / compositing
37
cb = (1,0,0) ab = 0.9 cf = (0,1,0) af = 0.4 c = af*cf + (1 - af)*ab*cb a = af + (1 - af)*ab c = (0.54,0.4,0) a = 0.94
Alpha blending is used in volume rendering and depth peeling. More on this later...
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Depth Peeling
38
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
1 1
Depth Peeling
39
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
1 1
Depth Peeling
39
2 2
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
1 1
Depth Peeling
39
2 2 3 3
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
1 1
Depth Peeling
39
2 2 3 3 4 4
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
1 1
Depth Peeling
39
2 2 3 3 4 4
Depth peeling is the only way to get correct transparency results in VTK. Make sure to use it!
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
Ray-tracing algorithm
40
CS530 / Spring 2020 : Introduction to Scientific Visualization. Graphics Primer 01/14/2020
41
https://www.cs.purdue.edu/homes/cs530/projects/project0.html