From ddbba7d37cc28731782904afc16b96532375a452 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 13 Sep 2021 16:07:10 -0700 Subject: [PATCH] Code refactor. Signed-off-by: Robin Signed-off-by: rbarrand --- .../Features/PostProcessing/KelvinToRGB.azsli | 4 ++-- .../Features/PostProcessing/KelvinToRgb.azsli | 4 ++-- .../HsvToLinearColor.azsli | 16 -------------- .../LinearColorToHsv.azsli | 21 ------------------- 4 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRGB.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRGB.azsli index c621e05e12..aa57f0f4a1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRGB.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRGB.azsli @@ -50,10 +50,10 @@ float3 HslToRgb(float3 hsl) } // Color temperature -float3 KelvinToRgb(float k) +float3 KelvinToRgb(float kelvin) { float3 ret; - const float kelvin = clamp(k, 1000.0f, 40000.0f) / 100.0f; + kelvin = clamp(kelvin, 1000.0f, 40000.0f) / 100.0f; if(kelvin <= 66.0f) { ret.r = 1.0f; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRgb.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRgb.azsli index c621e05e12..aa57f0f4a1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRgb.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/3rdParty/Features/PostProcessing/KelvinToRgb.azsli @@ -50,10 +50,10 @@ float3 HslToRgb(float3 hsl) } // Color temperature -float3 KelvinToRgb(float k) +float3 KelvinToRgb(float kelvin) { float3 ret; - const float kelvin = clamp(k, 1000.0f, 40000.0f) / 100.0f; + kelvin = clamp(kelvin, 1000.0f, 40000.0f) / 100.0f; if(kelvin <= 66.0f) { ret.r = 1.0f; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli deleted file mode 100644 index 9175229f58..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -float3 HsvToLinearColor(float3 color) -{ - const float4 k = float4(1.0f, 2.0f / 3.0f, 1.0f / 3.0f, 3.0f); - const float3 p = abs(frac(color.xxx + k.xyz) * 6.0f - k.www); - return color.z * lerp(k.xxx, saturate(p - k.xxx), color.y); -} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli deleted file mode 100644 index 2887fdd411..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include - -float3 LinearColorToHsv(float3 color) -{ - const float4 k = float4(0.0f, -1.0f / 3.0f, 2.0f / 3.0f, -1.0f); - const float4 p = lerp(float4(color.bg, k.wz), float4(color.gb, k.xy), step(color.b, color.g)); - const float4 q = lerp(float4(p.xyw, color.r), float4(color.r, p.yzx), step(p.x, color.r)); - const float d = q.x - min(q.w, q.y); - const float e = EPSILON; - return float3(abs(q.z + (q.w - q.y) / (6.0f * d + e)), d / (q.x + e), q.x); -}