Download presentation
Presentation is loading. Please wait.
1
Unit-7 Lighting and Shading
Course code: 10CS65 | Computer Graphics and Visualization Unit-7 Lighting and Shading Engineered for Tomorrow Prepared by : Asst. Prof. Sandhya Kumari Department: Computer Science and Engineering Date : dd.mm.yyyy
2
Shading – Light and Matter
Our perception depends on: light directly – intensity, spectrum (color), position material of objects that “reflects” or “transmit” light, roughness, color of the surface Speed of computation – significant factor
3
Shading – Light and Matter
Generally we do not need to compute all, but just those rays that contribute to the final image Methods: Global – ray tracing, radiosity – very slow Local – constant, Gouraud, Phong etc. – relatively fast
4
Shading – Light and Matter
Interaction between light and materials can be classified as specular surfaces – ideal mirror diffuse surfaces – reflected light is ideally reflected to all directions uniformly translucent surfaces – allow some lights to penetrate the surface – refraction – glass, water optical properties – Snell’s law
5
Shading – Light sources
Light source – an object with a surface Each point (x,y,z) on the surface can emit light with characterization: direction of emission (,) intensity of energy emitted at each wavelength illumination function I(x,y,z,,,) Basic light sources (sufficient for rendering the most simple scenes): ambient lighting point sources spotlights distance light
6
Shading – Light sources
Light - an object with a surface Each point (x,y,z) on the surface can emit light with characterization: direction of emission (,) intensity of energy emitted at each wavelength illumination function I(x,y,z,,,) Usually I = [ Ir , Ig , Ib ]T is handled as a scalar value Basic light sources - sufficient for rendering the most simple scenes: ambient lighting point sources spotlights distance light
7
Shading – Light sources
Ambient light Ia- uniform light in the space (room etc.) Ideal point source – emits equally in all directions I(p0) Light received at a point p full shadow – umbra partial shadow – penumbra for non-point sources (d is distance)
8
Shading – Light sources
Spotlights – very narrow angles of emission, if = 180° -> point source distribution of light within the cone – usually cose() ; e determines how rapidly intensity drops off cos() = sT l s – vector that points from ps to a point s on a surface l – vector of the light direction
9
Shading – Distant light sources
we replace location of light sources with their directions p0 = [ x , y , z , 0 ]T ( 0 is correct !) Phong Reflection Model I = Ia + Id + Is disadvantages linear model superposition
10
Ambient, Diffuse, Specular Reflections
Ambient reflection 0 ka 1 Ia = ka La global ambient term or light Diffuse reflection characterized by rough surfaces perfectly diffuse surfaces – Lambertian surfaces
11
Ambient, Diffuse, Specular Reflections
Lambert’s law: diffuse reflection 0 kd 1 if the influence of the distance is considered
12
Ambient, Diffuse, Specular Reflections
Specular Reflection: 0 ks 1 as ideal specular reflection <100 , 500> metallic surfaces
13
Polygonal Shading How to display surfaces with shading?
Flat (constant) shading glShadeModel(GL_FLAT); Mach bands
14
Polygonal Shading Interpolative and Gouraud shading Gouraud shading
glShadeModel(GL_SMOOTH); normal in a vertex average normal vector intensity computation for a vertex intensity & color interpolation for a scan-line
15
Polygonal Shading Phong shading normal in a vertex
interpolation of a normal normal interpolation along the scan-line intensity computation Phong shading is almost always done off-line
16
Light Source in OpenGL OpenGL supports the four types of light sources
-point, spotlight, ambient, and distant OpenGL functions glLightfv(GLenum source, GLenum parameter, GLfloat *pointer_to_array) glLihjtf(GLenum source, GLenum parameter, GLfloat value) Four vector parameters can set: the position (or direction) of light source and the amount of ambient, diffuse, and specular light associated with the source
17
Global Rendering – Ray tracing
global versus local lightings models
18
Global Rendering – Ray tracing
Algorithm complexity: O(M2 N 2k) M – resolution of a screen N – number of objects k – number of levels of the tree Typical program: POV Ray – available free
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.