CPSC 314 TEXTURE MAPPING UGRAD.CS.UBC.CA/~cs314 Glen Berseth (Based of Mikhail Bessmeltsev and Dinesh Pai)

Slides:



Advertisements
Similar presentations
Lecture 8 Transparency, Mirroring
Advertisements

Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Graphics Pipeline.
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. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures II Week 8, Wed.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures I Week 8, Mon.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures I Week 9, Wed.
HCI 530 : Seminar (HCI) Damian Schofield.
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)
Texturing, Clipping Week 9, Mon 27 Oct 2003
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
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.
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.
1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures.
Computer Graphics Inf4/MSc Computer Graphics Lecture 7 Texture Mapping, Bump-mapping, Transparency.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
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 고려대학교 컴퓨터 그래픽스 연구실.
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.
Texture Mapping. 2 Motivation A typical modern graphics card can handle 10s of millions of polygons a second. How many individual blades of grass are.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
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.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Computer Graphics 2 Lecture 7: Texture Mapping Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
CHAPTER 8 Color and Texture Mapping © 2008 Cengage Learning EMEA.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures II Week 9, Fri.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
Real-Time Relief Mapping on Arbitrary Polygonal Surfaces Fabio Policarpo Manuel M. Oliveira Joao L. D. Comba.
1Ellen L. Walker 3D Vision Why? The world is 3D Not all useful information is readily available in 2D Why so hard? “Inverse problem”: one image = many.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
MIT EECS 6.837, Durand and Cutler Texture Mapping & Other Fun Stuff.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Textures I Week 9, Fri.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Texture Mapping Greg Humphreys University of Virginia CS 445, Fall 2003.
Mapping: Image Texturing CPSC 591/691. Texture Mapping Two-dimensional techniques place a two-dimensional (flat) image onto an object using methods similar.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Texturing CMSC 435/ What is Texturing? 2 Texture Mapping Definition: mapping a function onto a surface; function can be: – 1, 2, or 3D – sampled.
Texturing Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
- Introduction - Graphics Pipeline
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.
So Far We have assumed that we know: The point The surface normal
Textures II Week 10, Mon Mar 22
Procedural Animation Lecture 6: Mapping
ATCM 6317 Procedural Animation
CS-378: Game Technology Lecture #4: Texture and Other Maps
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
Advanced Computer Graphics: Texture
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

CPSC 314 TEXTURE MAPPING UGRAD.CS.UBC.CA/~cs314 Glen Berseth (Based of Mikhail Bessmeltsev and Dinesh Pai)

PROBLEMS ON ILLUMINATION (whiteboard)

CODING A3 & THEORY A3 Out tonight Coding A3 (due Nov, 6 th ) : Lighting & Shading A bit of texturing Theory A3 (due Oct, 30 th, in class) : Clipping Rasterization Lighting & Shading

SOME HINTS ON THEORY A3

Mathematical representations: Explicit functions Parametric functions Implicit functions SHAPES - CURVES/SURFACES

Curves: y is a function of x: Only works in 2D Surfaces: z is a function of x and y: Cannot define arbitrary shapes in 3D SHAPES: EXPLICIT FUNCTIONS z  sin( x)  cos( y) y  sin (x)

Curves: 2D: x and y are functions of a parameter value t 3D: x, y, and z are functions of a parameter value t SHAPES: PARAMETRIC FUNCTIONS t cos(t) C(t)  sin(t)

Surfaces: Surface S is defined as a function of parameter values s, t Names of parameters can be different to match intuition: SHAPES: PARAMETRIC FUNCTIONS sin(  ) cos(  ) cos(  ) S ( ,    sin(  ) cos(  )

SHAPES: IMPLICIT Surface (3D) or Curve (2D) defined by zero set (roots) of function E.g: S(x, y, z) : x 2  y 2  z 2  1  0

HOW TO INTERSECT ? Two lines in 2D? A line and a plane? A line and a sphere? (Whiteboard)

FACE-TO-FACE GRADING No show = no grade! If you don’t understand something in your own code, we’ll deduct points Your chance to make sure TA marks everything you did

12 WHY IS TEXTURE IMPORTANT?

12 TEXTURE MAPPING real life objects have nonuniform colors, normals to generate realistic objects, reproduce coloring & normal variations = texture can often replace complex geometric details

TEXTURE MAPPING hide geometric simplicity images convey illusion of geometry map a brick wall texture on a flat polygon create bumpy effect on surface usually: associate 2D information with a surface in 3D point on surface ↔ point in texture “paint” image onto polygon

COLOR TEXTURE MAPPING define color (RGB)for each point on object surface other: volumetric texture procedural texture

TEXTURE MAPPING u v (u0,v0)(u0,v0) (u1,v1)(u1,v1) (u2,v2)(u2,v2) (u, v) parameterization sometimes called (s,t)

TEXTURE MAPPING – Questions?

SURFACE TEXTURE u Define texture pattern over (u,v) domain (Image) Image – 2D array of “texels” Assign (u,v) coordinates to each point on object surface How: depends on surface type For polygons (triangle) Inside – use barycentric coordinates For vertices need mapping function (artist/programmer) v

TEXTURE MAPPING EXAMPLE + =

Pause …. --> Math Example

FRACTIONAL TEXTURE COORDINATES (0,0)(0,0)(1,0)(1,0) (0,1)(0,1)(1,1)(1,1) texture image

THREE.JS pass texture as a uniform: "texture.jpg") }}; var uniforms = { texture1: { type: "t", value: THREE.ImageUtils.loadTexture( var material = new THREE.ShaderMaterial( { uniforms, …}); uv will be passed on to the vertex shader (no need to write this) : attribute vec2 uv; use it, e.g., in Fragment Shader: uniform sampler2D texture1; varying vec2 texCoord; vec4 texColor = texture2D(texture1, texCoord);

HOW TO USE COLOR TEXTURES Replace Set fragment color to texture color gl_FragColor = texColor; Modulate Use texture color as reflection color in illumination equation kd = texColor;ka =texColor; gl_FragColor =ka*ia+ kd*id*dotProduct+…;

TEXTURE LOOKUP: TILING AND CLAMPING What if s or t is outside [0…1] ? Multiple choices Use fractional part of texture coordinates Cyclic repetition ( repeat ) Clamp every component to range [0…1] Re-use color values from texture image border

IN THREE.JS var texture= THREE.ImageUtils.loadTexture( "textures/water.jpg" ); texture.wrapS texture.wrapT = THREE.RepeatWrapping; = THREE.ClampToEdgeWrapping; texture.repeat.set(4, 4 );

23 (1,0)(1,0) (0,0)(0,0)(0,1)(0,1) (1,1)(1,1) TILED TEXTURE MAP (4,4)(4,4) (4,0)(4,0) (0,4)(0,4) (0,0)(0,0)

RECONSTRUCTION (image courtesy of Kiriakos Kutulakos, U Rochester)

RECONSTRUCTION how to deal with: pixels that are much larger than texels? minification pixels that are much smaller than texels ? magnification

MIPMAPPING Without MIP-mapping use “image pyramid” to precompute averaged versions of the texture store whole pyramid in single block of memory With MIP-mapping

MIPMAPSMIPMAPS multum in parvo -- many things in a small place prespecify a series of prefiltered texture maps of decreasing resolutions requires more texture storage avoid shimmering and flashing as objects move texture.generateMipmaps = true automatically constructs a family of textures from original texture size down to 1x1 texture.mipmaps[…] withoutwith

MIPMAP STORAGE only1/3more space required

HOW TO INTERPOLATE S,T?

Texture coordinate interpolation Perspective foreshortening problem Also problematic for color interpolation, etc. TEXTURE MAPPING

Screen space interpolation incorrect under perspective Problem ignored with shading, but artifacts more visible with texturing INTERPOLATION:SCREEN VS. WORLD SPACE V 0 (x’,y’) V 1 (x’,y’) P 1 (x,y,z) P 0 (x,y,z)

Screen space interpolation incorrect under perspective Problem ignored with shading, but artifacts more visible with texturing INTERPOLATION:SCREEN VS. WORLD SPACE V 0 (x’,y’) V 1 (x’,y’) P 1 (x,y,z) P 0 (x,y,z)

Preserves order BUT distorts distances PERSPECTIVE - REMINDER        0101 0 1 0 1 0 0 x0 x 100100a0 1100100a0 1 z  z   x  x T y   0 b z eye z eye eye NDC 0  y  z b  z   a  a  a  z ba  z b 

Perspective Correct Interpolation s 0, s 1, s 2 :texture coordinates of vertices , ,  :Barycentric coordinates (2D) of point P w 0, w 1, w 2 : homogenous coordinate of vertices Similarly for t TEXTURE COORDINATE INTERPOLATION (s,t)?   / w 0   / w 1   / w 2 s    s 0 / w 0    s 1 / w 1    s 2 / w 2 ( #, # ) ( #, #, #, # ) ) ( ), ), ), ) ) (, ) ( ), ) ) ( *, *, *, * ) Derivation (similar triangles): /lowk_persp_interp_techrep.pdf

OTHER USES FOR TEXTURES

usually provides colour, but … can also use to control other material/object properties surface normal (bump mapping) reflected color (environment mapping)

BUMP MAPPING: NORMALS AS TEXTURE object surface often not smooth – to recreate correctly need complex geometry model can control shape “effect” by locally perturbing surface normal random perturbation directional change over region

BUMP MAPPING

EMBOSSING at transitions rotate point’s surface normal by θ or - θ

BUMP MAPPING: LIMITATION

Why don’t we modify geometry instead of modifying normals?

DISPLACEMENT MAPPING bump mapping gets silhouettes wrong shadows wrong too change surface geometry instead only recently available with realtime graphics need to subdivide surface /wiki/Displacement_map ping#/media/File:Displacement.jpg

ENVIRONMENT MAPPING cheap way to achieve reflective effect generate image of surrounding map to object as texture

ENVIRONMENT MAPPING used to model object that reflects surrounding textures to the eye movie example: cyborg in Terminator 2 different approaches sphere, cube most popular others possible too

SPHERE MAPPING texture is distorted fish-eye view point camera at mirrored sphere spherical texture mapping creates texture coordinates that correctly index into this texture map

CUBE MAPPING 6 planar textures, sides of cube point camera in 6 different directions, facing out from origin

ACBACB E CUBE MAPPING F D

CUBE MAPPING direction of reflection vector r selects the face of the cube to be indexed co-ordinate with largest magnitude e.g., the vector (-0.2, 0.5, -0.84) selects the –Z face remaining two coordinates select the pixel from the face. difficulty in interpolating across faces

CUBE MAPPING how to calculate? direction of reflection vector r selects the face of the cube to be indexed co-ordinate with largest magnitude e.g., the vector (-0.2, 0.5, -0.84) selects the –Z face remaining two coordinates select the pixel from the face. difficulty in interpolating across faces

ENVIRONMENT MAPS (EM) in theory, every object should have a separate EM in theory, every time something moves, you should re-compute EM “you’ll be surprised at what you can get away with”

VOLUMETRIC TEXTURE define texture pattern over 3D domain - 3D space containing the object texture function can be digitized or procedural for each point on object compute texture from point location in space e.g., ShaderToy computing is cheap, memory access is expensive !

PROCEDURAL TEXTURE EFFECTS: BOMBING randomly drop bombs of various shapes, sizes and orientation into texture space (store data in table) for point P search table and determine if inside shape if so, color by shape’s color otherwise, color by object’s color

PERLIN NOISE: PROCEDURAL TEXTURES several good explanations

PERLIN NOISE: TURBULENCE multiple feature sizes add scaled copies of noise

PERLIN NOISE: TURBULENCE multiple feature sizes add scaled copies of noise

THE RENDERING PIPELINE Vertex Shader Vertex Post- Processing Rasterization Per-Sample Operations Framebuffe r Vertice s and attributes Modelview transform Interpolation Per-vertex attributes Clipping Viewport transform Scan conversion Fragment Shader Texturing/... Lighting/shading Depth test Blending

SHADOWS

Need at least 2 shader passes: 1.Draw everything as it’s viewed from the LIGHT SOURCE

SHADOWS Need at least 2 shader passes: 1.Draw everything as it’s viewed from the LIGHT SOURCE Depth per pixel (‘depth map’)

SHADOWS (IDEA) Need at least 2 shader passes: 1.Draw everything as it’s viewed from the LIGHT SOURCE Depth per pixel (‘depth map’). 2.Now draw everything from CAMERA When computing color per pixel: Find corresponding depth map pixel: D - distance from light source Is distance from me to the camera > D? Yes: I am occluded! I’m in SHADOW. No: I’m LIT!

SHADOWS (IDEA) Need at least 2 shader passes: 1.Draw everything as it’s viewed from the LIGHT SOURCE Depth per pixel (‘depth map’). 2.Now draw everything from CAMERA When computing color per pixel: Find corresponding depth map pixel: D - distance from light source Is distance from me to the camera > D? Yes: I am occluded! I’m in SHADOW. No: I’m LIT!