Environment Mapping

Environment Mapping

Environment Mapping CSE 781 Han-Wei Shen Environment 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 mapping supported by graphics hardware Basic Idea Assuming the environment is far away and the object does not reflect itself – the reflection at a point can be solely decided by the reflection vector environment map n eye r e reflective surface Basic Steps Create a 2D environment map For each pixel on a reflective object, compute the normal Compute the reflection vector based on the eye position and surface normal Use the reflection vector to compute an index into the environment texture Use the corresponding texel to color the pixel Finding the reflection vector r = 2 (n.e) n - e n Assuming e and n are all normalized e r r r e e.n Blinn and Newell’s 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 ρ (ρ = 0, φ = 0) z π (rx,ry, rz) 3π/4 x (ρ = π/2, φ = 0) π/2 y π/4 ρ = arccos(-rz) ρ: latitude [0, π] φ = atan2(ry, rx) 0 π/2 π 3 π/2 2π φ: longitude [0, 2π] φ Issues Seams at φ = 0 when the triangle vertices span over Distortion at the poles, and when the triangle vertices span over Not really been used much in practice Cubic Environment Mapping Introduced by Nate Green 1986 (also known as environment cube map) Place the camera in the center of the environment and project it to 6 sides of a cube Cubic Environment Mapping (2) 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 plane Then use the remaining two components to access the texture from that plane. 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 of. Environment Cube Map Rendering Examples Sphere Mapping The image texture is taken from a perfectly reflective sphere, which is viewed from the eye orthographically. Synthetic scene can be generated using ray tracing (u,v) (u,v,sqrt(1-u^2-v^2)) (0,0,0) Sphere Mapping (2) To access the sphere map texture The surface normal (n) and eye (e) vectors need to be first transformed to the eye space 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 = (rx,ry,rz) + (0,0,1) reflection vector Directoin to the eye in local space 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).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us