DOC PREVIEW
Brown CSCI 1480 - Lighting and Shading

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Lighting and ShadingCS148: Intro to CGInstructor: Dan MorrisTA: Sean WalkerJuly 14, 2005Pre-lecture business{ meshes.cpp example from last class{ pp2 is due today{ pp3 goes out today{ start thinking about pp4{ Remote students: email fax #’sOutline for today{ Lighting{ Shading{ Lighting and shading in OpenGLWhat have we done so far?{ We can model objects or load objects that someone else modeled{ We can create a scene with objects and a camera{ We know how our objects get transformed and rasterizedOpenGL magicpixelsobject coordinatesWhat color is an object?{ So far, we’ve used glColor3f() to say “my object is blue”{ But what color should a blue sphere’s pixels really be?What color is an object? [light.cpp]{ Pixel color – and color in the real world – depend on:z Light color and positionz Material propertiesz Camera positionz Object geometry, medium2We can’t capture all of these things…{ …so we make approximations depending on our compute power, our need for realism, etc.Illumination Models{ Part of our approximation is our mathematical representation of how light interacts with objects{ For example, one illumination model might be:pixel color == object colorWhat would a sphere look like under this illumination model?A blue sphere with this illumination modelIllumination Models{ Today we’ll look at the individual illumination models that make up the OpenGL lighting system:z Diffuse lightingz Ambient lightingz Specular lighting{ All of our examples will be in grayscale for right nowLighting framework{ We want to decide what color some point p on an object should be from a viewer’s perspective{ What data do we have to work with?pnslighteyev{ Lightz Positionz Brightness{ Objectz Materialz Surface normalDiffuse Lighting Model{ A fraction of incoming light is reradiated “diffusely” in all directions{ Some of this light will reach the eye{ Since light is radiated equally in all directions, the orientation of the surface relative to the eye doesn’t matterDiffuse Light: Surface orientation{ The orientation of the surface relative to the light does matter{ The “brightness” of a surface depends on how many photons hit a unit area{ If the light “sees” more of the object, it will hit it with more photonsWhen the object faces away from the light, a smaller portion of the light’s energy hits a unit area on the object3Diffuse Light: Lambert’s Law{ If s (vector to light) and n (normal) are “more aligned”, the object should be brighter{ What operation tells us “how aligned” two vectors are?{ Lambert’s law:Id= Ld(us•un)z Id: output (pixel) brightnessz Ld: light intensityz usand un: unit versions of s and nWhat’s the most important missing piece here?Diffuse Light: Diffuse Coefficient{ rd: diffuse reflection coefficient{ Captures many complex properties of an object in one number: how much light does it reflect?{ OpenGL convention: 0.0 --> 1.0Specular Lighting Model{ Light scatters most strongly in one direction{ Specifically, light scatters most strongly in the same direction a mirror would reflectSpecular (Mirror-Like) Reflection{ Angle of incidence ==angle of reflection{ Clearly r will be useful in deciding how bright the object appears…nθθrs’What is r in terms of s and n?{ Decompose s’:z m = (s’•un)un(parallel to n)z e = s’–m (perpendicular to n){ What is r in terms of e and m?z r = e + (-m)z r = e + (-m) = (s’–m) – m = s’–2mz r = s’–2 ( s’•un) unnrs’mee-mSpecular Illumination{ More light goes out along the direction r{ The more the view axis v lines up with r, the brighter the object should appear{ Is= Lsrs(ur•uv)What does each term mean?{ Doesn’t capture the fact that some materials are “more specular” than others{ rstells us what color the material reflects, but now how that color falls off with angle4Specular Illumination: Phong Model{ Add a parameter f that tells us “how specular” a material is:Is= Lsrs(ur•uv)f{ Higher f = more specular; light falls off faster as v moves away from r{ In OpenGL terminology, f is “shininess”Specular Illumination: ExamplesWhich sphere isshinier?Same shininessas above spheres,both have reducedrsAmbient Lighting Model{ Stuff pointing away from lights isn’t really pitch black{ But we can’t model all the reflections in a real scene...{ So we just add “ambient lighting” that doesn’t depend on orientation:Ia= LaraAmbient Lighting: Examples{ Too much ambient light: everything gets washed out{ Too little ambient light: very deep shadowsPutting it All Together{ In our illumination model, the light at a point is equal to:I = Lara+ Ldrd(us• un) + Lsrs(ur• uv)f{ We can do this computation for all lights in a scene and add the results togetherWhat happens if the surface normal points away from the light?Outline for today{ Lighting{ Shading{ Lighting and shading in OpenGL5An aside: Normals in OpenGL{ Normals in OpenGL are associated with vertices, not faces{ Why? Objects in 3D graphics are usually discrete approximations of continuous real-world objects{ Surface normal actually changes over the surface of the “real” object{ Vertex normals are ”samples” of the real normalAn aside: Normals in OpenGL{ Before I call glVertex(), I usually call:{ glNormal3f(x,y,z);To tell GL what the current surface normal is.{ Normals are transformed through the whole pipeline, so they’re specified in object coordinates{ Mesh files usually specify normalsLimitations of our lighting model{ Now we know how to compute the pixel color for a given point{ This took a few multiplications, so it would be expensive to do this for every single pixel{ Plus, we don’t usually have exact surface normals everywhere, since we often approximate curved objects with flat polygonsShading{ Shading is the process of filling polygons with color based on the illumination at some points on the polygon{ Usually we evaluate I (illumination) at vertices, and use that data to shade the polygonFlat Shading{ Simplest, fastest shading algorithm:z Pick a point on the polygonz Compute illumination at that pointz Fill the whole polygon with that colorGouraud Shading{ Most realistic shading algorithm supported by OpenGLz Compute illumination at all verticesz Interpolate illumination values when rasterizing the polygon453216Flat Shading vs. Gouraud ShadingWhen might I want flat shading?Phong Shading{ Instead of interpolating color, interpolate normals and re-compute color at each pixel{ Also


View Full Document

Brown CSCI 1480 - Lighting and Shading

Download Lighting and Shading
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lighting and Shading and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lighting and Shading 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?