University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures II Week 9, Fri.

Slides:



Advertisements
Similar presentations
Graphics Pipeline.
Advertisements

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.
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
Computer Graphics Bing-Yu Chen National Taiwan University.
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 6, 2014 TEXTURE MAPPING TEXTURES BUMP MAPPING ENVIRONMENT MAPPING PROCEDURAL TEXTURING.
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 Viewing/Projections I.
Textures, Procedural Approaches, Sampling Week 4, Thu Jun 2
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures III, Procedural.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures I Week 9, Wed.
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
Texturing, Clipping Week 9, Mon 27 Oct 2003
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility II Week 7,
Texture mapping. Adds realism to computer graphics Texture mapping applies a pattern of color Bump mapping alters the surface Mapping is cheaper than.
OpenGL Texture Mapping
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
OpenGL Texture Mapping April 16, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Basic Stragegy Three steps to applying a texture.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Hidden Surfaces III Week.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
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.
1 Texture. 2 Overview Introduction Painted textures Bump mapping Environment mapping Three-dimensional textures Functional textures Antialiasing textures.
CSE 381 – Advanced Game Programming Basic 3D Graphics
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
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,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Textures III Week 10,
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
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.
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.
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
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 Procedural Approaches.
Vector Graphics Digital Multimedia Chap 이병희
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Procedural Approaches.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Procedural II, Collision.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures III, Procedural.
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.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Textures I Week 9, Fri.
Module 05 –Bump mapping Module 05 – Bump mapping Module 05 Advanced mapping techniques: Bump mapping.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Texture Mapping Greg Humphreys University of Virginia CS 445, Fall 2003.
CPSC 314 TEXTURE MAPPING UGRAD.CS.UBC.CA/~cs314 Glen Berseth (Based of Mikhail Bessmeltsev and Dinesh Pai)
Recap Last lecture we looked at local shading models –Diffuse and Phong specular terms –Flat and smooth shading Some things were glossed over –Light source.

© University of Wisconsin, CS559 Spring 2004
OpenGL Texture Mapping
© University of Wisconsin, CS559 Fall 2004
(c) University of Wisconsin, CS 559
3D Game Programming Texture Mapping
Textures II Week 10, Mon Mar 22
Advanced Computer Graphics: Texture
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Texture Mapping Jung Lee.
OpenGL Texture Mapping
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Textures II Week 9, Fri Mar 16

2 Reading for Last Time and Today FCG Chap 11 Texture Mapping except 11.8 RB Chap Texture Mapping FCG Sect 16.6 Procedural Techniques FCG Sect 16.7 Groups of Objects

3 Corrected Correction: HSI/HSV and RGB HSV/HSI conversion from RGB hue same in both value is max, intensity is average HSI: HSV:

4 News H3 Q2: OK to use either HSV or HSI

5 News Project 3 grading slot signup Mon Tue 10-12:30, 4-6 Wed 11-12, 2:30-4

6 Review: Back-face Culling y z eye VCS NDCS eye works to cull if y z

7 Review: Invisible Primitives why might a polygon be invisible? polygon outside the field of view / frustum solved by clipping polygon is backfacing solved by backface culling polygon is occluded by object(s) nearer the viewpoint solved by hidden surface removal

8 Review: Texture Coordinates texture image: 2D array of color values (texels) assigning texture coordinates (s,t) at vertex with object coordinates (x,y,z,w) use interpolated (s,t) for texel lookup at each pixel use value to modify a polygon’s color or other surface property specified by programmer or artist glTexCoord2f(s,t) glVertexf(x,y,z,w)

9 glTexCoord2d(1, 1); glVertex3d (x, y, z); (1,0) (0,0)(0,1) (1,1) Review: Tiled Texture Map glTexCoord2d(4, 4); glVertex3d (x, y, z); (4,4) (0,4) (4,0) (0,0)

10 Review: Fractional Texture Coordinates (0,0)(1,0) (0,1)(1,1) (0,0)(.25,0) (0,.5) (.25,.5) texture image

11 Review: Texture action when s or t is outside [0…1] interval tiling clamping functions replace/decal modulate blend texture matrix stack glMatrixMode( GL_TEXTURE );

12 Texturing II

13 Texture Pipeline Texel color (0.9,0.8,0.7) (x, y, z) Object position (-2.3, 7.1, 17.7) (s, t) Parameter space (0.32, 0.29) Texel space (81, 74) (s’, t’) Transformed parameter space (0.52, 0.49) Final color (0.45,0.4,0.35) Object color (0.5,0.5,0.5)

14 Texture Objects and Binding texture object an OpenGL data type that keeps textures resident in memory and provides identifiers to easily access them provides efficiency gains over having to repeatedly load and reload a texture you can prioritize textures to keep in memory OpenGL uses least recently used (LRU) if no priority is assigned texture binding which texture to use right now switch between preloaded textures

15 Basic OpenGL Texturing create a texture object and fill it with texture data: glGenTextures(num, &indices) to get identifiers for the objects glBindTexture(GL_TEXTURE_2D, identifier) to bind following texture commands refer to the bound texture glTexParameteri(GL_TEXTURE_2D, …, …) to specify parameters for use when applying the texture glTexImage2D(GL_TEXTURE_2D, ….) to specify the texture data (the image itself) enable texturing: glEnable(GL_TEXTURE_2D) state how the texture will be used: glTexEnvf(…) specify texture coordinates for the polygon: use glTexCoord2f(s,t) before each vertex: glTexCoord2f(0,0); glVertex3f(x,y,z);

16 Low-Level Details large range of functions for controlling layout of texture data state how the data in your image is arranged e.g.: glPixelStorei(GL_UNPACK_ALIGNMENT, 1) tells OpenGL not to skip bytes at the end of a row you must state how you want the texture to be put in memory: how many bits per “pixel”, which channels,… textures must be square and size a power of 2 common sizes are 32x32, 64x64, 256x256 smaller uses less memory, and there is a finite amount of texture memory on graphics cards ok to use texture template sample code for project 4

17 Texture Mapping texture coordinates specified at vertices glTexCoord2f(s,t); glVertexf(x,y,z); interpolated across triangle (like R,G,B,Z) …well not quite!

18 Texture Mapping texture coordinate interpolation perspective foreshortening problem

19 Interpolation: Screen vs. World Space screen space interpolation incorrect problem ignored with shading, but artifacts more visible with texturing P 1 (x,y,z) V 0 (x’,y’) V 1 (x’,y’) P 0 (x,y,z)

20 Texture Coordinate Interpolation perspective correct interpolation , ,  : barycentric coordinates of a point P in a triangle s0, s1, s2 : texture coordinates of vertices w0, w1,w2 : homogeneous coordinates of vertices (s1,t1) (s0,t0) (s2,t2) (x1,y1,z1,w1) (x0,y0,z0,w0) (x2,y2,z2,w2)  (s,t)?

21 Reconstruction how to deal with: pixels that are much larger than texels? apply filtering, “averaging” pixels that are much smaller than texels ? interpolate

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

23 MIPmaps 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 gluBuild2DMipmaps automatically constructs a family of textures from original texture size down to 1x1 withoutwith

24 MIPmap storage only 1/3 more space required

25 Texture Parameters in addition to color can control other material/object properties surface normal (bump mapping) reflected color (environment mapping)

26 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

27 Bump Mapping

28 Bump Mapping

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

30 Displacement Mapping bump mapping gets silhouettes wrong shadows wrong too change surface geometry instead only recently available with realtime graphics need to subdivide surface

31 Environment Mapping cheap way to achieve reflective effect generate image of surrounding map to object as texture

32 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 OpenGL support GL_SPHERE_MAP, GL_CUBE_MAP others possible too

33 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

34 Cube Mapping 6 planar textures, sides of cube point camera in 6 different directions, facing out from origin

35 Cube Mapping A B C E F D

36 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 (normalized by the 3 rd coordinate) selects the pixel from the face. e.g., (-0.2, 0.5) gets mapped to (0.38, 0.80). difficulty in interpolating across faces

37 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 common for natural material/irregular textures (stone, wood,etc…)

38 Volumetric Bump Mapping Marble Bump

39 Volumetric Texture Principles 3D function   x,y,z) texture space – 3D space that holds the texture (discrete or continuous) rendering: for each rendered point P(x,y,z) compute   x,y,z) volumetric texture mapping function/space transformed with objects

40 Procedural Textures generate “image” on the fly, instead of loading from disk often saves space allows arbitrary level of detail

41 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 otherwise, color by objects color

42 Procedural Texture Effects simple marble function boring_marble(point) x = point.x; return marble_color(sin(x)); // marble_color maps scalars to colors

43 Perlin Noise: Procedural Textures several good explanations FCG Section

44 Perlin Noise: Coherency smooth not abrupt changes coherent white noise

45 Perlin Noise: Turbulence multiple feature sizes add scaled copies of noise

46 Perlin Noise: Turbulence multiple feature sizes add scaled copies of noise

47 Perlin Noise: Turbulence multiple feature sizes add scaled copies of noise function turbulence(p) t = 0; scale = 1; while (scale > pixelsize) { t += abs(Noise(p/scale)*scale); scale/=2; } return t;

48 Generating Coherent Noise just three main ideas nice interpolation use vector offsets to make grid irregular optimization sneaky use of 1D arrays instead of 2D/3D one

49 Interpolating Textures nearest neighbor bilinear hermite

50 Vector Offsets From Grid weighted average of gradients random unit vectors

51 Optimization save memory and time conceptually: 2D or 3D grid populate with random number generator actually: precompute two 1D arrays of size n (typical size 256) random unit vectors permutation of integers 0 to n-1 lookup g(i, j, k) = G[ ( i + P[ (j + P[k]) mod n ] ) mod n ]

52 Perlin Marble use turbulence, which in turn uses noise: function marble(point) x = point.x + turbulence(point); return marble_color(sin(x))

53 Procedural Approaches

54 Procedural Modeling textures, geometry nonprocedural: explicitly stored in memory procedural approach compute something on the fly often less memory cost visual richness fractals, particle systems, noise

55 Fractal Landscapes fractals: not just for “showing math” triangle subdivision vertex displacement recursive until termination condition

56 Self-Similarity infinite nesting of structure on all scales

57 Fractal Dimension D = log(N)/log(r) N = measure, r = subdivision scale Hausdorff dimension: noninteger D = log(N)/log(r) D = log(4)/log(3) = 1.26 coastline of Britain Koch snowflake

58 Language-Based Generation L-Systems: after Lindenmayer Koch snowflake: F :- FLFRRFLF F: forward, R: right, L: left Mariano’s Bush: F=FF-[-F+F+F]+[+F-F-F] } angle 16

59 1D: Midpoint Displacement divide in half randomly displace scale variance by half

60 2D: Diamond-Square diamond step generate a new value at square midpoint average corner values + random amount gives diamonds when have multiple squares in grid square step generate new value at diamond midpoint average corner values + random amount gives squares again in grid