180 likes | 208 Views
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. Our perception depends on:
E N D
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
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 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 Shading – Light and Matter
Interaction between light and materialscan 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 Shading – Light and Matter
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 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 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 –umbrapartial shadow – penumbra for non-point sources (d is distance) 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 Shading – 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 Shading – Distant light sources
Ambient reflection 0 ka 1 Ia = ka La global ambient term or light Diffuse reflection characterized by rough surfaces perfectly diffuse surfaces – Lambertian surfaces Ambient, Diffuse, Specular Reflections
Lambert’s law: diffuse reflection 0 kd 1 if the influence of the distance is considered Ambient, Diffuse, Specular Reflections
Specular Reflection: 0 ks 1 as ideal specular reflection <100 , 500> metallic surfaces Ambient, Diffuse, Specular Reflections
How to display surfaces with shading? Flat (constant) shading glShadeModel(GL_FLAT); Mach bands 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 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 Polygonal Shading
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
global versus local lightings models 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 Global Rendering – Ray tracing Typical program: POV Ray – available free