跳转到内容

Core Node Math 1.0.0

本规范绑定 aelion.visual.nodes/1.0.0,主要给 Material Compiler、Shader 实现和 Golden 测试使用。普通 Material 作者可以通过 materialGraph() 的类型化方法调用这些节点,不需要自己重写公式。

除特别说明外,颜色输入都是线性、预乘 alpha 的 RGBA vec4,标量使用 32-bit GPU float。WebGL2 和 WebGPU 必须实现同一公式;修改公式或 alpha 行为需要升级 node set/typeVersion,而不是直接改变现有节点结果。

Node结果
math.adda + b
math.subtracta - b
math.multiplya × b
math.dividea / b;调用方不得提供零分母
math.clampmin(max(value, min), max)
math.smoothstept=clamp((x-edge0)/(edge1-edge0),0,1),结果 t²(3-2t);两 edge 不得相等
time.transition-curve(linear)clamp(progress,0,1)
time.transition-curve(smooth)smoothstep(0,1,clamp(progress,0,1))

非有限 uniform、非法 specialization 和未知 node/typeVersion 必须在 compiler/runtime 边界拒绝。

令输入颜色为 c=(rgb,a)

Node结果
composite.mixmix(a,b,clamp(amount,0,1))
color.temperaturemax(rgb × (1+t, 1+0.15t, 1-0.55t),0),alpha 不变
color.lift-blackmix(rgb,1,clamp(amount,0,1)),alpha 不变
color.scale-rgbmax(rgb × scale,0),alpha 不变
color.exposurecolor.scale-rgb(c, 2^stops)
color.contrast(rgb-0.5)×amount+0.5,alpha 不变
color.saturationmix(luma,rgb,amount)luma=dot(rgb,(0.2126,0.7152,0.0722))
color.invert(a-rgb,a),保持 premultiplied 范围
composite.screen1-(1-base.rgb)(1-overlay.rgb);alpha ab+ao-ab×ao
composite.multiply(base.rgb×overlay.rgb, base.a×overlay.a)
composite.addmin(base+overlay,1)

color.extract-highlights → blur.gaussian → color.scale-rgb → composite.screen 是受支持的四 pass Soft Glow pattern。Highlight 使用 max(rgb-threshold,0);Gaussian radius clamp 到 [0,64],横/纵 pass 使用相同离散 kernel 与边缘 clamp。

  • 同 backend、同 shader、同输入的 8-bit deterministic output:每 channel 绝对误差 ≤1
  • WebGL2/WebGPU 8-bit cross-backend:每 channel ≤2,alpha 同样计入。
  • compareMaterialGolden() 默认容差为 2,报告 differing values、maximum error 与 mean error;尺寸不同必须直接拒绝。
  • transition Golden 至少覆盖 progress 0/0.25/0.5/0.75/1;0 和 1 必须保持端点 identity。
  • PQ/HLG、10-bit 和 float HDR 不使用本表的 8-bit tolerance;当前本地 pipeline 会 fail closed,待独立 HDR corpus 后再增加规范。

Compiler 的 node registry 是可执行真源;修改公式、端口、alpha 行为或 tolerance 都必须升级 node set/typeVersion,并更新双后端 Golden。