11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.

Slides:



Advertisements
Similar presentations
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
Advertisements

Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures II Week 8, Wed.
Computer Graphics - Class 10
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
IN4151 Introduction 3D graphics 1 Introduction 3D Computer Graphics part 1 Projective display Viewing pipeline Graphics hardware Image-based rendering.
Lighting and Shading Wen-Chieh (Steve) Lin
(conventional Cartesian reference system)
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
7M836 Animation & Rendering
CS 376 Introduction to Computer Graphics 03 / 30 / 2007 Instructor: Michael Eckmann.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
©Larry F. Hodges (modified by Amos Johnson) 1 Shading Models.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
SET09115 Intro Graphics Programming
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
Shading in OpenGL.
CS 638, Fall 2001 Admin Grad student TAs may have had their accounts disabled –Please check and the lab if there is a problem If you plan on graduating.
Shading and Illumination. OpenGL Shading Without ShadingWith Shading.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Computer Graphics I, Fall 2010 Shading in OpenGL.
Lecture 9: Lighting and Shading 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Lecture 14 Shading models 1.Shading Constant Shading (to be implemented) Gouraud Shading Phong Shading 2.Light and shading with OpenGL 1.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
03/19/2002(c) University of Wisconsin, CS 559 Last Time BSP Tree rendering and exact visibility in mazes Local Shading –Diffuse term –Specular term.
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Recap Last lecture we looked at local shading models –Diffuse and Phong specular terms –Flat and smooth shading Some things were glossed over –Light source.
Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics.
Computer Graphics Lecture 26 Mathematics of Lighting and Shading Part II Taqdees A. Siddiqi
© University of Wisconsin, CS559 Spring 2004
Unit-7 Lighting and Shading
So Far We have assumed that we know: The point The surface normal
Chapter 14 Shading Models.
Last Time Midterm Shading Light source Shading Interpolation
Vectors, Normals, & Shading
© University of Wisconsin, CS559 Fall 2004
Shading in OpenGL Ed Angel
Fundamentals of Computer Graphics Part 6 Shading
CS5500 Computer Graphics May 29, 2006
Last Time Liang-Barsky Details Weiler-Atherton clipping algorithm
Chapter 14 Shading Models.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Shading in OpenGL
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview

11/5/2002 (c) University of Wisconsin, CS 559 Today Shading Interpolation More on light sources Texture Mapping Homework 4 due

11/5/2002 (c) University of Wisconsin, CS 559 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 point Shading so Far

11/5/2002 (c) University of Wisconsin, CS 559 Shading Interpolation Several options: –Flat shading –Gouraud interpolation –Phong interpolation New hardware provides other options

11/5/2002 (c) University of Wisconsin, CS 559 Flat 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?

11/5/2002 (c) University of Wisconsin, CS 559 Gouraud 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?

11/5/2002 (c) University of Wisconsin, CS 559 Phong Interpolation Interpolate normals across faces Shade each pixel Advantages: –High quality, narrow specularities Disadvantages: –Expensive –Still an approximation for most surfaces Not to be confused with Phong’s specularity model

11/5/2002 (c) University of Wisconsin, CS 559

11/5/2002 (c) University of Wisconsin, CS 559 Shading 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

11/5/2002 (c) University of Wisconsin, CS 559 The Current Generation Current hardware allows you to break from the standard illumination model Programmable Vertex Shaders allow you to write a small program that determines how the color of a vertex 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

11/5/2002 (c) University of Wisconsin, CS 559 The 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

11/5/2002 (c) University of Wisconsin, CS 559 Light 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)

11/5/2002 (c) University of Wisconsin, CS 559 Point and Directional Sources Point light: L(x) = ||p light - x|| –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) = L light –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);

11/5/2002 (c) University of Wisconsin, CS 559 Spotlights 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) n glLightfv(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-off direction

11/5/2002 (c) University of Wisconsin, CS 559 Mapping 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 mapping of some type

11/5/2002 (c) University of Wisconsin, CS 559 Texture Mapping The soup tin is easily described by pasting a label on the plain cylinder Texture mapping associates the color of a point with the color in an image: the texture –Soup tin: Each point on the cylinder get the label’s color Question to address: Which point of the texture do we use for a given point on the surface? Establish a mapping from surface points to image points –Different mappings are common for different shapes –We will, for now, just look at triangles (polygons)

11/5/2002 (c) University of Wisconsin, CS 559 Basic Mapping The texture lives in a 2D space –Parameterize points in the texture with 2 coordinates: (s,t) –These are just what we would call (x,y) if we were talking about an image, but we wish to avoid confusion with the world (x,y,z) Define the mapping from (x,y,z) in world space to (s,t) in texture space –To find the color in the texture, take an (x,y,z) point on the surface, map it into texture space, and use it to look up the color of the texture With polygons: –Specify (s,t) coordinates at vertices –Interpolate (s,t) for other points based on given vertices

11/5/2002 (c) University of Wisconsin, CS 559 Example Mappings

11/5/2002 (c) University of Wisconsin, CS 559 Texture Interpolation Specify where the vertices in world space are mapped to in texture space Linearly interpolate the mapping for other points in world space –Straight lines in world space go to straight lines in texture space Texture map s t Triangle in world space

11/5/2002 (c) University of Wisconsin, CS 559 Interpolating Coordinates (x 1, y 1 ), (s 1, t 1 )(x 2, y 2 ), (s 2, t 2 ) (x 3, y 3 ), (s 3, t 3 )

11/5/2002 (c) University of Wisconsin, CS 559 Pipelines and Texture Mapping Texture mapping is done in canonical screen space as the polygon is rasterized When describing a scene, you assume that texture interpolation will be done in world space Which property of perspective projection means that the “wrong thing” will happen if we apply our simple interpolations from the previous slide? Perspective correct texture mapping does the right thing, but at a cost Is it a problem with orthographic viewing?

11/5/2002 (c) University of Wisconsin, CS 559 Basic OpenGL Texturing Specify texture coordinates for the polygon: –Use glTexCoord2f(s,t) before each vertex: Eg: glTexCoord2f(0,0); glVertex3f(x,y,z); Create a texture object and fill it with texture data: –glGenTextures(num, &indices) to get identifiers for the objects –glBindTexture(GL_TEXTURE_2D, identifier) to bind the texture Following texture commands refer to the bound texture –glTexParameteri(GL_TEXTURE_2D, …, …) to specify parameters for use when applying the texture –glTexImage2D(GL_TEXTURE_2D, ….) to specify the texture data (the image itself) MORE…

11/5/2002 (c) University of Wisconsin, CS 559 Basic OpenGL Texturing (cont) Enable texturing: glEnable(GL_TEXTURE_2D) State how the texture will be used: –glTexEnvf(…) Texturing is done after lighting You’re ready to go…