Bump Mapping CSE 781 Roger Crawfis.

Slides:



Advertisements
Similar presentations
Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
Advertisements

COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
Virtual Realism TEXTURE MAPPING. The Quest for Visual Realism.
Normal Map Compression with ATI 3Dc™ Jonathan Zarge ATI Research Inc.
Michael I. Gold NVIDIA Corporation
Topics in Computer Graphics Spring Application.
Exploration of bump, parallax, relief and displacement mapping
Week 8 - Friday.  What did we talk about last time?  Radiometry  Photometry  Colorimetry  Lighting with shader code  Ambient  Directional (diffuse.
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 Visual detail without geometry. Texture Mapping desire for heightened realism.
Advanced Texture and Lighting
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
(conventional Cartesian reference system)
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
Computer Graphics Inf4/MSc Computer Graphics Lecture 7 Texture Mapping, Bump-mapping, Transparency.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Geometric Objects and Transformations. Coordinate systems rial.html.
ECSE 4750: Computer Graphics Rensselaer Polytechnic Institute Nov 5, 2012 Texture and Texture Mapping.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
A Crash Course in HLSL Matt Christian.
1 Dr. Scott Schaefer Programmable Shaders. 2/30 Graphics Cards Performance Nvidia Geforce 6800 GTX 1  6.4 billion pixels/sec Nvidia Geforce 7900 GTX.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CS 445 / 645: Introductory Computer Graphics Light.
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.
Game Programming 06 The Rendering Engine
Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
BUMP-MAPPING SET09115 Intro to Graphics Programming.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Bump Map 1. High Field Function: H(u, v) New Normal : N’
Lab: Vertex Shading Chris Wynn Ken Hurley. Objective Hands-On vertex shader programming Start with simple programs … Part 1: Textured-Lit Teapot.
Real-Time Relief Mapping on Arbitrary Polygonal Surfaces Fabio Policarpo Manuel M. Oliveira Joao L. D. Comba.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
Advanced Texture Mapping Bump Mapping & Environment Mapping (Reflection)
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
Real-Time Relief Mapping on Arbitrary Polygonal Surfaces Fabio Policarpo Manuel M. Oliveira Joao L. D. Comba.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Computer Graphics Overview
- Introduction - Graphics Pipeline
Ying Zhu Georgia State University
Programmable Shaders Dr. Scott Schaefer.
Buffers and texture mapping
Graphics Processing Unit
3D Graphics Rendering PPT By Ricardo Veguilla.
How to Bump Map a Skinned Polygonal Model
Bump Mapping -1 Three scales of detail on an object
The Graphics Rendering Pipeline
Real-time Computer Graphics Overview
Chapter IX Bump Mapping
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Chapter XIV Normal Mapping
Computer Graphics Introduction to Shaders
Advanced Texture Mapping
Texture Mapping Jung Lee.
Presentation transcript:

Bump Mapping CSE 781 Roger Crawfis

Bump Mapping Many textures are the result of small perturbations in the surface geometry Modeling these changes would result in an explosion in the number of geometric primitives. Bump mapping attempts to alter the lighting across a polygon to provide the illusion of texture.

Bump Mapping Example Crawfis 1991

Bump Mapping Crawfis 1991

Bump Mapping Consider the lighting for a modeled surface.

Bump Mapping We can model this as deviations from some base surface. The question is then how these deviations change the lighting. N

Bump Mapping Assumption: small deviations in the normal direction to the surface. X = X + B N Where B (our height field) is defined as a 2D function parameterized over the surface: B = f(u,v)

Bump Mapping Step 1: Putting everything into the same coordinate frame as B(u,v). x(u,v), y(u,v), z(u,v) – this is given for parametric surfaces, but easy to derive for other analytical surfaces. Or O(u,v)

Bump Mapping Define the tangent plane to the surface at a point (u,v) by using the two vectors Ou and Ov, resulting from the partial derivatives. The normal is then given by: N = Ou  Ov N

Bump Mapping The new surface positions are then given by: O’(u,v) = O(u,v) + B(u,v) N Where, N = N / |N| Differentiating leads to: O’u = Ou + Bu N + B (N)u  O’u = Ou + Bu N O’v = Ov + Bv N + B (N)v  O’v = Ov + Bv N If B is small (remember it is a small height pertubation).

Bump Mapping This leads to a new normal: N’(u,v)  O’u  O’v = Ou  Ov - Bu(N  Ov) + Bv(N  Ou) + Bu Bv(N  N) = N - Bu(N  Ov) + Bv(N  Ou) = N + D D N’ N

Bump Mapping For efficiency, can store Bu and Bv in a 2-component texture map. This is commonly called an offset vector map. Note: It is oriented in tangent-space, not object space. The cross products are geometry terms only (we only care about the relative direction). N’ will of course need to be normalized after the calculation and before lighting.

Bump Mapping An alternative representation of bump maps can be viewed as a rotation of the normal. The rotation axis is the cross-product of N and N’.

Bump Mapping Store in a texture and use textures to alter the surface normal Does not change the shape of the surface Just shaded as if it were a different shape Swirly Bump Map Sphere w/Diffuse Texture Sphere w/Diffuse Texture & Bump Map

Simple textures work great Bump Map Cylinder w/Diffuse Texture Map Cylinder w/Texture Map & Bump Map

What's Missing? There are no bumps on the silhouette of a bump-mapped object

Bump Mapping We can store: The height displacement Model space normals Object space normals Tangent space normals The offset vectors in tangent space The rotations in tangent space Matrices Quaternians Euler angles Model dependent (encoded for that specific model) versus reusable (same material).

Normal Maps Store the normal directly in the texture.

Normal Maps Diffuse Color Texture Map Normal Map Each pixel RGB values is really a normal vector relative to the surface at that point. -1 to 1 range is mapped to 0 to 1 for the texture so normals become colors.

Normal Map Operation Vertex Normal Vertex Normal Normals from For each pixel, determine the normal from a texture image. Use that to compute the color.

Does this make any difference? Just texture mapped Texture and normal maps Notice: The geometry is unchanged. There’s the same number of vertices and triangles. This effect is entirely from the normal map.

Some details Normal maps are typically in object or model space We have to rotate them to our world coordinate system. What does it take to rotate something to a specific frame?

Normals, Tangents, and Binormals Z: Normal Y: Binormal X: Tangent The normal is given. The tangent is determined by which way u is for the texture map. The binormal (bitangent) is the cross product of the two.

HLSL code for normal mapping struct VS_INPUT { float4 position : POSITION0; float2 texCoord : TEXCOORD0; float3 normal : NORMAL0; float3 binormal : BINORMAL0; float3 tangent : TANGENT0; }; struct VS_OUTPUT float4 worldPosition : TEXCOORD1; // Note: tangentToWorld is actually // TEXCOORD2, 3, and 4 float3x3 tangentToWorld : TEXCOORD2; VS_OUTPUT VertexShader( VS_INPUT input ) { VS_OUTPUT output; // transform the position into projection space float4 worldPosition = mul(input.position, World); output.worldPosition = worldPosition; output.position = mul(mul(worldPosition, View), Projection); output.tangentToWorld[0] = mul(input.tangent, World); output.tangentToWorld[1] = mul(input.binormal, World); output.tangentToWorld[2] = mul(input.normal, World); output.texCoord = input.texCoord; return output; }

Pixel Shader float4 PixelShader( VS_OUTPUT input ) : COLOR0 { float3 N = tex2D(NormalMapSampler, input.texCoord); N = normalize(mul(N, input.tangentToWorld)); float3 V = normalize(Eye - input.worldPosition); float3 L = normalize(LightPosition - input.worldPosition); float3 H = normalize(V + L); float4 diffuse = LightColor * max(dot(N, L), 0); float4 specular = LightColor * pow(saturate(dot(N, H)), SpecularPower); float4 diffuseTexture = tex2D(DiffuseTextureSampler, input.texCoord); // return the combined result. return (diffuse + LightAmbientColor) * diffuseTexture + specular * SpecularColor; }

Normal Maps Notes: Can transform the light to tangent space. Saves computation at the fragment level. More expensive at the vertex level. Many lights? Can bake the normals into world space and use them directly. http://www.computerarts.co.uk/__data/assets/image/185268/varieties/7.jpg

Normal Maps http://amber.rc.arizona.edu/lw/normalmaps.html

Normal Maps http://amber.rc.arizona.edu/lw/normalmaps.html

Other Mappings BDRF (minimizing the bumps) Horizon maps (adding shadows) Parallax mapping (adding occlusion) Displacement mapping (changing the geometry) Geometry images Not bump mapping, but an encoding of the geometry into a texture map.

Height Mapping With the new power of programmable shaders, height maps are becoming fairly easy. You do the math on the GPU. This is required when you do displacement mapping unless you have two textures for the same thing (displacement map and normal map).

Comparison View Dependent Displacement Mapping Bump Mapping Horizon (shadows) Displacement Mapping

Depth Billboards You can use pseudo-depth textures to model simple geometry or billboards Used for “depth sprites”, where a screen aligned image can also have correct depth Previous stage must be Dot Product program Best precision if source texture is unsigned HILO, though other formats may be used If the new depth value is outside of the range of the near and far depth range values, the fragment is rejected (that is, it’s clipped to near/far planes) Calculates two dot products, and replaces the fragment (window) depth with their quotient Output color is always (0,0,0,0)

Imposters with Depth