#ifdef DESC [program] type: graphics vertex: main fragment: main [binding] name: verts rate: vertex [attribute] name: position type: vec2 [attribute] name: uv type: vec2 [interpolator] name: uv type: vec2 [struct] name: Config [variable] name: exposure type: float [cbuffer] name: config type: Config stage: fragment [texture] name: src stage: fragment dimension: 2 [target] name: colour type: vec4 #endif #ifdef VERTEX_SHADER void main() { interpolator.uv = uv; gl_Position = vec4(position, 1.0, 1.0); } #endif #ifdef FRAGMENT_SHADER vec3 to_srgb(vec3 lin) { bvec3 cutoff = lessThan(lin, 0.0031308.xxx); vec3 higher = 1.055.xxx * pow(lin, vec3(1.0 / 2.4)) - 0.055.xxx; vec3 lower = lin.rgb * 12.92.xxx; return mix(higher, lower, cutoff); } vec3 aces(vec3 x) { float a = 2.51; float b = 0.03; float c = 2.43; float d = 0.59; float e = 0.14; return clamp( (x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0f ); } vec3 hejl(vec3 x, float whitepoint) { vec4 vh = vec4(x, whitepoint); vec4 va = (1.425 * vh) + 0.05; vec4 vf = ((vh * va + 0.004f) / ((vh * (va + 0.55f) + 0.0491f))) - 0.0821f; return vf.rgb / vf.www; } void main() { vec2 uv = interpolator.uv; vec3 lin = texture(src, uv).rgb * config.exposure; lin = hejl(lin, 1.0); colour = vec4(to_srgb(lin), 1.0); } #endif