home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Samples / Media / SeaFloor.vsh < prev    next >
Encoding:
Text File  |  2002-11-12  |  2.0 KB  |  66 lines

  1. vs.1.1
  2. ;------------------------------------------------------------------------------
  3. ; Constants specified by the app
  4. ;    c0      = ( 0, 0, 0, 0 )
  5. ;    c1      = ( 1, 0.5, 2, 4 )
  6. ;    c4-c7   = world-view-projection matrix
  7. ;    c8-c11  = world-view matrix
  8. ;    c12-c15 = view matrix
  9. ;    c20     = light direction
  10. ;    c21     = material diffuse color * light diffuse color
  11. ;    c22     = material ambient color
  12. ;    c28     = projection matrix
  13. ;
  14. ; Vertex components (as specified in the vertex DECL)
  15. ;    v0    = Position
  16. ;    v3    = Normal
  17. ;    v6    = Texcoords
  18. ;------------------------------------------------------------------------------
  19.  
  20. dcl_position0 v0
  21. dcl_normal0   v3
  22. dcl_texcoord0 v6
  23.  
  24. ;------------------------------------------------------------------------------
  25. ; Vertex transformation
  26. ;------------------------------------------------------------------------------
  27.  
  28. ; Transform to view space (world matrix is identity)
  29. m4x4 r9, v0, c12
  30.  
  31. ; Transform to projection space
  32. m4x4 r10, r9, c28
  33.  
  34. ; Store output position
  35. mov oPos, r10
  36.  
  37.  
  38. ;------------------------------------------------------------------------------
  39. ; Lighting calculation
  40. ;------------------------------------------------------------------------------
  41.  
  42. dp3 r1.x, v3, c20    ; r1 = normal dot light
  43. mul r0, r1.x, c21    ; Multiply with diffuse
  44. add oD0, r0, c22      ; Add in ambient
  45.  
  46.  
  47. ;------------------------------------------------------------------------------
  48. ; Texture coordinates
  49. ;------------------------------------------------------------------------------
  50.  
  51. ; Copy tex coords
  52. mov oT0.xy, v6
  53.  
  54. ;------------------------------------------------------------------------------
  55. ; Fog calculation
  56. ;------------------------------------------------------------------------------
  57.  
  58. ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
  59. add r0.x, -r9.z, c23.y
  60. mul r0.x, r0.x, c23.z
  61. max r0.x, r0.x, c0.x       ; clamp fog to > 0.0
  62. min oFog, r0.x, c1.x     ; clamp fog to < 1.0
  63.  
  64.  
  65.  
  66.