rasterizer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "video_core/shader/shader.h"
  6. namespace Pica {
  7. namespace Rasterizer {
  8. struct Vertex : Shader::OutputVertex {
  9. Vertex(const OutputVertex& v) : OutputVertex(v) {}
  10. // Attributes used to store intermediate results
  11. // position after perspective divide
  12. Math::Vec3<float24> screenpos;
  13. // Linear interpolation
  14. // factor: 0=this, 1=vtx
  15. void Lerp(float24 factor, const Vertex& vtx) {
  16. pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor);
  17. // TODO: Should perform perspective correct interpolation here...
  18. tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor);
  19. tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor);
  20. tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor);
  21. screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor);
  22. color = color * factor + vtx.color * (float24::FromFloat32(1) - factor);
  23. }
  24. // Linear interpolation
  25. // factor: 0=v0, 1=v1
  26. static Vertex Lerp(float24 factor, const Vertex& v0, const Vertex& v1) {
  27. Vertex ret = v0;
  28. ret.Lerp(factor, v1);
  29. return ret;
  30. }
  31. };
  32. void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2);
  33. } // namespace Rasterizer
  34. } // namespace Pica