DOC PREVIEW
UW-Madison CS 559 - Shading Interpolation

This preview shows page 1-2-14-15-29-30 out of 30 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 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 30 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 30 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 30 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 30 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 30 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Last TimeTodayLight SourcesPoint and Directional SourcesSpotlightsShading so FarShading InterpolationFlat shadingGouraud ShadingPhong InterpolationSlide 11Shading and OpenGLThe Current GenerationThe Full StoryMapping TechniquesTexture MappingExample MappingsBasic MappingTexture InterpolationInterpolating CoordinatesSteps in Texture MappingPipelines and Texture MappingPerspective Correct MappingBasic OpenGL TexturingBasic OpenGL Texturing (cont)Nasty DetailsControlling Different ParametersExample: Diffuse shading and textureSpecular ColorSome Other Uses4/1/04 © University of Wisconsin, CS559 Spring 2004Last Time•Local Lighting model–Diffuse illumination–Specular illumination–Ambient illumination4/1/04 © University of Wisconsin, CS559 Spring 2004Today•Light Sources•Shading Interpolation•Mapping Techniques4/1/04 © University of Wisconsin, CS559 Spring 2004Light Sources•Two aspects of light sources are important for a local shading model:–Where is the light coming from (the L vector)?–How much light is coming (the I values)?•Various light source types give different answers to the above questions:–Point light source: Light from a specific point–Directional: Light from a specific direction–Spotlight: Light from a specific point with intensity that depends on the direction–Area light: Light from a continuum of points (later in the course)4/1/04 © University of Wisconsin, CS559 Spring 2004Point and Directional Sources•Point light:–The L vector depends on where the surface point is located–Must be normalized - slightly expensive–To specify an OpenGL light at 1,1,1:•Directional light: L(x) = Llight–The L vector does not change over points in the world–OpenGL light traveling in direction 1,1,1 (L is in opposite direction):Glfloat light_position[] = { 1.0, 1.0, 1.0, 1.0 };glLightfv(GL_LIGHT0, GL_POSITION, light_position);Glfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };glLightfv(GL_LIGHT0, GL_POSITION, light_position);-xp-xpL(x)lightlight4/1/04 © University of Wisconsin, CS559 Spring 2004Spotlights•Point source, but intensity depends on L:–Requires a position: the location of the source–Requires a direction: the center axis of the light–Requires a cut-off: how broad the beam is–Requires and exponent: how the light tapers off at the edges of the cone•Intensity scaled by (L·D)nglLightfv(GL_LIGHT0, GL_POSITION, light_posn);glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_dir);glLightfv(GL_LIGHT0, GL_SPOT_CUTOFF, 45.0);glLightfv(GL_LIGHT0, GL_SPOT_EXPONENT, 1.0);cut-offdirection4/1/04 © University of Wisconsin, CS559 Spring 2004•So far, we have discussed illuminating a single point•We have assumed that we know:–The point–The surface normal–The viewer location (or direction)–The light location (or direction)•But commonly, normal vectors are only given at the vertices•It is also expensive to compute lighting for every pointShading so Far psdiaakkIIkI )()( NHNL --4/1/04 © University of Wisconsin, CS559 Spring 2004Shading Interpolation•Take information specified or computed at the vertices, and somehow propagate it across the polygon (triangle)•Several options:–Flat shading–Gouraud interpolation–Phong interpolation4/1/04 © University of Wisconsin, CS559 Spring 2004Flat shading•Compute shading at a representative point and apply to whole polygon–OpenGL uses one of the vertices•Advantages: –Fast - one shading computation per polygon, fill entire polygon with same color•Disadvantages:–Inaccurate–What are the artifacts?4/1/04 © University of Wisconsin, CS559 Spring 2004Gouraud Shading•Shade each vertex with it’s own location and normal•Linearly interpolate the color across the face•Advantages:–Fast: incremental calculations when rasterizing–Much smoother - use one normal per shared vertex to get continuity between faces•Disadvantages:–What are the artifacts?–Is it accurate?4/1/04 © University of Wisconsin, CS559 Spring 2004Phong Interpolation•Interpolate normals across faces•Shade each pixel individually•Advantages:–High quality, narrow specularities•Disadvantages:–Expensive–Still an approximation for most surfaces•Not to be confused with Phong’s specularity model4/1/04 © University of Wisconsin, CS559 Spring 20044/1/04 © University of Wisconsin, CS559 Spring 2004Shading and OpenGL•OpenGL defines two particular shading models–Controls how colors are assigned to pixels–glShadeModel(GL_SMOOTH) interpolates between the colors at the vertices (the default, Gouraud shading)–glShadeModel(GL_FLAT) uses a constant color across the polygon•Phong shading requires a significantly greater programming effort – beyond the scope of this class–Also requires fragment shaders on programmable graphics hardware4/1/04 © University of Wisconsin, CS559 Spring 2004The Current Generation•Current hardware allows you to break from the standard illumination model•Programmable Vertex Shaders and Fragment Shaders allow you to write a small program that determines how the color of a vertex or pixel is computed–Your program has access to the surface normal and position, plus anything else you care to give it (like the light)–You can add, subtract, take dot products, and so on•Fragment shaders are most useful for lighting because they operate on every pixel4/1/04 © University of Wisconsin, CS559 Spring 2004The Full Story•We have only touched on the complexities of illuminating surfaces–The common model is hopelessly inadequate for accurate lighting (but it’s fast and simple)•Consider two sub-problems of illumination–Where does the light go? Light transport–What happens at surfaces? Reflectance models•Other algorithms address the transport or the reflectance problem, or both–Much later in class, or a separate course (CS 779)4/1/04 © University of Wisconsin, CS559 Spring 2004Mapping Techniques•Consider the problem of rendering a soup can–The geometry is very simple - a cylinder–But the color changes rapidly, with sharp edges–With the local shading model, so far, the only place to specify color is at the vertices–To do a soup can, would need thousands of polygons for a simple shape–Same thing for an orange: simple shape but complex normal vectors•Solution: Mapping techniques use simple geometry modified by a detail map of some type4/1/04 © University of Wisconsin, CS559 Spring 2004Texture Mapping•The soup tin is


View Full Document

UW-Madison CS 559 - Shading Interpolation

Documents in this Course
Filters

Filters

14 pages

Lecture 2

Lecture 2

24 pages

Clipping

Clipping

22 pages

Modeling

Modeling

33 pages

Filters

Filters

26 pages

Dithering

Dithering

33 pages

Lecture 4

Lecture 4

20 pages

Load more
Download Shading Interpolation
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 Shading Interpolation 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 Shading Interpolation 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?