From 2a5c77f43ff1d69e78f12f13435a38c5eb2ed854 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 22:03:34 -0700 Subject: VideoCommon: Handle emboss texgen with only a single normal Fixes a large number of effects in Rogue Squadron 2 and 3. --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index bf56307025..e1e6fd68a6 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -90,22 +90,14 @@ 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]); + dst->normal[0].Normalize(); } static void TransformTexCoordRegular(const TexMtxInfo& texinfo, int coordNum, -- cgit v1.2.3 From 784079853d9daa4d5e4de0b49b610ec0e58a2b0c Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 19 Apr 2022 17:46:20 -0700 Subject: VideoCommon: Add comment explaining why only the first normal gets normalized Co-authored-by: Scott Mansell --- Source/Core/VideoBackends/Software/TransformUnit.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Source/Core/VideoBackends/Software/TransformUnit.cpp') diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index e1e6fd68a6..6fcf42df9e 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -97,6 +97,11 @@ void TransformNormal(const InputVertexData* src, OutputVertexData* dst) 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(); } -- cgit v1.2.3