Announcements. Written Assignment 2 is out see the web page. Computer Graphics

Similar documents
Texture and other Mappings

Shading. Flat shading Gouraud shading Phong shading

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Texturas. Objectives. ! Introduce Mapping Methods. ! Consider two basic strategies. Computação Gráfica

Computer Graphics. - Texturing Methods -

Surface Rendering. Surface Rendering

CPSC / Texture Mapping

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Texture Mapping and Sampling

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

3D Rasterization II COS 426

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Cap. 3 Textures. Mestrado em Engenharia Informática (6931) 1º ano, 1º semestre

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Texture mapping. Computer Graphics CSE 167 Lecture 9

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Overview. Hierarchy. Level of detail hierarchy Texture maps Procedural shading and texturing Texture synthesis and noise.

Graphics for VEs. Ruth Aylett

Computer Graphics I Lecture 11

CS 488. More Shading and Illumination. Luc RENAMBOT

Computer Graphics. Shadows

Topics and things to know about them:

CS 5600 Spring

Graphics for VEs. Ruth Aylett

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Computer Graphics 7 - Texture mapping, bump mapping and antialiasing

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

Computergrafik. Matthias Zwicker. Herbst 2010

Recall: Indexing into Cube Map

Texturing. Texture Mapping. Texture Mapping. Have seen: colour can be assigned to ver7ces But: don t want to represent all this detail with geometry

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

+ = To Do. Texture Mapping. Adding Visual Detail. Parameterization. Option: Varieties of projections. Computer Graphics. geometry

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Einführung in Visual Computing

CS 431/636 Advanced Rendering Techniques

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Reading. Texture Mapping. Non-parametric texture mapping. Texture mapping. Required. Angel, 8.6, 8.7, 8.9, 8.10,

+ = To Do. Adding Visual Detail. Texture Mapping. Parameterization. Option: Varieties of projections. Foundations of Computer Graphics (Fall 2012)

Computer Graphics 10 - Shadows

Texturing Theory. Overview. All it takes is for the rendered image to look right. -Jim Blinn 11/10/2018

INF3320 Computer Graphics and Discrete Geometry

CS212. OpenGL Texture Mapping and Related

Shading/Texturing. Dr. Scott Schaefer

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

Reading. Texture Mapping. Non-parametric texture mapping. Texture mapping. Required. Angel, 8.6, 8.7, 8.9, Recommended

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

lecture 18 - ray tracing - environment mapping - refraction

TEXTURE MAPPING. DVA338 Computer Graphics Thomas Larsson, Afshin Ameri

Graphics and Interaction Rendering pipeline & object modelling

Texture-Mapping Tricks. How Bad Does it Look? We've Seen this Sort of Thing Before. Sampling Texture Maps

Texture. Detail Representation

Other Rendering Techniques CSE 872 Fall Intro You have seen Scanline converter (+z-buffer) Painter s algorithm Radiosity CSE 872 Fall

Pipeline Operations. CS 4620 Lecture 10

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

CHAPTER 1 Graphics Systems and Models 3

CMSC427 Final Practice v2 Fall 2017

CS 130 Final. Fall 2015

CS 450: COMPUTER GRAPHICS TEXTURE MAPPING SPRING 2015 DR. MICHAEL J. REALE

Soft shadows. Steve Marschner Cornell University CS 569 Spring 2008, 21 February

Computer Graphics. Lecture 9 Environment mapping, Mirroring

9. Illumination and Shading

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

CS5620 Intro to Computer Graphics

Reading. 12. Texture Mapping. Texture mapping. Non-parametric texture mapping. Required. w Watt, intro to Chapter 8 and intros to 8.1, 8.4, 8.6, 8.8.

Shadows. Shadows. Spatial relationship between objects. Shadows as depth cue. Spatial relationship between objects

6.837 Introduction to Computer Graphics Quiz 2 Thursday November 20, :40-4pm One hand-written sheet of notes allowed

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Texture Mapping. Brian Curless CSE 457 Spring 2015

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

Overview. A real-time shadow approach for an Augmented Reality application using shadow volumes. Augmented Reality.

COMP environment mapping Mar. 12, r = 2n(n v) v

Introduction to Digital Modelling and Animation in Design week 4 Textures

CS 354R: Computer Game Technology

Texture Mapping. Reading. Implementing texture mapping. Texture mapping. Daniel Leventhal Adapted from Brian Curless CSE 457 Autumn 2011.

Complex Features on a Surface. CITS4241 Visualisation Lectures 22 & 23. Texture mapping techniques. Texture mapping techniques

CT5510: Computer Graphics. Texture Mapping

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

CEng 477 Introduction to Computer Graphics Fall 2007

The Rasterization Pipeline

CMSC 435/634: Introduction to Graphics

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Computer Graphics Global Illumination

Shadows in the graphics pipeline

Texture. Texture Maps

Textures and normals in ray tracing

CS 4620 Program 3: Pipeline

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Today. Texture mapping in OpenGL. Texture mapping. Basic shaders for texturing. Today. Computergrafik

Transcription:

Announcements Written Assignment 2 is out see the web page 1

Texture and other Mappings Shadows Texture Mapping Bump Mapping Displacement Mapping Environment Mapping Watt Chapter 8 COMPUTER GRAPHICS 15-462 10/08/01 2

Shadows Shadows occur where objects are hidden from a light source Omit any intensity contribution from hidden light sources Umbra and penumbra (function of size of light source) Soft shadows and hard shadows (point light source at a distance) Important perceptual clue for connecting objects to ground (feet in particular) But object-to-object shadows also important And in general have shadows from many light sources 3

Shadows Simplest case: Point light source (no penumbra) and shadows only on the ground plane Good for flight simulators Shadow is projection of polygon onto the surface with the center of projection at the light source 4

Shadows Put light source at origin with Simple perspective projection through the origin: 1 0 0 1 M = 0 0 0 1/ y 1 0 0 0 0 ÿ ÿ 1 0ÿ ÿ 0 0 Translate back with T ( x1, y1, z1) T ( x1, y1, z1) 5

Or in OpenGL GlFloat m[16]; /* shadow projection matrix */ For (i=0;i<15;i++) m[i]=0.0; m[0] = m[5] =m[10] = 1.0; m[7] = -1.0/y1; glbegin(gl_polygon); /* draw the polygon normally */ glend(); glmatrixmode(gl_modelview); glpushmatrix(); /* save state*/ gltranslatef(x1,y1,z1); /* translate back */ glmultmatrixf(m); /* project*/ gltranslate(-x1,-y1,-z1); /* move light to origin */ glcolor3fv(shadow_color); glbegin(gl_polygon); /* draw the polygon again */ glend(); glpopmatrix(); /* restore state * 6

Shadows If a perspective transform does a point light source, what does a directional light source? 7

Shadows But shadow maps only do shadows on the ground plane and the objects have to be far enough apart to not cast shadows on each other (although your eye isn t particularly good at picking up these problems). Z-buffer Algorithm: Render from light source to compute depth map (z distance to closest object for each pixel in the map). While rendering, if a point (x,y,z) is visible, map (x,y,z) in the coordinates of the viewpoint to (x,y,z ), the coordinates of the point from the light. If z is greater than the value in the z-buffer for that point, then a surface is nearer to the light source than the point under consideration and the point is in shadow. If so, render with a shadow intensity, if not render as normal. Handles multiple light sources (with multiple z-buffers), moving objects and lights (at the cost of several renderings). Clearly a winning strategy with hardware. 8

Other Shadow Algorithms Projecting polygons scan line (Appel 1968) Build a data structure that links all polygons where one might shadow the other (depends on polygon location and lighting source location animation would require recalculating). Multiple data structures for multiple lights. When scan converting have three possibilities Shadow polygon does not cover generated scan line segment Shadow polygon completely covers segment (adjust intensity for shadow) Shadow polygon partially covers segment, subdivide and repeat Point light source Scanline Polygon A Polygon B View point 9 Shadow of A on B

Other Shadow Algorithms Shadow Volumes (Crow 1977) Compute the volume of space swept out by an object, intersected with the viewing volume. Include these invisible objects in rendering pipeline. Render visible objects as in shadow if they are in front of a back facing shadow polygon and in back of a front facing polygon. Extend the z buffer to contain this extra information. Point light source Polygon Intersection of shadow volume with view volume View volume 10

Last time we talked about shading. But uniformly colored or shaded surfaces are unrealistic. Real objects have small surface features One option: use a huge number of polygons with appropriate surface coloring and reflectance characteristics Another option: use a mapping algorithm to modify the shading algorithm Texture mapping Bump mapping Displacement mapping Environmental mapping 11

The Quest for Visual Realism 12

2D Texture Mapping Texture images to make our surfaces more life-like Scan textures from the world (clouds, wood grain) or paint them yourself Storethetextureina2Dimage Map the image onto the surface by a function which maps (u,v) coordinates of our parametric surface onto (x,y) image coordinates When shading a surface point, we look up the appropriate pixel from the 2D image, and use that to affect the final color Voila! Your favorite picture painted onto a donut. This technique is called parametric texture mapping But how to map from texture coordinates to object coordinates? Easy for a parametric surface, less obvious for other models. 13

Texture Mapping: General Texture Space Object Space Screen Space T ( u) T ( u, v) ( x, y, z ) w w w ( x, y ) s s T ( u, v, w) 14

Specifying the Mapping Function Some objects have natural parameterizations: Sphere: use spherical coordinates (φ,θ)=(2πu,πv) Cylinder: use cylindrical coordinates (u,θ)=(u,2πv) 15

Specifying the Mapping Function Some objects have natural parameterizations: Parametric surface (such as B-spline or Bezier): use patch parameters (u,v) u v = u = v min min s + s t + t max max s t s t min min min min ( u ( v max max u v min min ) ) Doesn t take into account the curvature of the surface: stretching. Just like with roller coaster. 16

Specifying the Mapping Function What about arbitrary polygonal objects? Two step mapping: To a canonical shape first Then project normals from object a) From texture value to object b) Use normals to find texture c) Line from center to point to texture value 17

Or design the mapping by hand 18

Texture Mapping in OpenGL A parallel pipeline for pixel operations: Texture mapping is part of the shading process 19

Texture Mapping in OpenGL Glubyte my_texels[512][512]; glteximage2d(gl_texture_2d, 0, 3, 512, 512, 0, GL_RGB,GL_UNSIGNED_BYTE, my_texels); /* level, components, w, h, border, format, type, tarray */ glenable(gl_texture_2d); /* assign texture coordinates */ glbegin(gl_quad); gltexcoord2f(0.0, 0.0); glvertex2f(x1,y1,z1); gltexcoord2f(1.0, 0.0); glvertex2f(x2,y2,z2); gltexcoord2f(1.0,1.0); glvertex2f(x3,y3,z3); gltexcoord2f(0.0,1.0); glvertex2f(x4,y4,z4); glend(); Can map to all or part of array 20

Grungy details we ve ignored Specify s or t out of range? Use GL_TEXTURE_WRAP in gltexparameter because many textures are carefully designed to repeat Aliasing? Mapping doesn t send you to the center of a texel. Can average nearest 2x2 texels using GL_LINEAR Mipmapping: use textures of varying resolutions. 64x64 becomes 32x32,16x16,8x8,4x4,2x2 and 1x1 arrays with glubuild2dmipmaps 21

Texture Generation Photographs Drawings Procedural methods (2D or 3D) Associate each x,y,z value directly with an s,t,r value in the texture block (sculpting in marble and granite) 22

Procedural Methods Reaction-Diffusion Greg Turk, Siggraph 91 23

Solid Textures Have a 3-D array of texture values (e.g., a block of marble) Use a function [xyz] -> [RGB] to map colors to points in space Sucha3Dmapiscalledasolid texture map In practice the map is often defined procedurally No need to store an entire 3D array of colors Just define a function to generate a color for each 3D point The most interesting solid textures are random ones a great marble algorithm has now become cliché Evaluate the texture coordinates in object coordinates - otherwise moving the object changes its texture! From: An Image Synthesizer by Ken Perlin, SIGGRAPH '85 24

Uses for Texture Mapping (Heckbert 1986) Use texture to affect a variety of parameters surface color - color (radiance) of each point on surface (Catmull 1974) surface reflectance - reflectance coefficients k d, k s,orn shiny normal vector - bump mapping (Blinn 1978) geometry - displacement mapping transparency - transparency mapping (clouds) (Gardener 1985) light source radiance - environment mapping (Blinn 1978) 25

Bump Mapping: A Dirty Trick Which spots bulge out, and which are indented? Answer: None! This is a flat image. The human visual system is hard-coded to expect light from above In CG, we can perturb the normal vector without having to make any actual change to the shape. 26

Bump Mapping Basic texture mapping paints on to a smooth surface How do you make a surface look rough? Option 1: model the surface with many small polygons Option 2: perturb the normal vectors before the shading calculation Real Bump Fake Bump Flat Plane + = Sphere w/diffuse Texture Map Bump Map Sphere w/diffuse Texture + Bump Map 27

Bump Mapping Basic texture mapping paints on to a smooth surface How do you make a surface look rough? Option 1: model the surface with many small polygons Option 2: perturb the normal vectors before the shading calculation» the surface doesn t actually change, but shading makes it look that way» bump map fakes small displacements above or below the true surface» can use texture-mapping for this texture image gives amount to perturb surface normal What kind of anomaly will this produce? Greg Turk 28

Bump Mapping Let p( u,v) be a point on a parametric surface. Unit normal is p p Where p u = x u y u z u ÿ ÿ ÿ ÿ ÿ ÿ n = p v u v pu pv = Partial derivatives lying in the tangent plane to surface at point P x y v v z v ÿ ÿ ÿ ÿ ÿ ÿ 29

Bump Mapping Displace the surface in the normal direction by d u, v ( ) Then p' = p+d ( u, v)n We don t actually change the surface (p), just the normal. Need to calculate: n ' = p p u ' ' v 30

31 Bump Mapping Compute the partial derivatives by differentiating p If d is small Pre-compute arrays of u u v u d u d u n n p p ), ( ' + + = v v v u d v d v n n p p ), ( ' + + = u v u d v d p n p n n n + + = ' u d v d,

Another Bump Mapping Example + = Bump Map Cylinder w/diffuse Texture Map 32

Radiance vs. Reflectance Mapping + = Sphere w/ Uniform Diffuse coefficient Radiance Map Sphere w/ Radiance Map Texture specifies (isotropic) radiance for each point on surface + = Sphere w/ Uniform Diffuse coefficient Reflectance (k d )Map Texture specifies diffuse color (k d coefficients) for each point on surface - three coefficients, one each for R, G, and B radiance channels 33 Sphere w/ Reflectance Map

Displacement Mapping Use texture map to displace each point on the surface Texture value gives amount to move in direction normal to surface How is this different from bump mapping? 34

Environment Mapping Specular reflections that mirror the environment Cube is a natural intermediate object for a room 35

Environment Mapping Generate the environment map either by scanning or by rendering the scene from the point of view of the object (win here because people s ability to do the reverse mapping in their heads is bad they won t notice flaws) OpenGL can automatically generate the coordinates for a spherical mapping. Given a vertex and a normal, find point on sphere that has same tangent: gltexgenfv(gl_s, GL_SPHERE_MAP,0); gltexgenfv(gl_t,gl_sphere_map,0); glenable (GL_TEXTURE_GEN_S); glenable (GL_TEXTURE_GEN_T); 36

More Tricks: Light Mapping Quake uses light maps in addition to (radiance) texture maps. Texture maps are used to add detail to surfaces, and light maps are used to store pre-computed illumination. The two are multiplied together at run-time, and cached for efficiency. Radiance Texture Map Only Radiance Texture + Light Map Light Map 37

A Donut 38

A Much More Interesting Donut 39

Videos? 40

Announcements Written Assignment 2 is out see the web page 41