Computer Graphics. Bing-Yu Chen National Taiwan University

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

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

Imaging and Raster Primitives

CS212. OpenGL Texture Mapping and Related

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

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

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

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

Lecture 5. Scan Conversion Textures hw2

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

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

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

Lecture 07: Buffers and Textures

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

Texture Mapping. Mike Bailey.

Texture Mapping and Sampling

CS 432 Interactive Computer Graphics

Texture Mapping and Special Effects

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

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

Texture Mapping CSCI 4229/5229 Computer Graphics Fall 2016

INF3320 Computer Graphics and Discrete Geometry

An Interactive Introduction to OpenGL Programming. An Interactive Introduction to OpenGL Programming. SIGGRAPH New Orleans 1

4 Introduction to OpenGL Programming. Chapter 4. Introduction to OpenGL Programming. Department of Computer Science and Engineering 4-1

Computer Graphics. Bing-Yu Chen National Taiwan University

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

E.Order of Operations

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

Computational Strategies

Chapter 6 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

ก ก ก.

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

Grafica Computazionale

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

INF3320 Computer Graphics and Discrete Geometry

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

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

CS 354R: Computer Game Technology

Introduction to OpenGL. Prof. Dr.-Ing. Lars Linsen

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

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

Rasterization Overview

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

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

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

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

Computer Graphics. Bing-Yu Chen National Taiwan University

9.Texture Mapping. Chapter 9. Chapter Objectives

3D Rasterization II COS 426

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

Computer Graphics Texture Mapping

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

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

World Coordinate System

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

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

CS179: GPU Programming

Rationale for Non-Programmable Additions to OpenGL 2.0

Texture mapping. Computer Graphics CSE 167 Lecture 9

Workshop 3D capture, modelling and augmented reality Capture 3D, modélisation et réalité augmentée

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

Lighting and Texturing

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

CS 130 Final. Fall 2015

Module 13C: Using The 3D Graphics APIs OpenGL ES

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

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

An Interactive Introduction to OpenGL Programming

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

CS 5610 / Spring Depth Buffering and Hidden Surface Removal

CS4620/5620: Lecture 14 Pipeline

Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E.

Dynamic Texturing. Mark Harris NVIDIA Corporation

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

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

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

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

Framebuffer Objects. Emil Persson ATI Technologies, Inc.

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

CS 179 GPU Programming

OpenGL ES for iphone Games. Erik M. Buck

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

11494 Interactive and GPU Computing Lab. 6-06/05/2015. Textures

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

GeForce3 OpenGL Performance. John Spitzer

Textures. Texture coordinates. Introduce one more component to geometry

Rendering Objects. Need to transform all geometry then

Programming Graphics Hardware

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

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Computer Graphics - Week 7

CS452/552; EE465/505. Clipping & Scan Conversion

EE 4702 GPU Programming

Lecture 5 3D graphics part 3

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Transcription:

Computer Graphics Bing-Yu Chen National Taiwan University

Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering Lighting Evaluation and NURBS Texture Mapping Advanced OpenGL Topics Imaging modified from Dave Shreiner, Ed Angel, and Vicki Shreiner. An Interactive Introduction to OpenGL Programming. ACM SIGGRAPH 2001 Conference Course Notes #54. & ACM SIGGRAPH 2004 Conference Course Notes #29.

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

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

Pixel Pipeline CPU CPU Poly. Poly. DL DL Pixel Pixel Per Per Vertex Vertex Texture Texture Raster Raster Frag Frag FB FB Programmable pixel storage and transfer operations glbitmap(), gldrawpixels() CPU Pixel Storage Modes Pixel-Transfer Operations (and Pixel Map) Rasterization (including Pixel Zoom) Per Fragment Operations Frame Buffer Texture Memory glcopytex*image(); glreadpixels(), glcopypixels()

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

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

Rendering Fonts using Bitmaps 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()

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

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

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

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

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

Texture Mapping y z x geometry screen t image s

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

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

Applying Textures I Three steps 1 specify texture read or generate image assign to texture enable texturing 2 assign texture coordinates to vertices 3 specify texture parameters wrapping, filtering

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

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

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

Specify Texture Image 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 CPU CPU Poly. Poly. pixel scales, biases and lookups can be done DL DL Pixel Pixel Per Per Vertex Vertex Texture Texture Raster Raster Frag Frag FB FB

Converting A Texture Image 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

Specifying a Texture: Other Methods Use frame buffer as source of texture image uses current buffer as source image glcopyteximage1d(...) glcopyteximage2d(...) Modify part of a defined texture gltexsubimage1d(...) gltexsubimage2d(...) gltexsubimage3d(...) Do both with glcopytexsubimage2d(...), etc.

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

Generating Texture Coordinates Automatically generate texture coords gltexgen{ifd}[v]() specify a plane generate texture coordinates based upon distance from plane generation modes GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP Ax + By + Cz + D = 0

Tutorial: Texture

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

Filter Modes Example: gltexparameteri( target, type, mode ); Texture Magnification Polygon Texture Minification Polygon

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

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

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

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

Is There Room for a Texture? Query largest dimension of texture image typically largest square texture doesn t consider internal format size glgetintegerv( GL_MAX_TEXTURE_SIZE, &size ) 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

Texture Residency 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 can set priority to have some kicked out first establish 0.0 to 1.0 priorities for texture objects