Date post: | 14-Dec-2015 |
Category: |
Documents |
Upload: | emely-wile |
View: | 219 times |
Download: | 4 times |
CAP 4703CAP 4703Computer Graphic Computer Graphic
MethodsMethodsProf. Roy LevowProf. Roy Levow
Chapter 6Chapter 6
Light and MatterLight and Matter
Surface maySurface may– emit lightemit light– reflect lightreflect light
Rendering equationRendering equation– Recusrively applying the effect from a Recusrively applying the effect from a
source to the viewer yields thesource to the viewer yields the Equation cannot be solved in generalEquation cannot be solved in general Approximate approaches can be Approximate approaches can be
computationally intensivecomputationally intensive
ApproximationsApproximations
Ray tracingRay tracing– trace light from source to eyetrace light from source to eye
most rays don’t reach the eyemost rays don’t reach the eye
RadiosityRadiosity– Treat surfaces as small regions each emitting Treat surfaces as small regions each emitting
fixed lightfixed light Calculate emission independent of viewerCalculate emission independent of viewer
Simplified ray tracingSimplified ray tracing– Single interaction between light source and Single interaction between light source and
each surfaceeach surface
Light and SurfacesLight and Surfaces
Interaction with SurfacesInteraction with Surfaces
Specular surfaceSpecular surface– Similar to mirrorSimilar to mirror– Light leaves atLight leaves at
same angle as same angle as entryentry
Interaction with Surfaces (cont)Interaction with Surfaces (cont)
Diffuse SurfaceDiffuse Surface– Light leaves inLight leaves in
all directionsall directions
Interaction with Surfaces (cont)Interaction with Surfaces (cont)
Translucent Translucent SurfaceSurface– some light some light
penetrates surfacepenetrates surface– leaves at modified leaves at modified
angle – refractionangle – refraction– some reflectedsome reflected
Light SourcesLight Sources
Six variable illumination Six variable illumination functionfunction
I(x,y,x,theta, phi, lambda)I(x,y,x,theta, phi, lambda)– Generally too complex to Generally too complex to
compute for all pointscompute for all points
Light SourcesLight Sources
Consider four simpler light sourcesConsider four simpler light sources– Ambient lightingAmbient lighting
Omnidirectional; constant everywhereOmnidirectional; constant everywhere
– Point sourcePoint sourceRadiates in all directionsRadiates in all directions
– Spot lightsSpot lightsSmall cone of constant lightSmall cone of constant light
– Distant lightDistant lightrays are parallelrays are parallel
Color SourcesColor Sources
Describe color with 3-dimensional Describe color with 3-dimensional RGB vectorRGB vector– (Ir, Ig, Ib)(Ir, Ig, Ib)TT
Characteristics of Light SourcesCharacteristics of Light Sources
Ambient light Ambient light – every point in scene receives same light every point in scene receives same light
in every directionin every direction Point sourcePoint source
– Intensity decreases with inverse square Intensity decreases with inverse square of distanceof distance
– Often approximate with formOften approximate with form
(a + bd +cd(a + bd +cd22))-1-1 where d is distance to soften effectwhere d is distance to soften effect
Characteristics of Light SourcesCharacteristics of Light Sources
Spot lightSpot light– Light limited to cone of angleLight limited to cone of angle– diminishes toward edges of cone asdiminishes toward edges of cone as
coscosee(theta) for some value of e(theta) for some value of e
– intensity as for point sourceintensity as for point source Distant sourceDistant source
– constant intensityconstant intensity– fixed directionfixed direction
Phong Reflection ModelPhong Reflection Model
Described by 4 Described by 4 vectorsvectors
n – normal to pn – normal to p
v – to viewerv – to viewer
l – to sourcel – to source
r – reflected rayr – reflected ray
Phong Reflection ModelPhong Reflection Model
SupportsSupports– ambientambient– diffusediffuse– specularspecularor combination of theseor combination of these
Uses 3 x 3 matrixUses 3 x 3 matrix– columns for r – g – bcolumns for r – g – b– rows for ambient, diffuse, specularrows for ambient, diffuse, specular
Color source and reflection matricesColor source and reflection matrices
Phong Reflection ModelPhong Reflection Model
resulting intensity is sum or products resulting intensity is sum or products of corresponding termsof corresponding termsIIirir = R = RirairaLLiraira+R+RirdirdLLirdird+R+RirsirsLLirsirs
= I= Iiraira+I+Iirdird+I+Iirsirs
for red, etcfor red, etc Sum over all points for complete Sum over all points for complete
effecteffect
Ambient ReflectionAmbient Reflection
Ra = kRa = kaa, 0 <= k, 0 <= kaa <= 1 <= 1– a fraction of light is reflecteda fraction of light is reflected– one coefficient for each colorone coefficient for each color
Diffuse reflectionDiffuse reflection
Lambertian surfacesLambertian surfaces– reflect only vertical reflect only vertical
componentcomponent
– RRdd proportional to proportional to cos(theta)cos(theta)
– IIdd = k = kdd (l . n) L (l . n) Ldd / (a + bd +cd/ (a + bd +cd22))
Specular ReflectionSpecular Reflection
Phong model equationPhong model equationIIss = k = kss L Lss (R . v) (R . v)aa
kkss is shininess coefficient is shininess coefficient
OpenGL ShadingOpenGL Shading
Polygonal shadingPolygonal shading– Generate shading on individual polygonsGenerate shading on individual polygons
Flat shadingFlat shading glShadeModel(GL_FLAT);glShadeModel(GL_FLAT);– select one vertex of polygon for normalselect one vertex of polygon for normal– same color throughout polygonsame color throughout polygon– tends to produce artificial looking surfaces with tends to produce artificial looking surfaces with
distinctly colored regionsdistinctly colored regions– eye is very sensitive to changeeye is very sensitive to change
Mach BandsMach Bands
Flat ShadingFlat Shading
Interpolative and Gourand ShadingInterpolative and Gourand Shading
GL_SMOOTHGL_SMOOTH– average normalsaverage normals– example: plates 4 & 5example: plates 4 & 5