Texture Mapping and Programmable Graphics Hardware

Slides:



Advertisements
Similar presentations
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Advertisements

Exploration of bump, parallax, relief and displacement mapping
Graphics Pipeline.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 6, 2014 TEXTURE MAPPING TEXTURES BUMP MAPPING ENVIRONMENT MAPPING PROCEDURAL TEXTURING.
1Notes  Assignment 1 is out, due October 12  Inverse Kinematics  Evaluating Catmull-Rom splines for motion curves  Wednesday: may be late (will get.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
(conventional Cartesian reference system)
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Texture Mapping.
Now Playing: Coulibaly Amadou & Mariam from Dimanche a Bamako Released August 2, 2005.
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte.
CSE 381 – Advanced Game Programming Shading.
Now Playing: Quicksand Under Carpet New Radiant Storm King from Leftover Blues: Released 2004.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
ECSE 4750: Computer Graphics Rensselaer Polytechnic Institute Nov 5, 2012 Texture and Texture Mapping.
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
Shading. What is Shading? Assigning of a color to a pixel in the final image. So, everything in shading is about how to select and combine colors to get.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
A Crash Course in HLSL Matt Christian.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Texture Mapping Applications 2. Parallax Mapping with Slope  parallax mapping assumes that the surface is a single plane  a better approximation  surface.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam October 30, 2003 Shading 1/35 CIS 736 Computer Graphics Lecture 17 of 42 Illumination.
Stream Processing Main References: “Comparing Reyes and OpenGL on a Stream Architecture”, 2002 “Polygon Rendering on a Stream Architecture”, 2000 Department.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Game Programming 06 The Rendering Engine
Computer Graphics 2 Lecture 7: Texture Mapping Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.

- Introduction - Graphics Pipeline
Ying Zhu Georgia State University
Week 7 - Wednesday CS361.
Week 2 - Friday CS361.
ATEC Procedural Animation
ATCM 3310 Procedural Animation
Graphics Processing Unit
Deferred Lighting.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Procedural Animation Lecture 6: Mapping
ATCM 6317 Procedural Animation
Chapter XIV Normal Mapping
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Texture Mapping Jung Lee.
Presentation transcript:

Texture Mapping and Programmable Graphics Hardware Rick Skarbez, Instructor COMP 575 October 16, 2007

Announcements Programming Assignment 2 (3D graphics in OpenGL) is out Due Thursday, October 25 by 11:59pm Programming Assignment 3 (Rasterization) is out Due Thursday, November 1 by 11:59pm

Last Time Discussed programming assignments 2 & 3 Presented the concept of Binary Space Partition (BSP) Trees Described how they can be used to implement a painter’s algorithm Began our discussion of texture mapping

Today More mapping Finish up Texture Mapping Bump Maps Displacement Maps Discussion of programmable graphics hardware Discussion of class project

Fuchs, Kedem, & Naylor; SIGGRAPH 1980 BSP Trees Fuchs, Kedem, & Naylor; SIGGRAPH 1980 Based on the concept of binary space partitioning A plane divides space into two half-spaces; all objects can be classified as being on one side or the other A preprocessing step builds a BSP tree that can be used for any viewpoint However, assumes that the geometry does not change http://www.gamedev.net/reference/articles/article657.asp

BSP Tree Illustration Let’s see an example (in 2D, not 3D) Space Here, a line divides the plane into two half- planes Space BSP Tree X C X B D E Y D A B A C Y E

BSP Tree Review Use implicit planes to carve up space (and the geometry in it) into distinct subspaces One BSP tree can be used for any viewpoint Can be used to implement a painter’s algorithm Or to speed up a raytracer... We’ll be seeing this again Any questions?

Texturing Example Before Texturing After Texturing

Texture Mapping Texture mapping allows us to render surfaces with very complex appearance How it works: Store the appearance as a function or image Take a picture Map it onto a surface made up of simple polygons Paste the picture on an object

Mapping Example

Sampling Issues So we can define the mapping, and it works fine As long as the size of the rendered image is approximately the same size as the texture source What if the textured polygon renders much smaller in the final image than the original texture? How about much bigger?

Mip-mapping to the Rescue Mip-mapping is a technique that creates multiple resolutions of an image i.e. Takes a 512x512 image and filters it to create 256x256, 128x128, 64x64, ..., 1x1 versions of it Then, when you’re looking up your texture coordinates, it uses the most appropriate mip-map level Or, more likely, interpolates between the two closest

Mip-mapping Example Original Texture Lower Resolution Versions Original Images from David Luebke @ UVa

Assigning Texture Coordinates We generally want an even sharing of texels (pixels in the texture) across all triangles But what about this case? Want to texture the teapot: Right has more even texel distribution, but does not preserve curvature. Do we want this? Or this?

Planar Mapping Just use the texture to fill all of space Same color for all z-values (u, v) = (x, y) http://www.siggraph.org/education/materials/HyperGraph/mapping/r_wolfe/r_wolfe_mapping_1.htm

Cylindrical Mapping “Wrap” the texture around your object Like a coffee can Same color for all pixels with the same angle u = θ / 2π v = y

Spherical Mapping “Wrap” the texture around your object Like a globe Same color for all pixels with the same angle u = ϕ / 2π v = (π - θ) / π

Spherical Mapping Example

Cube Mapping Not quite the same as the others Uses multiple textures (6, to be specific) Maps each texture to one face of a cube surrounding the object to be textured Then applies a planar mapping to each face

Environment Maps Cube mapping is commonly used to implement environment maps This allows us to “hack” reflection/refraction Render the scene from the center of the cube in each face direction Store each of these results into a texture Then render the scene from the actual viewpoint, applying the environment textures

Environment Mapping Example

Solid Textures We’ve talked a lot about 2D (image) textures Essentially taking a picture and pasting it on a surface No reason a texture HAS to be 2D, though Can have 1D textures (not that interesting) Can have 3D textures

3D Textures Actually, very easy to render with Much simpler than 2D textures However, much more difficult to generate

Relevant OpenGL Functions glTexImage2D glEnable(GL_TEXTURE_2D) glTexParameter glBindTexture gluBuild2DMipmaps glTexEnv glHint(GL_PERSPECTIVE_CORRECTION, GL_NICEST) glTexCoord2df(s,t)

Texture Mapping Review Texture mapping is a relatively simple way to add a lot of visual complexity to a scene Without increasing its geometric complexity Use mip-mapping to alleviate sampling problems There are infinitely many possible mappings Usually want to use the most “similar” one Texturing a plane? Use planar Texturing a sphere? Use spherical

Other Mapping Techniques So, now we know some things about texture mapping Allows us to change the color of simple geometry But color isn’t the only property a point can have Normals Bump mapping Location Displacement Mapping

Bump Mapping How do we get this? The underlying model is just a sphere

Bump Mapping Requires per-pixel (Phong) shading Just interpolating from the vertex normals gives a smooth-looking surface Bump mapping uses a “texture” to define how much to perturb the normal at that point Results in a “bumpy” surface http://en.wikipedia.org/wiki/Bump_mapping http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php http://nehe.gamedev.net/data/articles/article.asp?article=20

Bump Mapping At each point on the surface: Rendered Sphere Bump Map Note: Silhouette doesn’t change Rendered Sphere Bump Map Bump Mapped Sphere At each point on the surface: Do a look-up into the bump map “texture” Perturb the normal slightly based on the “color” Note that “colors” are actually just 3- or 4- vectors Images from Wikipedia

More Bump Mapping Examples

Displacement Mapping Bump mapping adds realism, but it only changes the appearance of the object We can do one better, and actually change the geometry of the object This is displacement mapping http://www.soylent-green.com/tutes/Displacement.html http://en.wikipedia.org/wiki/Displacement_mapping http://download.nvidia.com/developer/GPU_Gems_2/GPU_Gems2_ch08.pdf

Displacement Mapping Displacement mapping shifts all points on the surface in or out along their normal vectors Assuming a displacement texture d, p’ = p + d(p) * n Note that this actually changes the vertices, so it needs to happen in geometry processing

What does this buy us over bump mapping? Displacement Mapping Bump Mapping Displacement Mapping What does this buy us over bump mapping?

Movie Break! Red’s Dream Pixar, 1987 Available online: http://www.metacafe.com/watch/47464/pixar_reds_dream/

Motivating Programmable Graphics Hardware Note that neither of these techniques can be implemented using the fixed- function pipeline that we’ve talked about so far Bump mapping needs to delay lighting calculations until fragment processing Displacement mapping needs to be able to do a lookup and edit vertices in the geometry step

Programmable Graphics Hardware Most recent graphics cards are programmable Not quite like a CPU for various reasons On most hardware: Replace the vertex processing stage with a programmable vertex shader Replace the fragment processing stage with a programmable fragment (or pixel) shader Some things are still fixed-function, like rasterization

Shader Programs Vertex shader programs Fragment shader programs Run on each vertex, independently Output vertex properties (coordinates, texture coordinates, normal, color, etc.) Fragment shader programs Run on each fragment, independently Output the color of the fragment Can also kill a fragment

Programming Shaders Still a somewhat painful process Somewhere between C and assembly in terms of difficulty Cg is a bit lower level GLSL is more like C Thankfully, most shader programs are short

Shading Languages Cg GLSL

Cg I can talk a little bit about Cg It’s actually both a language and a runtime environment Compiles your code down to machine language for your specific hardware Can compile on the fly or ahead of time Why choose one or the other?

Cg Vertex Program Example

Cg Fragment Program Example

Programmable Hardware Review Most modern graphics hardware is programmable Can write your own vertex processing and fragment processing There are several languages for shader programming, including Cg and GLSL Any questions?

Schedule for the Rest of the Semester Programming Assignment 2 due 10/25 Programming Assignment 3 due 11/1 These already out Assignment 3 due 11/8 Final Project Proposal due 11/8

Schedule for the Rest of the Semester Programming Assignment 4 due approx. 11/20 Raytracing Final Exam -- Friday 12/14 @ 4:00pm Final Project due approx. 12/6 Can be flexible with this

Final Project Pretty much open-ended Proposal due 11/8 Can work on whatever you think is interesting Should be roughly 1.5-2.5x a regular assignment Proposal due 11/8 You must meet with me before then to discuss your project The “proposal” is a short (< 1 page) document that summarizes your project

Final Project “Topics” Make a game Something more graphically advanced than assignments 1 or 2 Implement some advanced OpenGL techniques Shadows, environment mapping, etc. Implement something interesting with programmable shading Displacement mapping, toon shading, etc.

Final Project “Topics” Add some advanced features to the raytracer Depth-of-field, soft shadows, caustics, etc. These will become clear later Implement a full rasterizer Extend your rasterizer from assignment 3 to do lighting, texture mapping, etc.

Final Project “Topics” Implement some advanced UI Use a webcam, joystick, Xbox controller, etc. to do something interesting Implement some functional/analytic graphics Bezier curves, splines, etc. Fractals Implement some image processing tools i.e. Photoshop

Final Project “Topics” Generate some sufficiently advanced animation sequence Implement some high-dynamic range tone-mapping techniques If any of this (or anything else) interests you, and we haven’t yet covered it in class, contact me and I’ll point you to some info

Next Time Enjoy your fall break! When we come back, it’s on to raytracing