d3d9.vsh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; part of the Irrlicht Engine Shader example.
  2. ; This Direct3D9 vertex shader will be loaded by the engine.
  3. ; Please note that these example shaders don't do anything really useful.
  4. ; They only demonstrate that shaders can be used in Irrlicht.
  5. vs.1.1
  6. dcl_position v0; ; declare position
  7. dcl_normal v1; ; declare normal
  8. dcl_color v2; ; declare color
  9. dcl_texcoord0 v3; ; declare texture coordinate
  10. ; transpose and transform position to clip space
  11. mul r0, v0.x, c4
  12. mad r0, v0.y, c5, r0
  13. mad r0, v0.z, c6, r0
  14. add oPos, c7, r0
  15. ; transform normal
  16. dp3 r1.x, v1, c0
  17. dp3 r1.y, v1, c1
  18. dp3 r1.z, v1, c2
  19. ; renormalize normal
  20. dp3 r1.w, r1, r1
  21. rsq r1.w, r1.w
  22. mul r1, r1, r1.w
  23. ; calculate light vector
  24. m4x4 r6, v0, c10 ; vertex into world position
  25. add r2, c8, -r6 ; vtxpos - lightpos
  26. ; normalize light vector
  27. dp3 r2.w, r2, r2
  28. rsq r2.w, r2.w
  29. mul r2, r2, r2.w
  30. ; calculate light color
  31. dp3 r3, r1, r2 ; dp3 with negative light vector
  32. lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
  33. mul oD0, r5.y, c9 ; ouput diffuse color
  34. mov oT0, v3 ; store texture coordinates