Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and prof. Han-Wei Shen (Ohio State University). CSC.

Slides:



Advertisements
Similar presentations
Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
Advertisements

Bump Mapping CSE 781 Roger Crawfis.
Texture Mapping I Real-time Rendering Texture Mapping I CSE 781 Prof. Roger Crawfis.
03/16/2009Dinesh Manocha, COMP770 Texturing Surface’s texture: its look & feel Graphics: a process that takes a surface and modifies its appearance using.
Texture Mapping Jian Huang, CS594, Fall 03 This set of slides references the ones used at Ohio State for instruction.
Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and prof. Han-Wei Shen (Ohio State University). CSC.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
3D Graphics Rendering and Terrain Modeling
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
Visual Appearance (Shading & Texture mapping)
Computer Graphics Bing-Yu Chen National Taiwan University.
Texture Visual detail without geometry. Texture Mapping desire for heightened realism.
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 6, 2014 TEXTURE MAPPING TEXTURES BUMP MAPPING ENVIRONMENT MAPPING PROCEDURAL TEXTURING.
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.
Texture mapping. Adds realism to computer graphics Texture mapping applies a pattern of color Bump mapping alters the surface Mapping is cheaper than.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
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: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Computer Graphics Texture Mapping Eriq Muhammad Adams
Computer Graphics Texture Mapping
Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping 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.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
An Interactive Introduction to OpenGL Programming Ed Angel
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
Texture Mapping (cont.) Jian Huang, CS 594, updated in Fall’08.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Texture Mapping (cont.) Jian Huang, CS 594, Fall 2003.
Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Computer Graphics 2 Lecture 7: Texture Mapping Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Computing & Information Sciences Kansas State University Advanced CG 2 of 8: MappingsCIS 636/736: (Introduction to) Computer Graphics CIS 736 Computer.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Texture Mapping Greg Humphreys University of Virginia CS 445, Fall 2003.
Texturing Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.

Week 7 - Monday CS361.
Texture Mapping cgvr.korea.ac.kr.
OpenGL Texture Mapping
So Far We have assumed that we know: The point The surface normal
3D Game Programming Texture Mapping
CS-378: Game Technology Lecture #4: Texture and Other Maps
Texture mapping - other methods
Advanced Computer Graphics: Texture
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Texture Mapping Jung Lee.
Presentation transcript:

Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and prof. Han-Wei Shen (Ohio State University). CSC 830 Computer Graphics Lecture 6 Texture & more

Announcements Term Project Proposal Due – April 14 th (next class) Assignment 4 [Shading] & 5 [texture]

Can you do this …

Texture Mapping Surfaces “in the wild” are very complex Cannot model all the fine variations We need to find ways to add surface detail How?

Texture Mapping Particles and fractals –gave us lots of detail information –not easy to model –mathematically and computationally challenging

Texture Mapping Of course, one can model the exact micro-geometry + material property to control the look and feel of a surface But, it may get extremely costly So, graphics use a more practical approach – texture mapping

Texture Mapping Solution - (its really a cheat!!) How? MAP surface detail from a predefined multi-dimensional table (“texture”) to a simple polygon

Slide Courtesy of Leonard McMillan & Jovan Popovic, MIT

OpenGL functions - demo During initialization read in or create the texture image and place it into the OpenGL state. glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData); Before rendering your textured object, enable texture mapping and tell the system to use this particular texture. glBindTexture (GL_TEXTURE_2D, 13);

OpenGL functions During rendering, give the cartesian coordinates and the texture coordinates for each vertex. glBegin (GL_QUADS); glTexCoord2f (0.0, 0.0); glVertex3f (0.0, 0.0, 0.0); glTexCoord2f (1.0, 0.0); glVertex3f (10.0, 0.0, 0.0); glTexCoord2f (1.0, 1.0); glVertex3f (10.0, 10.0, 0.0); glTexCoord2f (0.0, 1.0); glVertex3f (0.0, 10.0, 0.0); glEnd ();

What happens when outside the 0-1 range? (u,v) should be in the range of 0~1 What happens when you request ( )? –Tile: repeat (OGL); the integer part of the value is dropped, and the image repeats itself across the surface –Mirror: the image repeats itself but is mirrored (flipped) on every other repetition –Clamp to edge – value outside of the range are clamped to this range –Clamp to border – all those outside are rendered with a separately defined color of the border

Methods for modifying surface After a texture value is retrieved (may be further transformed), the resulting values are used to modify one or more surface attributes Called combine functions or texture blending operations –Replace: replace surface color with texture color –Decal: replace surface color with texture color, blend the color with underlying color with an alpha texture value, but the alpha component in the framebuffer is not modified –Modulate: multiply the surface color by the texture color (shaded + textured surface)

Slide Courtesy of Leonard McMillan & Jovan Popovic, MIT Okay, then how can you implement?

Texture and Texel Each pixel in a texture map is called a Texel Each Texel is associated with a (u,v) 2D texture coordinate The range of u, v is [0.0,1.0] due to normalization

(u,v) tuple For any (u,v) in the range of (0-1, 0-1) multiplied by texture image width and height, we can find the corresponding value in the texture map

F How do we get F(u,v)? We are given a discrete set of values: –F[i,j] for i= 0,…,N, j= 0,…,M Nearest neighbor: –F –F(u,v) = F[ round(N*u), round(M*v) ] Linear Interpolation: –i = floor(N*u), j = floor(M*v) –interpolate from F[i,j], F[i +1,j], F[i,j +1 ], F[i +1,j] Filtering in general !

Interpolation Nearest neighborLinear Interpolation

Filtering Textures Footprint changes from pixel to pixel: no single filter Resampling theory: Magnification:Interpolation Minification:Averaging We would like a constant cost per pixel TextureImage Image => Texture Texture => Image

Mip Mapping [Williams] MIP = Multim In Parvo = Many things in a small place G R B R GB d v u Trilinear interpolation

Mip Mapping - Example Courtesy of John hart

Was it working correctly?

No perspective Correction Perspective Correction

Probably the most common form of perspective texturing is done via a divide by Z. Its a very simple algorithm. Instead of interpolate U and V, we instead interpolate U/Z and V/Z. 1/Z is also interpolated. At each pixel, we take our texture co-ords, and divide them by Z. Hang on, you're thinking - if we divide by the same number twice (Z) don't we get back to where we started - like a double reciprocal? Well, sort of. Z is also interpolated, so we're not dividing by the same Z twice. We then take the new U and V values, index into our texture map, and plot the pixel. Pseudo-code might be: su = Screen-U = U/Z sv = Screen-V = V/Z sz = Screen-Z = 1/Z for x=startx to endx u = su / sz v = sv / sz PutPixel(x, y, texture[v][u]) su += deltasu sv += deltasv sz += deltasz end Very simple, and very slow.

Are correct_s & correct_t integer?

Useful links (Google – perspective correct texture) m20.showMessage?topicID=20.topic (Perspective correction with Z-buffering) m20.showMessage?topicID=20.topic p?resourcePath=/dl/proceedings/&toc=comp/proc eedings/cgiv/2005/2392/00/2392toc.xml&DOI= /CGIV (Perspective Correct Normal Vectors for Phong Shading ) p?resourcePath=/dl/proceedings/&toc=comp/proc eedings/cgiv/2005/2392/00/2392toc.xml&DOI= /CGIV map.htmhttp://easyweb.easynet.co.uk/~mrmeanie/tmap/t map.htm

Procedural Texture Periodic Checkerboard Scale: s= 10 If (u * s) % 2=0 && (v * s)%2=0 texture(u,v) = 0; // black Else texture(u,v) = 1; // white

Slide Courtesy of Leonard McMillan & Jovan Popovic, MIT

t

Environment Maps Use texture to represent reflected color Texture indexed by reflection vector Approximation works when objects are far away from the reflective object

Environment Maps Using a spherical environment map Spatially variant resolution

Environment Maps Using a cubical environment map

Environment Mapping Environment mapping produces reflections on shiny objects Texture is transferred in the direction of the reflected ray from the environment map onto the object Reflected ray: R=2(N·V)N- V What is in the map? Object Viewer Reflected ray Environment Map

Approximations Made The map should contain a view of the world with the point of interest on the object as the eye –We can’t store a separate map for each point, so one map is used with the eye at the center of the object –Introduces distortions in the reflection, but the eye doesn’t notice –Distortions are minimized for a small object in a large room The object will not reflect itself The mapping can be computed at each pixel, or only at the vertices

Environment Maps The environment map may take one of several forms: –Cubic mapping –Spherical mapping (two variants) –Parabolic mapping Describes the shape of the surface on which the map “resides” Determines how the map is generated and how it is indexed What are some of the issues in choosing the map?

Example

Refraction Maps Use texture to represent refraction

Opacity Maps Use texture to represent opacity Useful for billboarding

Illumination Maps Use texture to represent illumination footprint

Illumination Maps Quake light maps

Bump Mapping Use texture to perturb normals - creates a bump-like effect + = original surface bump map modified surface Does not change silhouette edges

Bump Mapping Many textures are the result of small perturbations in the surface geometry Modeling these changes would result in an explosion in the number of geometric primitives. Bump mapping attempts to alter the lighting across a polygon to provide the illusion of texture.

Bump Mapping This modifies the surface normals.

Bump Mapping

Consider the lighting for a modeled surface.

Bump Mapping We can model this as deviations from some base surface. The question is then how these deviations change the lighting. N

Bump Mapping Step 1: Putting everything into the same coordinate frame as B(u,v). –x(u,v), y(u,v), z(u,v) – this is given for parametric surfaces, but easy to derive for other analytical surfaces. –Or O(u,v)

Bump Mapping Define the tangent plane to the surface at a point (u,v) by using the two vectors O u and O v. The normal is then given by: N = O u  O v N

Bump Mapping The new surface positions are then given by: O’(u,v) = O(u,v) + B(u,v) N Where, N = N / |N| Differentiating leads to: O’ u = O u + B u N + B (N) u  O’ u = O u + B u N O’ v = O v + B v N + B (N) v  O’ v = O v + B v N If B is small.

Bump Mapping This leads to a new normal: N’(u,v) = O u  O v - B u (N  O v ) + B v (N  O u ) + B u B v (N  N) »= N - B u (N  O v ) + B v (N  O u ) »= N + D N D N’

Bump Mapping For efficiency, can store B u and B v in a 2-component texture map. The cross products are geometry terms only. N’ will of course need to be normalized after the calculation and before lighting. –This floating point square root and division makes it difficult to embed into hardware.

Displacement Mapping Use texture to displace the surface geometry + = Bump mapping only affects the normals, Displacement mapping changes the entire surface (including the silhouette)

3D Textures Use a 3D mapping Usually stored procedurally Can simulate an object carved from a material

3D Textures - Noise Pseudo-random Bandlimited few high or low frequencies Controllable

3D Textures - Noise Create a nD integer-aligned lattice of random numbers For any nDPoint p, noise is defined as: noise(nDPoint p) Find 2 neighbors of p Linearly interpolate neighbors’ table values Return interpolated value

Turbulence Noise with self-similarity Add together many octaves of noise

Turbulence

Animating Turbulence Use an extra dimension as time

Slide Courtesy of Leonard McMillan & Jovan Popovic, MIT