CS425 © 2003 Ray S. Babcock Pixels and Bitmaps ● OpenGL allows us to work directly with bits and groups of bits, or pixels, which flow down a parallel.

Slides:



Advertisements
Similar presentations
TEXTURE MAPPING JEFF CHASTINE 1. TEXTURE MAPPING Applying an image (or a texture ) to geometry 2D images (rectangular) 3D images (volumetric – such as.
Advertisements

OpenGL Texture Mapping
Buffers Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Buffers Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
CSC345: Advanced Graphics & Virtual Environments
OpenGL Texture Mapping
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
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.
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Texture Mapping. To add surface details… World of Warcraft, Blizzard Inc. More polygons (slow and hard to handle small details) Less polygons but with.
Computer Graphics Texture Mapping Eriq Muhammad Adams
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared.
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.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 8: Texture Mapping.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
Texture Mapping Fall, Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.
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.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
Texture Mapping Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
1 Texture Mapping. 2 Texture Aliasing MIPmaps Environment Mapping Bump Mapping Displacement Mapping Shadow Maps Solid Textures Antialiasing.
Texture Mapping Software College, Shandong University Instructor: Zhou Yuanfeng
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.
111/17/ :24 UML Solution Involves Selection of Discrete Representation Values.
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
CH8 Frame Buffer Object 1. Introduction Name OpenGL :Frame Buffer Object DirectX:Render Target Usage Render to Texture 2.
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.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
Buffers Computer Graphics I, Fall 2010.
Texture Mapping and NURBS Week 7 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
Buffers. 2 Objectives Introduce additional OpenGL buffers Learn to read and write buffers Learn to use blending.
Texture Mapping. For Further Reading Angel 7 th Ed: ­Chapter 7: 7.3 ~ 7.9 Beginning WebGL: ­Chapter 3 2.
1 Chapter 7 Texture Mapping. 2 The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number is.
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.
Buffers Ed Angel Professor Emeritus of Computer Science
Madhulika (18010), Assistant Professor, LPU.
Texture Mapping Fall, 2016.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
OpenGL Texture Mapping
Graphics, Fall 2017 Lecture 24: Texture Mapping
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
OpenGL Texture Mapping
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Introduction to Computer Graphics with WebGL
Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass, wall paper. Use.
Geb Thomas Adapted from the OpenGL Programming Guide
Class 26 more textures environmental textures Color ramps
Computer Graphics Buffers
3D Game Programming Texture Mapping
Buffers Ed Angel Professor Emeritus of Computer Science
OpenGL Texture Mapping
Class 27 more textures environmental textures Color ramps
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Texture Mapping Ed Angel Professor Emeritus of Computer Science
OpenGL Texture Mapping
Presentation transcript:

CS425 © 2003 Ray S. Babcock Pixels and Bitmaps ● OpenGL allows us to work directly with bits and groups of bits, or pixels, which flow down a parallel pipeline to the frame buffer.

CS425 © 2003 Ray S. Babcock Frame Buffer

CS425 © 2003 Ray S. Babcock Depth k ● May have 32 bits for front RGBA value. ● May also have 32 bits for back buffer RGBA value (double buffering). ● May also have 32 bits for depth values. ● There may be other buffers: ● Accumulation buffer ● Stencil buffer ● Extra color buffers ● OpenGL allows us to read or write rectangular blocks of pixels. (bit block transfer operation or bitblt “bit blat”)

CS425 © 2003 Ray S. Babcock Architecture of a graphics system

CS425 © 2003 Ray S. Babcock Bitmaps Rectangular arrays of bits

CS425 © 2003 Ray S. Babcock Displaying a Bitmap GLubyte wb[2] = { 0x00, 0xff }; GLubyte check[512]; int I, j; for (i=0; i<64; i++) for (j=0; j<8; j++) check[i*8+j] = wb[i/8+j % 2]; … glBitmap(64, 64, 0.0, 0.0, 0.0, 0.0, check);

CS425 © 2003 Ray S. Babcock glBitmap( … ); GLsizei c : height GLsizei r : width GLfloat xo : x origin of bitmap (offset cur rp ) GLfloat yo : y origin of bitmap (offset cur rp ) GLfloat xi : x increment GLfloat yi : y increment const GLubyte * bitmap Increment added to raster position after the bitmap is rasterized. (cur rp = current raster position)

CS425 © 2003 Ray S. Babcock Results of Example Code

CS425 © 2003 Ray S. Babcock OpenGL BITBLT Functions (more on this later) ● void glLogicOp(GLenum op) ● GL_COPY ● GL_OR ● GL_XOR e.g. glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); (others) glDrawPixels, glReadPixels, glCopyPixels, glReadBuffer, glDrawBuffer, glPixelStore{if} …

CS425 © 2003 Ray S. Babcock Texture Mapping ● Texture mapping combines the best features of geometric objects with blocks of pixels. ● Textures are patterns. (stripes, checkerboard, grass, wood, gravel, etc.) ● Textures can be 1D, 2D, 3D, 4D. (we concentrate on 2D textures)

CS425 © 2003 Ray S. Babcock An Example

CS425 © 2003 Ray S. Babcock 2D Texture Mapping ● Coordinate systems ● Screen coordinates ● World coordinates ● Texture coordinates ● Parametric coordinates (curved surfaces) ● Textures start out as two-dimensional images. (photographs, program output...) ● The image is brought into the program as an array. ● Elements of the texture array are TEXELS or texture elements.

CS425 © 2003 Ray S. Babcock Cont. ● However, it is convenient to think of the texture map array as a continuous, rectangular, two-dimensional texture pattern T(s,t). ● The independent variables s and t are texture coordinates. ● These are normalized to vary over [0,1]. ● A texture map associates a unique point T with each point on a geometric object that is itself mapped to screen coordinates.

CS425 © 2003 Ray S. Babcock Cont. ● x = x(s,t), ● y = y(s,t), ● z = z(s,t), ● w = w(s,t). ● Inverse? ● s = s(x,y,z,w) and t = t(x,y,z,w). ● These are often very difficult to generate.

CS425 © 2003 Ray S. Babcock The process

CS425 © 2003 Ray S. Babcock Difficulties 1. Distortion often occurs with regular patterns. 2. The rendering process works pixel by pixel, so we are more interested in the inverse map from screen coordinates to texture coordinates. (The shade of a pixel is determined by what part of the texture?)

CS425 © 2003 Ray S. Babcock Preimage of a pixel

CS425 © 2003 Ray S. Babcock Aliasing in texture generation

CS425 © 2003 Ray S. Babcock Mapping A point p on a surface is a function of two parameters u and v. For each pair of values, we generate the point x(u,v) p(u,v) = y(u,v) z(u,v) We can often map a point in texture space T(s,t) to a point on the surface p(u,v) by u = as + bt + c and v = ds + et + f

CS425 © 2003 Ray S. Babcock Cont. As long as ae not equal to bd, this mapping is invertible. Linear mapping makes it easy to map a texture to a group of parametric surface patches. However, it doesn't take into account the curvature of the surface. Equal-sized texture patches must be stretched to fit over the surface patch.

CS425 © 2003 Ray S. Babcock Linear Texture Mapping

CS425 © 2003 Ray S. Babcock Two-Part Mapping 1. Map the texture to a simple three- dimensional intermediate surface sphere, cylindar, or cube 2. The intermediate surface is mapped to the surface being rendered.

CS425 © 2003 Ray S. Babcock With a Cylinder

CS425 © 2003 Ray S. Babcock With a Box

CS425 © 2003 Ray S. Babcock Step 2 From intermediate to surface

CS425 © 2003 Ray S. Babcock Texture Mapping in OpenGL OpenGL's texture maps rely on its pipeline architecture. The pipelines merge during rendering. Texture mapping is done as primitives are rasterized.

CS425 © 2003 Ray S. Babcock Cont. Two-dimensional texture mapping starts with an array of texels. glTexImage2D(GL_TEXTURE_2D, level, components, width, height, border, format, type, tarray); glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_texels);

CS425 © 2003 Ray S. Babcock GlTexImage2D GLenum target Set to either GLTEXTURE_2D or GL_PROXY_TEXTURE_2D. Glint level With only one resolution, set to 0. ( multiple level of details) Glint internalFormat Indicates which of the R,G,B,and A components or luminance or intensity values are selected for use in describing the texels of an image. (1-4 or one of 38 symbolic constants, see man)

CS425 © 2003 Ray S. Babcock GlTexImage2D cont. GLsizei width GLsizei height Give the dimensions of the texture image. GLint border Gives the width of the border (0 no border or 1 for a border) Both width and height must be of the form (2^m + 2b) where m is a non-negative integer and b is the value of border. Maximum size depends on implementation of OpenGL (minimum of 64 x 64).

CS425 © 2003 Ray S. Babcock GlTexImage2D cont. GLenum format GLenum type Format and Type describe the format and data type of the texture image data. const GLvoid * texels Contain the texture image data.

CS425 © 2003 Ray S. Babcock glEnable(GL_TEXTURE_2D) As we do with other options, we must enable texture mapping.

CS425 © 2003 Ray S. Babcock Mapping the texture to an object

CS425 © 2003 Ray S. Babcock Left to the Application glBegin(GL_QUAD) glTexCoord2f(0.0, 0.0); glVertex2f(x1,y1,z1); glTexCoord2f(1.0, 0.0); glVertex2f(x2,y2,z2); glTexCoord2f(1.0, 1.0); glVertex2f(x3,y3,z3); glTexCoord2f(0.0, 1.0); glVertex2f(x4, y4, z4); glEnd( );

CS425 © 2003 Ray S. Babcock Use all or part of texture

CS425 © 2003 Ray S. Babcock Bilinear Interpolation

CS425 © 2003 Ray S. Babcock What happens when (s,t) (1.0, 1.0) GlTexParameteri( target, pname, *params); Glenum target – target texture (GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D) Glenum pname – symbolic name of the texture parameter. (see man for choices) const GLfloat *params - pointer to an array where the value(s) of pname are found. e.g. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);

CS425 © 2003 Ray S. Babcock Point Sampling Linear Filtering

CS425 © 2003 Ray S. Babcock magnification/minification

CS425 © 2003 Ray S. Babcock magnification/minification cont. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

CS425 © 2003 Ray S. Babcock Examples

CS425 © 2003 Ray S. Babcock Examples cont.

CS425 © 2003 Ray S. Babcock Examples cont.

CS425 © 2003 Ray S. Babcock Examples cont.

CS425 © 2003 Ray S. Babcock Mipmapping OpenGL allows you to have different textures at different resolutions.