520 likes | 631 Views
Shading (introduction to rendering). Rendering. We know how to specify the geometry but how is the color calculated. Rendering. We know how to specify the geometry but how is the color calculated. Rendering. We know how to specify the geometry but how is the color calculated.
E N D
Rendering • We know how to specify the geometry but how is the color calculated
Rendering • We know how to specify the geometry but how is the color calculated
Rendering • We know how to specify the geometry but how is the color calculated
Rendering: simulation of light transport • What makes up the final color of an object?
Rendering: simulation of light transport • Diffuse scattering • matt surfaces • Specular reflection • shiny surfaces • highlight • Transparency • glass, water • penetrate the surface
Rendering: simulation of light transport • How do we represent these observations in a mathematical framework
Rendering: simulation of light transport • Real time rendering is generally not concerned with using a "correct" lighting equation, just a series of hacks to make things look right with as little computational effort as possible
Illumination Models • Local • Direct illumination of surfaces by light sources • Global • all light/surface interactions for entire environment
Local illumination • Input: • a 3D object • Material and color of the object • Position and structure of the light source • “Intensity” of the light source • Output: • Color and intensity of points of the given object A (modest) example of shading
Collection of triangles or mesh Representing 3D Objects
Dealing with color Three component intensity (red, green, blue) Luminance (intensity) of the source Red component of source red component of image Green component of source green component of image Blue component of source blue component of image Three similar but independent calculations We focus on one scalar value only
Diffuse reflection • A perfect diffuse reflector (Lambertiansurface) scatters the light equally in all directions • Same appearance to all viewers • Depends on • Material of the surface • The position of the light
Normals • What direction is the surface facing?
CrossProduct • n.x=a.y*b.z-a.z*b.y • n.y=a.z*b.x-a.x*b.z • n.z=a.x*b.y-a.y*b.x
Normals • A = V2 – V1 • B = V0 – V1 • N = A x B
Normals • For each triangle we can define a normal for the face • For each vertex we an define a normal by interpolating normals of attached faces
Diffuse: Two important vectors • To compute the intensity at P, we need • The unit normal vector N, • The unit vector L, from Pto the light N L θ P
Diffuse: Two important vectors • To compute the intensity at P, we need • The unit normal vector N, • The unit vector L, from Pto the light N L θ P What is the diffuse color at P?
Lambert’s cosine law • I : diffuse reflection at P • Id: intensity of the light from source • coefficient of diffuse reflection
Coefficient of diffuse reflection • kd is usually determined by a trial and error approach • Examples: Component Gold Black plastic Silver Red 0.75 0.01 0.5 Green 0.6 0.01 0.5 Blue 0.22 0.01 0.5 kd=1 kd=0.75 kd=0.25 kd=0.5 kd=0.05
Specular reflection • Diffusive reflection: no highlights, rough surface • Specular reflection: highlights, shiny and smooth surfaces • View dependent reflection
Three important vectors • To compute the intensity at P, we need • The unit normal vector N, • The unit vector L, from Pto the light • The unit vector V, from P to the viewer N L V P
Three important vectors • To compute the intensity at P, we need • The unit normal vector N, • The unit vector L, from Pto the light • The unit vector V, from P to the viewer N L V P What is the specular illumination at P?
The shininess coefficient increasing n 0 90o -90o
The Phong model for specular reflection • I : specular reflection at P • Id: intensity of the light from source • coefficient of specular reflection • n: controls shininess N N L R L R V P P
Ambient light • “Physical rules” are too simplified • No indirect or global interaction of light • A hack to overcome the problem: use “ambient light”
Ambient light specification • Not situated at any particular point • Spreads uniformly in all directions • Ia: intensity of ambient light in the environment • I: ambient light at a given point • : coefficient of ambient light reflection ka=1 ka=0 ka=0.5
A combined model(The Phong local illumination model) • The final model = diffuse + specular + ambient
Flat Shading • Individual faces are visualized • Same color for any point in the face
Smooth Shading • Visualize the underlying surface • Each point on the face has its own color • Two techniques Gouraud and Phong shading
Shading N
Clarification • Phong reflection model or phong lighting refers to • Phong Shading refers to filling a triangle by interpolating the normal and calculating the color at each point
Gouraud Shading • Specular highlight quality tied to detail of mesh • Specular highlights can even be missed
Incorporating a distance term a,b,c are control parameters Empirical formula:
Multiple light sources • The total reflection at p is the sum of all contributed intensities from all sources • OpenGL allows us to define several light sources