diff --git a/GPU/Math3D.h b/GPU/Math3D.h index 49311a7433..e1095511b1 100644 --- a/GPU/Math3D.h +++ b/GPU/Math3D.h @@ -173,6 +173,7 @@ public: Vec3() {} Vec3(const T a[3]) : x(a[0]), y(a[1]), z(a[2]) {} Vec3(const T& _x, const T& _y, const T& _z) : x(_x), y(_y), z(_z) {} + Vec3(const Vec2& _xy, const T& _z) : x(_xy.x), y(_xy.y), z(_z) {} template Vec3 Cast() const @@ -334,6 +335,8 @@ public: Vec4() {} Vec4(const T a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3]) {} Vec4(const T& _x, const T& _y, const T& _z, const T& _w) : x(_x), y(_y), z(_z), w(_w) {} + Vec4(const Vec2& _xy, const T& _z, const T& _w) : x(_xy.x), y(_xy.y), z(_z), w(_w) {} + Vec4(const Vec3& _xyz, const T& _w) : x(_xyz.x), y(_xyz.y), z(_xyz.z), w(_w) {} template Vec4 Cast() const diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 40260d40ca..b00a2d9e7c 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -206,10 +206,18 @@ static inline void GetTextureCoordinates(const VertexData& v0, const VertexData& { // projection mapping, TODO: Move this code to TransformUnit! Vec3 source; - if (gstate.getUVProjMode() == GE_PROJMAP_POSITION) { + switch (gstate.getUVProjMode()) { + case GE_PROJMAP_POSITION: source = ((v0.modelpos * w0 + v1.modelpos * w1 + v2.modelpos * w2) / (w0+w1+w2)); - } else { + break; + + case GE_PROJMAP_UV: + source = Vec3f((v0.texturecoords * w0 + v1.texturecoords * w1 + v2.texturecoords * w2) / (w0 + w1 + w2), 0.0f); + break; + + default: ERROR_LOG_REPORT(G3D, "Software: Unsupported UV projection mode %x", gstate.getUVProjMode()); + break; } Mat3x3 tgen(gstate.tgenMatrix);