Introduction 3D texture mapping 2D texture mapping Other forms of texture mapping. Graphics 2011/2012, 4th quarter. Lecture 06: texture mapping

Similar documents
INTRODUCTION TO RENDERING TECHNIQUES

ROCKS AND MINERALS. Richard L. Yepez and Kathleen E. Yepez. An Art Skills Tutorial

GPU Shading and Rendering: Introduction & Graphics Hardware

TEXTURE AND BUMP MAPPING

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Activity Set 4. Trainer Guide

Making natural looking Volumetric Clouds In Blender 2.48a

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

COMP-557: Fundamentals of Computer Graphics McGill University, Fall 2010

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

MD5-26 Stacking Blocks Pages

Reflection and Refraction

Area of Parallelograms (pages )

A Short Introduction to Computer Graphics

Summary: Transformations. Lecture 14 Parameter Estimation Readings T&V Sec Parameter Estimation: Fitting Geometric Models

Dhiren Bhatia Carnegie Mellon University

Computer Graphics. Geometric Modeling. Page 1. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science - Technion. An Example.

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model

Name Class. Date Section. Test Form A Chapter 11. Chapter 11 Test Bank 155

Name: Section Registered In:

Abstract. These two vectors define a plane tangent to the surface at that point. Their cross product is Recent work in computer graphics has been

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

Geometry and Measurement

Copyright 2011 Casa Software Ltd. Centre of Mass

Chapter 8 Geometry We will discuss following concepts in this chapter.

The small increase in x is. and the corresponding increase in y is. Therefore

Basic Shapes. Most paintings can be broken down into basic shapes. See how this famous painting by Cézanne can be broken down into basic shapes.

Solving Simultaneous Equations and Matrices

Solutions to Homework 10

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Algebra Geometry Glossary. 90 angle

H.Calculating Normal Vectors

What Resolution Should Your Images Be?

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

4. How many integers between 2004 and 4002 are perfect squares?

Creating Your Own 3D Models

Geometry Notes PERIMETER AND AREA

Shear :: Blocks (Video and Image Processing Blockset )

MicroStation V8i Training Manual 3D Level 3

Lecture 7. Matthew T. Mason. Mechanics of Manipulation. Lecture 7. Representing Rotation. Kinematic representation: goals, overview

Perimeter, Area, and Volume

Matrix Multiplication

Largest Fixed-Aspect, Axis-Aligned Rectangle

Volume visualization I Elvins

Math 1B, lecture 5: area and volume

Area of Parallelograms, Triangles, and Trapezoids (pages )

(Refer Slide Time: 1:42)

1 Review of Least Squares Solutions to Overdetermined Systems

High Dynamic Range and other Fun Shader Tricks. Simon Green

Task: Representing the National Debt 7 th grade

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

12.5 Equations of Lines and Planes

Vector Math Computer Graphics Scott D. Anderson

AP Physics - Vector Algrebra Tutorial

Space Perception and Binocular Vision

Graphic Design. Background: The part of an artwork that appears to be farthest from the viewer, or in the distance of the scene.

Curves and Surfaces. Goals. How do we draw surfaces? How do we specify a surface? How do we approximate a surface?

6 Space Perception and Binocular Vision

Indicator 2: Use a variety of algebraic concepts and methods to solve equations and inequalities.

Physics Midterm Review Packet January 2010

1 Symmetries of regular polyhedra

Vectors Math 122 Calculus III D Joyce, Fall 2012

521493S Computer Graphics. Exercise 2 & course schedule change

CSE 167: Lecture 13: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

6. LECTURE 6. Objectives

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

Thnkwell s Homeschool Precalculus Course Lesson Plan: 36 weeks

Linear Algebra Notes for Marsden and Tromba Vector Calculus

The GED math test gives you a page of math formulas that

Platonic Solids. Some solids have curved surfaces or a mix of curved and flat surfaces (so they aren't polyhedra). Examples:

MAC Learning Objectives. Module 10. Polar Form of Complex Numbers. There are two major topics in this module:

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

Materials in NX Render

4 The Rhumb Line and the Great Circle in Navigation

Physical Quantities and Units

Grade 8 Mathematics Geometry: Lesson 2

Pre-Algebra Academic Content Standards Grade Eight Ohio. Number, Number Sense and Operations Standard. Number and Number Systems

Section Continued

An Overview of the Finite Element Analysis

Pushes and Pulls. TCAPS Created June 2010 by J. McCain

Geometry Unit 6 Areas and Perimeters

Relevant Reading for this Lecture... Pages

Computer-Generated Photorealistic Hair

n 2 + 4n + 3. The answer in decimal form (for the Blitz): 0, 75. Solution. (n + 1)(n + 3) = n lim m 2 1

Section 1.1. Introduction to R n

3. INNER PRODUCT SPACES

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

Realtime 3D Computer Graphics Virtual Reality

Solids. Objective A: Volume of a Solids

Finite Element Formulation for Plates - Handout 3 -

How To Make A Texture Map Work Better On A Computer Graphics Card (Or Mac)

1 Review of Newton Polynomials

Geometry of Minerals

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Visual Arts Scope and Sequence

10.1. Solving Quadratic Equations. Investigation: Rocket Science CONDENSED

Transcription:

Lecture 6 Texture mapping

Linear interpolation Texture mapping We already learned a lot: Vectors, basic geometric entities Intersection of objects Matrices, transformations And some shading

Motivation Linear interpolation Texture mapping For example, we can... use vectors to represent points use 3 points to represent triangles use matrix multiplication to transform them use our (simple) shading model to put color on them

Motivation Linear interpolation Texture mapping For example, we can... use vectors to represent points use 3 points to represent triangles use matrix multiplication to transform them use our (simple) shading model to put color on them

Motivation Linear interpolation Texture mapping For example, we can... use vectors to represent points use 3 points to represent triangles use matrix multiplication to transform them use our (simple) shading model to put color on them

Motivation Linear interpolation Texture mapping For example, we can... use vectors to represent points use 3 points to represent triangles use matrix multiplication to transform them use our (simple) shading model to put color on them Q: But how do we get the colors in between two vertices?

Linear interpolation Linear interpolation Texture mapping Given two vectors a, b, linear interpolation is defined as p(t) = (1 t) a + t b with a (scalar) parameter 0 t 1. Note: If a, b are scalars and t = 1/2 this is usually refered to as average ;) If a, b are color values (r, g, b), this gives us a smooth transition from a to b

Linear interpolation Texture mapping Linear interpolation to color triangles With this we can linearly interpolate color 1 between two vertices 2 between two edges Q: How to do this efficiently? What about phong shading? We will learn this in a later lecture

Texture mapping Linear interpolation Texture mapping Adding lots of detail to our models to realistically depict skin, grass, bark, stone, etc., would increase rendering times dramatically, even for hardware-supported projective methods.

Texture mapping Linear interpolation Texture mapping Adding lots of detail to our models to realistically depict skin, grass, bark, stone, etc., would increase rendering times dramatically, even for hardware-supported projective methods.

Basic idea Linear interpolation Texture mapping Basic idea of texture mapping: Instead of calculating color, shade, light, etc. for each pixel we just paste images to our objects in order to create the illusion of realism

Different approaches Linear interpolation Texture mapping Different approaches exist, for example 2D vs. 3D: 3D Object 2D mapping (aka image textures): paste an image onto the object 3D mapping (aka solid or volume textures): create a 3D texture and carve the object 2D texture 3D texture

Outline 1 Linear interpolation Texture mapping 2 3D stripe textures Texture arrays Solid noise 3 Basic idea Spherical mapping Triangles 4 Bump mapping Displacement mapping Environment mapping Linear interpolation Texture mapping

Texturing 3D objects 3D stripe textures Texture arrays Solid noise Let s start with 3D mapping, which is a procedural approach, i.e. we use a mathematical procedure to create a 3D texture, i.e. Then we use the coordinates of each point in our 3D model to calculate the appropriate color value using that procedure, i.e. f(x, y, z) = c with c R 3 f(x p, y p, z p ) = c p

3D stripe textures 3D stripe textures Texture arrays Solid noise A simple example: stripes along the X-axis stripe( x p, y p, z p ) { if ( sin x p > 0 ) return color0; else return color1; } } Note: any alternating function will do it (sin is slow)

3D stripe textures 3D stripe textures Texture arrays Solid noise A simple example: stripes along the X-axis stripe( x p, y p, z p ) { if ( sin x p > 0 ) return color0; else return color1; } } Note: any alternating function will do it (sin is slow)

3D stripe textures 3D stripe textures Texture arrays Solid noise Stripes along the Z-axis: stripe( x p, y p, z p ) { if ( sin z p > 0) return color0; else return color1; } }

3D stripe textures 3D stripe textures Texture arrays Solid noise And what happens here? stripe( x p, y p, z p ) { if ( sin x p > 0 & sin z p > 0) return color0; else return color1; } } This looks almost like a checkerboard, and should come in handy when working on practical assignment 1.2

3D stripe textures 3D stripe textures Texture arrays Solid noise Stripes with controllable width: stripe( point p, real width ) { if ( sin(π x p /width) > 0 ) return color0; else return color1; } } Try this at home :) Note that we do not multiply but divide by width!

3D stripe textures 3D stripe textures Texture arrays Solid noise Smooth variation between two colors, instead of two distinct ones: stripe( point p, real width ) { t = (1 + sin(π x p /width))/ 2 return (1 - t) c 0 + t c 1 } Try this at home :) Note: if that doesn t look familiar, check the slides on linear interpolation again ;)

Texture arrays 3D stripe textures Texture arrays Solid noise Again: this is often called solid or volumetric texturing. It is called procedural because we compute the color values for a point p R 3 with a procedure. Carving vs. array lookup Alternatively, we can do an array lookup in a 3D array (using all three coordinates of p for indexing), or in a 2D array (using only two coordinates of p).

2D texture arrays 3D stripe textures Texture arrays Solid noise We ll call the two dimensions to be mapped u and v, and assume an n x n y image as texture. Then every (u, v) needs to be mapped to a color in the image, i.e. we need a mapping from pixels to texels.

2D texture arrays 3D stripe textures Texture arrays Solid noise A standard way is to remove the integer portion of u and v, so that (u, v) lies in the unit square.

2D texture arrays 3D stripe textures Texture arrays Solid noise The pixel (i, j) in the n x n y image for (u, v) is found by i = un x and j = vn y x is the floor function that give the highest integer value x.

Nearest neighbor interpolation 3D stripe textures Texture arrays Solid noise This is a version of nearest-neighbor interpolation, because we take the color of the nearest neighbor: c(u, v) = c i,j with i = un x and j = vn y

Bilinear interpolation 3D stripe textures Texture arrays Solid noise For smoother effects we may use bilinear interpolation: c(u, v) = (1 u )(1 v )c ij +u (1 v )c (i+1)j +(1 u )v c i(j+1) +u v c (i+1)(j+1) where u = un x un x and v = vn y vn y Notice: all weights are between 0 and 1 and add up to 1, i.e. (1 u )(1 v ) + u (1 v ) + (1 u )v + u v = 1

Trilinear interpolation 3D stripe textures Texture arrays Solid noise Using 2D arrays with bilinear interpolation is easily extended to using 3D arrays with trilinear interpolation: c(u, v, w) = (1 u )(1 v )(1 w )c ijk +u (1 v )(1 w )c (i+1)jk +...

Using random noise 3D stripe textures Texture arrays Solid noise So far: rather simple textures (e.g. stripes). We can create much more complex (and realistic) textures, e.g. resembling wooden structures. Or we can create some randomness by adding noice, e.g. to create the impression of a marble like structure.

Perlin noise 3D stripe textures Texture arrays Solid noise Goal: create texture with random appearance, but not too random (e.g., marble patterns, mottled textures as on birds eggs) 1st idea: random color at each point Problem: too much noise, similar to white noise on TV 2nd idea: smoothing of white noise Problem: bad results and/or computationally too expensive 3rd idea: create lattice with random numbers & interpolate between them Problem: lattice becomes too obvious Perlin noise makes lattice less obvious by using three tricks...

Perlin noise 3D stripe textures Texture arrays Solid noise Perlin noise is based on the following ideas: Use a 1D array of random unit vectors and hashing to create a virtual 3D array of random vectors; Compute the inner product of (u, v, w)-vectors with the random vectors Use Hermite interpolation to get rid of visible artifacts

Random unit vectors 3D stripe textures Texture arrays Solid noise Random unit vectors are obtained as follows: v x = 2ξ 1 v y = 2ξ 1 v z = 2ξ 1 where ξ, ξ, and ξ are random numbers in [0, 1]. Notice that 1 v i 1, so we get vectors in the unit cube. If (v 2 x + v 2 y + v 2 z) < 1, we normalize the vector and keep it; otherwise not. Why? Perlin reports that an array with 256 such random unit vectors works well with his technique.

Hashing 3D stripe textures Texture arrays Solid noise We use this 1D array of random unitvectors to create a (pseudo-)random 3D array of random unitvectors, using the following hashing function: Γ ijk = G(φ(i + φ(j + φ(k)))) where G is our array of n random vectors, and φ(i) = P [i mod n] where P is an array of length n containing a permutation of the integers 0 through n 1.

Hashing 3D stripe textures Texture arrays Solid noise

Hashing 3D stripe textures Texture arrays Solid noise

Perlin noise 3D stripe textures Texture arrays Solid noise Perlin noise is based on the following ideas: Use a 1D array of random unit vectors and hashing to create a virtual 3D array of random vectors; Compute the inner product of (u, v, w)-vectors with the random vectors Use Hermite interpolation to get rid of visible artifacts

Hermite interpolation 3D stripe textures Texture arrays Solid noise With our random vectors and hashing function in place, the noise value n(x, y, z) for a point (x, y, z) is computed as: n(x, y, z) = x +1 y +1 z +1 i= x j= y k= z Ω ijk (x i, y j, z k) where Ω ijk (u, v, w) = ω(u)ω(v)ω(w)(γ ijk (u, v, w)) and ω(t) = { 2 t 3 3 t 2 + 1 if t < 1 0 otherwise

Hermite interpolation 3D stripe textures Texture arrays Solid noise Characteristics of hermite interpolation (or why this creates better noise than linear ): Linear interpolation: linear weights, i.e. ω t Hermite interpolation: cubic weights, i.e. ω t 3

Summary 3D stripe textures Texture arrays Solid noise Perlin noise: Virtual 3D array & hashing Scalar product with random unit vector Hermite interpolation

Outline 1 Linear interpolation Texture mapping 2 3D stripe textures Texture arrays Solid noise 3 Basic idea Spherical mapping Triangles 4 Bump mapping Displacement mapping Environment mapping 3D stripe textures Texture arrays Solid noise

Basic idea Spherical mapping Triangles Now let s look at 2D mapping, which maps an image onto an object (cf. wrapping up a gift) Instead of a procedural, we use a lookup-table approach here, i.e. for each point in our 3D model, we look up the appropriate color value in the image. How do we do this? Again, let s look at some simple examples.

Spherical texture mapping Basic idea Spherical mapping Triangles How do we map a rectangular image onto a sphere?

Spherical texture mapping Basic idea Spherical mapping Triangles Example: use world map and sphere to create a globe

Spherical texture mapping Basic idea Spherical mapping Triangles We have seen the parametric equation of a sphere with radius r and center c: x = x c + r cos φ sin θ y = y c + r sin φ sin θ z = z c + r cos θ Given a point (x, y, z) on the surface of the sphere, we can find θ and φ by θ = arccos z zc r φ = arctan y yc x x c

Spherical texture mapping Basic idea Spherical mapping Triangles For each point (x, y, z) we have θ = arccos z zc r φ = arctan y yc x x c Since both u and v must range from [0, 1], and (θ, φ) [0, π] [ π, π], we must convert: u = v = π θ π φ mod 2π 2π

Texturing triangles Basic idea Spherical mapping Triangles Mapping an image onto a triangle is done by specifying (u, v) coordinates for the vertices. So, our triangle vertices a = (x a, y a ), b = (xb, y b ), c = (x c, y c ) become a = (u a, v a ), b = (u b, v b ), c = (u c, v c ) (0.8, 0.7) (0.1, 0.9) (0.6, 0.1)

Texturing triangles Basic idea Spherical mapping Triangles Remember that barycentric coordinates are very useful for interpolating over a triangle and related textures ;) p(β, γ) = a + β( b a) + γ( c a) (0.8, 0.7) (0.1, 0.9) (0.6, 0.1) now becomes u(β, γ) = u a + β(u b u a ) + γ(u c u a ) v(β, γ) = v a + β(v b v a ) + γ(v c v a ) We get the texture coordinates by linearly interpolating the vertex coordinates over β, γ for 0 β + γ 1.

Texturing triangles Basic idea Spherical mapping Triangles (0.8, 0.7) Again, we can use bilinear interpolation to avoid artifacts. Note that the area and shape of the triangle don t have to match that of the mapped triangle. (0.1, 0.9) (0.6, 0.1) Also, (u, v) coordinates for the vertices may lie outside the range [0, 1] [0, 1].

Texturing triangles Basic idea Spherical mapping Triangles Be careful with perspective, because objects further away appear smaller, so linear interpolation can lead to artifacts: To avoid this, we have to consider the depth of vertices with respect to the viewer. Perspective projection is covered in a later lecture. Fortunately, this is supported by modern hardware and APIs.

MIP-mapping Basic idea Spherical mapping Triangles If viewer is close: Object gets larger Magnify texture Perfect distance: Not always perfect match (misalignment, etc.) If viewer is further away: Object gets smaller Minify texture Problem with minification: efficiency (esp. when whole texture is mapped onto one pixel!)

MIP-mapping Basic idea Spherical mapping Triangles Solutions: MIP maps Pre-calculated, optimized collections of images based on the original texture Dynamically chosen based on depth of object (relative to viewer) Supported by todays hardware and APIs

Outline 1 Linear interpolation Texture mapping 2 3D stripe textures Texture arrays Solid noise 3 Basic idea Spherical mapping Triangles 4 Bump mapping Displacement mapping Environment mapping Basic idea Spherical mapping Triangles

Bump mapping Bump mapping Displacement mapping Environment mapping One of the reasons why we apply texture mapping: Real surfaces are hardly flat but often rough and bumpy. These bumps cause (slightly) different reflections of the light.

Bump mapping Bump mapping Displacement mapping Environment mapping Instead of mapping an image or noise onto an object, we can also apply a bump map, which is a 2D or 3D array of vectors. These vectors are added to the normals at the points for which we do shading calculations. The effect of bump mapping is an apparent change of the geometry of the object.

Bump mapping Displacement mapping Environment mapping Bump mapping Major problems with bump mapping: silhouettes and shadows

Displacement mapping Bump mapping Displacement mapping Environment mapping To overcome this shortcoming, we can use a displacement map. This is also a 2D or 3D array of vectors, but here the points to be shaded are actually displaced. Normally, the objects are refined using the displacement map, giving an increase in storage requirements.

Displacement mapping Bump mapping Displacement mapping Environment mapping

Environment mapping Bump mapping Displacement mapping Environment mapping Let s look at image textures again: If we can map an image of the environment to an object...

Environment mapping Bump mapping Displacement mapping Environment mapping... why not use this to make objects appear to reflect their surroundings specularly? Idea: place a cube around the object, and project the environment of the object onto the planes of the cube in a preprocessing stage; this is our texture map. During rendering, we compute a reflection vector, and use that to look-up texture values from the cubic texture map.

Environment mapping Bump mapping Displacement mapping Environment mapping

Bump mapping Displacement mapping Environment mapping

And now? Bump mapping Displacement mapping Environment mapping In case you didn t notice: it s halftime :)... so let s sit back and have a break before we continue. Lifted, copyrighted by Pixar/Disney (but you find various versions of it on YouTube)

What s next? Bump mapping Displacement mapping Environment mapping The midterm exam! Time and date: Friday, 25.5.11 9:00-12:00 h Zaal: EDUC-GAMMA Note: no responsibility is taken for the correctness of this information. For final information about time and room see http://www.cs.uu.nl/education/vak.php?vak=infogr

The midterm exam Bump mapping Displacement mapping Environment mapping What do I have to do? Come in time Bring a pen (no pencil) Bring your student id And know the answers ;) Note: You may not use books, notes, or any electronic equipment (including cell phones!).

The midterm exam Bump mapping Displacement mapping Environment mapping The exam covers lectures 1-5 and tutorials 1-3. If you...... followed the lectures... read the textbook... and actively did the exercises... you should be fine.

Important dates Bump mapping Displacement mapping Environment mapping Today (Tue, 15.5.) Only one tutorial (room 61) Thu, 17.5. No tutorial and lecture (holiday) Tue, 22.5. Lecture 7 and Thursday tutorial Thu, 24.5. No tutorial(?) and lecture Fri, 25.5. Midterm exam