Texture mapping. Computer Graphics CSE 167 Lecture 9

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

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

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

CSE 167: Lecture 11: Textures 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

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

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

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

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2014

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

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Computer Graphics. Lecture 8 Antialiasing, Texture Mapping

3D Rasterization II COS 426

Computer Graphics 7 - Texture mapping, bump mapping and antialiasing

CS GPU and GPGPU Programming Lecture 12: GPU Texturing 1. Markus Hadwiger, KAUST

Texture Mapping and Sampling

CS GPU and GPGPU Programming Lecture 11: GPU Texturing 1. Markus Hadwiger, KAUST

CS GPU and GPGPU Programming Lecture 16+17: GPU Texturing 1+2. Markus Hadwiger, KAUST

CPSC / Texture Mapping

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

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

TEXTURE MAPPING. DVA338 Computer Graphics Thomas Larsson, Afshin Ameri

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

Texture and other Mappings

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

Textures. Texture coordinates. Introduce one more component to geometry

Overview. Goals. MipMapping. P5 MipMap Texturing. What are MipMaps. MipMapping in OpenGL. Generating MipMaps Filtering.

CT5510: Computer Graphics. Texture Mapping

CS 354R: Computer Game Technology

Computer Graphics. - Texturing Methods -

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

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

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

INF3320 Computer Graphics and Discrete Geometry

Sampling, Aliasing, & Mipmaps

Texture Mapping. Michael Kazhdan ( /467) HB Ch. 14.8,14.9 FvDFH Ch. 16.3, , 16.6

Texture Mapping. Computer Graphics, 2015 Lecture 9. Johan Nysjö Centre for Image analysis Uppsala University

Texture Mapping 1/34

CS 428: Fall Introduction to. Texture mapping and filtering. Andrew Nealen, Rutgers, /18/2010 1

INF3320 Computer Graphics and Discrete Geometry

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

Sampling, Aliasing, & Mipmaps

Perspective Projection and Texture Mapping

Programming Graphics Hardware

lecture 18 - ray tracing - environment mapping - refraction

Textures and normals in ray tracing

CS 130 Final. Fall 2015

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

Texture Mapping 1/34

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

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

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

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

Mattan Erez. The University of Texas at Austin

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

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

-=Catmull's Texturing=1974. Part I of Texturing

Sampling, Aliasing, & Mipmaps

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

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

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

Barycentric Coordinates and Parameterization

Lecture 07: Buffers and Textures

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Mipmaps. Lecture 23 Subsection Fri, Oct 30, Hampden-Sydney College. Mipmaps. Robb T. Koether. Discrete Sampling.

Texture Mapping. Mike Bailey.

CSE 167: Lecture #17: Volume Rendering. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Computer Graphics Texture Mapping

Surface Rendering. Surface Rendering

CSE 167: Introduction to Computer Graphics Lecture #18: More Effects. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

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.

AMCS / CS 247 Scientific Visualization Lecture 10: (GPU) Texture Mapping. Markus Hadwiger, KAUST

Lecture 6: Texture. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

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

CS 431/636 Advanced Rendering Techniques

Texture Mapping and Special Effects

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

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

Einführung in Visual Computing

03 RENDERING PART TWO

The Rasterizer Stage. Texturing, Lighting, Testing and Blending

CSE 167: Introduction to Computer Graphics Lecture #19: Wrapping Up. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

CS 5600 Spring

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

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Magnification and Minification

Evolution of GPUs Chris Seitz

Pipeline Operations. CS 4620 Lecture 10

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

Shading. Flat shading Gouraud shading Phong shading

Topics and things to know about them:

Rasterization Overview

More Texture Mapping. Texture Mapping 1/46

Texture Mapping. Brian Curless CSE 457 Spring 2016

Mattan Erez. The University of Texas at Austin

Computer Graphics. - Texturing - Philipp Slusallek

RASTERISED RENDERING

Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E.

Transcription:

Texture mapping Computer Graphics CSE 167 Lecture 9

CSE 167: Computer Graphics Texture Mapping Overview Interpolation Wrapping Texture coordinates Anti aliasing Mipmaps Other mappings Including bump mapping CSE 167, Winter 2018 2

Large triangles Advantages Often sufficient for simple geometry Fast to render Disadvantages Per vertex colors look boring and computergenerated Based on slides courtesy of Jurgen Schulze CSE 167, Winter 2018 3

Texture mapping Map textures (images) onto surface polygons Same triangle count, much more realistic appearance CSE 167, Winter 2018 4

Texture mapping Objective: map locations in texture to locations on 3D geometry Texture coordinate space Texture pixels (texels) have texture coordinates (s,t) Convention Bottom left corner of texture is at (s,t) = (0,0) Top right corner is at (s,t) = (1,1) (1,1) t (0,0) s Texture coordinates CSE 167, Winter 2018 5

Texture mapping Store 2D texture coordinates s,t with each triangle vertex v 1 (s,t) = (0.65,0.75) (0.65,0.75) (1,1) v 0 (s,t) = (0.6,0.4) t (0.4,0.45) (0.6,0.4) v 2 (s,t) = (0.4,0.45) Triangle in any space before projection (0,0) Texture coordinates s CSE 167, Winter 2018 6

Texture mapping Each point on triangle gets color from its corresponding point in texture (1,1) v 1 (s,t) = (0.65,0.75) v 0 (s,t) = (0.6,0.4) t (0.4,0.45) (0.65,0.75) (0.6,0.4) v 2 (s,t) = (0.4,0.45) Triangle in any space before projection (0,0) Texture coordinates s CSE 167, Winter 2018 7

Primitives Modeling and viewing transformation Shading Projection Rasterization Texture mapping Fragment processing Includes texture mapping Frame-buffer access (z-buffering) Image CSE 167, Winter 2018 8

Texture look up Given texture coordinates (s,t) at current pixel Closest four texels in texture space are at (s 0,t 0 ), (s 1,t 0 ), (s 0,t 1 ), (s 1,t 1 ) How to compute pixel color? Interpolate t 1 t t 0 s 0 s s 1 CSE 167, Winter 2018 9

Nearest neighbor interpolation Use color of closest texel t 1 t t 0 s 0 s s 1 Simple, but low quality and aliasing CSE 167, Winter 2018 10

Bilinear interpolation 1. Linear interpolation horizontally Ratio in s direction is c top = tex(s 0,t 1 ) (1 r s ) + tex(s 1,t 1 ) r s c bot = tex(s 0,t 0 ) (1 r s ) + tex(s 1,t 0 ) r s 2. Linear interpolation vertically Ratio in t direction is c = c bot (1 r t ) + c top r t r s r t s s t t 1 1 s s t t 0 0 0 0 t 1 c top t c bot t 0 s 0 s s 1 t 1 c top c t c bot t 0 s 0 s s 1 CSE 167, Winter 2018 11

Interpolation OpenGL Nearest neighbor Bilinear GL_NEAREST: Nearest neighbor interpolation GL_LINEAR: Bilinear interpolation CSE 167, Winter 2018 12

Wrapping Texture image extends from [0,0] to [1,1] in texture space What if (s,t) texture coordinates are beyond that range? Wrap Repeat (and optionally mirror) texture Clamp texture CSE 167, Winter 2018 13

Wrapping: repeat Repeat the texture Creates discontinuities at edges, unless texture is designed to line up (1,1) t (0,0) s Seamless brick wall texture (by Christopher Revoir) Texture Space CSE 167, Winter 2018 14

Wrapping: clamp Use edge or specified color everywhere outside data range [0..1] (1,1) t (0,0) s Texture Space CSE 167, Winter 2018 15

Wrapping Repeat Repeat and mirror Clamp to edge color Clamp to specified color OpenGL GL_REPEAT GL_MIRRORED_REPEAT GL_CLAMP_TO_EDGE: repeats last pixel in the texture GL_CLAMP_TO_BORDER: requires setting border color CSE 167, Winter 2018 16

Texture coordinates What if texture extends across multiple polygons? Parameterize surface Mapping between 3D positions on surface and 2D texture coordinates Defined by texture coordinates of triangle vertices Example mappings Cylindrical Spherical Orthographic Cube Parametric Skin CSE 167, Winter 2018 17

Texture atlas charts atlas surface [Sander2001] CSE 167, Winter 2018 18

Skin mapping CSE 167, Winter 2018 19

Skin mapping CSE 167, Winter 2018 20

Skin mapping [Piponi2000] CSE 167, Winter 2018 21

Skin mapping CSE 167, Winter 2018 22

Orthographic mapping Use linear transformation of object s XYZ coordinates CSE 167, Winter 2018 23 w z y x t s 0 0 1 0 0 0 0 1 xyz in object space xyz in camera space

Planar mapping CSE 167, Winter 2018 24

Planar mapping CSE 167, Winter 2018 25

Spherical mapping Use spherical coordinates Shrink wrap sphere to object Texture map Mapping result CSE 167, Winter 2018 26

Spherical mapping CSE 167, Winter 2018 27

Spherical mapping CSE 167, Winter 2018 28

Cylindrical mapping Similar to spherical mapping, but with cylindrical coordinates CSE 167, Winter 2018 29

Cylindrical mapping CSE 167, Winter 2018 30

Spherical and cylindrical mapping spherical cylindrical CSE 167, Winter 2018 31

Multiple mappings Complex objects CSE 167, Winter 2018 32

Cube mapping CSE 167, Winter 2018 33

Cube mapping CSE 167, Winter 2018 34

Cube mapping CSE 167, Winter 2018 35

Parametric mapping Surface given by parametric functions Very common in CAD Clamp (u,v) parameters to [0..1] and use as texture coordinates (s,t) CSE 167, Winter 2018 36

Aliasing What could cause this aliasing effect? CSE 167, Winter 2018 37

Aliasing Sufficiently sampled, no aliasing Insufficiently sampled, aliasing Image: Robert L. Cook High frequencies in the input data can appear as lower frequencies in the sampled signal CSE 167, Winter 2018 38

Antialiasing: Intuition Pixel may cover large area on triangle in camera space Corresponds to many texels in texture space Need to compute average Image plane Camera space Texture space Texels Pixel area CSE 167, Winter 2018 39

Antialiasing using MIP maps Averaging over texels is expensive Many texels as objects get smaller Large memory access and computation cost Precompute filtered (averaged) textures Texture at multiple resolutions Practical solution to aliasing problem Fast and simple Available in OpenGL, implemented in GPUs Reasonable quality CSE 167, Winter 2018 40

MIP maps (mipmaps) MIP stands for multum in parvo (much in little) (Williams 1983) Before rendering Precompute and store down scaled versions of textures Reduce resolution by factors of two successively Use high quality filtering (averaging) scheme Increases memory cost by 1/3 1/3 = ¼+1/16+1/64+ Width and height of texture should be powers of two (non power of two supported since OpenGL 2.0) CSE 167, Winter 2018 41

Mipmaps Example: resolutions 512x512, 256x256, 128x128, 64x64, 32x32 pixels Level 1 Level 0 4 3 2 CSE 167, Winter 2018 42

Mipmaps One texel in level 4 is the average of 44=256 texels in level 0 Level 1 Level 0 4 3 2 CSE 167, Winter 2018 43

Mipmaps Level 0 Level 1 Level 2 Level 3 Level 4 CSE 167, Winter 2018 44

Rendering with mipmaps Mipmapping Interpolate texture coordinates of each pixel as without mipmapping Compute approximate size of pixel in texture space Look up color in nearest mipmap E.g., if pixel corresponds to 10x10 texels use mipmap level 3 Use interpolation as before CSE 167, Winter 2018 45

Image plane Mipmapping Camera space Texture space Texels Pixel area Mip-map level 0 Mip-map level 1 Mip map level 2 Mip map level 3 CSE 167, Winter 2018 46

Nearest mipmap, nearest neighbor interpolation Visible transition between mipmap levels CSE 167, Winter 2018 47

Nearest mipmap, bilinear interpolation Visible transition between mipmap levels CSE 167, Winter 2018 48

Trilinear mipmapping Use two nearest mipmap levels E.g., if pixel corresponds to 10x10 texels, use mipmap levels 3 (8x8) and 4 (16x16) 2 Step approach: 1. Perform bilinear interpolation in both mip maps 2. Linearly interpolate between the results Requires access to 8 texels for each pixel Supported by hardware without performance penalty CSE 167, Winter 2018 49

Anisotropic filtering Method of enhancing the image quality of textures on surfaces that are at oblique viewing angles Different degrees or ratios of anisotropic filtering can be applied The degree refers to the maximum ratio of anisotropy supported by the filtering process. For example, 4:1 anisotropic filtering supports presampled textures up to four times wider than tall CSE 167, Winter 2018 50

Mipmaps in OpenGL Mipmapping tutorial with source code http://www.videotutorialsrock.com/opengl_tutorial /mipmapping/text.php CSE 167, Winter 2018 51

Bump mapping Texture = change in surface normal Sphere w/ diffuse texture Swirly bump map Sphere w/ diffuse texture and swirly bump map CSE 167, Winter 2018 52

Displacement mapping CSE 167, Winter 2018 53

Displacement map base surface hand-painted displacement map (detail) Paweł Filip tolas.wordpress.com displaced surface CSE 167, Winter 2018 54

Illumination maps Quake introduced illumination maps or light maps to capture lighting effects in video games Texture map: Light map Texture map + light map: CSE 167, Winter 2018 55

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 CSE 167, Winter 2018 56

Environment map CSE 167, Winter 2018 57

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