Download presentation
Presentation is loading. Please wait.
Published byChristopher Wheeler Modified over 9 years ago
1
Illumination Illumination
2
Light Sources Directional Light (Infinitely far away) Point Light (Emit in all directions) Spot Light (Emit within a cone) Inner cone outer cone
3
Radial Intensity Attenuation The amplitude of a radiant energy at the distance d l is attenuated by the factor 1/d l 2. For realistic effects: 1/ (a 0 +a 1 d l +a 2 d l 2 )local f l,radatten (d l )= 1.0infinity
4
Directional Light Sources 0 0 < ≤ 90 0 Object is within the spot light if cos ≥ cos l V obj. V light = cos V light V obj ll
5
Angular Intensity Attenuation f angatten ( ) = cos a 1.0if light source is not spotlight f l,angatten = 0.0if V obj.V light =cos < cos l (outside of spotlight cone) (V obj. V light ) al otherwise V obj V light ll
6
Extended Light Sources Warn Model Approximate it as a light-emitting surface
7
Ambient Lighting Background Light A surface that is not directly exposed to a light source may still be visible due to the reflected light from nearby objects. I a : intensity parameter of ambient reflection Ambient reflection is: independent of viewing direction and surface orientation depends on the surface properties eye
8
Ambient Lighting
9
Not created by any light source A constant lighting from all directions Contributed by scattered light in a surrounding RGB multiplies separately Material ColorLight Color
10
Diffuse Lighting Light is scattered with equal intensity in all directions, independent of the viewing direction. The surface appears equally bright from any viewing angle. Ex: rough or grainy surfaces
11
Diffuse Lighting Assume light bounces in all directions Diffuse surface
12
Diffuse Lighting
13
Surface Normal n Surface Normal n Surface Normal n Full ReflectionNonePartial L
14
Diffuse Lighting Diffuse Material Color Light Color Ambient + Diffuse Ambient + Diffuse
15
Diffuse Lighting Lambert’s cosine law: The amount of radiant energy coming from any surface area d A in a direction N relative to the surface normal is proportional to cos N. radiant energy per unit time intensity = ------------------------------------- projected area cos N / (d A cos N ) = constant N (surface normal) Radiant energy direction NN NN dAdA
16
Diffuse Lighting Background lighting with ambient light I ambdiff = k d I a k d : Fraction of the incident light that is to be scattered as diffuse reflections (diffuse reflection coefficient)
17
Diffuse Lighting I l,incident = I l cos I l,diff = k d. I l,incident = k d. I l cos k d. I l (N.L)if N.L > 0 I l,diff = 0.0 if N.L ≤ 0 L = (P source -P surf ) / |P source -P surf | Ambient and point-source: k a. I a + k d. I l (N.L)if N.L>0 I diff = k a. I a if N.L≤0 N (surface normal) L (to incident light source) A (area) A cos cos = N.L
18
Diffuse Lighting
20
Specular Lighting The incident light is reflected in a concentrated region around specular reflection angle. Ex: a bright spot on shiny surfaces
21
Specular Lighting
22
Create shining surface (surface perfectly reflects) Viewpoint dependent Ambient + Diffuse + Specular Material Color Light Color Specular
23
Specular Lighting N – surface normal L – to light source R – direction of ideal specular reflection V – to viewer – viewer angle relative to specular reflection direction if =0, ideal reflector (mirror) N R L V
24
Specular Lighting Sets the intensity of specular reflection proportional to cos ns . n s : specular reflection exponent 100 or more => shiny near 1=> dull infinite=> perfect reflector
25
Specular Lighting A larger n s shows more concentration of the reflection
26
Specular Lighting
27
Phong Model W( ): specular reflection coefficient of the surface I l,spec = W( ) I l cos ns opaque surface: W( )=constant=k s (0.0-1.0) transparent surface: reflection is appreciable if approaches to 90 0. N R L Shiny surface (large n s ) N R L Dull surface (small n s )
28
Phong Model cos = V. R I l,spec = W( ) I l cos ns k s I l (V.R) ns if V.R>0 & N.L>0 I l,spec = 0.0 if V.R<0 & N.L≤0 R = (2N.L)N - L N R L V
29
Phong Model H: halfway vector between V and L H=(L+V) / |L+V| Replace V.R (cos ) by N.H (cos ) k s I l (N.H) ns if V.R>0 & N.L>0 I l,spec = 0.0 if V.R<0 & N.L≤0 Requires less computation N R L V H
30
Lighting
31
Diffuse and Specular Lightings I = I diff + I spec = k a I a + k d I l (N.L) + k s I l (N.H) ns
32
Multiple Light Sources I = I ambdiff + ∑ n l=1 ( I l,diff + I l,spec ) = k a I a + ∑ n l=1 I l (k d (N.L) + k s (N.H) ns )
33
Surface Light Emission Ex: light bulb, etc. - Position a directional light source behind the surface - Simulate the emission with a set of point light sources distributed over the surface Radiocity model can be used to model realistic surface emission.
34
Surface Light Emission Color is emitted by the material only Ambient + Diffuse + Specular + Emissive Material Emissive Color + Ambient + Diffuse + Specular
35
Surface Light Emission Extending the Light Model: I = I surfemission + I ambdiff + ∑ n l=1 f l,radatten f l,angatten ( I l,diff + I l,spec ) k d. I l (N.L l )if N.L > 0 I l,diff = 0.0 if N.L ≤ 0 k s I l max{0.0, (N.H l ) ns } if V.R>0 & N.L>0 I l,spec = 0.0 if V.R<0 & N.L≤0 1/ (a 0 +a 1 d l +a 2 d l 2 ) local f l,radatten (d l )= 1.0 infinity 1.0if light source is not spotlight f l,angatten = 0.0if V obj.V light =cos < cos l (V obj. V light ) al otherwise
36
Surface Light Emission Intensity Overflow: - If any term exceeds the maximum intensity, set the intensity to maximum. - Divide the intensity if each term by the magnitude of the largest term to scale intensities between 0.0-1.0 - Set negative intensities to 0.0.
37
RGB Color I l = ( I lR, I lG, I lB ) k a = (k aR, k aG, k aB ) Ex: for blue component I lB,diff = k dB I lB (N.L l ) I l,spec = k sB I lB max{0.0, (N.H l ) ns }
38
Luminance Lightness or darkness of a color (Brightness) luminance = ∫ visible f (f) I (f) df f: frequency I (f): intensity of light component with frequency f that is radiating in a particular direction (f): experimentally determined proportionality function that varies with f and illumination level Green component contribute most to the luminance Blue component contribute least to the luminance luminance = 0.299 R + 0.587 G + 0.114 Bor luminance = 0.2125 R + 0.7154 G + 0.0721 B
39
Transparency Transparent: objects behind are seen Opaque: objects behind cannot be seen Translucent: objects behind appear blurred Transparent surfaces produce reflected and transmitted light. Translucent surfaces have both diffuse and specular transmission. Ray tracing can be used.
40
Light Refraction Snell’s Law: sin r = ( i / r ) sin i i : angel of incidence i : index of refraction for the incident material r : index of refraction for the refracting material Ex: air: 1.0 glass: 1.61 N RL T ii rr ii reflection refraction ii rr air glass air
41
Light Refraction T = [( i / r ) cos i - cos r ] N - ( i / r )L Gives realistic effect but requires calculation Ray tracing N RL T ii rr ii reflection refraction ii rr
42
Light Refraction Ignoring path shift due to refraction: I = (1-k t ) I refl + k t I trans I trans : transmitted intensity I refl : reflected intensity k t : transparency coefficient 1.0 – transparent 0.0 – opaque (1-k t ): opacity factor N RL T ii rr ii reflection refraction ii rr
43
Light Refraction In Depth-Buffer Approach: Process opaque surfaces first Then, compare the depths of the transparent surfaces with the depth-buffer If a transparent surface is visible, combine its intensity with the intensity that is previously stored in the frame buffer.
44
Light Refraction
46
Atmospheric Effects f atmo (d) = e - d orf atmo (d) = e -( d) 2 d: distance of the object to the viewing position : to set a positive density value for the atmosphere Higher value means denser atmosphere, where colors are muted. Combining atmosphere color with the object’s color: I = f atmo (d) I obj + (1- f atmo (d)) I atmo
47
Shadows Generated by a visible surface detection method Surfaces that are visible from the view position are shaded according to the lighting model, which can be combined with texture patterns Shadow areas are displayed with ambient light only or ambient light combined with textures
48
Polygon Rendering Constant-Intensity Surface Rendering Accurate in the following cases: Polygon is not a section of a curved surface All light sources are sufficiently far from the surface (N.L is constant) Viewing position is sufficiently far from the surface (V.R is constant)
49
Polygon Rendering
50
Gouraud Surface Rendering Linearly interpolates vertex intensities across the polygon faces. 1. Determine the average unit normal vector at each vertex of the polygon 2. Apply an illumination model at each polygon vertex to obtain the light intensity at that position 3. Linearly interpolate the vertex intensities over the projected area of the polygon
51
Polygon Rendering Gouraud Surface Rendering (1) At each vertex, average the normal vectors of the polygons that share the same vertex, to obtain the normal vector of the vertex: ∑ n k=1 N k N V = -------------------- | ∑ n k=1 N k | V N N N N NVNV
52
Polygon Rendering Gouraud Surface Rendering (3) Interpolate vertex values to obtain the intensities at the intersection of a scan line with the polygon P y x
53
Polygon Rendering Scan conversion algorithm
54
Polygon Rendering Phong Surface Rendering Interpolates normal vectors. N N3 N1 N2
55
Polygon Rendering Phong Surface Rendering For each polygon: 1. Determine the average unit normal vector at each vertex of the polygon 2. Linearly interpolate the vertex normals over the projected area of the polygon (similar to Gouraud method) 3. Apply an illumination model at positions along scan lines to calculate pixel intensities using the interpolated normal vectors Apply the same incremental methods to obtain normal vectors on successive scan lines.
56
Polygon Rendering Flat shadingGouraud shadingPhong shading Source: Michal Necasek
57
Texture Mapping Texel: a component of texture description Four RGB components: - Red component - Green component - Blue component - an index into a color table or a single luminance value
58
Texture Mapping Linear Texture Patterns (1D) s - coordinate texture space s 0.0 1.0 3 x n elements RGBRGB
59
Texture Mapping Surface Texture Patterns (2D) s,t - coordinate texture space s(0,0) 3 x m x n elements t (1,0) (0,1)
60
Texture Mapping Surface Texture Patterns (2D) Texture space (s,t-coord) Texture-surface transformation Viewing and projection transformation Texture space Object space Image space Texture-surface transformation Viewing and projection transformation Method 1 Method 2 Object space (u,v-coord) Image space (x,y-coord)
61
Texture Mapping Surface Texture Patterns (2D) Method 1: Mapping from Texture Space to Object Space – u = u(s,t) = a u s + b u t + c u v = v(s,t) = a v s + b v t + c v Mapping from Object Space to Image Space – use viewing and projection transformations Disadvantage: If the texture patch does not match up with the pixel boundaries, the fractional area of pixel coverage must be calculated.
62
Texture Mapping Surface Texture Patterns (2D) Method 2: M VP -1 : inverse viewing- projection transformation M T -1 : inverse texture-map transformation Pattern Array projected pixel area pixel area Surface M VP -1 M T -1
63
Texture Mapping Volume Texture Patterns (3D) s,t,r - coordinate texture space s 3 x m x n x k elements t r
64
Surface Light Emission Divide surfaces to eliminate the overlap.
65
Depth Cueing f depth (d) is multiplied by each pixel’s color f depth (d) = (d max -d)/(d max -d min ) d: distance of a point from the viewing position d min : 0.0 d max : 1.0
66
OpenGL glPolygonMode(GL_FRONT_AND BACK, GL_LINE) displays both visible and hidden edges glEnable (GL_FOG) glFogi (GL_FOG_MODE, GL_LINEAR) generates fog effect. Uses depth cueing. glEnable (GL_CULL_FACE) glDisable (GL_CULL_FACE) glCullFace (mode) used for backface removal GL_BACK (default), GL_FRONT (if inside a building), GL_FRONT_AND_BACK
67
OpenGL glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH) initializes GLUT, requests a depth buffer and a frame buffer glClear (GL_DEPTH_BUFFER_BIT) initially depth buffer has the background color. It must be cleared every time before displaying a new frame. glEnable (GL_DEPTH_TEST) glDisable (GL_DEPTH_TEST) to activate depth buffer routines glClearDepth (maxDept) to set maxDepth to another value (0.0 – 1.0) glDepthRange (nearNormDept, farNormDept) to adjust normalization values (defaults: near- 0.0, far- 1.0)
68
OpenGL glDepthFunction (testCondition) to specify a test condition for depth-buffer routines GL_LESS (default), GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL, GL_NEVER, GL_ALWAYS glDepthMask (writeStatus) to set the status of depth-buffer routines TRUE: read/write FALSE: read only
69
Light Sources Point light source Infinitely distant light source
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.