summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/TransformUnit.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-04-22 23:24:22 -0400
committerGitHub <noreply@github.com>2022-04-22 23:24:22 -0400
commit56bb965ab944bd01bf511df31b7c9d91f8e62bd4 (patch)
treea6078a76e52a86d89ec2f53b94bab9aeb0894bd0 /Source/Core/VideoBackends/Software/TransformUnit.cpp
parent2e01dc0c82b5f73215e3425ab45ff6c7ee50b389 (diff)
parent784079853d9daa4d5e4de0b49b610ec0e58a2b0c (diff)
Merge pull request #10584 from Pokechu22/emboss-single-normal-v2
VideoCommon: Handle emboss texgen with only a single normal
Diffstat (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/TransformUnit.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp
index bf56307025..6fcf42df9e 100644
--- a/Source/Core/VideoBackends/Software/TransformUnit.cpp
+++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp
@@ -90,22 +90,19 @@ void TransformPosition(const InputVertexData* src, OutputVertexData* dst)
}
}
-void TransformNormal(const InputVertexData* src, bool nbt, OutputVertexData* dst)
+void TransformNormal(const InputVertexData* src, OutputVertexData* dst)
{
const float* mat = &xfmem.normalMatrices[(src->posMtx & 31) * 3];
- if (nbt)
- {
- MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]);
- MultiplyVec3Mat33(src->normal[1], mat, dst->normal[1]);
- MultiplyVec3Mat33(src->normal[2], mat, dst->normal[2]);
- dst->normal[0].Normalize();
- }
- else
- {
- MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]);
- dst->normal[0].Normalize();
- }
+ MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]);
+ MultiplyVec3Mat33(src->normal[1], mat, dst->normal[1]);
+ MultiplyVec3Mat33(src->normal[2], mat, dst->normal[2]);
+ // The scale of the transform matrix is used to control the size of the emboss map effect, by
+ // changing the scale of the transformed binormals (which only get used by emboss map texgens).
+ // By normalising the first transformed normal (which is used by lighting calculations and needs
+ // to be unit length), the same transform matrix can do double duty, scaling for emboss mapping,
+ // and not scaling for lighting.
+ dst->normal[0].Normalize();
}
static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum,