Emboss Bump Mapping - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Emboss Bump Mapping

Description:

Implementation on TNT. Calculate vectors, texcoords on the host ... Implementation on TNT (cont'd) Combiner 0 alpha setup: (1-T0a) T1a - 0.5 ... – PowerPoint PPT presentation

Number of Views:284
Avg rating:3.0/5.0
Slides: 15
Provided by: michae200
Category:
Tags: bump | emboss | mapping | tnt

less

Transcript and Presenter's Notes

Title: Emboss Bump Mapping


1
Emboss Bump Mapping
  • Michael I. Gold
  • NVIDIA Corporation

2
Bump Mapping
  • Real bump mapping uses per-pixel lighting
  • Lighting calculation at each pixel based on
    perturbed normal vectors
  • Computationally expensive
  • For more information see
  • Blinn, J. Simulation of Wrinkled Surfaces.
    Computer Graphics. 12, 3 (August 1978), 286-292

3
Emboss Bump Mapping
  • Emboss bump mapping is a hack
  • Diffuse lighting only, no specular component
  • Under-sampling artifacts
  • Possible on todays consumer hardware
  • If it looks good, do it!

4
Diffuse Lighting Calculation
  • C (LN) ? Dl ? Dm
  • L is light vector
  • N is normal vector
  • Dl is light diffuse color
  • Dm is material diffuse color
  • Bump mapping changes N per pixel
  • Emboss bump mapping approximates (LN)

5
Approximate diffuse factor LN
  • Texture map represent height field
  • 0,1 height represents range of bump function
  • First derivative represents slope m
  • m increases/decreases base diffuse factor Fd
  • (Fdm) approximates (LN) per pixel

6
Approximate derivative
  • Embossing approximates derivative
  • Lookup height H0 at point (s,t)
  • Lookup height H1 at point slightly perturbed
    toward light source (s?s, t?t)
  • subtract original height H0 from perturbed height
    H1
  • difference represents instantaneous slope mH1-H0

7
Compute the Bump
Original bump (H0) overlaid with second bump (H1)
perturbed toward light source
Original bump (H0)
brightens image
darkens image
Subtract original bump from second (H1-H0)
8
Compute the Lighting
  • Evaluate fragment color Cf
  • Cf (LN) ? Dl ? Dm
  • (LN) ? (Fd (H1-H0))
  • Dm ? Dl encoded in surface texture color Ct
  • Could control Dl seperately if youre clever
  • Cf (Fd (H1-H0)) ? Ct

9
Is that all? Its so easy!
  • Were not quite done yet. We still must
  • Build a texture
  • Calculate texture coordinate offsets ?s, ?t
  • Calculate diffuse factor Fd
  • Both are derived from normal N and light vector L
  • Now we have to do some math

10
Building a Texture
  • Conserve Textures!
  • Current multitexture hardware only supports two
    textures
  • Bump map in ALPHA channel
  • Maximum bump 1.0
  • Level ground 0.5
  • Maximum depression 0.0
  • Surface color in RGB channels
  • Set internalformat to RGBA8 !!

11
Calculate Texture Offsets
  • Rotate light vector into normal space
  • Need Normal coordinate system
  • Derive coordinate system from normal and up
    vector
  • Normal is z-axis
  • Cross product is x-axis
  • Throw away up vector, derive y-axis as cross
    product of x- and z-axes
  • Build 3x3 matrix from axes
  • Transform light vector into Normal space

12
Calc Texture Offsets (contd)
  • Use normal-space light vector for offsets
  • L Mn ? L
  • Use Lx, Ly for ?s, ?t
  • Use Lz for diffuse factor!
  • If light vector is near normal, Lx, Ly are
    small
  • If light vector is near tangent plane, Lx and
    Ly are large
  • What is Lz is less than zero?
  • Light is on opposite side from normal
  • Fade contribution toward zero

13
Implementation on TNT
  • Calculate vectors, texcoords on the host
  • Pass diffuse factor as vertex alpha
  • Could use vertex color for light diffuse color
  • H0 and surface color from texture unit 0
  • H1 from texture unit 1 (same texture, different
    coordinates)
  • ARB_multitexture extension
  • Combiners extension (TBD)

14
Implementation on TNT (contd)
  • Combiner 0 alpha setup
  • (1-T0a) T1a - 0.5
  • T1a-T0a maps to -1,1 but hardware clamps to
    0,1
  • 0.5 bias balances the loss from clamping
  • Could modulate light diffuse color with T0c
  • Combiner 1 rgb setup
  • (T0cC0a T0cFda - 0.5) 2
  • 0.5 bias balances the loss from clamping
  • scale by 2 brightens the image
Write a Comment
User Comments (0)
About PowerShow.com