Demo: bumpy_shiny_patch - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Demo: bumpy_shiny_patch

Description:

Title: About the bumpy_shiny_patch Demo Author: Cass Everitt Last modified by: Staff Created Date: 5/24/1999 4:51:10 PM Document presentation format – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 18
Provided by: Cass171
Category:

less

Transcript and Presenter's Notes

Title: Demo: bumpy_shiny_patch


1
Demo bumpy_shiny_patch
  • Cass Everitt

2
Overview
  • The bumpy_shiny_patch demo illustrates three key
    new extensions working together
  • NV_evaluators
  • NV_vertex_program
  • NV_texture_shader
  • The goal of bumpy_shiny_patch is to render a
    bumpy, mirrored, and deformable patch -- with an
    RGB glossmap to boot

3
Game Plan
  • Use 4 NV_evaluators maps to generate
  • P, dP/du, dP/dv, and (s,t) texture coordinates
  • Pass these values in to a vertex program
  • Use NV_vertex_program to
  • Produce a set of normalized basis vectors
  • T normalize(dP/du), N normalize(T?dP/Dv), and
    B N?T
  • Calculate the 3x3 texel matrix CMS
  • basis vectors for S (surface to object space)
  • M is the upper 3x3 of the inverse transpose of
    the MODELVIEW matrix
  • C is the rotation from eye-space to world-space
    (or cubemap-space)
  • Put the texel matrix into the appropriate texture
    coordinates
  • Calculate the cubemap space eye vector, and put
    itinto the appropriate texture coordinates

4
Game Plan (2)
  • Use NV_texture_shader reflect cube map dot
    product program to
  • Calculate a per-pixel reflection vector based on
    the normal map normals and the interpolated
    cubemap space eye vector
  • Use the reflection vector to look into a cubic
    environment map
  • Final simple 2D pass to modulate the
    framebuffer results with an RGB glossmap

5
NV_evaluators
  • Map 0 uses a 4x4 patch for position
  • Map 1 uses a 3x4 patch for dP/du
  • This map is the difference of adjacent columns
    from map 0
  • Map 2 uses a 4x3 patch for dP/dv
  • This map is the difference of adjacent rows from
    map 0
  • Map 8 uses a 2x2 patch for texture coordinates
  • The tessellation scheme is irrelevant -- thats
    the point!

6
NV_vertex_program
  • The vertex program used to compute all the
    relevant values is shown
  • Note the following program parameter settings
  • c0-3 GL_MODELVIEW_PROJECTION_NV,
    GL_IDENTITY_NV
  • c4 (1, 2, 0, -1) // misc constants
  • c5 (refract_term, refract_term, 1,
    bump_scale)
  • c8-11 GL_MODELVIEW, GL_IDENTITY_NV
  • c12-15 GL_MODELVIEW, GL_INVERSE_NV
  • c20-22 modelview_cubemap matrix
    (object-space -gt cubemap-space transform)
  • c43-45 modelview_negate_cubemap matrix
    (object-space position -gt cubemap-space eye
    vector)

7
NV_vertex_program (2)
!!VP1.0 positionDP4 oHPOS.x, c0,
vOPOS DP4 oHPOS.y, c1, vOPOS DP4
oHPOS.z, c2, vOPOS DP4 oHPOS.w, c3,
vOPOS R0 normalize3(v1) ---
tangentDP3 R0.w, v1, v1 RSQ R0.w,
R0.w MUL R0.xyz, v1, -R0.w R2
cross(R0,v2) --- normalMUL R2, R0.zxyw,
v2.yzxw MAD R2, R0.yzxw, v2.zxyw,
-R2 R2 normalize(R2)DP3 R2.w, R2, R2
RSQ R2.w, R2.w MUL R2.xyz, R2,
R2.w R1 cross(R0,R2) --- binormalMUL
R1, R0.zxyw, R2.yzxw MAD R1, R0.yzxw,
R2.zxyw, -R1
8
NV_vertex_program (3)
We need the "texel matrix" to be (C)(MV)(S)(B),
where C is the cubemap rotation, MV is the
modelview matrix and S is the matrix that
transforms vectors from texture space to object
space, and B is a simple uniform scaling
matrix. Specifically it is b 0 0
B 0 b 0 0 0 1 Tx
Bx Nx R0.x R1.x R2.x S Ty By Ny
R0.y R1.y R2.y Tz Bz Nz R0.z
R1.z R2.z and (C)(MV) is pre-computed
c20.x c20.y c20.z
(C)(MV) c21.x c21.y c21.z
c22.x c22.y c22.z so (S)(B)
is R3.x R3.y R3.z
bR0.x bR1.x R2.x (S)(B) R4.x R4.y
R4.z bR0.y bR1.y R2.y
R5.x R5.y R5.z bR0.z bR1.z R2.z
9
NV_vertex_program (4)
so (C)(MV)(S)(B) is DP3(
c20, R3) DP3( c20, R4) DP3( c20, R5)
(C)(MV)(S)(B) DP3( c21, R3) DP3(
c21, R4) DP3( c21, R5)
DP3( c22, R3) DP3( c22, R4) DP3( c22,
R5) oTEX1.x oTEX1.y
oTEX1.z oTEX2.x
oTEX2.y oTEX2.z
oTEX3.x oTEX3.y oTEX3.z
10
NV_vertex_program (5)
calculate (S)(B) -- c5.x b (bump scale
term)MUL R3, R0, c5.wMUL R4, R1, c5.w
compute (C)(MV)(S)(B) and put it in the correct
texture coordinates c20-23
modelview_cubemap matrix (object-space -gt
cubemap-space transform)DP3 oTEX1.x, c20,
R3 DP3 oTEX1.y, c20, R4 DP3 oTEX1.z,
c20, R2DP3 oTEX2.x, c21, R3 DP3
oTEX2.y, c21, R4 DP3 oTEX2.z, c21,
R2DP3 oTEX3.x, c22, R3 DP3 oTEX3.y,
c22, R4 DP3 oTEX3.z, c22, R2 calculate
cubemap-space eye vectorDP4 oTEX1.w,
vOPOS, c43DP4 oTEX2.w, vOPOS,
c44DP4 oTEX3.w, vOPOS, c45 col0
white and pass tex0 coordinates throughMOV
oCOL0, c4 MOV oTEX0, vTEX0END
11
NV_texture_shader
  • Configure the texture shader stages as follows

// stage 0 -- normal mapglActiveTextureARB(
GL_TEXTURE0_ARB )normalmap.bind()glTexEnvi(GL_
TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV,
GL_TEXTURE_2D)// stage 1 -- dot
productglActiveTextureARB( GL_TEXTURE1_ARB
)glTexEnvi(GL_TEXTURE_SHADER_NV,
GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV)glTexE
nvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPU
T_NV, GL_TEXTURE0_ARB)// stage 2 -- dot
productglActiveTextureARB( GL_TEXTURE2_ARB
)glTexEnvi(GL_TEXTURE_SHADER_NV,
GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV)glTexE
nvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPU
T_NV, GL_TEXTURE0_ARB)// stage 3 -- dot
product, cube map lookupglActiveTextureARB(
GL_TEXTURE3_ARB )cubemap.bind()glTexEnvi(GL_TE
XTURE_SHADER_NV, GL_SHADER_OPERATION_NV,
GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV)glTexEnvi(GL
_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV,
GL_TEXTURE0_ARB)glTexEnvi(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE, GL_REPLACE)
12
The Bump Map and Gloss Map
13
The Environment Map
14
The Results
15
Note
  • In this example, the upper-left 3x3 of the
    modelview matrix (M) and the upper-left 3x3 of
    the inverse transpose of the modelview
    matrix(M-t) are used interchangeably. This is
    because the modelview matrix contains only
    rigid-body transformations (rotation and
    translation), and in this case the matrices are
    identical.

16
Related Information
  • See The dot_product_reflect and
    dot_product_reflect_torus Demos presentation and
    the corresponding demos for simple examples of
    object-space and tangent-space reflective bump
    mapping

17
Questions, comments, feedback
  • Cass Everitt, ceveritt_at_nvidia.com
  • www.nvidia.com/developer
Write a Comment
User Comments (0)
About PowerShow.com