From ea46006a19d57c8d755c0eb792b8b19fdf487d2e Mon Sep 17 00:00:00 2001 From: Pentalimbed Date: Sun, 15 Sep 2024 15:39:54 +0100 Subject: [PATCH] fix: skylighting CB alignment --- .../Skylighting/Shaders/Skylighting/Skylighting.hlsli | 10 ++++------ package/Shaders/Common/SharedData.hlsli | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli b/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli index 5ee3e51b0..d26a3d598 100644 --- a/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli +++ b/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli @@ -7,15 +7,13 @@ struct SkylightingSettings row_major float4x4 OcclusionViewProj; float4 OcclusionDir; - float3 PosOffset; // xyz: cell origin in camera model space - uint pad0; - uint3 ArrayOrigin; // xyz: array origin, w: max accum frames - uint pad1; + float4 PosOffset; // xyz: cell origin in camera model space + uint4 ArrayOrigin; // xyz: array origin int4 ValidMargin; float MinDiffuseVisibility; float MinSpecularVisibility; - uint pad2[2]; + uint pad[2]; }; #endif @@ -58,7 +56,7 @@ namespace Skylighting const static sh2 unitSH = float4(sqrt(4 * shPI), 0, 0, 0); sh2 scaledUnitSH = unitSH / 1e-10; - float3 positionMSAdjusted = positionMS - params.PosOffset; + float3 positionMSAdjusted = positionMS - params.PosOffset.xyz; float3 uvw = positionMSAdjusted / ARRAY_SIZE + .5; if (any(uvw < 0) || any(uvw > 1)) diff --git a/package/Shaders/Common/SharedData.hlsli b/package/Shaders/Common/SharedData.hlsli index 5e4ab2874..28ffa0ca4 100644 --- a/package/Shaders/Common/SharedData.hlsli +++ b/package/Shaders/Common/SharedData.hlsli @@ -113,11 +113,10 @@ struct SkylightingSettings row_major float4x4 OcclusionViewProj; float4 OcclusionDir; - float3 PosOffset; // xyz: cell origin in camera model space - uint pad0; - uint3 ArrayOrigin; // xyz: array origin, w: max accum frames - uint pad1; + float4 PosOffset; // xyz: cell origin in camera model space + uint4 ArrayOrigin; // xyz: array origin int4 ValidMargin; + float MinDiffuseVisibility; float MinSpecularVisibility; uint pad2[2];