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

  1. vs.1.1
  2.  
  3. ;Vertex Shader for DX7 class hardware
  4. ;Constants 
  5. ;
  6. ;c0-c3 Object
  7. ;c4-c7 Projection
  8. ;c8-c11 Total matrix
  9. ;c12 - Light Direction (In World Space)
  10. ;c33 - .5,.5,.5,.5
  11. ;
  12. ;Input
  13. ;
  14. ;V0 - Position
  15. ;V3 - Normal
  16. ;V7 - Texture 
  17. ;V8 - Tangent
  18.  
  19. dcl_position v0
  20. dcl_normal v3
  21. dcl_texcoord v7
  22. dcl_tangent v8
  23.  
  24. ;Take normal and binormal into worldspace first
  25. m3x3 r7.xyz,v8,c0
  26. mov r7.w, c32.w
  27. m3x3 r8.xyz,v3,c0
  28. mov r8.w, c32.w
  29.  
  30. ;Cross product, orientation flip here
  31. ;content dependent
  32. mul r0,r7.zxyw,-r8.yzxw;
  33. mad r5,r7.yzxw,-r8.zxyw,-r0;
  34.  
  35. ;transform the light vector
  36. dp3 r6.x,r7,c12
  37. dp3 r6.y,r5,c12
  38. dp3 r6.z,r8,c12
  39.  
  40. ;bias around 128
  41. add r6.xyz,-r6.xyz,c32
  42.  
  43. ;this is also our texture coordinate
  44. ;on our basis
  45. mul oT1.xy,r6.xy,c33
  46.  
  47. ;transform into projection space
  48. m4x4 oPos,v0,c8
  49. mov oT0.xy,v7
  50.