d3d8.vsh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. ; transpose and transform position to clip space
  7. mul r0, v0.x, c4
  8. mad r0, v0.y, c5, r0
  9. mad r0, v0.z, c6, r0
  10. add oPos, c7, r0
  11. ; transform normal
  12. dp3 r1.x, v1, c0
  13. dp3 r1.y, v1, c1
  14. dp3 r1.z, v1, c2
  15. ; renormalize normal
  16. dp3 r1.w, r1, r1
  17. rsq r1.w, r1.w
  18. mul r1, r1, r1.w
  19. ; calculate light vector
  20. m4x4 r6, v0, c10 ; vertex into world position
  21. add r2, c8, -r6 ; vtxpos - lightpos
  22. ; normalize light vector
  23. dp3 r2.w, r2, r2
  24. rsq r2.w, r2.w
  25. mul r2, r2, r2.w
  26. ; calculate light color
  27. dp3 r3, r1, r2 ; dp3 with negative light vector
  28. lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
  29. mul oD0, r5.y, c9 ; ouput diffuse color
  30. mov oT0, v3 ; store texture coordinates