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

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