Added GT Toon map;

Changed shadow bias from fixed to slope based;
This commit is contained in:
2025-08-25 10:47:26 +09:00
parent 973f617590
commit e35650f052
8 changed files with 65 additions and 20 deletions

View File

@@ -44,8 +44,36 @@ Shader "Hidden/Shader/UTSTonemapping"
inline float3 UTSToonmap(float3 x)
{
// See https://www.desmos.com/calculator/j4tpqazyfw
#if 1
// GT Tonemap, see https://www.desmos.com/calculator/gslcdxvipg
float p = 1.0;
float a = 1.0;
float m = 0.22;
float l = 0.4;
float c = 1.33;
float b = 0.0;
float l0 = (l * (p - m)) / a;
float L0 = m - m / a;
float L1 = m + (1 - m) / a;
float3 Lx = m + a * (x - m);
float3 Tx = m * pow(x / m, c) + b;
float S0 = m + l0;
float S1 = m + a * l0;
float C2 = (a * p) / (p - S1);
float3 Sx = p - (p - S1) * exp(-(C2 * (x - S0)) / p);
float3 w0 = 1.0 - smoothstep( 0.0, m, x);
float3 w2 = smoothstep(m + l0, m + l0, x);
float3 w1 = 1.0 - w0 - w2;
return Tx * w0 + Lx * w1 + Sx * w2;
#else
// Modified ACES, see https://www.desmos.com/calculator/j4tpqazyfw
return (x * (2.63 * x + 0.03)) / (x * (2.11 * x + 0.72) + 0.31);
#endif
}
float4 CustomPostProcess(Varyings input) : SV_Target
@@ -55,9 +83,13 @@ Shader "Hidden/Shader/UTSTonemapping"
// Note that if HDUtils.DrawFullScreen is not used to render the post process, you don't need to call ClampAndScaleUVForBilinearPostProcessTexture.
float3 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex, s_linear_clamp_sampler, ClampAndScaleUVForBilinearPostProcessTexture(input.texcoord.xy)).rgb;
#if 1
float3 color = UTSToonmap(sourceColor);
#else
float whiteScale = 1.0 / UTSToonmap(5.3);
float3 color = UTSToonmap(sourceColor * whiteScale);
color *= whiteScale;
#endif
return float4(color, 1);
}