Add small scale for color grading LUT

This commit is contained in:
Wojtek Figat
2026-01-12 23:56:31 +01:00
parent 2501095500
commit e494c9ec76
5 changed files with 18 additions and 9 deletions

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c0b43b79fe3ad34ebf5fa47d49e017c768b48c1bd688ba521a684bab7ef286bd
size 12311
oid sha256:0a7c3aef4378698c6875a7574ec17890d88e87013242e5f8327cc72050bfda8b
size 12377

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eb59d5d69de414b28dad32c673193d138709c16bd31bb8a1cf435d329a6bd1c1
size 22997
oid sha256:a430a05bdfa8476cc742748d5406e9c8c80a7e1ed00f392947b8c88cdf7cd176
size 23062

View File

@@ -281,8 +281,11 @@ float4 CombineLUTs(float2 uv, uint layerIndex)
#endif
// Move from encoded LUT color space to linear color
//float3 linearColor = encodedColor.rgb; // Default
#if COLOR_GRADING_LUT_LOG
float3 linearColor = LogToLinear(encodedColor.rgb) - LogToLinear(0); // Log
#else
float3 linearColor = encodedColor.rgb; // Default
#endif
// Apply white balance
linearColor = WhiteBalance(linearColor);
@@ -300,7 +303,7 @@ float4 CombineLUTs(float2 uv, uint layerIndex)
color = lerp(color, lutColor, LutWeight);
}
return float4(color, 1);
return float4(color / COLOR_GRADING_LUT_SCALE, 1);
}
// Vertex shader that writes to a range of slices of a volume texture

View File

@@ -5,6 +5,10 @@
#include "./Flax/Math.hlsl"
// Shared configs for Color Grading LUT
#define COLOR_GRADING_LUT_LOG 1
#define COLOR_GRADING_LUT_SCALE 1.04f
// Fast reversible tonemapper
// http://gpuopen.com/optimized-reversible-tonemapper-for-resolve/
float3 FastTonemap(float3 c)

View File

@@ -115,18 +115,20 @@ static const float LUTSize = 32;
half3 ColorLookupTable(half3 linearColor)
{
// Move from linear color to encoded LUT color space
//float3 encodedColor = linearColor; // Default
#if COLOR_GRADING_LUT_LOG
float3 encodedColor = LinearToLog(linearColor + LogToLinear(0)); // Log
#else
float3 encodedColor = linearColor; // Default
#endif
float3 uvw = encodedColor * ((LUTSize - 1) / LUTSize) + (0.5f / LUTSize);
#if USE_VOLUME_LUT
half3 color = ColorGradingLUT.Sample(SamplerLinearClamp, uvw).rgb;
#else
half3 color = SampleUnwrappedTexture3D(ColorGradingLUT, SamplerLinearClamp, uvw, LUTSize).rgb;
#endif
return color;
return color * COLOR_GRADING_LUT_SCALE;
}
// A random texture generator