Code refactor.
Signed-off-by: Robin <rbarrand@amazon.com> Signed-off-by: rbarrand <rbarrand@amazon.com>
This commit is contained in:
Vendored
+2
-2
@@ -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;
|
||||
|
||||
Vendored
+2
-2
@@ -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;
|
||||
|
||||
-16
@@ -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);
|
||||
}
|
||||
-21
@@ -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 <Atom/RPI/Math.azsli>
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user