Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

Similar documents
Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

CS212. OpenGL Texture Mapping and Related

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

CT5510: Computer Graphics. Texture Mapping

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

ก ก ก.

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

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

Lecture 07: Buffers and Textures

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

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

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

Texture Mapping CSCI 4229/5229 Computer Graphics Fall 2016

Texture Mapping. Mike Bailey.

Texture Mapping and Sampling

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

CS 432 Interactive Computer Graphics

Lighting and Texturing

Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or

CMSC 425: Lecture 12 Texture Mapping Thursday, Mar 14, 2013

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

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

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

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CS452/552; EE465/505. Texture Mapping in WebGL

Computer Graphics. Bing-Yu Chen National Taiwan University

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

Assignment #5: Scalar Field Visualization 3D: Direct Volume Rendering

INF3320 Computer Graphics and Discrete Geometry

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

Steiner- Wallner- Podaras

9.Texture Mapping. Chapter 9. Chapter Objectives

Imaging and Raster Primitives

+ = Texturing: Glue n-dimensional images onto geometrical objects. Texturing. Texture magnification. Texture coordinates. Bilinear interpolation

Most device that are used to produce images are. dots (pixels) to display the image. This includes CRT monitors, LCDs, laser and dot-matrix

Lecture 5. Scan Conversion Textures hw2

Texture Mapping. Texture Mapping. Map textures to surfaces. Trompe L Oeil ( Deceive the Eye ) The texture. Texture map

Texture and other Mappings

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

Discussion 3. PPM loading Texture rendering in OpenGL

Computer Graphics

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

Computational Strategies

Computergraphics Exercise 15/ Shading & Texturing

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

Lecture 5 3D graphics part 3

Computer Graphics Texture Mapping

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

Grafica Computazionale

Shading. Flat shading Gouraud shading Phong shading

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

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

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

Assignment #3: Scalar Field Visualization 3D: Cutting Plane, Wireframe Iso-surfacing, and Direct Volume Rendering

Texture. No Textures

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

CS 130 Final. Fall 2015

Page 6 PROCESSOR PROCESSOR FRAGMENT FRAGMENT. texy[1] texx. texy[1] texx. texy[0] texy[0]

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Shading/Texturing. Dr. Scott Schaefer

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

INF3320 Computer Graphics and Discrete Geometry

QUESTION 1 [10] 2 COS340-A October/November 2009

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

Texture Mapping and Special Effects

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

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

Department of Computer Sciences Graphics Spring 2013 (Lecture 19) Bump Maps

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

CS179: GPU Programming

LSU EE Homework 3 Solution Due: 12 October 2015

General Purpose computation on GPUs. Liangjun Zhang 2/23/2005

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC

Texture mapping. Computer Graphics CSE 167 Lecture 9

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Computer Graphics Texture Mapping

Magnification and Minification

Image I/O and OpenGL Textures

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

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.

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

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

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

Textures. Datorgrafik 2006

3D Rasterization II COS 426

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

lecture 16 Texture mapping Aliasing (and anti-aliasing)

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

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

IntMu.Lab5. Download all the files available from

OpenGL & Visualization

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

Screen Space & World Space

Methodology for Lecture

Transcription:

Graphics Texture Mapping 고려대학교컴퓨터그래픽스연구실

3D Rendering Pipeline 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Viewing Coordinates Projection Transformation 2D Projection Coordinates Clipping 2D Projection Coordinates Viewport Transformation 2D Device Coordinates Scan Conversion Image 2D Device Coordinates Surface details can be added...

Texture Surface Add visual detail to surfaces of 3D objects With Surface Texture Polygonal Model

Texture Mapping 2D projective transformation Texture coordinate system (s, t) to Device coordinate system (x, y)

2D Texture Texture map as a continuous (s, t) coordinate space [0,1] For mapping it into a discrete texture image space Texture Map Texture Image

Textures Color variation in interior of 3D polygon When scan converting a polygon Vary pixel colors according to values fetched from a texture t Texture-Surface Transformation y y s Viewing and Projection Transformation s Texture Space z Object Space x x s Image Space

Texels and Textures Texels texture elements Texture coordinates (s, t) s = f t = g ( x, y, z) ( x, y, z)

Texture Mapping Overview Steps: Define texture Specify mapping from texture to surface Lookup texture values during scan conversion (0, 1) t s Texture Coordinate System v (0, 0) u Modeling Coordinate System (1, 0) y x Device Coordinate System

Texture Mapping Process Scan conversion Interpolate texture coordinates Distortion due to the bilinear interpolation Subdivide the polygon into smaller ones α (u 1, v 1 ) γ β (u 2, v 2 ) (u 3, v 3 )

Texture Mapping : Artifact of Linear Interpolation Linear Interpolation of Texture Coordinate Corrected Interpolation

Texture Modulation Texture Shaded Color Texture Value

Mipmap Problem Some objects can be too far or too small to be rendered with full-scale texture without any texture artifacts Mipmap Artifacts occur due to sparse texture sampling A collection of textures which are pre-calculated to reduce the artifacts Each level have a half size of the previous level Far or small objects will use smaller mipmap texture While close or large objects will use higher resolution of mipmap

Mipmap Construction Example

Mipmap Effect Without Mipmap With Mipmap

Normal Mapping Overview So called bump mapping Perturbs surface normal vectors

Normal Mapping Normal information can be stored in a RGB image (x, y, z) to (R, G, B) respectively The textures with normal information Can be used to add details to the surface rendered result

Normal Mapping Example (1/3)

Normal Mapping Example (2/3)

Normal Mapping Example (3/3)

Environment Mapping Maps a surrounding environment texture Around a surface of an object To approximate effects like reflection or refraction View dependant Due to reflective mapping process Not need to assign texture coordinates to a model Since surface normals are used to map the environment texture

2 Kinds of Environment Mapping (1/2) Spherical environment mapping Efficient use of texture memory Poor distribution of texels per solid angle Cannot linearly interpolate between texture coordinates Particularly near the edge of the map Map is only valid for one viewer direction Cubic environment mapping A slower technique compared to spherical mapping Unless hardware accelerated Uses more memory than sphere mapping But gains in lower CPU usage Independent of viewing position

2 Kinds of Environment Mapping (2/2) Spherical Cubic

Environment Mapping

Constructing a Texture Map Steps: Read an image for the texture map Define parameters that determine how the texture should be applied Define texture coordinates for the vertices ex) making the image into a 2D texture map GLubyte myimage[64][64][3]; glenable(gl_texture_2d); glteximage2d(gl_texture_2d, 0, 3, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, myimage);

1D, 2D, & 3D Texture Maps void glteximage1d(glenum target, GLint level, GLint iformat, GLsizei width, GLint border, GLenum format, GLenum type, Glvoid *texels); void glteximage2d(glenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, Glvoid *texels); void glteximage3d(glenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, Glsizei depth, GLint border, GLenum format, GLenum type, Glvoid *texels);

2D Texture Map 2D texture function void glteximage2d(glenum target, GLint level, GLint internalformat, Glsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* texels); Defines a texture image on 2D target GL_TEXTURE_2D Only level Level of detail. 0 if there are no Mipmaps internalformat format of texel data width, height Width and height of the texture image Border The width of the border format Format of pixel data type Data type of the pixel data texels A pointer to the image data in memory

Texture Map Internal Format constants Type constants The name of constants meaning The name of constants meaning GL_RGBA R, G, B, A GL_UNSIGNED_BYTE unsigned 8 bit integer GL_RGB R, G, B GL_BYTE signed 8 bit integer GL_ALPHA A GL_UNSIGNED_SHORT unsigned 16 bit integer GL_LUMINANCE Intensity GL_SHORT signed 16 bit integer GL_LUMINANCE_ALPHA Intensity, A GL_INT signed 32 bit integer GL_FLOAT single precision float Format constants The name of constants GL_COLOR_INDEX GL_RGB GL_RGBA GL_RED GL_GREEN GL_BLUE GL_ALPHA meaning Color index R, G, B value R, G, B, value Red value Green value Blue value Alpha value

Texture Map Generating the texture name void glgentextures(glsizei n, GLuint* texturenames); Generates the texture name to identify from others. n The number of the texture texturenames Array for texture name unsigned int texturenames[3]; glgentextures(3, texturename);

Texture Map The use of texture void glbindtexture(glsizei target, GLuint texturename); Binds the texture name Select texture you want to use among some textures Target GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D texturename Texture name

Texture Map Texture function void gltexenvf(glenum target, GLenum pname, GLint param) target pname param A texture environment. Must be GL_TEXTURE_ENV The symbolic name of a single-valued texture environment parameter. Must be GL_TEXTURE_ENV_MODE Parameter value PARAM GL_BLEND GL_DECAL GL_MODULATE GL_REPLACE meaning Blended with environment color The object color totally depends on the texture color The computed surface color is multiplied by the texture color Just draw the surface using the texture colors only gltexenvi(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_DECAL)

Texture Parameters Preimage of the pixel Texture mapping is not really applied to the surface But rather a pixel in screen Magnification each texel covers multiple pixels Minification each pixel covers multiple texels Magnification Minification

Texture Filtering Discussion Texture map is a square But the polygon-to-be-textured is not always a square There could be a distortion like magnification or minification Magnification : one and more pixel for one texel Minification : one pixel for some texels void gltexparameterf(glenum target, GLenum pname, GLfloat param) In short, one texel doesn t always belong to one pixel. Target Dimension (GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D) pname The filter (e.g. GL_TEXTURE_MAG_FILTER or GL_TEXTURE_MIN_FILTER) Param Parameter for filtering

Mipmap Parameter for filtering param GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR meaning Chooses the mipmap that most closely matches the size of the pixel being textured. (the texture element nearest to the center of the pixel) Chooses the two mipmaps that most closely match the size of the pixel being textured (the texture element nearest to the center of the pixel) Chooses the mipmap that most closely matches the size of the pixel being textured (a weighted average of the four texture elements that are closest to the center of the pixel) Chooses the two mipmaps that most closely match the size of the pixel being textured (a weighted average of the four texture elements that are closest to the center of the pixel)

Texture Filtering The parameter of texture filter Param Meaning GL_NEAREST GL_LINEAR Use the nearest texel from the center of pixel Interpolate the nearest 4 texels from the center of pixel

Repeating and Clamping Texture repeating and clamping If the texture coordinate is below 0 or above 1 OpenGL repeats texture or clamp Repeating is just like tiling Clamping limits the value within specified range ex) the value above 1.0 is re-set to 1.0 Uses gltexparameterf()

Repeating and Clamping Texture repeating and clamping pname constant value Pname meaning GL_TEXTURE_WRAP_S Assign the method for texture coordinate s that is out of 0.0~1.0 GL_TEXTURE_WRAP_T Assign the method for texture coordinate t that is out of 0.0~1.0 param constant value Param meaning GL_REPEAT Repeat if texture coordinate is out of 0.0~1.0 GL_CLAMP Replace the border value if texture coordinate is out of 0.0~1.0

Repeating and Clamping Repeating Clamping Wrap S : GL_REPEAT Wrap T : GL_REPEAT Wrap S : GL_CLAMP Wrap T : GL_CLAMP

Texture Coordinate Mapping between points on geometric objects and texels void gltexcoord{1234}{sifd}(type scoord,...); void gltexcoord{1234}{sifd}v(type *coord); ex) mapping the texture to a quadrilateral glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3fv(vertex[0]); gltexcoord2f(0.0, 1.0); glvertex3fv(vertex[1]); gltexcoord2f(1.0, 1.0); glvertex3fv(vertex[2]); gltexcoord2f(1.0, 0.0); glvertex3fv(vertex[3]); glend();

Texture Coordinate Texture Coordinate void gltexcoord2f(float s, float t) Set 2D texture coordinate s t Image coordinate for horizontal direction Image coordinate for vertical direction Range : usually 0~1 If not, texture is repeating or clamping glbegin(gl_quads); gltexcoord2f(0.0f, 0.0f); glvertex3f(-1.0, 1.0, 0.0f); gltexcoord2f(1.0f, 0.0f); glvertex3f(1.0, 1.0, 0.0f); gltexcoord2f(1.0f, 1.0f); glvertex3f(1.0, -1.0, 0.0f); gltexcoord2f(0.0f, 1.0f); glvertex3f(-1.0, -1.0, 0.0f); glend();

Curved Surfaces with Specular Reflection

Improved Illumination Model with Multiple Lights

Original Texture Mapping