CS 4363/6353 TEXTURE MAPPING PART II. WHAT WE KNOW We can open image files for reading We can load them into texture buffers We can link that texture.

Slides:



Advertisements
Similar presentations
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Advertisements

Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
TEXTURE MAPPING JEFF CHASTINE 1. TEXTURE MAPPING Applying an image (or a texture ) to geometry 2D images (rectangular) 3D images (volumetric – such as.
OpenGL Texture Mapping
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Today: - Make sure everyone is set up with an OpenGL environment - OpenGL basics:
GLSL Applications: 2 of 2 Patrick Cozzi University of Pennsylvania CIS Spring 2011.
Shadow Mapping RTR Team Why Shadows? 2 RTR Team 2009.
TA: Zhicheng Yan, Sushma S Kini, Mary Pietrowicz
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
OpenGL 3.0 Texture Arrays Presentation: Olivia Terrell, Dec. 4, 2008.
Texture Mapping. To add surface details… World of Warcraft, Blizzard Inc. More polygons (slow and hard to handle small details) Less polygons but with.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL.
Texture Mapping. Example Mappings Mapping Techniques Consider the problem of rendering a sphere in the examples The geometry is very simple - a sphere.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Textures.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
CS 480/680 Computer Graphics Shader Applications Dr. Frederick C Harris, Jr. Fall 2011.
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Texture Mapping Fall, Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CG1 Labs Wei Li. Back Face Culling // enable back-face culling glEnable( GL_CULL_FACE ); // orientation of front-facing polygons glFrontFace( GL_CCW );
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + =
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
OpenGL Shader Language Vertex and Fragment Shading Programs.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shader Applications Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
OpenGL-ES 3.0 And Beyond Boston Photo credit :Johnson Cameraface OpenGL Basics.
OpenGL Graphics Textures. Quiz You didn't see that coming!
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
 Learn how you can use the shader through OpenGL ES  Add texture on object and make the object have a different look!!
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
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.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
Mouse Input. For Further Reading Learning WebGL, Lesson 11: 2.
MP3 Frequently Asked Questions (IN OFFICE HOURS).
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
Wilf Comp Ambient Occlusion + Order Independent Transparency POST CONCLUSIONS.
Texture Mapping. For Further Reading Angel 7 th Ed: ­Chapter 7: 7.3 ~ 7.9 Beginning WebGL: ­Chapter 3 2.
Advanced Texture Mapping Bump Mapping & Environment Mapping (Reflection)
MP3.. Start at the very beginning. Almost. Either start from nothing yourself, or use the empty template for this MP. Run through the provided files are.
Viewing and Texture Mapping In OPENGL. VIEWING 1.One or more objects 2.A viewer with a projection surface 3.Projectors that go from the object(s) to.
Texture Mapping CEng 477 Introduction to Computer Graphics.
Environment Maps Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Texture Mapping Fall, 2016.
Tips for Environment Mapping
Texture Mapping We can improve the realism of graphics models by mapping a texture pattern (image) onto the modeled object surface. We refer to this technique.
Texture Mapping Part II
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Chapters VIII Image Texturing
3D Game Programming Texture Mapping
OpenGL Texture Mapping
OpenGL Texture Mapping
CS 480/680 Computer Graphics GLSL Overview.
Texture Mapping Ed Angel Professor Emeritus of Computer Science
Textures in WebGL.
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

CS 4363/6353 TEXTURE MAPPING PART II

WHAT WE KNOW We can open image files for reading We can load them into texture buffers We can link that texture buffer to a variable in the fragment shader We can access the texture in the fragment shader using a sampler2D

RECTANGLE TEXTURES There’s another mode called GL_TEXTURE_RECTANGLE Works just like GL_TEXTURE_2D, but… Texture coordinate range is the width and height of the image (not normalized) Can’t be mipmapped Texture coordinates cannot repeat Do not support compression Useful for when you need to process image data (image processing), not just texture Typically, you create an orthographic projection with 0,0 on the bottom left First quadrant of the Cartesian system

OpenGL SuperBible Example

CUBE MAPPING Used for “skyboxes” Used for faking reflections Comprised of 6 individual images Treated as one texture Can be mipmapped ( glGenerateMipmap (GL_TEXTURE_CUBE_MAP) ) We’re going to have 3 texture coordinates! S T R It’s easiest to think of this as a normal because the cube “surrounds” you

Neg X Neg Y Neg Z Pos X Pos Y Pos Z OpenGL SuperBible – Chapter 7

LOADING CUBE MAPS Create/Bind a buffer like normal Still load using glTexImage2D, but must pass: GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Y Example: glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, w, h, 0, GL_BGR, GL_UNSIGNED_BYTE, bitmap_data);

TEXTURE PARAMETERS Still have MAG and MIN filters, but… Specify it’s a GL_TEXTURE_CUBE_MAP Specify how to wrap each texture coordinate Example glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

SKYBOXES Literally just a giant box with a texture on it It follows the camera! It doesn’t rotate with the camera How do we map the cube map to the cube? What are the texture coordinates?

SKYBOXES Literally just a giant box with a texture on it It follows the camera! It doesn’t rotate with the camera How do we map the cube map to the cube? What are the texture coordinates? The same as their positions!

SKYBOXES Literally just a giant box with a texture on it It follows the camera! It doesn’t rotate with the camera How do we map the cube map to the cube? What are the texture coordinates? How do we sample the texture in our fragment shader? Using a sampleCube variable

// Skybox Shader by Richard S. Wright, Jr. #version 330 in vec4 vVertex; uniform mat4 mvpMatrix; varying vec3 vVaryingTexCoord; void main (void) { vVaryingTexCoord = normalize (vVertex.xyz); gl_Position = mvpMatrix * vVertex; } #version 330 out vec4 vFragColor; uniform samplerCube cubeMap; varying vec3 vVaryingTexCoord; void main (void) { vFragColor = texture (cubeMap, vVaryingTexCoord); }

REFLECTIONS OpenGL SuperBible – Chapter 7

// Reflection Shader – Richard S. Wright Jr. #version 330 in vec4 vVertex; in vec3 normal; uniform mat4 mvpMatrix; uniform mat4 mvMatrix; uniform mat3 normalMatrix; // Just the rots of the mv uniform mat4 mInverseCamera;// The camera matrix inverted smooth out vec3 vVaryingTexCoord; void main (void) { // Normal in eye space – only rots vec3 vEyeNormal = normalMatrix * vNormal; // Vertex in eye space vec4 vVert4 = mvMatrix * vVertex; vec3 vEyeVertex = normalize(vVert4.xyz/vVert4.w); // Calculate a reflection vector, then invert it vec4 vCoords = vec4(reflect(vEyeVertex, vEyeNormal), 1.0); vCoords = mInverseCamera * vCoords; vVaryingTexCoord.xyz = normalize(vCoords.xyz); gl_Position = mvpMatrix * vVertex; }

USING MULTIPLE TEXTURES Second texture useful for: Adding multiple colors together Using it as a bump map Using it as a specular map Using it as a transparency map

FOR COLOR ALONE

BUMP MAPPING Used to approximate very rough surfaces Using the second texture to adjust the normals of the surface Per fragment, not per vertex In the case below, all N◦L is the same

BUMP MAPPING Used to approximate very rough surfaces Using the second texture to adjust the normals of the surface Per fragment, not per vertex In the case below, all N◦L is not the same Gives off a different amount of light! Note – the geometry has not changed!

EXAMPLE

EXAMPLE FROM BOOK

AN EXTREME EXAMPLE

PARALLAX MAPPING Approximate parallax Changes the texture coordinate based on view vector and normal Need a height map

BILLBOARDING Image always faces the camera (think of the math!) Typically has transparency Useful for trees Useful for particle effects

POINT SPRITES OpenGL 1.5 Based on billboarding Can place a 2D texture using a single point! Previously, needed two triangles 1/4 th the bandwidth No aligning the quad to face the camera Using them Bind a 2D texture Draw using glPolygonMode (GL_FRONT, GL_POINTS)

TEXTURE ARRAYS Packing several images into a single texture units (GL_TEXTURE0) Good for 2D animations Similar use: glBindTexture (GL_TEXTURE_2D_ARRAY, texBufID); glTexParameteri (GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); However, to load the image, we are now in 3D! glTexImage3D (GL_TEXTURE_2D_ARRAY, level, internal_format, w, h, depth, border, format, NULL); The depth parameter specifies how many images are in the array

LOADING THE ARRAYS for (int i = 0; i < num_images; i++) { data = loadBitmap (“image”+i+”.bmp”); glTexSubImage(GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, w, h, 1, GL_BGR, GL_UNSIGNED_BYTE, data); }

ACCESSING THE IMAGES Normally, you specify the image index from the client side GLuint loc = glGetUniform (progID, “image_num”); glUniform1f (loc, counter); // some int Then, in the vertex shader, use it as the 3 rd texture coordinate: uniform float image_num; in vec4 vTexCoords; smooth out vec3 imageTexCoords; void main (void) { imageTexCoords.st = vTexCoords.st; imageTexCoords.p = image_num; … }

YOUR FRAGMENT SHADER Must have a sampler2DArray variable Must use the texture2DArray function uniform sampler2DArray texture; smooth in vec3 imageTexCoords; out vFragColor; void main () { vFragColor = texture2DArray (texture, imageTexCoods.stp); }