From c0edd5d5e84321c4d8ebd5195d758d8f38eec294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Stompo=CC=81r?= Date: Sun, 4 Jan 2026 00:46:53 +0100 Subject: [PATCH] Use proper normals resolution --- Engine/Core/Extensions/Metal/MTLPixelFormat+Extension.swift | 2 +- Engine/Shaders/DeferredRendering/GBuffer.metal | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/Core/Extensions/Metal/MTLPixelFormat+Extension.swift b/Engine/Core/Extensions/Metal/MTLPixelFormat+Extension.swift index 444cc40c..865c5598 100644 --- a/Engine/Core/Extensions/Metal/MTLPixelFormat+Extension.swift +++ b/Engine/Core/Extensions/Metal/MTLPixelFormat+Extension.swift @@ -9,7 +9,7 @@ extension MTLPixelFormat { .rgba16Float } static var gBufferNMC: MTLPixelFormat { - .rgba16Float + .rgba32Float } static var gBufferPRC: MTLPixelFormat { .rgba32Float diff --git a/Engine/Shaders/DeferredRendering/GBuffer.metal b/Engine/Shaders/DeferredRendering/GBuffer.metal index 53eb4af8..8d110777 100644 --- a/Engine/Shaders/DeferredRendering/GBuffer.metal +++ b/Engine/Shaders/DeferredRendering/GBuffer.metal @@ -29,7 +29,7 @@ struct RasterizerData { struct GBufferData { half4 albedoRoughness [[color(0)]]; - half4 normalMetallic [[color(1)]]; + float4 normalMetallic [[color(1)]]; float4 positionReflectance [[color(2)]]; half2 velocity [[color(3)]]; }; @@ -94,7 +94,7 @@ fragment GBufferData fragmentGBuffer(RasterizerData in [[stage_in]], // should be possible to configure it float3 normalEncoded = material.normals.sample(textureSampler, in.uv).xyz; float3 normalDecoded = normalEncoded * 2 - 1; - half3 normalWorldSpace = half3(TBN * normalDecoded); + float3 normalWorldSpace = float3(TBN * normalDecoded); half3 color = material.albedo.sample(textureSampler, in.uv).rgb; half2 current = half2(in.currentClipSpacePosition.xy / in.currentClipSpacePosition.w); half2 previous = half2(in.previousClipSpacePosition.xy / in.previousClipSpacePosition.w); @@ -104,7 +104,7 @@ fragment GBufferData fragmentGBuffer(RasterizerData in [[stage_in]], return { half4(color, roughness), - half4(normalWorldSpace, metallic), + float4(normalWorldSpace, metallic), float4(in.cameraSpacePosition, 0.04), velocity };