import { edge, node } from './builders.mjs'; /** * The "Adjust colors" shader as an asset document: brightness, contrast and saturation, 1 neutral, * on the straight colour – rgb += brightness - 1; rgb = (rgb - 0.5) * contrast + 0.5; * rgb = mix(luma, rgb, saturation). Brightness adds (user decision, #62 follow-up), so 1 is +0. */ export function adjustColorsShader(id = 'adjust-colors', name = 'Adjust colors') { const property = (nodeId, propertyName, x, y) => node(nodeId, 'ShaderProperty', x, y, { name: propertyName, default: 1, min: 0, max: 4 }); return { id, type: 'shader', name, props: {}, graph: { nodes: [ node(`${id}-texel`, 'ShaderTextureColor', 0, 0), property(`${id}-brightness`, 'brightness', 0, 160), property(`${id}-contrast`, 'contrast', 0, 320), property(`${id}-saturation`, 'saturation', 0, 480), node(`${id}-offset`, 'ShaderSubtract', 260, 160, { b: 1 }), node(`${id}-bright`, 'ShaderAdd', 520, 0), node(`${id}-shift`, 'ShaderSubtract', 780, 0, { b: 0.5 }), node(`${id}-scale`, 'ShaderMultiply', 1040, 0), node(`${id}-centre`, 'ShaderAdd', 1300, 0, { b: 0.5 }), node(`${id}-luma`, 'ShaderLuminance', 1560, 160), node(`${id}-mix`, 'ShaderMix', 1820, 0), node(`${id}-out`, 'ShaderOutput', 2080, 0), ], edges: [ edge(`${id}-e1`, `${id}-texel`, 'color', `${id}-bright`, 'a'), edge(`${id}-e2`, `${id}-brightness`, 'value', `${id}-offset`, 'a'), edge(`${id}-e12`, `${id}-offset`, 'result', `${id}-bright`, 'b'), edge(`${id}-e3`, `${id}-bright`, 'result', `${id}-shift`, 'a'), edge(`${id}-e4`, `${id}-shift`, 'result', `${id}-scale`, 'a'), edge(`${id}-e5`, `${id}-contrast`, 'value', `${id}-scale`, 'b'), edge(`${id}-e6`, `${id}-scale`, 'result', `${id}-centre`, 'a'), edge(`${id}-e7`, `${id}-centre`, 'result', `${id}-luma`, 'color'), edge(`${id}-e8`, `${id}-luma`, 'value', `${id}-mix`, 'a'), edge(`${id}-e9`, `${id}-centre`, 'result', `${id}-mix`, 'b'), edge(`${id}-e10`, `${id}-saturation`, 'value', `${id}-mix`, 't'), edge(`${id}-e11`, `${id}-mix`, 'result', `${id}-out`, 'color'), ], }, }; }