Class 26 more textures environmental textures Color ramps

Slides:



Advertisements
Similar presentations
Coordinate System.
Advertisements

©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
Graphics Pipeline.
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
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
Introduction to OpenGL (Part 3) Ref: OpenGL Programming Guide (The Red Book)
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
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.
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
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
CSE 381 – Advanced Game Programming Basic 3D Graphics
Texture Mapping + Texture Object = Texture Mapped Object.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
2002 by Jim X. Chen: 1 So far, we only concerned with the rendering of geometric data. Two other important classes of data:
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
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.
GRAPHICS MODULE 14 STUDY BOOK. Graphic commands SCREEN - puts the screen into graphics mode WINDOW - allows scaling of the screen LINE - 3 formats –LINE.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Buffers Computer Graphics I, Fall 2010.
RENDERING TEXTURE 1/30/2016 A.ARUNA/ASSISTANT PROFESSOR/IT/SNSC E 1.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
OpenGL Vertex Arrays OpenGL vertex arrays store vertex properties such as coordinates, normal vectors, color values and texture coordinates. These properties.
Buffers. 2 Objectives Introduce additional OpenGL buffers Learn to read and write buffers Learn to use blending.
Tan-Chi Ho, CGGM Lab., CSIE of NCTU Pixel Operations and Buffers.
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.
Buffers Ed Angel Professor Emeritus of Computer Science
Texture Mapping Fall, 2016.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
OpenGL Texture Mapping
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
OpenGL Texture Mapping
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Chapters VIII Image Texturing
Michael Tanaya , Hua ming Chen
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
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Computer Graphics Buffers
3D Game Programming Texture Mapping
Buffers Ed Angel Professor Emeritus of Computer Science
OpenGL Texture Mapping
Geometric Objects and Transformations (I)
Class 27 more textures environmental textures Color ramps
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
OpenGL Texture Mapping
Presentation transcript:

Class 26 more textures environmental textures Color ramps Reading, writing, and copying pixels Drawing bitmaps Bump Maps

Wrapping Texture on Curved Surfaces We want to wrap texture onto a curved surface, such as a beer can or a chess piece. We assume as before that the object is modeled by a mesh, so it consists of a large number of small flat faces. Each vertex of the mesh has an associated texture coordinate pair (si, ti). The main question is finding the proper texture coordinate (s, t) for each vertex of the mesh.

OpenGL Reflection Mapping OpenGL provides a tool to perform approximate environment mapping where the texture is wrapped about a large enclosing sphere: glTexGenf(GL_S,GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGenf(GL_T,GL_TEXTURE_GEN_MODE, glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); (Can use GL_CUBE_MAP)

shrinkwrapping Now when a vertex P with its unit normal m is sent down the pipeline, OpenGL calculates a texture coordinate pair (s, t) suitable for indexing into the texture attached to the surrounding sphere. This is done for each vertex of the face on the object, and the face is drawn as always using interpolated texture coordinates (s, t) for points in between the vertices.

There is GL_CUBE also if you have 6 textures (views in 6 directions) that you want applied.

Example from Guha: sphereMapping.cpp

Another Example fieldAndSkyOnSphereMJB.cpp Note culling trick for one texture on inside and one texture on outside. In general, disble texturing as soon as you draw what you want textured.

For texturing: Use GL_REPLACE for no lighting, no "bleeding through" of color Use GL_MODULATE with a white background if you want lighting

Color Ramps greyscale : linearly go from (0,0,0) to (1,1,1) rainbow example, several linear sections – see code. ColorRamps.c

RedbookImage.c from Chapter 8 of the Red book http://glprogramming.com/red/chapter08.html run and discuss RedbookImage.c copies from part of the framebuffer to another part of the framebuffer Does NOT call glutPostRedisplay(), except on reset Does call flush() to show changes.

Reading, Writing, and Copying Pixel data glReadPixels() - Reads a rectangular array of pixels from the framebuffer and stores the data in processor memory. glDrawPixels() - Writes a rectangular array of pixels from data kept in processor memory into the framebuffer at the current raster position specified by glRasterPos*(). glCopyPixels() - Copies a rectangular array of pixels from one part of the framebuffer to another.

Reading, Writing, and Copying Pixel data glCopyPixels() command behaves similarly to a call to glReadPixels() followed by a call to glDrawPixels(), but the data is never written into processor memory.

void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); Reads pixel data from a rectangle in the framebuffer whose lower left coordinate is (x,y) and whose width is width and height is height and stores the data in the array pointed to by pixels.

format is the kind of data, for example GL_RGB, but it could also be void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); format is the kind of data, for example GL_RGB, but it could also be GL_BLUE, GL_LUMINANCE, GL_DEPTH_COMPONENT, ...

type is the type of the data, eg. GL_UNSIGNED_BYTE void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); type is the type of the data, eg. GL_UNSIGNED_BYTE

void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); Draws a rectangle of dimension width and height at the current roster position. format and type as in glReadPixels(). The array pointed to by pixels has the data to be drawn.

void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum buffer); copies a rectangle with lower left corner (x,y) and dimensions height and width from the buffer to the buffer at the current raster position.

Magnifying, Reducing, and Flipping an image void glPixelZoom(GLfloat zoomx, GLfloat zoomy);

void glPixelZoom(GLfloat zoomx, GLfloat zoomy); by default zoomx and zoomy are both 1.0 If they are both 2 then each image pixel gets drawn to 4 screen pixels. if (xrp,yrp) is the current raster position, image pixel in row n and column m, will go to the rectangle with corners (xrp + zoomx * n, yrp + zoomy * m) and (xrp + zoomx(n+1), yrp + zoomy(m+1)) draws to the pixel if the center of pixel in box.

Drawing bitmaps run RedbookDrawF.c

void glBitmap( GLsizei width, GLsizei height, GLfloat xbo, GLfloat ybo, GLfloat xbi, GLfloat ybi, const GLubyte *bitmap); draws the bitmap pointed to by bitmap. origin of bitmap at current raster position. xbo and ybo move the origin of the bitmap. width and height are the dimensions of the bitmap, in pixels. xbi and ybi are added to the raster position after drawing the bitmap.

Sample bitmap

starts at lower left corner GLubyte rasters[24] = { 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0xc0, 0xff, 0xc0};

Bump mapping – procedural textures bumpmapping.cpp Change the normals, to give an impression of a texture.