1 / 40

Illumination and Shading

Illumination and Shading. Illumination (Lighting). Model the interaction of light with surface points to determine their final color and brightness OpenGL computes illumination at vertices. illumination. Shading. Apply the lighting model at a set of points across the entire surface. Shading.

eros
Télécharger la présentation

Illumination and Shading

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Illumination and Shading

  2. Illumination (Lighting) • Model the interaction of light with surface points to determine their final color and brightness • OpenGL computes illumination at vertices illumination

  3. Shading • Apply the lighting model at a set of points across the entire surface Shading

  4. Illumination Model • The governing principles for computing the illumination • A illumination model usually considers: • Light attributes (light intensity, color, position, direction, shape) • Object surface attributes (color, reflectivity, transparency, etc) • Interaction among lights and objects (object orientation) • Interaction between objects and eye (viewing dir.)

  5. q Illumination Calculation • Local illumination: only consider the light, the observer position, and the object material properties • Example: OpenGL

  6. object 4 object 3 object 2 object 1 Illumination Models • Global illumination:take into account the interaction of light from all the surfaces in the scene • Example: Ray Tracing (CIS681)

  7. Basic Light Sources sun Light intensity can be independent or dependent of the distance between object and the light source Point light Directional light Spot light

  8. Calculating Reflection Vector The scalar projection of Lon N is a scalar equal to

  9. Simple local illumination • Consider three types of light contribution to compute the final illumination of an object • Ambient • Diffuse • Specular • Final illumination of a point (vertex) = ambient + diffuse + specular

  10. Ambient light contribution • Ambient light (background light): the light that is scattered by the environment • A very simple approximation of global illumination • Independent of the light position,object orientation, observer’s position or orientation – ambient light has no direction (Radiosity is the calculation of ambient light) object 4 object 3 object 2 object 1

  11. Ambient lighting example

  12. Ambient light calculation • Each light source has an ambient light contribution (Ia) • Different objects can reflect different amounts of ambient (different ambient reflection coefficient Ka, 0 <= Ka <= 1) • So the amount of ambient light that can be seen from an object is: Ambient = Ia * Ka

  13. Diffuse light contribution • Diffuse light: The illumination that a surface receives from a light source and reflects equally in all direction It does not matter where the eye is

  14. Diffuse lighting example

  15. Diffuse light calculation • Need to decide how much light the object point receive from the light source – based on Lambert’s Law Receive less light Receive more light

  16. Diffuse light calculation (2) • Lambert’s law: the radiant energy D that a small surface patch receives from a light source is: D = I * cos (q) I: light intensity q: angle between the light vector and the surface normal light vector (vector from object to light) q N : surface normal

  17. q N L q Diffuse light calculation (3) • Like the ambient light case, different objects can reflect different amount of diffuse light (different diffuse reflection coefficient Kd, 0 <= Kd <= 1)) • So, the amount of diffuse light that can be seen is: Diffuse = Kd * I * cos (q) cos(q) = N.L

  18. Specular light contribution • The bright spot on the object • The result of total reflection of the incident light in a concentrate region See nothing!

  19. Specular light example

  20. f q ? p Specular light calculation • How much reflection you can see depends on where you are The only position the eye can see specular from P if the object has an ideal reflection surface But for a non-perfect surface you will still see specular highlight when you move a little bit away from the idea reflection direction When f is small, you see more specular highlight

  21. N L R f q q V p Specular light calculation (2) • Phong lighting model specular = Ks * I * cosn(f) Ks: specular reflection coefficient N: surface normal at P I: light intensity f: angle between V and R cos(f): the larger is n, the smaller is the cos value cos(f) = R.V n

  22. Specular light calculation (3) • The effect of ‘n’ in the phong model n = 10 n = 90 n = 30 n = 270

  23. Put it all together • Illumination from a light: Illum = ambient + diffuse + specular = Ka * I + Kd * I * (N.L) + Ks * I * (R.V)n • If there are N lights Total illumination for a point P = S (Illum) • Some more terms to be added (in OpenGL): • Self emission • Global ambient • Light distance attenuation and spot light effect or (N.H)

  24. Polygon shading model • Flat shading – compute lighting once and assign the color to the whole polygon

  25. Flat shading • Only use one vertex (usually the first one) normal and material property to compute the color for the polygon • Benefit: fast to compute • It is used when: • The polygon is small enough • The light source is far away (why?) • The eye is very far away (why?) • OpenGL command: glShadeModel(GL_FLAT)

  26. Mach Band Effect • Flat shading suffers from “mach band effect” • Mach band effect – human eyes accentuate the discontinuity at the boundary perceived intensity Side view of a polygonal surface

  27. smooth shading Flat shading Smooth shading • Reduce the mach band effect – remove value discontinuity • Compute lighting for more points on each face

  28. Gouraud Shading • Gouraud shading attempts to smooth out the shading across the polygon facets • Begin by calculating the normal at each vertex N

  29. N Gouraud Shading • A feasible way to do this is by averaging the normals from surrounding facets • Then apply the reflection model to calculate intensities at each vertex

  30. P3 P2 Q P P1 P4 Gouraud Shading • We use linear interpolation to calculate intensity at edge intersection P IPRED = (1-)IP1RED + IP2RED where P divides P1P2 in the ratio 1- • Similarly for Q

  31. P3 P2 Q P P1 Gouraud Shading • Then we do further linear interpolation to calculate colour of pixels on scanline PQ

  32. Gouraud Shading

  33. Gouraud Shading Limitations - Specular Highlights • Gouraud shading gives intensities within a polygon which are a weighted average of the intensities at vertices • a specular highlight at a vertex tends to be smoothed out over a larger area than it should cover • a specular highlight in the middle of a polygon will never be shown

  34. Gouraud Shading Limitations - Mach Bands • The rate of change of pixel intensity is even across any polygon, but changes as boundaries are crossed • This ‘discontinuity’ is accentuated by the human visual system, so that we see either light or dark lines at the polygon edges - known as Mach banding

  35. N Phong Shading • Phong shading has a similar first step, in that vertex normals are calculated - typically as average of normals of surrounding faces

  36. P3 P2 N2 N Q P N1 P1 P4 Phong Shading • However rather than calculate intensity at vertices and then interpolate intensities as we do in Gouraud shading ... • In Phong shading we interpolate normals at each pixel ...

  37. P3 P2 N2 N Q P N1 P1 P4 Phong Shading • ... and apply the reflection model at each pixel to calculate the intensity - IRED, IGREEN, IBLUE

  38. Phong Shading

  39. Phong versus Gouraud Shading • A major advantage of Phong shading over Gouraud is that specular highlights tend to be much more accurate • vertex highlight is much sharper • a highlight can occur within a polygon • Also Mach banding greatly reduced • The cost is a substantial increase in processing time because reflection model applied per pixel • But there are limitations to both Gouraud and Phong

  40. Gouraud versus Phong

More Related