Game Programming (Mapping)

Slides:



Advertisements
Similar presentations
Lecture 8 Transparency, Mirroring
Advertisements

Exploration of bump, parallax, relief and displacement mapping
Graphics Pipeline.
03/16/2009Dinesh Manocha, COMP770 Texturing Surface’s texture: its look & feel Graphics: a process that takes a surface and modifies its appearance using.
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.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
Texture Visual detail without geometry. Texture Mapping desire for heightened realism.
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
(conventional Cartesian reference system)
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Computer Graphics Mirror and Shadows
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 638, Fall 2001 Admin Grad student TAs may have had their accounts disabled –Please check and the lab if there is a problem If you plan on graduating.
Computer Graphics Texture Mapping
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
Game Programming (Mapping) Spring.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
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.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
CS-378: Game Technology Lecture #8: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Recap Last lecture we looked at local shading models –Diffuse and Phong specular terms –Flat and smooth shading Some things were glossed over –Light source.
Ying Zhu Georgia State University
Discrete Techniques.
Week 7 - Wednesday CS361.
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan
Texture Mapping Fall, 2016.
Week 7 - Monday CS361.
Photorealistic Rendering vs. Interactive 3D Graphics
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
So Far We have assumed that we know: The point The surface normal
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
Interactive Graphics Algorithms Ying Zhu Georgia State University
(c) 2002 University of Wisconsin
© University of Wisconsin, CS559 Fall 2004
Chapter IX Bump Mapping
Real-time Rendering Shadow Maps
Real-Time Rendering Intro to Shadows
UMBC Graphics for Games
(c) 2002 University of Wisconsin
(c) University of Wisconsin, CS 559
CS5500 Computer Graphics May 29, 2006
CS-378: Game Technology Lecture #4: Texture and Other Maps
Last Time Presentation of your game and idea Environment mapping
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Frame Buffer Applications
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Game Programming (Mapping) 2014. Spring

Texture Mapping The problem Solution Colors, normals, etc. are only specified at vertices. How do we add detail between vertices? Solution Specify the details in an image (the texture) and specify how to apply the image to the geometry (the map) Works for shading parameters other than color, as we shall see The basic underlying idea is the mapping

Basic Mapping The texture lives in a 2D space Parameterize points in the texture with 2 coordinates: (s,t) These are just what we would call (x,y) if we were talking about an image, but we wish to avoid confusion with the world (x,y,z) Define the mapping from (x,y,z) in world space to (s,t) in texture space With polygons: Specify (s,t) coordinates at vertices Interpolate (s,t) for other points based on given vertices

Basic Mapping

I assume you recall… Texture sampling (aliasing) is a big problem d v Mipmaps and other filtering techniques are the solution u v d

I assume you recall… GL_NEAREST GL_LINEAR Mipmappping

I assume you recall… The texture value for points that map outside the texture image can be generated in various ways Repeat, Clamp, … Width and height of texture images is constrained (powers of two, sometimes must be square) Wrap S : GL_CLAMP Wrap T : GL_CLAMP Wrap S : GL_CLAMP Wrap T : GL_REPEAT Wrap S : GL_REPEAT Wrap T : GL_CLAMP Wrap S : GL_REPEAT Wrap T : GL_REPEAT

Textures in Games The game engine provides some amount of texture support Artists are supplied with tools to exploit this support They design the texture images They specify how to apply the image to the object Commonly, textures are supplied at varying resolutions to support different hardware performance Note that the texture mapping code does not need to be changed - just load different sized maps at run time Textures are, without doubt, the most important part of a game’s look

Example Texture Tool

Standard Pipeline

Multitexturing Bump skin + Key-frame model WOW! geometry Result Some effects are easier to implement if multiple textures can be applied Future lectures: Light maps, bump maps, shadows, … Key-frame model geometry Decal skin Bump skin Gloss skin WOW! Result +

Packing Textures Problem Solution The limits on texture width/height make it inefficient to store many textures For example: long, thin objects Solution Artists pack the textures for many objects into one image The texture coordinates for a given object may only index into a small part of the image Care must be taken at the boundary between sub-images to achieve correct blending Mipmapping is restricted

Combining Textures

Texture Matrix Normally, the texture coordinates given at vertices are interpolated and directly used to index the texture The texture matrix applies a homogeneous transform to the texture coordinates before indexing the texture What use is this?

Animating Texture (method 1) Loading a texture onto the graphics card is very expensive But once there, the texture matrix can be used to “transform” the texture For example, changing the translation can select different parts of the texture If the texture matrix is changed from frame to frame, the texture will appear to move on the object This is particularly useful for things like flame, or swirling vortices, or pulsing entrances, …

Projective Texturing The texture should appear to be projected onto the scene, as if from a slide projector Solution: Equate texture coordinates with world coordinates Think about it from the projector’s point of view: wherever a world point appears in the projector’s view, it should pick up the texture Use a texture matrix equivalent to the projection matrix for the projector – maps world points into texture image points Details available in many places

Environment Mapping Environment Map Viewer Reflected ray Object Environment mapping produces reflections on shiny objects Texture is transferred in the direction of the reflected ray from the environment map onto the object Reflected ray: R=2(N·V)N-V What is in the map? Environment Map Viewer Reflected ray Object

Environment Maps The environment map may take one of several forms: Cubic mapping Spherical mapping (two variants) Parabolic mapping Describes the shape of the surface on which the map “resides” Determines how the map is generated and how it is indexed What are some of the issues in choosing the map?

Environment Mapping Cube mapping is the norm nowadays eye x y z n

Need For Speed Underground Environment Mapping www.debevec.org Need For Speed Underground Far Cry

Light Maps Speed up lighting calculations by pre-computing lighting and storing it in maps Allows complex illumination models to be used in generating the map (eg shadows, radiosity) Used in complex rendering algorithms (Radiance), not just games Issues: How is the mapping determined? How are the maps generated? How are they applied at run-time?

Example www.flipcode.com Call of duty

Example Nearest interpolation Linear interpolation What type of lighting (diffuse, specular, reflections) can the map store?

Example No light maps With light maps

Applying Light Maps Actually, make points darker with light map Use multi-texturing hardware First stage: Apply color texture map Second stage: Modulate with light map Actually, make points darker with light map DirectX allows you to make points brighter with texture

Fog Maps Dynamic modification of light-maps Put fog objects into the scene Compute where they intersect with geometry and paint the fog density into a dynamic light map Use same mapping as static light map uses Apply the fog map as with a light map Extra texture stage

Fog Map Example

Stores heights: can derive normals Bump Mapping Texture values perturb surface normals Bump map Stores heights: can derive normals + Bump mapped geometry = geometry

Dot Product bump mapping Store normal vectors in the bump map Apply the bump map using the dot3 operator Takes a dot product www.nvidia.com

Normal Mapping DOOM 3 James Hastings-Trew

Environment Bump Mapping Perturb the environment map lookup directions with the bump map Nvidia Far Cry

Displacement Mapping Normal Mapping Problem Displacement Mapping Doesn’t take into account geometric surface depth Does not exhibit parallax No self-shadowing of the surface Coarse silhouettes expose the actual geometry being drawn Displacement Mapping Displace actual positions from Heightfield Map

Displacement Mapping (Result) Displacement Offset

Billboards Billboards are texture-mapped polygons, typically used for things like trees Image-based rendering method where complex geometry (the tree) is replaced with an image placed in the scene (the textured polygon) The texture has alpha values associated with it: 1 where the tree is, and 0 where it isn’t So you can see through the polygon in places where the tree isn’t

Planar Reflections (Flat Mirrors) Use the stencil buffer, color buffer and depth buffer Basic idea: We need to draw all the stuff around the mirror We need to draw the stuff in the mirror, reflected, without drawing over the things around the mirror Key point: You can reflect the viewpoint about the mirror to see what is seen in the mirror, or you can reflect the world about the mirror

Reflecting Objects If the mirror passes through the origin, and is aligned with a coordinate axis, then just negate appropriate coordinate Otherwise, transform into mirror space, reflect, transform back Wall Mirror

Reflection Example The stencil buffer after the second pass The color buffer after the second pass – the reflected scene cleared outside the stencil

Reflection Example The color buffer after the final pass

So what game did you play recently ?

Why Shadows? Shadows tell us about the relative locations and motions of objects

Facts about Shadows Shadows can be considered as areas hidden from the light source Suggests the use of hidden surface algorithms For scenes with static lights and geometry, the shadows are fixed Can pre-process such cases Cost is in moving lights or objects Point lights have hard edges, and area lights have soft edges

Ground Plane Shadows Shadows cast by point light sources onto planes are an important case that is relatively easy to compute Shadows cast by objects (cars, players) onto the ground Accurate if shadows don’t overlap Can be fixed, but not well L(directional light) (xp,yp,zp) (xsw,ysw,zsw)

Shadows in Light Maps Static shadows can be incorporated into light maps When creating the map, test for shadows by ray-casting to the light source - quite efficient Area light sources should cast soft shadows Interpolating the texture will give soft shadows, but not good ones, and you loose hard shadows Sampling the light will give better results: Cast multiple rays to different points on the area light, and average the results Should still filter for best results

Soft Shadow Example

Shadows in Games Megaman Grand Theft Auto Metal Gear

Projective Shadows Create a texture (dark on white) representing the appearance of the occluder as seen by the light Game programmers frequently call this a shadow map Can create it by “render to texture” with the light as viewpoint Use projective texturing to apply it to receivers Works if the appearance of the occluder from the light is reasonably constant Requires work to identify occluders and receivers

Shadow Volumes A shadow volume for an object and light is the volume of space that is shadowed That is, all points in the volume are in shadow for that light/object pair Creating the volume: Find silhouette edges of shadowing object as seen by the light source Extrude these edges away from the light, forming polygons Clip the polygons to the view volume

Shadow Volumes

Shadow Volume