Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Computer Graphics
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Surface Rendering Methods
November 14, 2005
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Content
Polygonal renderingflat shading
Gouraud shading
Phong shading
Global renderingray tracing
radiosity
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Polygonal Rendering
Shading a polygonal meshflat or constant shading
interpolative, smooth, or Gouraud shading
Phong shading
polygonal mesh
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Flat Shading (1)
Constant shadingflat polygon
n: constant
distant light source
l: constant
distant viewer
v: constant
One shading calculation for each polygonOne shading calculation for each polygon
In OpenGL
distant source and viewer
glShadeModel(GL_FLAT);
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Flat Shading (2)
Disappointing for a smooth surfacelateral inhibition
human visual system has a remarkable sensitivity
Mach bandsperceive the increases in brightness along the edges
flat shading of polygonal mesh
We need smoother shading techniques to avoid it!!We need smoother shading techniques to avoid it!!We need smoother shading techniques to avoid it!!
perceived and actual intensities at an edge
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Gouraud Shading
In OpenGL
One lighting calculation for each vertexOne lighting calculation for each vertexbilinear interpolation of colors
Defining vertex normal through interpolation
glShadeModel(GL_SMOOTH);
4321
4321
nnnn
nnnnn
++++++
=
normals near interior vertex
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Wireframe
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Flat Shading
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Gouraud Shading
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Bump Mapping
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Environmental Mapping
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Phong Shading
Not preventing the appearance of Mach bands
If polygonal mesh is too coarse to capture illumination effects in polygon interiors?
One shading calculation for each pixelOne shading calculation for each pixel off-line
Computing vertex normal at each point
interpolate normals across each polygoninterpolate interpolate normalsnormals across each polygonacross each polygon
normals on an edge interpolation of normals
( ) ( ) BA nnn 1 ααα +−=
( ) ( ) DC nnn 1 , βββα +−=
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Phong Shading
Gouraud
Wireframe
Phong
Flat
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Example: Shading & Subdivision
Gouraud PhongFlat
Loop SubdivisionLevel 1
Level 2
Control Mesh
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Global Rendering (1)
Local lighting model cannot handle:blocking some of the light from the source from reaching the other spheres
scattering some light among spheres
global lighting model local lighting model
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Global Rendering (2)
Global effectsshadows
refractions
inter-object reflections
Methodsray tracing
radiosity
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Shadows
Shadow == light sources are blockedcasting ray towards each light source Li
Si = 0 if ray is blocked, Si = 1 otherwise
( ) ( )∑ ⋅+⋅++=L LL
nSDAAE ISKLNKIKII )RV(
ShadowTerm
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Ray Casting
Tracing primary rays from cameradirect illumination from unblocked lights only
( ) ( )∑ ⋅+⋅++=L LL
nSDAAE ISKLNKIKII )RV(
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Recursive Ray Tracing
Also tracing secondary rays from hit surfacesglobal illumination from mirror reflectionmirror reflection and transparencytransparency
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Mirror Reflection
Tracing secondary ray in direction of mirror reflection
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
radiancefor mirror
reflection ray
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Transparency (1)
Trace secondary ray in direction of refraction
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
radiance forrefraction ray
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Transparency (2)
Transparency coefficient is fraction transmittedKT = 1 if object is translucent
KT = 0 if object is opaque
0 < KT < 1 if object is semi-translucent
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
TransparencyCoefficient
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Refractive Transparency (1)
For thin surfacesignoring change in direction
assuming light travels straight through surface
LT −≅
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Refractive Transparency (2)
For solid objectsapplying Snell’s law:
ηr sin Θr = ηi sin Θi
Lη
ηN)coscos
η
η(T
r
iri
r
i −Θ−Θ=
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Ray Tracing (1)
Extension of ray castinglooking for the visible surface for each pixel
continuing to bounce the ray around the scene
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Ray Tracing (2)
Global effectsshadows
refractions
inter-object reflections
Highly realistic vs. computation time
( ) ( ) TTRSL LLn
SDAAE IKIKISKLNKIKII ++⋅+⋅++= ∑ )RV(
Transparency
Reflectance
Shadow
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Basic Ray Tracing Algorithm
For each pixelprimary ray
testing each surface if it is intersected
Intersected secondary rayreflection ray
transparent – refraction ray
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Basic Ray Tracing Algorithm
For each pixelprimary ray
testing each surface if it is intersected
Intersected secondary rayreflection ray
transparent – refraction ray
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Ray Tracing Tree (1)
Representing illumination computationone branch reflection
the other branch transmission
terminated reaching the preset maximum or striking a light source
Scene Ray Tree
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Ray Tracing Tree (2)
Pixel intensity sum of intensities at root node
starting at terminal node
If no surfaces are intersected, the intensity of background
Scene Ray Tree
Iback
Iback Iback
Ipixel
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Radiosity (1)
Goalsimulating diffuse inter-object reflections and shadows
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Radiosity (2)
Basic ideatreating every polygon as light source
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Radiosity (3)
Advantagesphysical modeling of shadows and indirect diffuse illumination
independent of any viewpoint
Equation
∑+= ijjiii FBρEB
Bi = Radiosity of patch iEi = Emission of patch iρi = Reflectivity of patch iFi = Form-factor between patches i and j
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Form Factors
Definitionfraction of energy leaving patch jthat arrives at patch i
Computationprojecting onto unit hemisphere
projecting onto unit circle base
dividing by area of circle
projecting scene onto hemi-cube
projecting ontounit hemisphere
projecting ontoHemi-cube
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Matrix Solution Methods
Matrix formulation
Progressive refinementiterating shoot radiosity from patches
O(n2) computation – getting pretty good solutions more quickly
⎥⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢⎢
⎣
⎡
⋅=
⎥⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢⎢
⎣
⎡
⋅⎥⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢⎢
⎣
⎡
−⋅−−⋅⋅⋅⋅
−⋅−−−⋅−−−⋅−−
nnnnnnnnn
n
n
n
E
E
E
E
B
B
B
B
Fρ1FρFρ
FρFρFρ
FρFρ1Fρ
FρFρFρ1
3
2
1
3
2
1
21
33323313
22222212
11121111
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Matrix Solution Methods
24 iterations
1 iteration
100 iterations
2 iterations
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Summary
Polygonal renderingflat
Gouraud
Phong
Global renderingray Tracing
radiosity
less expensive
more accurate
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Visible-Line Determination
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Visible-Surface Determination with Ambient Illumination Only
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Flat Shaded Polygons with Diffuse Reflection
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Gouraud Shaded Polygons with Diffuse Reflection
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Gouraud Shaded Polygons with Specular Reflection
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Phong Shaded Polygons with Specular Reflection
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Phong Shading of Curved Surfaces with Specular Reflection
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Improved Illumination Model and Multiple Lights
Sun-Jeong Kim http://www.hallym.ac.kr/~sunkim/teach/2005/cga
Texture Mapping