Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 18: Shading & Texture Mapping Many slides from Greg.

Slides:



Advertisements
Similar presentations
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
Advertisements

16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
03/16/2009Dinesh Manocha, COMP770 Texturing Surface’s texture: its look & feel Graphics: a process that takes a surface and modifies its appearance using.
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
Computer Graphics Bing-Yu Chen National Taiwan University.
Texture Visual detail without geometry. Texture Mapping desire for heightened realism.
Computer Graphics Inf4/MSc Computer Graphics Lecture 13 Illumination I – Local Models.
Computer Graphics (Fall 2008) COMS 4160, Lecture 18: Illumination and Shading 1
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Week 9 - Wednesday.  What did we talk about last time?  Fresnel reflection  Snell's Law  Microgeometry effects  Implementing BRDFs  Image based.
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
Computer Graphics (Spring 2008) COMS 4160, Lecture 19: Texture Mapping Many slides from Greg Humphreys, UVA and Rosalee.
(conventional Cartesian reference system)
Texture Mapping from Watt, Ch. 8 Jonathan Han. Topics Discussed Texture Map to Models Bump Maps, Light Maps Environment (Reflection) Mapping 3D Textures.
Computer Graphics (Spring 2008) COMS 4160, Lecture 15: Illumination and Shading
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Texture Mapping.
Texture Mapping April 9, The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008.
1 Texturing. 2 What is Texturing? 3 Texture Mapping Definition: mapping a function onto a surface; function can be:  1, 2, or 3D  sampled (image) or.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
David Luebke 1 9/13/2015 Texture Mapping. David Luebke 2 9/13/2015 Recap: Texture Map Rendering ● Rendering uses the mapping: ■ Find the visible surface.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
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.
ECSE 4750: Computer Graphics Rensselaer Polytechnic Institute Nov 5, 2012 Texture and Texture Mapping.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
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.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
1 Texture Mapping. 2 Texture Aliasing MIPmaps Environment Mapping Bump Mapping Displacement Mapping Shadow Maps Solid Textures Antialiasing.
Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS559: Computer Graphics Lecture 27: Texture Mapping Li Zhang Spring 2008 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys, UVA and Rosalee.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
CS559: Computer Graphics Lecture 20: Project 2 Review and Texture mapping Li Zhang Spring 2010 Many slides from Ravi Ramamoorthi, Columbia Univ, Greg Humphreys,
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
CS559: Computer Graphics Lecture 21: Subdivision, Bspline, and Texture mapping Li Zhang Spring 2008.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Local Illumination and Shading
Texture Mapping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
MIT EECS 6.837, Durand and Cutler Texture Mapping & Other Fun Stuff.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Texture Mapping Greg Humphreys University of Virginia CS 445, Fall 2003.
Texturing CMSC 435/ What is Texturing? 2 Texture Mapping Definition: mapping a function onto a surface; function can be: – 1, 2, or 3D – sampled.
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
CSE 167 [Win 17], Lecture 18: Texture Mapping Ravi Ramamoorthi
Texture Mapping cgvr.korea.ac.kr.
ATEC Procedural Animation
ATCM 3310 Procedural Animation
3D Graphics Rendering PPT By Ricardo Veguilla.
Texture Mapping COMP575/COMP770.
So Far We have assumed that we know: The point The surface normal
© University of Wisconsin, CS559 Fall 2004
Procedural Animation Lecture 6: Mapping
ATCM 6317 Procedural Animation
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics (Fall 2003)
Advanced Computer Graphics: Texture
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 18: Shading & Texture Mapping Many slides from Greg Humphreys, UVA and Rosalee Wolfe, DePaul tutorial teaching texture mapping visually Chapter 11 in text book covers some portions

To Do  Work on HW4 milestone  Prepare for final push on HW 4, HW 5

Outline  Brief discussion on Phong illumination model and Gouraud, Phong shading  Texture Mapping (bulk of lecture) These are key components of shading

Phong Illumination Model  Specular or glossy materials: highlights  Polished floors, glossy paint, whiteboards  For plastics highlight is color of light source (not object)  For metals, highlight depends on surface color  Really, (blurred) reflections of light source Roughness

Idea of Phong Illumination  Find a simple way to create highlights that are view- dependent and happen at about the right place  Not physically based  Use dot product (cosine) of eye and reflection of light direction about surface normal  Alternatively, dot product of half angle and normal  Raise cosine lobe to some power to control sharpness or roughness

Phong Formula -L R E

Alternative: Half-Angle (Blinn-Phong)  In practice, both diffuse and specular components for most materials H N

Flat vs. Gouraud Shading Flat - Determine that each face has a single normal, and color the entire face a single value, based on that normal. Gouraud – Determine the color at each vertex, using the normal at that vertex, and interpolate linearly for pixels between vertex locations. glShadeModel(GL_FLAT)glShadeModel(GL_SMOOTH)

Gouraud Shading – Details Scan line Actual implementation efficient: difference equations while scan converting

Gouraud and Errors  I 1 = 0 because (N dot E) is negative.  I 2 = 0 because (N dot L) is negative.  Any interpolation of I 1 and I 2 will be 0. I 1 = 0I 2 = 0 area of desired highlight

2 Phongs make a Highlight  Besides the Phong Reflectance model (cos n ), there is a Phong Shading model.  Phong Shading: Instead of interpolating the intensities between vertices, interpolate the normals.  The entire lighting calculation is performed for each pixel, based on the interpolated normal. (OpenGL doesn’t do this, but you can with current programmable shaders) I 1 = 0I 2 = 0

Problems with Interpolated Shading  Silhouettes are still polygonal  Interpolation in screen, not object space: perspective distortion  Not rotation or orientation-independent  How to compute vertex normals for sharply curving surfaces?  But at end of day, polygons is mostly preferred to explicitly representing curved objects like spline patches for rendering

Outline  Brief discussion on Phong illumination model and Gouraud, Phong shading  Texture Mapping (bulk of lecture) These are key components of shading

Texture Mapping  Important topic: nearly all objects textured  Wood grain, faces, bricks and so on  Adds visual detail to scenes  Meant as a fun and practically useful lecture Polygonal model With surface texture

Adding Visual Detail  Basic idea: use images instead of more polygons to represent fine scale color variation

Parameterization geometry + = image texture map Q: How do we decide where on the geometry each color from the image should go?

Option: Varieties of projections [Paul Bourke]

Option: unfold the surface [Piponi2000]

Option: make an atlas [Sander2001] chartsatlassurface

Option: it’s the artist’s problem

Outline  Types of projections  Interpolating texture coordinates  Broader use of textures

How to map object to texture?  To each vertex (x,y,z in object coordinates), must associate 2D texture coordinates (s,t)  So texture fits “nicely” over object

Idea: Use Map Shape  Map shapes correspond to various projections  Planar, Cylindrical, Spherical  First, map (square) texture to basic map shape  Then, map basic map shape to object  Or vice versa: Object to map shape, map shape to square  Usually, this is straightforward  Maps from square to cylinder, plane, sphere well defined  Maps from object to these are simply spherical, cylindrical, cartesian coordinate systems

Planar mapping  Like projections, drop z coord (s,t) = (x,y)  Problems: what happens near z = 0?

Cylindrical Mapping  Cylinder: r, θ, z with (s,t) = (θ/(2π),z)  Note seams when wrapping around (θ = 0 or 2π)

Spherical Mapping  Convert to spherical coordinates: use latitude/long.  Singularities at north and south poles

Cube Mapping

Outline  Types of projections  Interpolating texture coordinates  Broader use of textures

1 st idea: Gouraud interp. of texcoords Scan line Actual implementation efficient: difference equations while scan converting

Artifacts  McMillan’s demo of this is at  Another example  What artifacts do you see?  Why?  Why not in standard Gouraud shading?  Hint: problem is in interpolating parameters

Interpolating Parameters  The problem turns out to be fundamental to interpolating parameters in screen-space  Uniform steps in screen space  uniform steps in world space

Texture Mapping Linear interpolation of texture coordinates Correct interpolation with perspective divide Hill Figure 8.42

Interpolating Parameters  Perspective foreshortening is not getting applied to our interpolated parameters  Parameters should be compressed with distance  Linearly interpolating them in screen-space doesn’t do this

Perspective-Correct Interpolation  Skipping a bit of math to make a long story short…  Rather than interpolating u and v directly, interpolate u/z and v/z  These do interpolate correctly in screen space  Also need to interpolate z and multiply per-pixel  Problem: we don’t know z anymore  Solution: we do know w  1/z  So…interpolate uw and vw and w, and compute u = uw/w and v = vw/w for each pixel  This unfortunately involves a divide per pixel 

Texture Map Filtering  Naive texture mapping aliases badly  Look familiar? int uval = (int) (u * denom + 0.5f); int vval = (int) (v * denom + 0.5f); int pix = texture.getPixel(uval, vval);  Actually, each pixel maps to a region in texture  |PIX| < |TEX|  Easy: interpolate (bilinear) between texel values  |PIX| > |TEX|  Hard: average the contribution from multiple texels  |PIX| ~ |TEX|  Still need interpolation!

Mip Maps  Keep textures prefiltered at multiple resolutions  For each pixel, linearly interpolate between two closest levels (e.g., trilinear filtering)  Fast, easy for hardware  Why “Mip” maps?

MIP-map Example  No filtering:  MIP-map texturing: AAAAAAAGH MY EYES ARE BURNING Where are my glasses?

Outline  Types of projections  Interpolating texture coordinates  Broader use of textures

Texture Mapping Applications  Modulation, light maps  Bump mapping  Displacement mapping  Illumination or Environment Mapping  Procedural texturing  And many more

Modulation textures Map texture values to scale factor Wood texture Texture value

Bump Mapping  Texture = change in surface normal! Sphere w/ diffuse textureSwirly bump map Sphere w/ diffuse texture and swirly bump map

Displacement Mapping

Illumination Maps  Quake introduced illumination maps or light maps to capture lighting effects in video games Texture map: Texture map + light map: Light map

Environment Maps Images from Illumination and Reflection Maps: Simulated Objects in Simulated and Real Environments Gene Miller and C. Robert Hoffman SIGGRAPH 1984 “Advanced Computer Graphics Animation” Course Notes

Solid textures Texture values indexed by 3D location (x,y,z) Expensive storage, or Compute on the fly, e.g. Perlin noise 

Procedural Texture Gallery