From 20cf2a837c6e6bacc7fd5aa7ab07d52a08bbb1c2 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 10 Sep 2021 14:34:24 -0700 Subject: [PATCH] Improve code quality. Signed-off-by: Robin Signed-off-by: rbarrand --- .../Features/PostProcessing/KelvinToRGB.azsli | 66 +++++++-------- .../Features/PostProcessing/KelvinToRgb.azsli | 66 +++++++-------- .../AcesCc_To_AcesCg.azsli | 80 ------------------- .../AcesCg_To_AcesCc.azsli | 79 ------------------ ...nearColor.azsli => HsvToLinearColor.azsli} | 8 +- .../LinearColorToHsv.azsli | 21 +++++ .../LinearColor_To_Hsv.azsli | 21 ----- 7 files changed, 91 insertions(+), 250 deletions(-) delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCc_To_AcesCg.azsli delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_AcesCc.azsli rename Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/{Hsv_To_LinearColor.azsli => HsvToLinearColor.azsli} (50%) create mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColor_To_Hsv.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 9b06b23363..c621e05e12 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 @@ -16,60 +16,60 @@ // licensed and released under Creative Commons 3.0 Attribution // https://creativecommons.org/licenses/by/3.0/ -float3 HUEToRGB( float H ) +float3 HueToRgb(float hue) { - return saturate( float3( abs( H * 6.0f - 3.0f ) - 1.0f, - 2.0f - abs( H * 6.0f - 2.0f ), - 2.0f - abs( H * 6.0f - 4.0f ))); + return saturate(float3(abs(hue * 6.0f - 3.0f) - 1.0f, + 2.0f - abs(hue * 6.0f - 2.0f), + 2.0f - abs(hue * 6.0f - 4.0f))); } -float3 RGBToHCV( float3 RGB ) +float3 RgbToHcv(float3 rgb) { // Based on work by Sam Hocevar and Emil Persson - float4 P = ( RGB.g < RGB.b ) ? float4( RGB.bg, -1.0f, 2.0f/3.0f ) : float4( RGB.gb, 0.0f, -1.0f/3.0f ); - float4 Q1 = ( RGB.r < P.x ) ? float4( P.xyw, RGB.r ) : float4( RGB.r, P.yzx ); - float C = Q1.x - min( Q1.w, Q1.y ); - float H = abs(( Q1.w - Q1.y ) / ( 6.0f * C + 0.000001f ) + Q1.z ); - return float3( H, C, Q1.x ); + const float4 p = (rgb.g < rgb.b) ? float4(rgb.bg, -1.0f, 2.0f/3.0f) : float4(rgb.gb, 0.0f, -1.0f/3.0f); + const float4 q1 = (rgb.r < p.x) ? float4(p.xyw, rgb.r) : float4(rgb.r, p.yzx); + const float c = q1.x - min(q1.w, q1.y); + const float h = abs((q1.w - q1.y) / (6.0f * c + 0.000001f ) + q1.z); + return float3(h, c, q1.x); } -float3 RGBToHSL( float3 RGB ) +float3 RgbToHsl(float3 rgb) { - RGB.xyz = max( RGB.xyz, 0.000001f ); - float3 HCV = RGBToHCV(RGB); - float L = HCV.z - HCV.y * 0.5f; - float S = HCV.y / ( 1.0f - abs( L * 2.0f - 1.0f ) + 0.000001f); - return float3( HCV.x, S, L ); + rgb.xyz = max(rgb.xyz, 0.000001f); + const float3 hcv = RgbToHcv(rgb); + const float L = hcv.z - hcv.y * 0.5f; + const float S = hcv.y / (1.0f - abs(L * 2.0f - 1.0f) + 0.000001f); + return float3(hcv.x, S, L); } -float3 HSLToRGB( float3 HSL ) +float3 HslToRgb(float3 hsl) { - float3 RGB = HUEToRGB(HSL.x); - float C = (1.0f - abs(2.0f * HSL.z - 1.0f)) * HSL.y; - return ( RGB - 0.5f ) * C + HSL.z; + const float3 rgb = HueToRgb(hsl.x); + const float c = (1.0f - abs(2.0f * hsl.z - 1.0f)) * hsl.y; + return (rgb - 0.5f) * c + hsl.z; } // Color temperature -float3 KelvinToRGB( float k ) +float3 KelvinToRgb(float k) { float3 ret; - float kelvin = clamp( k, 1000.0f, 40000.0f ) / 100.0f; - if( kelvin <= 66.0f ) + const float kelvin = clamp(k, 1000.0f, 40000.0f) / 100.0f; + if(kelvin <= 66.0f) { - ret.r = 1.0f; - ret.g = saturate( 0.39008157876901960784f * log( kelvin ) - 0.63184144378862745098f ); + ret.r = 1.0f; + ret.g = saturate(0.39008157876901960784f * log(kelvin) - 0.63184144378862745098f); } else { - float t = max( kelvin - 60.0f, 0.0f ); - ret.r = saturate( 1.29293618606274509804f * pow( t, -0.1332047592f )); - ret.g = saturate( 1.12989086089529411765f * pow( t, -0.0755148492f )); + float t = max(kelvin - 60.0f, 0.0f); + ret.r = saturate(1.29293618606274509804f * pow(t, -0.1332047592f)); + ret.g = saturate(1.12989086089529411765f * pow(t, -0.0755148492f)); } - if( kelvin >= 66.0f ) - ret.b = 1.0f; - else if( kelvin < 19.0f ) - ret.b = 0.0f; + if(kelvin >= 66.0f) + ret.b = 1.0f; + else if(kelvin < 19.0f) + ret.b = 0.0f; else - ret.b = saturate( 0.54320678911019607843f * log( kelvin - 10.0f ) - 1.19625408914f ); + ret.b = saturate(0.54320678911019607843f * log(kelvin - 10.0f) - 1.19625408914f); return ret; } 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 9b06b23363..c621e05e12 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 @@ -16,60 +16,60 @@ // licensed and released under Creative Commons 3.0 Attribution // https://creativecommons.org/licenses/by/3.0/ -float3 HUEToRGB( float H ) +float3 HueToRgb(float hue) { - return saturate( float3( abs( H * 6.0f - 3.0f ) - 1.0f, - 2.0f - abs( H * 6.0f - 2.0f ), - 2.0f - abs( H * 6.0f - 4.0f ))); + return saturate(float3(abs(hue * 6.0f - 3.0f) - 1.0f, + 2.0f - abs(hue * 6.0f - 2.0f), + 2.0f - abs(hue * 6.0f - 4.0f))); } -float3 RGBToHCV( float3 RGB ) +float3 RgbToHcv(float3 rgb) { // Based on work by Sam Hocevar and Emil Persson - float4 P = ( RGB.g < RGB.b ) ? float4( RGB.bg, -1.0f, 2.0f/3.0f ) : float4( RGB.gb, 0.0f, -1.0f/3.0f ); - float4 Q1 = ( RGB.r < P.x ) ? float4( P.xyw, RGB.r ) : float4( RGB.r, P.yzx ); - float C = Q1.x - min( Q1.w, Q1.y ); - float H = abs(( Q1.w - Q1.y ) / ( 6.0f * C + 0.000001f ) + Q1.z ); - return float3( H, C, Q1.x ); + const float4 p = (rgb.g < rgb.b) ? float4(rgb.bg, -1.0f, 2.0f/3.0f) : float4(rgb.gb, 0.0f, -1.0f/3.0f); + const float4 q1 = (rgb.r < p.x) ? float4(p.xyw, rgb.r) : float4(rgb.r, p.yzx); + const float c = q1.x - min(q1.w, q1.y); + const float h = abs((q1.w - q1.y) / (6.0f * c + 0.000001f ) + q1.z); + return float3(h, c, q1.x); } -float3 RGBToHSL( float3 RGB ) +float3 RgbToHsl(float3 rgb) { - RGB.xyz = max( RGB.xyz, 0.000001f ); - float3 HCV = RGBToHCV(RGB); - float L = HCV.z - HCV.y * 0.5f; - float S = HCV.y / ( 1.0f - abs( L * 2.0f - 1.0f ) + 0.000001f); - return float3( HCV.x, S, L ); + rgb.xyz = max(rgb.xyz, 0.000001f); + const float3 hcv = RgbToHcv(rgb); + const float L = hcv.z - hcv.y * 0.5f; + const float S = hcv.y / (1.0f - abs(L * 2.0f - 1.0f) + 0.000001f); + return float3(hcv.x, S, L); } -float3 HSLToRGB( float3 HSL ) +float3 HslToRgb(float3 hsl) { - float3 RGB = HUEToRGB(HSL.x); - float C = (1.0f - abs(2.0f * HSL.z - 1.0f)) * HSL.y; - return ( RGB - 0.5f ) * C + HSL.z; + const float3 rgb = HueToRgb(hsl.x); + const float c = (1.0f - abs(2.0f * hsl.z - 1.0f)) * hsl.y; + return (rgb - 0.5f) * c + hsl.z; } // Color temperature -float3 KelvinToRGB( float k ) +float3 KelvinToRgb(float k) { float3 ret; - float kelvin = clamp( k, 1000.0f, 40000.0f ) / 100.0f; - if( kelvin <= 66.0f ) + const float kelvin = clamp(k, 1000.0f, 40000.0f) / 100.0f; + if(kelvin <= 66.0f) { - ret.r = 1.0f; - ret.g = saturate( 0.39008157876901960784f * log( kelvin ) - 0.63184144378862745098f ); + ret.r = 1.0f; + ret.g = saturate(0.39008157876901960784f * log(kelvin) - 0.63184144378862745098f); } else { - float t = max( kelvin - 60.0f, 0.0f ); - ret.r = saturate( 1.29293618606274509804f * pow( t, -0.1332047592f )); - ret.g = saturate( 1.12989086089529411765f * pow( t, -0.0755148492f )); + float t = max(kelvin - 60.0f, 0.0f); + ret.r = saturate(1.29293618606274509804f * pow(t, -0.1332047592f)); + ret.g = saturate(1.12989086089529411765f * pow(t, -0.0755148492f)); } - if( kelvin >= 66.0f ) - ret.b = 1.0f; - else if( kelvin < 19.0f ) - ret.b = 0.0f; + if(kelvin >= 66.0f) + ret.b = 1.0f; + else if(kelvin < 19.0f) + ret.b = 0.0f; else - ret.b = saturate( 0.54320678911019607843f * log( kelvin - 10.0f ) - 1.19625408914f ); + ret.b = saturate(0.54320678911019607843f * log(kelvin - 10.0f) - 1.19625408914f); return ret; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCc_To_AcesCg.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCc_To_AcesCg.azsli deleted file mode 100644 index 6a7f5fe794..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCc_To_AcesCg.azsli +++ /dev/null @@ -1,80 +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: (MIT OR Apache-2.0) AND LicenseRef-ACES - * - */ - -/* -License Terms for Academy Color Encoding System Components - -Academy Color Encoding System (ACES) software and tools are provided by the - Academy under the following terms and conditions: A worldwide, royalty-free, - non-exclusive right to copy, modify, create derivatives, and use, in source and - binary forms, is hereby granted, subject to acceptance of this license. - -Copyright © 2015 Academy of Motion Picture Arts and Sciences (A.M.P.A.S.). -Portions contributed by others as indicated. All rights reserved. - -Performance of any of the aforementioned acts indicates acceptance to be bound - by the following terms and conditions: - -* Copies of source code, in whole or in part, must retain the above copyright - notice, this list of conditions and the Disclaimer of Warranty. -* Use in binary form must retain the above copyright notice, this list of - conditions and the Disclaimer of Warranty in the documentation and/or other - materials provided with the distribution. -* Nothing in this license shall be deemed to grant any rights to trademarks, - copyrights, patents, trade secrets or any other intellectual property of - A.M.P.A.S. or any contributors, except as expressly stated herein. -* Neither the name "A.M.P.A.S." nor the name of any other contributors to this - software may be used to endorse or promote products derivative of or based on - this software without express prior written permission of A.M.P.A.S. or the - contributors, as appropriate. - -This license shall be construed pursuant to the laws of the State of California, -and any disputes related thereto shall be subject to the jurisdiction of the - courts therein. - -Disclaimer of Warranty: THIS SOFTWARE IS PROVIDED BY A.M.P.A.S. AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL A.M.P.A.S., OR ANY -CONTRIBUTORS OR DISTRIBUTORS, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, RESITUTIONARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -//////////////////////////////////////////////////////////////////////////////// -WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE ACADEMY SPECIFICALLY -DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES WHATSOEVER RELATED TO PATENT OR -OTHER INTELLECTUAL PROPERTY RIGHTS IN THE ACADEMY COLOR ENCODING SYSTEM, OR -APPLICATIONS THEREOF, HELD BY PARTIES OTHER THAN A.M.P.A.S.,WHETHER DISCLOSED OR -UNDISCLOSED. -*/ - -#pragma once - -static const float HALF_MAX = 65504.0f; - -float ACEScc_to_lin(float value) -{ - if (value < -0.3013698630) // (9.72-15)/17.52 - return (pow( 2., value*17.52-9.72) - pow( 2.,-16.))*2.0; - else if (value < (log2(HALF_MAX)+9.72)/17.52) - return pow( 2., value*17.52-9.72); - else // (value >= (log2(HALF_MAX)+9.72)/17.52) - return HALF_MAX; -} - -float3 AcesCc_To_AcesCg(float3 color) -{ - return float3( - ACEScc_to_lin(color.r), - ACEScc_to_lin(color.g), - ACEScc_to_lin(color.b)); -} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_AcesCc.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_AcesCc.azsli deleted file mode 100644 index 09b80b8254..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_AcesCc.azsli +++ /dev/null @@ -1,79 +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: (MIT OR Apache-2.0) AND LicenseRef-ACES - * - */ - -/* -License Terms for Academy Color Encoding System Components - -Academy Color Encoding System (ACES) software and tools are provided by the - Academy under the following terms and conditions: A worldwide, royalty-free, - non-exclusive right to copy, modify, create derivatives, and use, in source and - binary forms, is hereby granted, subject to acceptance of this license. - -Copyright © 2015 Academy of Motion Picture Arts and Sciences (A.M.P.A.S.). -Portions contributed by others as indicated. All rights reserved. - -Performance of any of the aforementioned acts indicates acceptance to be bound - by the following terms and conditions: - -* Copies of source code, in whole or in part, must retain the above copyright - notice, this list of conditions and the Disclaimer of Warranty. -* Use in binary form must retain the above copyright notice, this list of - conditions and the Disclaimer of Warranty in the documentation and/or other - materials provided with the distribution. -* Nothing in this license shall be deemed to grant any rights to trademarks, - copyrights, patents, trade secrets or any other intellectual property of - A.M.P.A.S. or any contributors, except as expressly stated herein. -* Neither the name "A.M.P.A.S." nor the name of any other contributors to this - software may be used to endorse or promote products derivative of or based on - this software without express prior written permission of A.M.P.A.S. or the - contributors, as appropriate. - -This license shall be construed pursuant to the laws of the State of California, -and any disputes related thereto shall be subject to the jurisdiction of the - courts therein. - -Disclaimer of Warranty: THIS SOFTWARE IS PROVIDED BY A.M.P.A.S. AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL A.M.P.A.S., OR ANY -CONTRIBUTORS OR DISTRIBUTORS, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, RESITUTIONARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -//////////////////////////////////////////////////////////////////////////////// -WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE ACADEMY SPECIFICALLY -DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES WHATSOEVER RELATED TO PATENT OR -OTHER INTELLECTUAL PROPERTY RIGHTS IN THE ACADEMY COLOR ENCODING SYSTEM, OR -APPLICATIONS THEREOF, HELD BY PARTIES OTHER THAN A.M.P.A.S.,WHETHER DISCLOSED OR -UNDISCLOSED. -*/ - -#pragma once - -float lin_to_ACEScc(float value) -{ - if (value <= 0) - return -0.3584474886; // =(log2( pow(2.,-16.))+9.72)/17.52 - else if (value < pow(2.,-15.)) - return (log2( pow(2.,-16.) + value * 0.5) + 9.72) / 17.52; - else // (value >= pow(2.,-15)) - return (log2(value) + 9.72) / 17.52; -} - -float3 AcesCg_To_AcesCc(float3 color) -{ - return float3( - lin_to_ACEScc(color.r), - lin_to_ACEScc(color.g), - lin_to_ACEScc(color.b) - ); -} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Hsv_To_LinearColor.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli similarity index 50% rename from Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Hsv_To_LinearColor.azsli rename to Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli index a938f124d8..9175229f58 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Hsv_To_LinearColor.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/HsvToLinearColor.azsli @@ -8,9 +8,9 @@ #pragma once -float3 Hsv_To_LinearColor(float3 color) +float3 HsvToLinearColor(float3 color) { - float4 K = float4(1.0f, 2.0f / 3.0f, 1.0f / 3.0f, 3.0f); - float3 p = abs(frac(color.xxx + K.xyz) * 6.0f - K.www); - return color.z * lerp(K.xxx, saturate(p - K.xxx), color.y); + 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 new file mode 100644 index 0000000000..2887fdd411 --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColorToHsv.azsli @@ -0,0 +1,21 @@ +/* + * 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); +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColor_To_Hsv.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColor_To_Hsv.azsli deleted file mode 100644 index 83a1e5d843..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearColor_To_Hsv.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 LinearColor_To_Hsv(float3 color) -{ - float4 K = float4(0.0f, -1.0f / 3.0f, 2.0f / 3.0f, -1.0f); - float4 p = lerp(float4(color.bg, K.wz), float4(color.gb, K.xy), step(color.b, color.g)); - float4 q = lerp(float4(p.xyw, color.r), float4(color.r, p.yzx), step(p.x, color.r)); - float d = q.x - min(q.w, q.y); - float e = EPSILON; - return float3(abs(q.z + (q.w - q.y) / (6.0f * d + e)), d / (q.x + e), q.x); -}