Engineered for Tomorrow Course code 10 CS 65

  • Slides: 18
Download presentation
Engineered for Tomorrow Course code: 10 CS 65 | Computer Graphics and Visualization Unit-7

Engineered for Tomorrow Course code: 10 CS 65 | 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

Shading – Light and Matter Our perception depends on: – – light directly –

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

Shading – Light and Matter Generally we do not need to compute all, but

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 materials can be classified as

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

Shading – Light sources Light source – an object with a surface Each point

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

Shading – Light sources Light - an object with a surface Each point (x,

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 = [ I r , I g , I b ]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.

Shading – Light sources Ambient light Ia- uniform light in the space (room etc. ) Ideal point source – emits equally in all directions I(p 0) Light received at a point p full shadow – umbra partial shadow – penumbra for non-point sources (d is distance)

Shading – Light sources Spotlights – very narrow angles of emission, if = 180°

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( ) = s. T l s – vector that points from ps to a point s on a surface l – vector of the light direction

Shading – Distant light sources we replace location of light sources with their directions

Shading – Distant light sources we replace location of light sources with their directions p 0 = [ x , y , z , 0 ]T ( 0 is correct !) Phong Reflection Model I = I a + Id + Is disadvantages • linear model • superposition

Ambient, Diffuse, Specular Reflections Ambient reflection 0 ka 1 Ia = ka La global

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

Ambient, Diffuse, Specular Reflections Lambert’s law: diffuse reflection 0 kd 1 if the influence

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

Ambient, Diffuse, Specular Reflections Specular Reflection: 0 ks 1 as ideal specular reflection <100 , 500> metallic surfaces

Polygonal Shading How to display surfaces with shading? Flat (constant) shading gl. Shade. Model(GL_FLAT);

Polygonal Shading How to display surfaces with shading? Flat (constant) shading gl. Shade. Model(GL_FLAT); Mach bands

Polygonal Shading Interpolative and Gouraud shading gl. Shade. Model(GL_SMOOTH); normal in a vertex •

Polygonal Shading Interpolative and Gouraud shading gl. Shade. Model(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 •

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

Light Source in Open. GL • Open. GL supports the four types of light

Light Source in Open. GL • Open. GL supports the four types of light sources -point, spotlight, ambient, and distant • Open. GL functions – gl. Lightfv(GLenum source, GLenum parameter, GLfloat *pointer_to_array) – gl. Lihjtf(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 Rendering – Ray tracing global versus local lightings models

Global Rendering – Ray tracing global versus local lightings models

Global Rendering – Ray tracing Algorithm complexity: O(M 2 N 2 k) M –

Global Rendering – Ray tracing Algorithm complexity: O(M 2 N 2 k) M – resolution of a screen N – number of objects k – number of levels of the tree Typical program: POV Ray – available free