bump mapping

14
Topics in Computer Graphics Spring 2010

Upload: waneta

Post on 11-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

Bump Mapping. Topics in Computer Graphics Spring 2010. Application. Shading. Maps. Height map (Grey scale). Base texture (RGB). Normal map (normal encoded RGB). Normal Map & Height Field. Normal Map. Normal vector encoded as rgb [-1,1] 3 [0,1] 3 : rgb = n*0.5 + 0.5 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Bump Mapping

Topics in Computer Graphics

Spring 2010

Page 2: Bump Mapping

Application

Page 3: Bump Mapping

Shading

Page 4: Bump Mapping

Maps

Base texture (RGB)

Height map (Grey scale)

Normal map (normal encoded RGB)

Page 5: Bump Mapping

Normal Map & Height Field

Page 6: Bump Mapping

Normal MapNormal vector encoded as rgb

[-1,1]3 [0,1]3: rgb = n*0.5 + 0.5RGB decoding in fragment shaders

vec3 n = texture2D(NormalMap, texcoord.st).xyz * 2.0 – 1.0

In tangent space, the default (unit) normal points in the +z direction. Hence the RGB color for the straight up normal is (0.5,

0.5, 1.0). This is why normal maps are a blueish colorNormals are then used for shading computation

Diffuse: n•lSpecular: (n•h)shininess

Computations done in tangent space

Page 7: Bump Mapping

In order to build this Tangent Space, we need to define an orthonormal (per vertex) basis, which will define our tangent space.

Tangent space is composed of 3 orthogonal vectors (T, B, N)Tangent (S Tangent)Bitangent (T Tangent)Normal

One has to calculate a tangent space matrix for every single vertex

Tangent Space

Page 8: Bump Mapping

Tangent SpaceSuppose a point pi in world coordinate

system for whose texture coordinates are (ui, vi)

Writing this equation for the points p1, p2 and p3, defining the triangle :p1 = u1.T + v1.B p2 = u2.T + v2.Bp3 = u3.T + v3.B

Page 9: Bump Mapping

Tangent Space6 eqns, 6 unknowns

T,B: (unit) vectors in

object space

Page 10: Bump Mapping

TBN Matrix Per VertexUse the averaged face normal as the vertex

normalDo the same for tangent and bitangent

vectorsNote that the T, B vectors might not be

orthogonal to the normal vectorUse Gram-Schmidt to make sure they are

orthonormal

Page 11: Bump Mapping

Coordinate Transformation

zoy

ox

o

zyx

zyx

zyx

zoy

ox

o

zzz

yyy

xxx

zT

yT

xT

zT

yT

xT

zzz

yyy

xxx

zoy

ox

o

v

v

v

NNN

BBB

TTT

v

v

v

NBT

NBT

NBT

v

v

v

v

v

v

NBT

NBT

NBT

v

v

v

1

Tangent space to object space

Object space to tangent space

This reference (http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson8.php) is correctTyphoonLabs is not right.

Page 12: Bump Mapping

What is mat3 (v1,v2,v3)?!It turns out to be “blue”

)(

)(

)(

3 deduce We

333

222

111

zyx

zyx

zyx

vvv

vvv

vvv

mat

This is the matrix that converts object space to tangent space

Page 13: Bump Mapping

Referencehttp://www.opengl.org/sdk/docs/tutorials

/TyphoonLabs/Chapter_4.pdfhttp://www.ozone3d.net/tutorials/bump_mapping.phphttp://www.paulsprojects.net/tutorials/simplebump/

simplebump.htmlhttp://www.terathon.com/code/tangent.htmlhttp://www.blacksmith-studios.dk/projects/

downloads/tangent_matrix_derivation.phphttp://jerome.jouvie.free.fr/OpenGl/Lessons/

Lesson8.php

Page 14: Bump Mapping