Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 445 / 645: Introductory Computer Graphics Light.

Similar presentations


Presentation on theme: "CS 445 / 645: Introductory Computer Graphics Light."— Presentation transcript:

1 CS 445 / 645: Introductory Computer Graphics Light

2 Administrivia l Assignment 3 Due –Sunday, October 21 st at Midnight l Midterm Exam –Tuesday, October 23 rd –See web page for reading material –Review in class today

3 Lighting Models l Lighting Models –Ambient n Normals don’t matter –Lambert/Diffuse n Angle between surface normal and light –Phong/Specular n Surface normal, light, and viewpoint –Rendering Equation (Kajiya)

4 Shading Models (Direct lighting) l Flat Shading –Compute Phong lighting once for entire polygon l Gouraud Shading –Compute Phong lighting at the vertices and interpolate lighting values across polygon l Phong Shading –Compute averaged vertex normals –Interpolate normals across polygon and perform Phong lighting across polygon

5 Shading Models (Indirect lighting) l Ray Tracing Radiosity

6 Radiosity l Ray tracing models specular reflection and refractive transparency, but still uses an ambient term to account for other lighting effects l Radiosity is the rate at which energy is emitted or reflected by a surface l By conserving light energy in a volume, these radiosity effects can be traced

7 Radiosity l Radiosity of patch ‘i’ is   i is the rate at which light is emitted   i is patch i’s reflectivity l F j,i is the form factor –fraction of patch j that reaches patch i as determined by orientation of both patches and obstructions l Use A j /A i (Area of patch j / Area of patch I) to scale units to total light emitted by j as received per unit area by i

8 Form Factors l Compute n-by-n matrix of form factors to store radiosity relationships between each light patch and every other light patch H ij = 1 or 0 depending on occlusion

9 Form Factor – Another example l Spherical projections to model form factor –project polygon A j on unit hemisphere centered at (and tangent to) A i Contributes cos  j / r 2 –Project this projection to base of hemisphere Contributes cos  i –Divide this area by area of circle base Contributes 

10 Form Factor – Another Model l Hemicube allows faster computations –Analytic solution of hemisphere is expensive –Use rectangular approximation, hemicube –cosine terms for top and sides are simplified –Dimension of 50 – 200 squares is good

11 Solving for all Patches l One patch defined by: l Symmetry: A i F i,j = A j F j,I l Therefore: l And: l Use matrix algebra to solve for B i ’s

12 Radiosity l Radiosity is expensive to compute –Get your PhD by improving it l Emitted light and viewpoint can change l Light angles and object positions cannot –Computing form factors is expensive l Specular reflection information is not modeled

13 View-dependent vs View-independent l Ray-tracing models specular reflection well, but diffuse reflection is approximated l Radiosity models diffuse reflection accurately, but specular reflection is ignored l Advanced algorithms combine the two

14 Texture Mapping l Limited ability to generate complex surfaces with geometry l Images can convey the illusion of geometry l Images painted onto polygons is called texture mapping

15 Texture Mapping l Texture map is an image, two-dimensional array of color values (texels) l Texels are specified by texture’s (u,v) space l At each screen pixel, texel can be used to substitute a polygon’s surface property l We must map (u,v) space to polygon’s (s, t) space U V S T

16 Texture Mapping l (u,v) to (s,t) mapping can be explicitly set at vertices by storing texture coordinates with each vertex l How do we compute (u,v) to (s,t) mapping for points in between –Watch for aliasing –Watch for many to one mappings –Watch for perspective foreshortening effects and linear interpolation

17 Bump Mapping l Use textures to modify surface geometry l Use texel values to modify surface normals of polygon l Texel values correspond to height field –Height field models a rough surface l Partial derivative of bump map specifies change to surface normal

18 Bump Mapping

19 Displacement Mapping l Bump mapped normals are inconsistent with actual geometry. Problems arise (shadows). l Displacement mapping actually affects the surface geometry

20 Assignment 3 – Plane Rendering l Plane defined by Ax + By + Cz + D = 0 l (A, B, C) defines normal to the plane l -D specifies translation from origin l Ex: 1x + 0y + 0z + 4 = 0 –All values of y and z work. X must be –4 –y-z plane at x = -4 –y-z plane has normal of (1, 0, 0)

21 Plane Rendering l Imagine first rendering plane of desired size centered on x-z plane l We must then rotate and translate this plane so its normal aligns with the (A, B, C) vector and the plane is –D from the origin U = Normal of x-z plane (0, 1, 0) V = Normal of clip plane (A, B, C)

22 Plane Rendering l Angle between U and V is computed with the dot product: u.dot.v = ||V|| ||U|| cos (n) Rotate -n degrees Rotate about VxU l Vector to rotate about is VxU: [v y u z -v z u y, -v x u z +v z u x, v x u y -v y u x ]

23 Clipping Plane Rendering l So we have a glRotate to execute –glRotatef (-n, VxU x, VxU y, VxU z ) l And we have a glTranslate to execute –glTranslatef (0, -D, 0) l And we have a command to draw a polygon –glBegin (GL_POLYGON) n glVertex3fv(front-left); glVertex3fv(front-right); n glVertex3fv(back-right); glVertex3fv(back-left); l So just put them in the right order –An exercise for the reader

24 Review l Hearn and Baker –Chapter 2 –Chapter 3 (84-102, 117-126) –Chapter 5 –Chapter 6 (225-248) –Chapter 11 (No Quaternions) [Recently added] –Chapter 12 (432-456) –Chapter 14 –Chapter 15 –Appendix 1 – 4 l OpenGL Red Book –Chapter 1 - 3

25 Review l If you’re going to print out all the slides from my lectures, please try to keep our costs down. –Render multiple slides to a page. –Convert black backgrounds to white to reduce toner usage n Make sure you convert fonts to black u Doesn’t PowerPoint have a mode that does this automatically?

26 Review l Vector arithmetic –Add, subtract –Dot (to determine angle between and length of projection (when normalized vectors) –Cross product (Right-hand rule) l Coordinate space –Right-handed coordinate system –openGL camera initialized to look down –z axis

27 Review l OpenGL –No significant coding required –I might ask you to tell me what a function does n One you’ve used for the projects –I might ask you to tell me what order to put the transformation commands –Direction of rotations –Ordering of polygon vertices –Back-face rendering l Rendering Pipeline (model, light, view, clip, project) l Line Drawing, Circle Drawing –Difference Equations, symmetry l Triangle Rasterization

28 Review l Polygon rasterization –Example Problems –Active Edge Table l Clipping –Parametric equations of lines –Slope-intercept equation of line –Outcode –Line-plane intersection

29 Review l Homogeneous Coordinate System –What does w do? l Modeling Transformations –Rotate, translate, scale, rotate about arbitrary axis l Viewing Transformations –Orthographic (parallel) and Perspective l Understand how matrix formed by compositing many modeling and viewing transformations effect the vertices of a model and its rendering

30 Review l Color –Metamers –Relative changes versus absolute values –RGB sensitivity –Color spaces n Intuitive spaces, distance between similar colors l Lighting Equations –Dependent on what factors –Calculate the reflection vector –Know how parameters effect images

31 Review l Shading –Flat, Gouraud, Phong n Improvements versus cost –Indirect lighting n Ray tracing, radiosity u Viewer dependent/independent u Costs/benefits


Download ppt "CS 445 / 645: Introductory Computer Graphics Light."

Similar presentations


Ads by Google