From 395d4387ba76ee8113f85dcde79c639644391138 Mon Sep 17 00:00:00 2001 From: Colin Cornaby Date: Wed, 4 Dec 2024 00:15:09 -0800 Subject: [PATCH] Fixing normal based UV calculation in Metal shader The matrix multiply order was incorrect. Also added some clarity to the varaible names. --- .../ShaderSrc/FixedPipelineShaders.metal | 15 ++++++++------- .../pfMetalPipeline/ShaderSrc/ShaderTypes.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfMetalPipeline/ShaderSrc/FixedPipelineShaders.metal b/Sources/Plasma/FeatureLib/pfMetalPipeline/ShaderSrc/FixedPipelineShaders.metal index 7623c5c186..d8a8496fed 100644 --- a/Sources/Plasma/FeatureLib/pfMetalPipeline/ShaderSrc/FixedPipelineShaders.metal +++ b/Sources/Plasma/FeatureLib/pfMetalPipeline/ShaderSrc/FixedPipelineShaders.metal @@ -246,10 +246,10 @@ vertex ColorInOut pipelineVertexShader(Vertex in [[stage_in]], // Fog out.fogColor = uniforms.calcFog(vCamPosition); - const float4 normal = (uniforms.localToWorldMatrix * float4(in.normal, 0.f)) * uniforms.worldToCameraMatrix; + const float4 cameraSpaceNormal = normalize(((float4(in.normal, 0.f) * uniforms.localToWorldMatrix) * uniforms.worldToCameraMatrix)); for (size_t layer=0; layer