1 / 37

Hardware Accelerated Anisotropic Lighting

Hardware Accelerated Anisotropic Lighting. Mark J. Kilgard NVIDIA Corporation. Credit for this Idea. Wolfgang Heirdrich and Hans-Peter Seidel (University of Erlangen, Germany)

glynis
Download Presentation

Hardware Accelerated Anisotropic Lighting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hardware Accelerated Anisotropic Lighting Mark J. Kilgard NVIDIA Corporation

  2. Credit for this Idea • Wolfgang Heirdrich and Hans-Peter Seidel (University of Erlangen, Germany) • They were inspired by an technique developed by Malte Zöckler, Detlev Stalling, and Hans-Christian Hege (Konrad-Zuse-Zentrum für Informationstechnick in Berlin) • Scientific visualization technique that morphed into realistic rendering trick

  3. Anisotropic Surfaces • What do these surfaces have in common? • Satin cloth • Christmas tree balls (the ornaments covered in threads) • Compact Discs • Brushed metal • Hair • Answer: they all exhibit anisotropic lighting characteristics

  4. “Normal” Surfaces • Traditional lighting models consider 3D surfaces as being locally flat • The normal vector at a point on the surface is orthogonal to the flatness • Implicitly assumes surface tangents are uniformly distributed (isotropic distribution) • Effects such as bump mapping may perturb the surface normals, but substructure of the surface still modeled as locally flat

  5. Some surfaces have a grain • Woven satin cloth has an inherent grain (locally, favors a particular surface tangent orientation) • As does brushed metal • As does hair • As do the groves on a record or CD • As do satin fibers on Xmas tree ornament • Accounts for unique visual appearance!

  6. What creates anisotropy? • Key to anisotropic surfaces:distribution of surface normals along thesurface scratches or fibers is different from the distribution across them • A relatively distant observer sees the lighting result, but not the microstructure

  7. Specular Highlight on Sphere Normal specular highlight looks like a “spot”

  8. Anisotropic Sphere Consider satin thread Christmas tree ornament Specular highlight looks like a halo!

  9. Visualize Sphere’s Grain Satin threads run from pole to pole Similar to pattern of hair on human head!

  10. Different Lighting Effect Change the grain to lines of latitude... …changes the lighting appearance!

  11. A Record or LP Grooves capture the light

  12. A Brushed Metal Torus

  13. Again, Grain Changes Lighting

  14. Standard Local Lighting Model • Intensity at a surface point: Iout = Iambient + Idiffuse + IspecularwhereIambient = ka IaIdiffuse = Kd < L·N >  IinIspecular = Ks  pow(< V·R >, n)  Iin

  15. Symbol Cheat Sheet Iin -- incoming intensity from a lightKa -- ambient materialKd -- diffuse materialKs -- specular material

  16. Symbol Cheat Sheet (2) < L·N > -- dot product of (normalized) light vector and surface normal vector < V·R > -- dot product of (normalized) view vector and reflection vectorpow(x, y) -- x raised to yth powern -- material shininess

  17. Lighting a Fiber • How would you light a thread or hair? • There is no traditional surface normal! • Logically, each point on the thread has an infinite “circle” of normals perpendicular to the tangent at the point.

  18. Normals for a Fiber Side view: possible normals tangent at a point Head on view: infinite circle of possible normals tangent sticks out of page!

  19. Normals, Normals Everywhere! • Too many normals to pick from! • Which normal should be used for lighting? • Ideally, integrate the contribution of all normals. • To hard, so just pick the most significant normal and use it. • (Most significant normal’s contribution still will be less than full contribution.)

  20. Most Significant Normal • Pick the normal that is co-planar with the light vector and view vector. • This vector will maximize the lighting dot products (i.e., it’s the most significant vector).

  21. Math is Cool • Without determining the most significant normal (N) explicitly, the < L·N > and< V·R > dot products can be expressed in terms of L, T, and V. • Reminders: L -- vector to light for point on thread T -- tangent vector for point on thread V -- vector to viewer for point on thread

  22. The Cool Math • < L·N > = sqrt( 1 - (< L ·T >) 2) • < V·R > = sqrt( 1 - (< L ·T >) 2)  sqrt( 1 - (< V ·T >) 2) - < L ·T >  < V ·T > • Cool observation:< L·N > and < V·R > can be determined by a bivariate function of< L ·T > and < V ·T >

  23. Wish Hardware Could... • Compute the two dot products < L ·T > and < V ·T > • (Note: assume constant viewer and directional light so V and L vectors are constant, but T can vary per-vertex) • Then compute an arbitrary function based on the two dot productsWould you believe OpenGL does this!

  24. OpenGL supports this! • OpenGL 4x4 texture matrix computes 4 dot products (we only need two). • Treat texture matrix rows as constant vectors. • Consider the texture coordinate to be the tangent vector (varying at vertices) • OpenGL also supports arbitrary bivariate functions, usually referred to as 2D texture maps! • Note that the output of the texture matrix is the input to our bivariate function!

  25. Setting up the Texture Matrix Lx Ly Lz 1 Vx Vy Vz 1 0 0 0 0 0 0 0 2 Tx Ty Tz 1 1/2(< L ·T > ) +1 1/2(< V ·T > ) +1 0 1 = 1/2  • Rows contains L and V vectors • Also scale & bias from [-1, 1] dot product space to [0, 1] texture space

  26. And pre-compute a 2D texture • Texture acts as 2D table to computeIout = Iambient + Idiffuse + Ispecular= Ka Ia + Kd < L·N >  Iin + Ks  pow(< V·R >, n)  Iin • Varying parameters are in above equation are < L·N > and < V·R > (I.e, bivariate)

  27. Brightness • It may be desirable to raise the diffuse and specular terms to a small power (between 2 or 4) to account for the fact that the most-significant normal does not account for the entire lighting of the anisotropic surface

  28. Example 2D Texture < V ·R > axis < L ·N > axis

  29. Anisotropic Rendering • When rendering anisotropic surfaces • Setup and enable 2D texture that encodes lighting model as a function of < L·N > and < V·R > • Setup texture matrix as described • Pass per-vertex tangent vector of surface or fiber as texture coordinate using glTexCoord3f(Tx,Ty,Tz) • Result: anisotropic lighting!

  30. Caveats • If tangent vectors need to be transformed to eye space, concatenate inverse transpose of modelview matrix into texture matrix with glMultMatrix • Send only unit length tangent vectors (there is no equivalent to glEnable(GL_NORMALIZE) to unit-ize your tangent vectors texture coordinates) • Per-vertex lighting artifacts apply

  31. Self-shadowing • Anisotropic light model does not account for self-shadowing due to back faces (lighting fibers do not have this issue) • Standard OpenGL lighting models self-shadowing by clamping negative lighting dot products to zero • By enabling and modulated with a extremely saturated OpenGL light source, self-shadowing can be supported • This requires sending normals

  32. Self-shadowing Example Back-side not self-shadowed (bad, too bright) Backside self-shadowed(good)

  33. Multiple Lights Sources • As described, each light requires a distinct 2D texture and texture matrix • Multiple passes with additive blending can simulate multiple light sources • ARB_multitexture with an additive texture environment can also support multiple lights • Also, a 3D texture could be used to handle two lights (would require a big texture)

  34. Modeling Anisotropic Surfaces • Unfortunately, few 3D modelers have support for assigning anisotropic tangent vector distributions • Can be assigned implicitly for common shapes like disks and spheres

  35. References • Heidrich and Seidel “Efficient Rendering of Anisotropic Surfaces Using Computer Graphics Hardware,” http://www9.informatik.uni-erlangen.de/eng/research/rendering/anisotropic/ • Zöckler, Stalling, and Hege, “Interactive Visualization of 3D-Vector Fields Using Illuminated Stream Lines,” Proceedings of Visualization ‘96, pp. 107-113. http://www.zib.de/stalling/isl.html • David Banks, “Illumination in Diverse Codimensions,” SIGGRAPH ‘94 Proceedings, pp. 327-334.

  36. 3D Vector Field Visualization by Zöckler, Stalling, and Hege Electrostatic field of a benzene molecule

  37. Conclusions • Unconventional light models that incorporate anisotropic lighting effects can be hardware accelerated by OpenGL • A large class of objects with interesting visual properties can be rendered in real-time • Games that incorporate anisotropic lighting effects have opportunity to stand out from the crowd!

More Related