diff options
| author | Jules Blok <jules.blok@gmail.com> | 2016-09-01 01:41:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-01 01:41:03 +0200 |
| commit | 9a660fdf1847a276eb90aae8806a6245a51f0ac2 (patch) | |
| tree | c1391aceec02c1367e3c6121118c770c84fc8aac /Source/Core/VideoBackends/Software/TransformUnit.cpp | |
| parent | def0b42fb7002dc14340fa54562dd878c115557e (diff) | |
| parent | 94cbe0c12ade07c5ae2a1eaf980ecea1829d0bf5 (diff) | |
Merge pull request #3707 from OrN/proj_stq-zz
Fix bug with texture coordinate q value being 0
Diffstat (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/TransformUnit.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index 57492cc326..38734fa17c 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -106,24 +106,26 @@ void TransformNormal(const InputVertexData* src, bool nbt, OutputVertexData* dst static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bool specialCase, const InputVertexData* srcVertex, OutputVertexData* dstVertex) { - const Vec3* src; + Vec3 src; switch (texinfo.sourcerow) { case XF_SRCGEOM_INROW: - src = &srcVertex->position; + src = srcVertex->position; break; case XF_SRCNORMAL_INROW: - src = &srcVertex->normal[0]; + src = srcVertex->normal[0]; break; case XF_SRCBINORMAL_T_INROW: - src = &srcVertex->normal[1]; + src = srcVertex->normal[1]; break; case XF_SRCBINORMAL_B_INROW: - src = &srcVertex->normal[2]; + src = srcVertex->normal[2]; break; default: _assert_(texinfo.sourcerow >= XF_SRCTEX0_INROW && texinfo.sourcerow <= XF_SRCTEX7_INROW); - src = (Vec3*)srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW]; + src.x = srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW][0]; + src.y = srcVertex->texCoords[texinfo.sourcerow - XF_SRCTEX0_INROW][1]; + src.z = 1.0f; break; } @@ -133,18 +135,18 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo if (texinfo.projection == XF_TEXPROJ_ST) { if (texinfo.inputform == XF_TEXINPUT_AB11 || specialCase) - MultiplyVec2Mat24(*src, mat, *dst); + MultiplyVec2Mat24(src, mat, *dst); else - MultiplyVec3Mat24(*src, mat, *dst); + MultiplyVec3Mat24(src, mat, *dst); } else // texinfo.projection == XF_TEXPROJ_STQ { _assert_(!specialCase); if (texinfo.inputform == XF_TEXINPUT_AB11) - MultiplyVec2Mat34(*src, mat, *dst); + MultiplyVec2Mat34(src, mat, *dst); else - MultiplyVec3Mat34(*src, mat, *dst); + MultiplyVec3Mat34(src, mat, *dst); } if (xfmem.dualTexTrans.enabled) @@ -177,6 +179,15 @@ static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, bo MultiplyVec3Mat34(tempCoord, postMat, *dst); } } + + // When q is 0, the GameCube appears to have a special case + // This can be seen in devkitPro's neheGX Lesson08 example for Wii + // Makes differences in Rogue Squadron 3 (Hoth sky) and The Last Story (shadow culling) + if (dst->z == 0.0f) + { + dst->x = MathUtil::Clamp(dst->x / 2.0f, -1.0f, 1.0f); + dst->y = MathUtil::Clamp(dst->y / 2.0f, -1.0f, 1.0f); + } } struct LightPointer |
