From 8bc2ce35d518a37cc07fba23613d85822c9c0ea6 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 18 Nov 2024 18:16:38 -0800 Subject: Add ACES filmic toggle to main shader --- tone.cginc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tone.cginc') diff --git a/tone.cginc b/tone.cginc index 371a8db..40965c5 100644 --- a/tone.cginc +++ b/tone.cginc @@ -21,7 +21,7 @@ float3 aces_filmic(float3 x) { // Nice properties: // 1. At x=0, the derivative is 1. // 2. No transcendental ops, and branchless. -float3 smooth_clamp(float3 x, float k) { +float3 smooth_min(float3 x, float k) { // Derivation of `b` from `k`: // f(x, b) = b * x / (x + b) // We want f(1, b) = k. @@ -40,12 +40,15 @@ float3 smooth_clamp(float3 x, float k) { float b = k/(1-k); return b * x / (x + b); } -float smooth_clamp(float x, float k) { +float smooth_min(float x, float k) { float e = 1E-4; k = min(1-e, k); float b = k/(1-k); return b * x / (x + b); } +float smooth_clamp(float x, float lo, float hi) { + return smooth_max(smooth_min(x, hi), lo); +} #endif // __TONE_INC -- cgit v1.2.3