Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i...

12
Environment Mapping H W i Sh Han-Wei Shen

Transcript of Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i...

Page 1: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

Environment Mapping

H W i ShHan-Wei Shen

Page 2: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

E i t M iEnvironment Mapping

Also called reflection mapping Also called reflection mapping First proposed by Blinn and Newell 1976 A cheap way to create reflections on curved

surfaces – can be implemented using texture i t d b hi h dmapping supported by graphics hardware

Page 3: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

B i IdBasic Idea

Assuming the environment is far away and Assuming the environment is far away and the object does not reflect itself – the reflection at a point can be solely decided byreflection at a point can be solely decided by the reflection vector

n

environment map

n

er

reflective surface

eye

reflective surface

Page 4: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

B i StBasic Steps Create a 2D environment map Create a 2D environment map For each pixel on a reflective object, compute

the normalthe normal Compute the reflection vector based on the eye

position and surface normalposition and surface normal Use the reflection vector to compute an index

into the environment textureinto the environment texture Use the corresponding texel to color the pixel

Page 5: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

Fi di th fl ti tFinding the reflection vector

r = 2 (n.e) n - e

en

r r

Assuming e and n are all normalized

r

ee.n

Page 6: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

Bli d N ll’Blinn and Newell’s Blinn and Newell’s Method (the first EM algorithm) Blinn and Newell s Method (the first EM algorithm) Convert the reflection vector into spherical coordinates

(which in turn will be normalized to [0,1] and used as ( [ ](u,v) texture coordinates

z( = , = 0)

z(rx,ry, rz)

3 /4

x

y

( = /2, = 0)

( )

/4

: latitude [0, ] longitude [0, 2 ]

= arccos(rz) = atan2(ry, rx)

3 0

Page 7: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

IIssues

Seams at = 0 when the triangle vertices Seams at = 0 when the triangle vertices span overDi t ti t th l d h th t i l Distortion at the poles, and when the triangle vertices span over N t ll b d h i ti Not really been used much in practice

Page 8: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

C bi E i t M iCubic Environment Mapping

Introduced by Nate Green 1986 (also known Introduced by Nate Green 1986 (also known as environment cube map) Pl th i th t f th Place the camera in the center of the environment and project it to 6 sides of a cubecube

Page 9: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

C bi E i t M i (2)Cubic Environment Mapping (2) Texture mapping process Texture mapping process Given the reflection vector (x,y,z), first find the major

component and get the corresponding plane. (-3.2, 5.1, -8 4) > z plane8.4) -> -z plane

Then use the remaining two components to access the texture from that plane.

N li th t (0 1) Normalize them to (0,1) (-3.2, 5.1) -> ((-3.2/8.4)/2+0.5, (5.1/8.4)/2+0.5) Then perform the texture lookup

No distortion or seam problems, although when two vertices of the same polygon pointing to different planes need to be taken care ofplanes need to be taken care of.

Page 10: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

E i t C b MEnvironment Cube Map

Rendering Examples Rendering Examples

Page 11: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

S h M iSphere Mapping

The image texture is taken from a perfectly The image texture is taken from a perfectly reflective sphere, which is viewed from the eye orthographicallyeye orthographically.

Synthetic scene can be t d i t i generated using ray tracing

(0,0,0)(u,v) (u,v,sqrt(1-u^2-v^2))

Page 12: Environment Mappingweb.cse.ohio-state.edu/~wang.3602/courses/cse5542-2013-spring/17-env.pdfCbi E i tM iCubic Environment Mapping Introduced by Nate Green 1986 (also knownIntroduced

S h M i (2)Sphere Mapping (2) To access the sphere map texture To access the sphere map texture The surface normal (n) and eye (e) vectors need to be first

transformed to the eye space Th t th fl ti t l Then compute the reflection vector as usual

(r = (rx,ry,rz) = e’-2(n’.e’)n’) Now, compute the sphere normal in the local space n = p p p

(rx,ry,rz) + (0,0,1)

Directoin to the eye in local spacereflection vector

Normalize it and use x and y to access the sphere texture map: u = rx / M + ½ ; v = ry /M + ½;

where M = 2 sqrt(rx^2 + ry^2 + (rz+1)^2)q ( y ( ) )