1
Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1 Lecture - - PowerPoint PPT Presentation
Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1 Lecture - - PowerPoint PPT Presentation
Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1 Lecture overview Color Rendering Illumination 2 Visualization pipeline Raw Data Data Enrichment/Enhancement Derived Data Visualization Mapping Abstract Visualization
2
Lecture overview
- Color
- Rendering
- Illumination
3
Visualization pipeline
Raw Data Derived Data Abstract Visualization Object Displayable Image Data Enrichment/Enhancement Visualization Mapping Rendering
4
Color
- The electromagnetic spectrum
visible to humans contains wavelengths ranging from about 400 to 700 nm
- Light we see consists of
different intensities of these wavelengths
5
Color
- The human eye contains three
receptors (cones): for red, green and blue
- Color we see is a combination
- f these
Response curves
6
Color systems
- Color system
- A way to represent color on a computer
- Most used:
- RGB
- HSV
7
RGB-model
- 3 primary colors: Red, Green and Blue
- Color cube:
- Color = point in cube
- Additive:
- C = rR + gG + bB
R G B
8
HSV-model
- More user oriented: based on
intuitive perception
- Hue (0-1 or 0-360°)
- Saturation (0-1)
- Value (0-1)
- Color is point in cone
9
Rendering
- How do I generate an image of a scene?
- Problems:
- World is complex (shape, light)
- World is 3 dimensional, screen is 2 dimensional
10
Subdivide problem
- Geometric modeling
- How do we define shape of objects?
- Projection and hidden surface removal
- How do we determine what is visible on screen and what
is not.
- Shading
- How do we model color, texture and contribution of
light?
- Rasterization
- Determine pixel values for visible objects
11
Graphics pipeline
Geometric model Viewing Camera parameters Light sources, materials Shading Visible surface determination Rasterize Raster display
12
Raster graphics
- Currently “standard” for computer graphics
- Screen is subdivided in grid of “squares”: picture elements
- r pixels
- Per pixel: n bits information
- Resolution: size of grid and number of bits per pixel
13
Raster graphics hardware
system bus system memory CPU display processor video controller
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
frame buffer monitor
14
Visualization pipeline
Raw Data Derived Data Abstract Visualization Object Displayable Image Data Enrichment/Enhancement Visualization Mapping Rendering
15
Graphics pipeline
Geometric model Viewing Camera parameters Light sources, materials Shading Visible surface determination Rasterize Raster display
16
Viewing
- Given a 3D model, how do we project this model on screen?
- Camera model
- Eye/view point:
- From which point do we look to the scene?
- Target point or viewing direction:
- Where do we look at?
- Viewing angles:
- What lens do we use?
17
The camera
18
Graphics pipeline
Geometric model Viewing Camera parameters Light sources, materials Shading Visible surface determination Rasterize Raster display
19
Why illumination
20
Illumination
- Illumination model
- Illumination (and therefore color) of point on surface is
determined by simulation of light in scene
- Illumination model is approximation of real light
transport
- Shading method
- determines for which points illumination is computed
- determines how illumination for other points is
computed
21
Illumination models
- Model(s) needed for
- Emission of light
- Scattering light at surfaces
- Reception on camera
- Desired model requirement
- Accurate
- Efficient to compute
22
Point light source
- Emits light equally in all directions
- Parameters
- Intensity IL
- Position P (px,py,pz)
- Approximation for small light sources
P
23
Direction light source
- Emits light in one direction
- Can be regarded as point light source at infinity
- E.g. sun
- Parameters
- Intensity IL
- Direction D (dx,dy,dz)
D
24
Surface illumination
- When light arrives at surface, it can be
- Absorbed
- Reflected
- Transmitted
reflection transmission absorption
25
Reflection model
- Total intensity on point reflected in certain direction is
determined by:
- Diffusely reflected light
- Specularly reflected light
- Reflection of ambient light
26
Diffuse reflection
- Incoming light is reflected equally in all directions
- Amount of reflected light depends only on angle of incident
light viewer surface
27
Diffuse reflection
- Lambert’ law: Reflected energy from a surface is
proportional to the cosine of the angle of direction of incoming light and normal of surface
- Id = kdILcos(θ) = kdIL (N•L)
- kd is diffuse reflection coefficient
θ viewer surface
N L V
28
Specular reflection
- Models reflections of shiny surfaces
θ θ
29
Specular reflection
- Shininess depends on roughness surface
- Incident light is reflected unequally in all directions
- Reflection strongest near mirror angle
very shiny less shiny
30
Specular reflection / Phong
- Light intensity observed by viewer depends on angle of
incident light and angle to viewer
- Phong model: Is = ksILcosn(α) = ksIL (V•R)n
- ks is specular reflection coefficient
- n is specular reflection exponent
θ θ
α L R N V
31
Specular reflection / Phong
increasing n increasing ks
32
Ambient light
- Even though parts of scene are not directly lit by light
sources, they can still be visible
- Because of indirect illumination
33
Ambient light
- “Ambient” light IA is an approach to this indirect
illumination
- Ambient light is independent of light sources and viewer
position
- Contribution of ambient light I = kaIa
- ka is ambient reflection coefficient
- Ia is ambient light intensity (constant over scene)
34
Total illumination model
- Total intensity Itotal at point P seen by viewer is
( )
∑
α + θ + =
i i n s i d i a a total
) ( cos k ) cos( k I I k I
α0 θ0 θ1 α1
( )
∑
⋅ + ⋅ + =
i n i s i d i a a total
) R V ( k ) L N ( k I I k I
35
Total illumination model
- In previous formula ka, kd dependent on wavelength
(different values for R, G and B)
- Often division into color and reflection coefficient of
surface where:
- 0 ≤ ka, ks, ks ≤ 1 (relative amounts)
- Ca is ambient reflected color of surface
- Cd is diffuse reflected color of surface
- Cs is specular reflected color of surface
( ) ( )
( ) ∑ α + θ + + =
i i n s s i d d i a a a e totaal
cos C k cos C k I I C k I I
36
Only emission and ambient
37
Including diffuse reflection
38
Including specular reflection
39
Illumination model
- Given model:
- Simple
- Effective
- Not real world
- More advanced models possible
40
Shading
- Illumination model computes illumination for a point on
surface
- But how do we compute the illumination for all points on all
(visible) surfaces?
- Shading methods:
- Flat shading
- Gouraud shading
- Phong shading
41
Normal vectors
- For illumination model we need normal vectors for
- the cell center
- the cell nodes
- every pixel in the image
42
Normal vectors
- Cell normals
- Use the cross product
- f two cell edges
- Node normals
- Compute cell normals
for neighbor cells
- Average cell normals
- 2
v 1 v 2 v 1 v n × × = 4 4 n 3 n 2 n 1 n n + + + =
43
Flat shading
- Determine illumination for one point on cell (e.g. center)
- Use this illumination for all points on cell
- Disadvantages:
- Does not account for changing direction to light source
- ver polygon
- Does not account for changing direction to eye over
polygon
- Discontinuity at polygon boundaries (when curved
surface approximated by polygon mesh
44
Flat shading
45
Gouraud shading
- Based on interpolation of illumination values
- Compute illumination for nodes of cell
- Algorithm
- for all nodes of cell
- get node normal
- compute node illumination using this normal
- for all pixels in projection of polygon
- compute pixel illumination by interpolation of node
illuminations
46
Gouraud shading
I1 I2 I3 ys IA IB
( )
2 1 A
I I 1 I α + α − =
( )
2 1 B
I I 1 I β + β − =
2 1 s 1
y y y y − − = α
3 1 s 1
y y y y − − = β IP
B A P
I I ) 1 ( I γ + γ − =
B A P A
x x x x − − = γ
47
Gouraud shading
48
Gouraud shading
- Advantages
- Interpolation is simple, hardware implementation
- Continuous shading
- Better results for curved surfaces
- Disadvantages
- Subtle illumination effects (e.g. highlights) require high
subdivision of surface in very small polygons
- Mach banding
49
Phong shading
- Based on normal interpolation
- Compute illumination for each visible point of cell
- Algorithm
- for each node of cell
- get node normal
- for each pixel in projection of cell
- compute point normal by interpolation of node
normals
- compute pixel illumination using interpolated normal
50
Phong shading
51
Phong shading
- Advantages
- Much better results for curved surfaces
- Nice highlights
- No Mach banding
- Disadvantages
- Computational expensive
- Normal interpolation and application of illumination
model for each pixel
52
Shading summarized
53
Shading
- Flat shading
- 1x application of illumination model per cell
- 1 color per polygon
- Gouraud shading
- 1x application of illumination model per node
- Interpolated colors
- Phong shading
- 1x application of illumination model per pixel
- Nice highlights
Increase computation time Increase quality
54