Illumination Illumination. Light Sources Directional Light (Infinitely far away) Point Light (Emit in all directions) Spot Light (Emit within a cone)

Slides:



Advertisements
Similar presentations
Computer Graphics - Shading -
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
Light Issues in Computer Graphics Presented by Saleema Amershi.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
IMGD 1001: Illumination by Mark Claypool
Lighting and Shading Wen-Chieh (Steve) Lin
3/23/2005 © Dr. Zachary Wartell 1 Illumination Models and Surface- Rendering Methods.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
CS 376 Introduction to Computer Graphics 03 / 30 / 2007 Instructor: Michael Eckmann.
CS5500 Computer Graphics March 26, Shading Reference: Ed Angel’s book.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Course Website: Computer Graphics 16: Illumination.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
LIGHTING Part One - Theory based on Chapter 6. Lights in the real world Lights bounce off surfaces and reflect colors, scattering light in many directions.
Shading Surface can either (both) 1.Emit light. E.g. light bult 2.Reflect light. E.g. Mirror.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
CS 445 / 645: Introductory Computer Graphics
Lecture 5: 3D Rendering Pipeline (II) Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
19/17/ :25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CS 325 Introduction to Computer Graphics 03 / 26 / 2010 Instructor: Michael Eckmann.
Illumination.
Illumination and Shading
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Visible Surface Detection
Specular Reflection Lecture 27 Mon, Nov 10, 2003.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Illumination and Shading Sang Il Park Sejong University.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
CS552: Computer Graphics Lecture 33: Illumination and Shading.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Light. Intensity calculation = wavelength I( ) = wavelength intensity of light reaching eye I( ) = I diff ( ) + I spec ( ) + I refl ( ) + I trans ( )
Computer Graphics: Illumination
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Basic Ray Tracing CMSC 435/634.
Shading To determine the correct shades of color on the surface of graphical objects.
Computer Graphics Chapter 9 Rendering.
Unit-7 Lighting and Shading
Lighting.
CSE 470 Introduction to Computer Graphics Arizona State University
Illumination and Shading
Illumination and Shading
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Illumination Illumination

Light Sources Directional Light (Infinitely far away) Point Light (Emit in all directions) Spot Light (Emit within a cone) Inner cone outer cone

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

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 ll 

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 ll

Extended Light Sources Warn Model Approximate it as a light-emitting surface

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

Ambient Lighting

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 

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

Diffuse Lighting Assume light bounces in all directions Diffuse surface

Diffuse Lighting

Surface Normal n  Surface Normal n   Surface Normal n   Full ReflectionNonePartial L 

Diffuse Lighting Diffuse Material Color Light Color Ambient + Diffuse Ambient + Diffuse 

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 NN NN dAdA

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)

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

Diffuse Lighting

Specular Lighting The incident light is reflected in a concentrated region around specular reflection angle. Ex: a bright spot on shiny surfaces

Specular Lighting

Create shining surface (surface perfectly reflects) Viewpoint dependent Ambient + Diffuse + Specular Material Color Light Color Specular

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  

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

Specular Lighting A larger n s shows more concentration of the reflection

Specular Lighting

Phong Model W(  ): specular reflection coefficient of the surface I l,spec = W(  ) I l cos ns  opaque surface: W(  )=constant=k s ( ) transparent surface: reflection is appreciable if  approaches to N R L Shiny surface (large n s ) N R L Dull surface (small n s ) 

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  

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

Lighting

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

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 )

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.

Surface Light Emission Color is emitted by the material only Ambient + Diffuse + Specular + Emissive Material Emissive Color + Ambient + Diffuse + Specular

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

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 Set negative intensities to 0.0.

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 }

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 = R G Bor luminance = R G B

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.

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 ii rr ii reflection refraction ii rr air glass air

Light Refraction T = [(  i /  r ) cos  i - cos  r ] N - (  i /  r )L Gives realistic effect but requires calculation  Ray tracing N RL T ii rr ii reflection refraction ii rr

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 ii rr ii reflection refraction ii rr

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.

Light Refraction

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

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

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)

Polygon Rendering

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

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

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

Polygon Rendering Scan conversion algorithm

Polygon Rendering Phong Surface Rendering Interpolates normal vectors. N N3 N1 N2

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.

Polygon Rendering Flat shadingGouraud shadingPhong shading Source: Michal Necasek

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

Texture Mapping Linear Texture Patterns (1D) s - coordinate texture space s x n elements RGBRGB

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)

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)

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.

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

Texture Mapping Volume Texture Patterns (3D) s,t,r - coordinate texture space s 3 x m x n x k elements t r

Surface Light Emission Divide surfaces to eliminate the overlap.

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

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

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)

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

Light Sources Point light source Infinitely distant light source