Imaging and Raster Primitives Vicki Shreiner. 2 Jobs Andrew Giles Andrew Giles Chuck Fultz Chuck Fultz SIGGraph - SIGGraph.

Slides:



Advertisements
Similar presentations
Graphics Pipeline.
Advertisements

Introduction and Basic OpenGL functionality
Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction.
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) =
Lighting, Materials, Fog and Textures
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
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.
CSE (Notre Dame) Computer Graphics Lecture 16 A Simple Draw Image Example More Texture Mapping Simple OpenGL Image Library (SOIL) Transparency &
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.
 Bitmap: A bitmap is a rectangular array of 0s and 1s that serves as a drawing mask for a corresponding rectangular portion of the window.  Applications:
Computer Graphics Texture Mapping Eriq Muhammad Adams
Introduction to Texture Mapping CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Texture Mapping + Texture Object = Texture Mapped Object.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
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.
An Interactive Introduction to OpenGL Programming Ed Angel
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
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
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.
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.
CG Summary: OpenGL Shading andTextures Angel, Chapters 5, 7; “Red Book” slides from AW, red book, etc. CSCI 6360/4360.
Review of OpenGL Basics
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.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
Texture Mapping. 2 3 Loading Textures void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
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.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
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.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
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.
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.
Texture Mapping CEng 477 Introduction to Computer Graphics.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
OpenGL Texture Mapping
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Texture Mapping
3D Game Programming Texture Mapping
OpenGL Texture Mapping
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Texture Mapping Ed Angel Professor Emeritus of Computer Science
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Presentation transcript:

Imaging and Raster Primitives Vicki Shreiner

2 Jobs Andrew Giles Andrew Giles Chuck Fultz Chuck Fultz SIGGraph - SIGGraph -

3 Imaging and Raster Primitives Describe OpenGL’s raster primitives: bitmaps and image rectangles Describe OpenGL’s raster primitives: bitmaps and image rectangles Demonstrate how to get OpenGL to read and render pixel rectangles Demonstrate how to get OpenGL to read and render pixel rectangles

4 Pixel-based primitives Bitmaps Bitmaps 2D array of bit masks for pixels update pixel color based on current color Images Images 2D array of pixel color information complete color information for each pixel OpenGL doesn’t understand image formats OpenGL doesn’t understand image formats

Frame Buffer Rasterization (including Pixel Zoom) Per Fragment Operations TextureM emory Pixel-Transfer Operations (and Pixel Map) CPU Pixel Storage Modes glReadPixels(), glCopyPixels() glBitmap(), glDrawPixels() glCopyTex*Image(); Pixel Pipeline Programmable pixel storage and transfer operations Programmable pixel storage and transfer operations CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture

6 Positioning Image Primitives glRasterPos3f( x, y, z ) raster position transformed like geometry discarded if raster position is outside of viewport may need to fine tune viewport for desired results Raster Position

7 Rendering Bitmaps glBitmap( width, height, xorig, yorig, xmove, ymove, bitmap ) render bitmap in current color at advance raster position by after rendering width height xorig yorig xmove

8 Rendering Fonts using Bitmaps OpenGL uses bitmaps for font rendering OpenGL uses bitmaps for font rendering each character is stored in a display list containing a bitmap window system specific routines to access system fonts glXUseXFont() wglUseFontBitmaps()

9 Rendering Images glDrawPixels( width, height, format, type, pixels ) render pixels with lower left of image at current raster position numerous formats and data types for specifying storage in memory best performance by using format and type that matches hardware

10 Reading Pixels glReadPixels( x, y, width, height, format, type, pixels ) read pixels form specified (x,y) position in framebuffer pixels automatically converted from framebuffer format into requested format and type Framebuffer pixel copy Framebuffer pixel copy glCopyPixels( x, y, width, height, type )

11 Raster Position glPixelZoom(1.0, -1.0); Pixel Zoom glPixelZoom( x, y ) expand, shrink or reflect pixels around current raster position fractional zoom supported glPixelZoom( x, y ) expand, shrink or reflect pixels around current raster position fractional zoom supported

12 Storage and Transfer Modes Storage modes control accessing memory Storage modes control accessing memory byte alignment in host memory extracting a subimage Transfer modes allow modify pixel values Transfer modes allow modify pixel values scale and bias pixel component values replace colors using pixel maps

Texture Mapping Ed Angel

14 Apply a 1D, 2D, or 3D image to geometric primitives Apply a 1D, 2D, or 3D image to geometric primitives Uses of Texturing Uses of Texturing simulating materials reducing geometric complexity image warping reflections Apply a 1D, 2D, or 3D image to geometric primitives Apply a 1D, 2D, or 3D image to geometric primitives Uses of Texturing Uses of Texturing simulating materials reducing geometric complexity image warping reflections Texture Mapping CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture

15 Texture Mapping s t x y z image geometry screen

16 Texture Mapping and the OpenGL Pipeline geometry pipeline vertices pixel pipeline image rasterizer Images and geometry flow through separate pipelines that join at the rasterizer Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect geometric complexity

17 Texture Example The texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective The texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective

18 Applying Textures I Three steps Three steps  specify texture read or generate image assign to texture  assign texture coordinates to vertices  specify texture parameters wrapping, filtering

19 Applying Textures II specify textures in texture objects set texture filter set texture function set texture wrap mode set optional perspective correction hint bind texture object enable texturing supply texture coordinates for vertex coordinates can also be generated specify textures in texture objects set texture filter set texture function set texture wrap mode set optional perspective correction hint bind texture object enable texturing supply texture coordinates for vertex coordinates can also be generated

20 Texture Objects Like display lists for texture images Like display lists for texture images one image per texture object may be shared by several graphics contexts Generate texture names Generate texture names glGenTextures( n, *texIds );

21 Texture Objects (cont.) Create texture objects with texture data and state Create texture objects with texture data and state glBindTexture( target, id ); Bind textures before using Bind textures before using glBindTexture( target, id );

22 Define a texture image from an array of texels in CPU memory Define a texture image from an array of texels in CPU memory glTexImage2D( target, level, components, w, h, border, format, type, *texels ); dimensions of image must be powers of 2 Texel colors are processed by pixel pipeline Texel colors are processed by pixel pipeline pixel scales, biases and lookups can be done Specify Texture Image CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture

23 Converting A Texture Image If dimensions of image are not power of 2 If dimensions of image are not power of 2 gluScaleImage( format, w_in, h_in, type_in, *data_in, w_out, h_out, type_out, *data_out ); *_in is for source image *_out is for destination image Image interpolated and filtered during scaling Image interpolated and filtered during scaling

24 Specifying a Texture: Other Methods Use frame buffer as source of texture image Use frame buffer as source of texture image uses current buffer as source imageglCopyTexImage2D(...)glCopyTexImage1D(...) Modify part of a defined texture Modify part of a defined textureglTexSubImage2D(...)glTexSubImage1D(...) Do both with glCopyTexSubImage2D(...), etc. Do both with glCopyTexSubImage2D(...), etc.

25 Based on parametric texture coordinates Based on parametric texture coordinates glTexCoord*() specified at each vertex glTexCoord*() specified at each vertex s t 1, 1 0, 1 0, 01, 0 (s, t) = (0.2, 0.8) (0.4, 0.2) (0.8, 0.4) A BC a b c Texture SpaceObject Space Mapping a Texture CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture

26 Tutorial: Texture

27 Filter Modes Filter Modes minification or magnification special mipmap minification filters Wrap Modes Wrap Modes clamping or repeating Texture Functions Texture Functions how to mix primitive’s color with texture’s color blend, modulate or replace texels Texture Application Methods

28 Filter Modes TexturePolygon MagnificationMinification PolygonTexture Example: glTexParameteri( target, type, mode );

29 Mipmapped Textures Mipmap allows for prefiltered texture maps of decreasing resolutions Mipmap allows for prefiltered texture maps of decreasing resolutions Lessens interpolation errors for smaller textured objects Lessens interpolation errors for smaller textured objects Declare mipmap level during texture definition Declare mipmap level during texture definition glTexImage*D( GL_TEXTURE_*D, level, … ) GLU mipmap builder routines GLU mipmap builder routines gluBuild*DMipmaps( … ) OpenGL 1.2 introduces advanced LOD controls OpenGL 1.2 introduces advanced LOD controls

30 Wrapping Mode Example: Example: glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) texture GL_REPEAT wrapping GL_CLAMP wrapping s t

31 Texture Functions Controls how texture is applied Controls how texture is applied glTexEnv{fi}[v]( GL_TEXTURE_ENV, prop, param ) GL_TEXTURE_ENV_MODE modes GL_TEXTURE_ENV_MODE modes GL_DECAL GL_ADD GL_COMBINE GL_MODULATE GL_BLEND GL_REPLACE Set blend color with GL_TEXTURE_ENV_COLOR Set blend color with GL_TEXTURE_ENV_COLOR

32 Perspective Correction Hint Texture coordinate and color interpolation Texture coordinate and color interpolation either linearly in screen space or using depth/perspective values (slower) Noticeable for polygons “on edge” Noticeable for polygons “on edge” glHint( GL_PERSPECTIVE_CORRECTION_HINT, hint ) where hint is one of GL_DONT_CARE GL_NICEST GL_FASTEST

33 Is There Room for a Texture? Query largest dimension of texture image Query largest dimension of texture image typically largest square texture doesn’t consider internal format size glGetIntegerv( GL_MAX_TEXTURE_SIZE, &size ) Texture proxy Texture proxy will memory accommodate requested texture size? no image specified; placeholder if texture won’t fit, texture state variables set to 0 doesn’t know about other textures only considers whether this one texture will fit all of memory

34 Texture Residency Working set of textures Working set of textures high-performance, usually hardware accelerated textures must be in texture objects a texture in the working set is resident for residency of current texture, check GL_TEXTURE_RESIDENT state If too many textures, not all are resident If too many textures, not all are resident can set priority to have some kicked out first establish 0.0 to 1.0 priorities for texture objects