// read the PDF about this if you precompute it! it's got helpful info! // can be optimized into lut (compute can gen it) float GTTonemap(float x) { float m = 0.22; // linear section start float a = 1.0; // contrast float c = 1.33; // black brightness float P = 1.0; // maximum brightness float l = 0.4; // linear section length float l0 = ((P-m)*l) / a; // 0.312 float S0 = m + l0; // 0.532 float S1 = m + a * l0; // 0.532 float C2 = (a*P) / (P - S1); // 2.13675213675 float L = m + a * (x - m); float T = m * pow(x/m, c); float S = P - (P - S1) * exp(-C2*(x - S0)/P); float w0 = 1 - smoothstep(0.0, m, x); float w2 = (x < m+l)?0:1; float w1 = 1 - w0 - w2; return float(T * w0 + L * w1 + S * w2); } // this costs about 0.2-0.3ms more than aces, as-is vec3 GTTonemap(vec3 x) { return vec3( GTTonemap(x.r), GTTonemap(x.g), GTTonemap(x.b) ); }