WIP: integrate film and RGB mixer tools; 346 native and 38 reference checks pass before formal acceptance
这个提交包含在:
1 父节点
a249436776
当前提交
f575c01893
25 个文件已更改
+1321
-22
没有与搜索条件相匹配的文件
@@ -29,3 +29,14 @@ RenderingEngine `default.metallib` SHA-256 `6fd43083a38e76c95c6256a331eabb85d97b
|
||||
保留原参数ID及944字节GPU前缀;新的参数仅追加。新增可重复通道混合器与胶片工具,沿用现有启停、折叠、蒙版、数量标记和相邻插入。旧工程缺省为严格中性,保留schema1尾层、schema2锚点及286键用户状态。
|
||||
|
||||
Cube只允许可静态表示的颜色数学;空间效果、颗粒和蒙版必须明确拒绝,完整预设保留其状态。待本机原版图像对照、原生回归和正式宿主验收完成后再记录结论。
|
||||
|
||||
## 开发检查点
|
||||
|
||||
已追加两种工具、42个宿主浮点参数及完整预设v5;旧ID与1104字节完整前缀保留。CST及原调色/蒙版/跟踪调度不重排;两个新根工具位于原显示域链/蜘蛛盘之后,schema1尾层之前。减色与颗粒用既有sRGB编码边界,晕光/辉光/暗角用宿主线性纹理;这属于本工程接入合同,并不声称与任意ACES管理的原版整条CMS完全等效。
|
||||
|
||||
原版Fx包装确认辉光使用固定2.5像素稀疏高斯预滤→向量Sobel阈值→用户diffusion高斯扩散→相加;晕光scatter缺省5,透射参数/500,boost缺省1;颗粒PCG与Box-Muller直接原版shader输出逐样本相符,相关性=1−2×colorVariation。暗角直接复用同一系统CIVignetteEffect及参数映射。证据:`ev_f0221c32adbaa1e108aa560f0f8fa60c067619ac9f5b06225df548e2671a448f`、`ev_932531fcd8aaebf06eabd6e22f1a56615ba2462f6efc3fb53cfdbdb9fd618816`、`ev_b500f2f762efd1dbbd8ae7efab9d48016482ff1463775039d25504cb4ccd9d3f`、`ev_850af09a4640201b65745c78a10a0e0a0ef67eee9614d129517f6bf13c54c11e`。
|
||||
|
||||
当前原生346项通过;独立原版CI/Metal对照仍在修正辉光边界采样。CI读取bitmap的上下行与Metal纹理相反,对照工具已有往返控制;产品CI→Metal往返验证无翻转。颗粒比对采用原版BoxMullerPCG/GrainFilter明确尺寸/种子,避免把Core Image内部切块的噪声坐标当作固定全帧坐标。此检查点尚未正式安装和宿主验收。
|
||||
|
||||
|
||||
独立原版对照38项现已全部通过:四组通道保持选项、12组减色、3种晕光半径、3种辉光阈值、4种PCG种子与12组颗粒。最大线性RGB绝对差0.0001328(通道双保持),低于预先记录的0.00015浮点容差;其余各项有各自阈值。辉光普通区域采用可分离预滤,最外一圈直接求原25点邻域,保留原版clamp边界,避免把裁切中间图的边界当作原图边界。见 `verification/FilmMixerReference.json`。这只覆盖声明的有限组件和参数,不代表原版整条CMS、全部素材或全部印片外观等价。
|
||||
@@ -3062,18 +3062,540 @@
|
||||
"pid": 2188,
|
||||
"step": 0.01,
|
||||
"title": "色彩平衡"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "mixer00",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 0,
|
||||
"offset": 1104,
|
||||
"pid": 2276,
|
||||
"step": 0.01,
|
||||
"title": "红输出 ← 红输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer01",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 0,
|
||||
"offset": 1108,
|
||||
"pid": 2277,
|
||||
"step": 0.01,
|
||||
"title": "红输出 ← 绿输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer02",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 0,
|
||||
"offset": 1112,
|
||||
"pid": 2278,
|
||||
"step": 0.01,
|
||||
"title": "红输出 ← 蓝输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer10",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 1,
|
||||
"offset": 1120,
|
||||
"pid": 2280,
|
||||
"step": 0.01,
|
||||
"title": "绿输出 ← 红输入"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "mixer11",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 1,
|
||||
"offset": 1124,
|
||||
"pid": 2281,
|
||||
"step": 0.01,
|
||||
"title": "绿输出 ← 绿输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer12",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 1,
|
||||
"offset": 1128,
|
||||
"pid": 2282,
|
||||
"step": 0.01,
|
||||
"title": "绿输出 ← 蓝输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer20",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 2,
|
||||
"offset": 1136,
|
||||
"pid": 2284,
|
||||
"step": 0.01,
|
||||
"title": "蓝输出 ← 红输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixer21",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 2,
|
||||
"offset": 1140,
|
||||
"pid": 2285,
|
||||
"step": 0.01,
|
||||
"title": "蓝输出 ← 绿输入"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "mixer22",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"mixerTab": 2,
|
||||
"offset": 1144,
|
||||
"pid": 2286,
|
||||
"step": 0.01,
|
||||
"title": "蓝输出 ← 蓝输入"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixerPreserveLuma",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1156,
|
||||
"pid": 2289,
|
||||
"step": 0.01,
|
||||
"title": "保持亮度"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"key": "mixerPreserveSaturation",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1160,
|
||||
"pid": 2290,
|
||||
"step": 0.01,
|
||||
"title": "保持饱和度"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "mixerMix",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1164,
|
||||
"pid": 2291,
|
||||
"step": 0.01,
|
||||
"title": "通道混合强度"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "mixerEnabled",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1152,
|
||||
"pid": 2288,
|
||||
"step": 0.01,
|
||||
"title": "通道混合器"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": -1,
|
||||
"key": "filmMix",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1172,
|
||||
"pid": 2293,
|
||||
"step": 0.01,
|
||||
"title": "胶片混合强度"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 0,
|
||||
"key": "filmSubtractive",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1176,
|
||||
"pid": 2294,
|
||||
"step": 0.01,
|
||||
"title": "启用减色"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 0,
|
||||
"key": "filmGammaAll",
|
||||
"kind": "float",
|
||||
"max": 4,
|
||||
"min": 0.25,
|
||||
"offset": 1180,
|
||||
"pid": 2295,
|
||||
"step": 0.01,
|
||||
"title": "整体减色"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 0,
|
||||
"key": "filmGammaCyan",
|
||||
"kind": "float",
|
||||
"max": 4,
|
||||
"min": 0.25,
|
||||
"offset": 1184,
|
||||
"pid": 2296,
|
||||
"step": 0.01,
|
||||
"title": "青色减色"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 0,
|
||||
"key": "filmGammaMagenta",
|
||||
"kind": "float",
|
||||
"max": 4,
|
||||
"min": 0.25,
|
||||
"offset": 1188,
|
||||
"pid": 2297,
|
||||
"step": 0.01,
|
||||
"title": "洋红减色"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 0,
|
||||
"key": "filmGammaYellow",
|
||||
"kind": "float",
|
||||
"max": 4,
|
||||
"min": 0.25,
|
||||
"offset": 1192,
|
||||
"pid": 2298,
|
||||
"step": 0.01,
|
||||
"title": "黄色减色"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 0,
|
||||
"key": "filmDensity",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": -1,
|
||||
"offset": 1196,
|
||||
"pid": 2299,
|
||||
"step": 0.01,
|
||||
"title": "密度"
|
||||
},
|
||||
{
|
||||
"default": 2,
|
||||
"filmTab": 0,
|
||||
"key": "filmDensityMode",
|
||||
"kind": "popup",
|
||||
"max": 2,
|
||||
"min": 1,
|
||||
"offset": 1200,
|
||||
"options": [
|
||||
"模式 1 · 最大值",
|
||||
"模式 2 · 平均值"
|
||||
],
|
||||
"pid": 2300,
|
||||
"step": 0.01,
|
||||
"title": "密度模式",
|
||||
"values": [
|
||||
2,
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"default": 6,
|
||||
"key": "filmValueMode",
|
||||
"kind": "float",
|
||||
"max": 6,
|
||||
"min": 6,
|
||||
"offset": 1204,
|
||||
"pid": 2301,
|
||||
"step": 0.01,
|
||||
"title": "胶片亮度模型"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 1,
|
||||
"key": "filmHalation",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1208,
|
||||
"pid": 2302,
|
||||
"step": 0.01,
|
||||
"title": "启用晕光"
|
||||
},
|
||||
{
|
||||
"default": 5,
|
||||
"filmTab": 1,
|
||||
"key": "filmScatter",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1212,
|
||||
"pid": 2303,
|
||||
"step": 1,
|
||||
"title": "散射半径"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 1,
|
||||
"key": "filmTransmission",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1216,
|
||||
"pid": 2304,
|
||||
"step": 1,
|
||||
"title": "染料透射"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 1,
|
||||
"key": "filmBoost",
|
||||
"kind": "float",
|
||||
"max": 5,
|
||||
"min": 0,
|
||||
"offset": 1220,
|
||||
"pid": 2305,
|
||||
"step": 0.01,
|
||||
"title": "晕光增强"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 2,
|
||||
"key": "filmBloom",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1224,
|
||||
"pid": 2306,
|
||||
"step": 0.01,
|
||||
"title": "启用辉光"
|
||||
},
|
||||
{
|
||||
"default": 50,
|
||||
"filmTab": 2,
|
||||
"key": "filmSensitivity",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1228,
|
||||
"pid": 2307,
|
||||
"step": 1,
|
||||
"title": "辉光灵敏度"
|
||||
},
|
||||
{
|
||||
"default": 30,
|
||||
"filmTab": 2,
|
||||
"key": "filmDiffusion",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1232,
|
||||
"pid": 2308,
|
||||
"step": 1,
|
||||
"title": "辉光扩散"
|
||||
},
|
||||
{
|
||||
"default": 50,
|
||||
"filmTab": 2,
|
||||
"key": "filmIntensity",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1236,
|
||||
"pid": 2309,
|
||||
"step": 1,
|
||||
"title": "辉光强度"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrain",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1240,
|
||||
"pid": 2310,
|
||||
"step": 0.01,
|
||||
"title": "启用颗粒"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainAmount",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1244,
|
||||
"pid": 2311,
|
||||
"step": 0.01,
|
||||
"title": "颗粒数量"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainSize",
|
||||
"kind": "float",
|
||||
"max": 20,
|
||||
"min": 1,
|
||||
"offset": 1248,
|
||||
"pid": 2312,
|
||||
"step": 1,
|
||||
"title": "颗粒大小"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainResponse",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": -1,
|
||||
"offset": 1252,
|
||||
"pid": 2313,
|
||||
"step": 0.01,
|
||||
"title": "胶片响应"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainColor",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1256,
|
||||
"pid": 2314,
|
||||
"step": 0.01,
|
||||
"title": "颜色变化"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainHold",
|
||||
"kind": "popup",
|
||||
"max": 5,
|
||||
"min": 1,
|
||||
"offset": 1260,
|
||||
"options": [
|
||||
"每帧更新",
|
||||
"保持 2 帧",
|
||||
"保持 3 帧",
|
||||
"保持 4 帧",
|
||||
"保持 5 帧"
|
||||
],
|
||||
"pid": 2315,
|
||||
"step": 0.01,
|
||||
"title": "颗粒帧保持",
|
||||
"values": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 3,
|
||||
"key": "filmGrainSeed",
|
||||
"kind": "float",
|
||||
"max": 65535,
|
||||
"min": 0,
|
||||
"offset": 1264,
|
||||
"pid": 2316,
|
||||
"step": 1,
|
||||
"title": "颗粒种子"
|
||||
},
|
||||
{
|
||||
"default": 0,
|
||||
"filmTab": 4,
|
||||
"key": "filmVignette",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1268,
|
||||
"pid": 2317,
|
||||
"step": 0.01,
|
||||
"title": "启用暗角"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"filmTab": 4,
|
||||
"key": "filmVignetteIntensity",
|
||||
"kind": "float",
|
||||
"max": 2,
|
||||
"min": -2,
|
||||
"offset": 1272,
|
||||
"pid": 2318,
|
||||
"step": 0.01,
|
||||
"title": "暗角强度"
|
||||
},
|
||||
{
|
||||
"default": 50,
|
||||
"filmTab": 4,
|
||||
"key": "filmVignetteRadius",
|
||||
"kind": "float",
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"offset": 1276,
|
||||
"pid": 2319,
|
||||
"step": 1,
|
||||
"title": "暗角半径"
|
||||
},
|
||||
{
|
||||
"default": 0.5,
|
||||
"filmTab": 4,
|
||||
"key": "filmVignetteFalloff",
|
||||
"kind": "float",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1280,
|
||||
"pid": 2320,
|
||||
"step": 0.01,
|
||||
"title": "暗角过渡"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"key": "filmEnabled",
|
||||
"kind": "bool",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"offset": 1168,
|
||||
"pid": 2292,
|
||||
"step": 0.01,
|
||||
"title": "胶片模拟"
|
||||
}
|
||||
],
|
||||
"sourceSHA256": {
|
||||
"template/tools/dump_model.mm": "04e04446aa351d774913bc25b06512fefe7969bdf4c6e471a91f1e9d6c4fc3b5",
|
||||
"大鱼调色/Plugin/DYCSTTypes.h": "3372e3cd77248eeb374e54675d2902befceea8e00a2afc4f9543116ef3027696",
|
||||
"大鱼调色/Plugin/DYColorManagement.h": "b0a4cd1b8c45dbce90a7b4f30f72ebf95ecd382895e74e3bfeda0f7cdb185157",
|
||||
"大鱼调色/Plugin/DYFilmMath.h": "e41d44790c6bb42db7c68520d442b39c381b4db4056d40a44426e21f62e9bf6b",
|
||||
"大鱼调色/Plugin/DYFilmTypes.h": "c35a43b5b93988e8517e5db8f281da0dfd1e02f5b0e7bfb62e7345cec444a36d",
|
||||
"大鱼调色/Plugin/DYModel.h": "80e88add97deeac7a9dc47d12f68b0245905786297de2e6553b3da15c729da6e",
|
||||
"大鱼调色/Plugin/DYModel.mm": "beadabb0773e911581dedc263f55a49e03dde6e6d1fc2329df18cb384710d234",
|
||||
"大鱼调色/Plugin/DYModel.mm": "f430633aeb2e2680c3db83caf06ddd1b16e84173ecd4fb4d4b66afb5362ad4ea",
|
||||
"大鱼调色/Plugin/DYSpiderState.h": "0c80747e41e8fc97762e301b011bd08c18865a825eaafde086ed79ace37b22f9",
|
||||
"大鱼调色/Plugin/DYToolState.h": "28088ec819307a60f2e52334fd807a514c3ff8a550bc0efbe7069b68a6242320",
|
||||
"大鱼调色/Plugin/DYToolState.mm": "9ddc4b7509ad63fc24d1724359b4a218609f90b971eee57f6cdeda0c1b309129",
|
||||
"大鱼调色/Plugin/DYUniforms.h": "8ef480025c739b29f55884ba0c7218e9d6fd8d80c46cfc72d6ee3da90215abe4",
|
||||
"大鱼调色/Plugin/DYToolState.mm": "6502e412532f2be2589188c1b99579ae59ab279d814805e38b0c8042e921a5bd",
|
||||
"大鱼调色/Plugin/DYUniforms.h": "8c494532d534b65622039605073b554bafd92ec0efe1e0d207d822b59862a1cb",
|
||||
"大鱼调色/Plugin/MaskCore/DYMask.h": "5b9aa44390d4a1fca1baf5e34cb9eefc8483c939a65cc2a0412b7b41fc85bc16",
|
||||
"大鱼调色/Plugin/MaskCore/DYMaskOperator.h": "43fa701ad574f38ce0ab4f4d3900bb034edaaa1adc09821d2f4443ee2b687ba2",
|
||||
"大鱼调色/Plugin/SpiderCore/DYColorMath.h": "bdd6278e17ff4208ad94a8b0e834c817c0a3475f205dd79898e8fd88e84a19c9",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"passed": true,
|
||||
"sha256": "9b8f6e407545429b77c1de88d4cceb738760771c5a7f1dbd9732bdcc95c23738",
|
||||
"sha256": "7476fb5a3cfad5f4dafb7a887dcc787b9cbcba6ad64df3b4939b336444cf8bfc",
|
||||
"version": "5.13",
|
||||
"displayversion": "5.6.7",
|
||||
"filterCount": 1,
|
||||
"nativeFloatParameters": 234,
|
||||
"nativeFloatParameters": 276,
|
||||
"customParameters": 3,
|
||||
"publications": [
|
||||
{
|
||||
|
||||
@@ -540,6 +540,48 @@
|
||||
<parameter name="高光 洋红 ↔ 绿" id="2201" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="高光 黄 ↔ 蓝" id="2202" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="色彩平衡" id="2188" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="红输出 ← 红输入" id="2276" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="红输出 ← 绿输入" id="2277" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="红输出 ← 蓝输入" id="2278" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="绿输出 ← 红输入" id="2280" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="绿输出 ← 绿输入" id="2281" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="绿输出 ← 蓝输入" id="2282" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="蓝输出 ← 红输入" id="2284" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="蓝输出 ← 绿输入" id="2285" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="蓝输出 ← 蓝输入" id="2286" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="保持亮度" id="2289" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="保持饱和度" id="2290" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="通道混合强度" id="2291" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="通道混合器" id="2288" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="胶片混合强度" id="2293" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="启用减色" id="2294" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="整体减色" id="2295" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="青色减色" id="2296" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="洋红减色" id="2297" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="黄色减色" id="2298" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="密度" id="2299" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="密度模式" id="2300" flags="12889161760" default="2" value="2" />
|
||||
<parameter name="胶片亮度模型" id="2301" flags="12889161760" default="6" value="6" />
|
||||
<parameter name="启用晕光" id="2302" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="散射半径" id="2303" flags="12889161760" default="5" value="5" />
|
||||
<parameter name="染料透射" id="2304" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="晕光增强" id="2305" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="启用辉光" id="2306" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="辉光灵敏度" id="2307" flags="12889161760" default="50" value="50" />
|
||||
<parameter name="辉光扩散" id="2308" flags="12889161760" default="30" value="30" />
|
||||
<parameter name="辉光强度" id="2309" flags="12889161760" default="50" value="50" />
|
||||
<parameter name="启用颗粒" id="2310" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="颗粒数量" id="2311" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="颗粒大小" id="2312" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="胶片响应" id="2313" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="颜色变化" id="2314" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="颗粒帧保持" id="2315" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="颗粒种子" id="2316" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="启用暗角" id="2317" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="暗角强度" id="2318" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="暗角半径" id="2319" flags="12889161760" default="50" value="50" />
|
||||
<parameter name="暗角过渡" id="2320" flags="12889161760" default="0.5" value="0.5" />
|
||||
<parameter name="胶片模拟" id="2292" flags="12889161760" default="1" value="1" />
|
||||
<parameter name="混合" id="10001" flags="12884901888" default="1" value="1" />
|
||||
<parameter name="翻转" id="10002" flags="12889161760" default="0" value="0" />
|
||||
<parameter name="输入点" id="10003" flags="12889161760" default="1" value="1" />
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ CONTENT_TAGS={'scenenode','layer','group','filter','behavior','mask'}
|
||||
def sha(data):return hashlib.sha256(data).hexdigest()
|
||||
|
||||
def model_identity():
|
||||
files=['大鱼调色/Plugin/DYModel.h','大鱼调色/Plugin/DYModel.mm','大鱼调色/Plugin/DYUniforms.h','大鱼调色/Plugin/DYColorManagement.h','大鱼调色/Plugin/DYCSTTypes.h','大鱼调色/Plugin/DYSpiderState.h','大鱼调色/Plugin/SpiderCore/DYColorMath.h','大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp','template/tools/dump_model.mm','大鱼调色/Plugin/DYToolState.h','大鱼调色/Plugin/DYToolState.mm','大鱼调色/Plugin/MaskCore/DYMaskOperator.h','大鱼调色/Plugin/MaskCore/DYMask.h']
|
||||
files=['大鱼调色/Plugin/DYModel.h','大鱼调色/Plugin/DYModel.mm','大鱼调色/Plugin/DYUniforms.h','大鱼调色/Plugin/DYColorManagement.h','大鱼调色/Plugin/DYCSTTypes.h','大鱼调色/Plugin/DYSpiderState.h','大鱼调色/Plugin/SpiderCore/DYColorMath.h','大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp','template/tools/dump_model.mm','大鱼调色/Plugin/DYFilmTypes.h','大鱼调色/Plugin/DYFilmMath.h','大鱼调色/Plugin/DYToolState.h','大鱼调色/Plugin/DYToolState.mm','大鱼调色/Plugin/MaskCore/DYMaskOperator.h','大鱼调色/Plugin/MaskCore/DYMask.h']
|
||||
return {name:sha((ROOT/name).read_bytes()) for name in files}
|
||||
|
||||
def refresh_metadata():
|
||||
|
||||
@@ -10,13 +10,19 @@ int main(int argc,const char **argv){@autoreleasepool{
|
||||
void *handle=dlopen(path.fileSystemRepresentation,RTLD_NOW|RTLD_LOCAL);
|
||||
if(!handle){fprintf(stderr,"%s\n",dlerror());return 1;}
|
||||
NSMutableDictionary *out=[NSMutableDictionary dictionary];
|
||||
for(NSString *name in @[@"FTChannelMixerFilter",@"FTFilmSaturationFilter",@"FTHalationFilter",@"FTBloomFilter",@"FTGrainFilter",@"FTGrainProcessor"]){
|
||||
for(NSString *name in @[@"FTChannelMixerFilter",@"FTFilmSaturationFilter",@"FTHalationFilter",@"FTBloomFilter",@"FTGrainFilter",@"FTGrainProcessor",@"FTNoiseGeneratorSimple"]){
|
||||
Class cls=NSClassFromString(name);NSMutableDictionary *entry=[NSMutableDictionary dictionary];
|
||||
for(int meta=0;meta<2;meta++){
|
||||
unsigned count=0;Method *methods=class_copyMethodList(meta?object_getClass(cls):cls,&count);NSMutableArray *list=[NSMutableArray array];
|
||||
for(unsigned i=0;i<count;i++)[list addObject:@{@"selector":NSStringFromSelector(method_getName(methods[i])),@"encoding":@(method_getTypeEncoding(methods[i]))}];free(methods);entry[meta?@"class":@"instance"]=list;
|
||||
}
|
||||
if([cls isSubclassOfClass:CIFilter.class]){@try{CIFilter *filter=[[cls alloc]init];[filter setDefaults];entry[@"attributes"]=filter.attributes?:@{};entry[@"inputKeys"]=filter.inputKeys?:@[];}@catch(NSException *e){entry[@"exception"]=e.reason;}}
|
||||
if([cls isSubclassOfClass:CIFilter.class]){@try{CIFilter *filter=[[cls alloc]init];[filter setDefaults];entry[@"attributes"]=filter.attributes?:@{};entry[@"inputKeys"]=filter.inputKeys?:@[];
|
||||
NSMutableDictionary *values=[NSMutableDictionary dictionary];
|
||||
for(NSString *key in @[@"gammaAll",@"gammaCyan",@"gammaMagenta",@"gammaYellow",@"density",@"densitySwitch",@"valueSwitch",@"scatter",@"dyeTransmission",@"boost",@"sensitivity",@"blurRadius",@"intensity",@"grainSize",@"filmResponse",@"correlation",@"stdRed",@"stdGreen",@"stdBlue",@"seed"]){@try{id value=[filter valueForKey:key];if([value isKindOfClass:NSNumber.class])values[key]=value;}@catch(NSException *e){}}
|
||||
for(NSString *key in @[@"colorKernel",@"genericKernel"]){@try{id value=[filter valueForKey:key];if(value)values[key]=[value name]?:@"";}@catch(NSException *e){}}
|
||||
entry[@"defaults"]=values;
|
||||
}@catch(NSException *e){entry[@"exception"]=e.reason;}}
|
||||
if([name isEqual:@"FTNoiseGeneratorSimple"]){id object=[[cls alloc]init];entry[@"defaults"]=@{@"radius":[object valueForKey:@"radius"],@"blurSize":[object valueForKey:@"blurSize"]};}
|
||||
out[name]=entry;
|
||||
}
|
||||
NSData *json=[NSJSONSerialization dataWithJSONObject:out options:NSJSONWritingPrettyPrinted|NSJSONWritingSortedKeys error:nil];
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Executes the user's installed Color Finale only as a read-only test oracle.
|
||||
// Product builds and product rendering never load these reference frameworks.
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreImage/CoreImage.h>
|
||||
#import <Metal/Metal.h>
|
||||
#import <MetalPerformanceShaders/MetalPerformanceShaders.h>
|
||||
#include <dlfcn.h>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include "../大鱼调色/Plugin/DYFilmMath.h"
|
||||
using Floats=std::vector<float>;
|
||||
static id<MTLDevice> gpu;
|
||||
static id<MTLCommandQueue> queue;
|
||||
static CIContext *context;
|
||||
static const unsigned W=64,H=48;
|
||||
static void require(bool p,NSString *m){if(!p)@throw [NSException exceptionWithName:@"FilmReference" reason:m userInfo:nil];}
|
||||
static float encode(float v){return v<=.0031308f?v*12.92f:1.055f*powf(fmaxf(0,v),1/2.4f)-.055f;}
|
||||
static float decode(float v){return v<=.04045f?v/12.92f:powf(fmaxf(0,(v+.055f)/1.055f),2.4f);}
|
||||
static id<MTLTexture> texture(const Floats& data={}){MTLTextureDescriptor *d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:W height:H mipmapped:NO];d.storageMode=MTLStorageModeShared;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;id<MTLTexture>t=[gpu newTextureWithDescriptor:d];require(t!=nil,@"texture allocation");if(!data.empty())[t replaceRegion:MTLRegionMake2D(0,0,W,H) mipmapLevel:0 withBytes:data.data() bytesPerRow:W*16];return t;}
|
||||
static Floats read(id<MTLTexture> t){Floats v(W*H*4);[t getBytes:v.data() bytesPerRow:W*16 fromRegion:MTLRegionMake2D(0,0,W,H) mipmapLevel:0];return v;}
|
||||
static void finish(id<MTLCommandBuffer> c){[c commit];[c waitUntilCompleted];require(c.status==MTLCommandBufferStatusCompleted,c.error.description?:@"GPU command");}
|
||||
static CIImage *image(id<MTLTexture> t){return [CIImage imageWithMTLTexture:t options:@{kCIImageColorSpace:NSNull.null}];}
|
||||
static Floats render(CIImage *ci){require(ci!=nil,@"reference output image");Floats v(W*H*4);[context render:ci toBitmap:v.data() rowBytes:W*16 bounds:CGRectMake(0,0,W,H) format:kCIFormatRGBAf colorSpace:nil];Floats top(v.size());for(unsigned y=0;y<H;y++)memcpy(top.data()+y*W*4,v.data()+(H-1-y)*W*4,W*16);return top;}
|
||||
static id<MTLComputePipelineState> pipeline(id<MTLLibrary> library,NSString *name){NSError *error=nil;id<MTLFunction> f=[library newFunctionWithName:name];require(f!=nil,name);id<MTLComputePipelineState>p=[gpu newComputePipelineStateWithFunction:f error:&error];require(p!=nil,error.description);return p;}
|
||||
static void dispatch(id<MTLComputeCommandEncoder> e){[e dispatchThreads:MTLSizeMake(W,H,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[e endEncoding];}
|
||||
static Floats point(id<MTLLibrary> library,id<MTLTexture> src,id<MTLTexture> aux,DYUniforms u,int operation){id<MTLTexture>out=texture();id<MTLCommandBuffer>c=[queue commandBuffer];id<MTLComputeCommandEncoder>e=[c computeCommandEncoder];[e setComputePipelineState:pipeline(library,@"dyFilmPoint")];[e setTexture:src atIndex:0];[e setTexture:aux?:src atIndex:1];[e setTexture:out atIndex:2];[e setBytes:&u length:sizeof(u) atIndex:0];struct {int operation;float radius;unsigned frame,reserved;}p={operation,0,u.filmFrameKey,0};[e setBytes:&p length:sizeof(p) atIndex:1];dispatch(e);finish(c);return read(out);}
|
||||
static NSDictionary *difference(const Floats&a,const Floats&b){double maximum=0,sum=0;unsigned count=0,nonfinite=0,different=0;for(size_t i=0;i<a.size();i++){if(i%4==3)continue;if(a[(i/4)*4+3]<=0)continue;double d=fabs(a[i]-b[i]);if(!std::isfinite(d))nonfinite++;else{maximum=fmax(maximum,d);sum+=d*d;count++;if(d>1e-5)different++;}}return @{@"maximum":@(maximum),@"rms":@(sqrt(sum/fmax(1,count))),@"nonfinite":@(nonfinite),@"different":@(different)};}
|
||||
int main(int argc,const char **argv){@autoreleasepool{@try{
|
||||
require(argc==2,@"Usage: verify_film_reference /absolute/path/default.metallib");gpu=MTLCreateSystemDefaultDevice();queue=[gpu newCommandQueue];context=[CIContext contextWithMTLDevice:gpu options:@{kCIContextWorkingColorSpace:NSNull.null,kCIContextOutputColorSpace:NSNull.null}];NSError *error=nil;
|
||||
id<MTLLibrary> dayu=[gpu newLibraryWithURL:[NSURL fileURLWithPath:@(argv[1])] error:&error];require(dayu!=nil,error.description);
|
||||
NSString *framework=@"/Applications/ColorFinale.app/Contents/PlugIns/ColorFinale.pluginkit/Contents/Frameworks/RenderingEngine.framework/Versions/A";
|
||||
require(dlopen([[framework stringByAppendingPathComponent:@"RenderingEngine"]fileSystemRepresentation],RTLD_NOW|RTLD_LOCAL)!=nullptr,@"load installed reference framework");
|
||||
id<MTLLibrary> original=[gpu newLibraryWithURL:[NSURL fileURLWithPath:[framework stringByAppendingPathComponent:@"Resources/metal_kernels.metallib"]] error:&error];require(original!=nil,error.description);
|
||||
Floats linear(W*H*4),encoded(linear.size());for(unsigned y=0;y<H;y++)for(unsigned x=0;x<W;x++){unsigned i=(y*W+x)*4;float a=(x%11==0)?0:(x%3==0?.25f:1);for(int k=0;k<3;k++){float c=float((x*17+y*23+k*71)%257)/256;if(x%17==0)c=k==0?1.3f:k==1?-.02f:c;linear[i+k]=float((__fp16)(decode(c)*a));encoded[i+k]=encode(a>0?linear[i+k]/a:0)*a;}linear[i+3]=encoded[i+3]=a;}
|
||||
id<MTLTexture>source=texture(linear),codes=texture(encoded);Floats probe=render(image(source));require([difference(linear,probe)[@"maximum"]doubleValue]==0,@"CI bitmap orientation control");id<MTLTexture>roundtrip=texture();id<MTLCommandBuffer>roundtripCommands=[queue commandBuffer];[context render:image(source) toMTLTexture:roundtrip commandBuffer:roundtripCommands bounds:CGRectMake(0,0,W,H) colorSpace:nil];finish(roundtripCommands);require([difference(linear,read(roundtrip))[@"maximum"]doubleValue]==0,@"CI texture orientation control");NSMutableArray *rows=[NSMutableArray array];bool passed=true;
|
||||
auto check=[&](NSString*name,const Floats&a,const Floats&b,double tolerance){NSDictionary *d=difference(a,b);BOOL ok=[d[@"nonfinite"]intValue]==0&&[d[@"maximum"]doubleValue]<tolerance;NSMutableDictionary *r=[d mutableCopy];r[@"name"]=name;r[@"pass"]=@(ok);r[@"tolerance"]=@(tolerance);[rows addObject:r];passed&=ok;};
|
||||
DYUniforms u={};u.mixerMix=1;u.mixerRed=(DYFloat4){.75,.3,-.05,0};u.mixerGreen=(DYFloat4){.15,.85,0,0};u.mixerBlue=(DYFloat4){.05,-.1,1.05,0};u.film.gammaAll=u.film.gammaCyan=u.film.gammaMagenta=u.film.gammaYellow=1;u.film.valueMode=6;
|
||||
for(int options=0;options<4;options++){
|
||||
u.mixerPreserveLuma=options&1;u.mixerPreserveSaturation=(options>>1)&1;CIFilter *f=[[NSClassFromString(@"FTChannelMixerFilter")alloc]init];[f setDefaults];[f setValue:image(codes) forKey:kCIInputImageKey];[f setValue:[CIVector vectorWithX:u.mixerRed.x Y:u.mixerRed.y Z:u.mixerRed.z]forKey:@"inputRVector"];[f setValue:[CIVector vectorWithX:u.mixerGreen.x Y:u.mixerGreen.y Z:u.mixerGreen.z]forKey:@"inputGVector"];[f setValue:[CIVector vectorWithX:u.mixerBlue.x Y:u.mixerBlue.y Z:u.mixerBlue.z]forKey:@"inputBVector"];[f setValue:@(u.mixerPreserveLuma>0) forKey:@"inputPreserveLuma"];[f setValue:@(u.mixerPreserveSaturation>0)forKey:@"inputPreserveSaturation"];
|
||||
Floats expected=render(f.outputImage);for(size_t i=0;i<expected.size()/4;i++)for(int k=0;k<3;k++){float a=expected[i*4+3];expected[i*4+k]=a>0?decode(expected[i*4+k]/a)*a:0;}check([NSString stringWithFormat:@"original-mixer-options-%d",options],expected,point(dayu,source,nil,u,0),.00015);
|
||||
}
|
||||
for(int mode=1;mode<=2;mode++)for(float density:{-.4f,0.f,.65f})for(float gamma:{.75f,1.3f}){
|
||||
u.film.densityMode=mode;u.film.density=density;u.film.gammaAll=gamma;u.film.gammaCyan=1.2;u.film.gammaMagenta=.9;u.film.gammaYellow=1.1;CIFilter *f=[[NSClassFromString(@"FTFilmSaturationFilter")alloc]init];[f setDefaults];[f setValue:image(codes)forKey:kCIInputImageKey];[f setValue:@(gamma)forKey:@"gammaAll"];[f setValue:@1.2 forKey:@"gammaCyan"];[f setValue:@.9 forKey:@"gammaMagenta"];[f setValue:@1.1 forKey:@"gammaYellow"];[f setValue:@(density)forKey:@"density"];[f setValue:@(mode)forKey:@"densitySwitch"];
|
||||
Floats expected=render(f.outputImage);for(size_t i=0;i<expected.size()/4;i++)for(int k=0;k<3;k++){float a=expected[i*4+3];expected[i*4+k]=a>0?decode(expected[i*4+k]/a)*a:0;}check([NSString stringWithFormat:@"original-subtractive-%d-%.2f-%.2f",mode,density,gamma],expected,point(dayu,source,nil,u,1),.00012);
|
||||
}
|
||||
for(float scatter:{1.f,5.f,20.f}){
|
||||
u.film.scatter=scatter;u.film.boost=1.7;u.film.dyeTransmission=70;CIFilter *f=[[NSClassFromString(@"FTHalationFilter")alloc]init];[f setDefaults];[f setValue:image(source)forKey:kCIInputImageKey];[f setValue:@(scatter)forKey:@"scatter"];[f setValue:@1.7 forKey:@"boost"];[f setValue:@(70.f/500)forKey:@"dyeTransmission"];
|
||||
CIImage *blur=[[[image(source)imageByClampingToExtent]imageByApplyingFilter:@"CIGaussianBlur" withInputParameters:@{kCIInputRadiusKey:@(scatter)}]imageByCroppingToRect:CGRectMake(0,0,W,H)];id<MTLTexture>aux=texture(render(blur));check([NSString stringWithFormat:@"original-halation-radius-%.0f",scatter],render(f.outputImage),point(dayu,source,aux,u,2),.00012);
|
||||
}
|
||||
for(float sensitivity:{20.f,50.f,80.f}){
|
||||
DYFilmSettings settings={};settings.sensitivity=sensitivity;settings.intensity=70;
|
||||
CIFilter *filter=[[NSClassFromString(@"FTBloomFilter")alloc]init];[filter setValue:image(source)forKey:kCIInputImageKey];[filter setValue:@2.5 forKey:@"blurRadius"];[filter setValue:@(sensitivity/100)forKey:@"sensitivity"];[filter setValue:@.7 forKey:@"intensity"];
|
||||
id<MTLTexture>horizontal=texture(),vertical=texture(),edges=texture();id<MTLCommandBuffer>commands=[queue commandBuffer];
|
||||
for(int direction=0;direction<2;direction++){id<MTLComputeCommandEncoder>e=[commands computeCommandEncoder];[e setComputePipelineState:pipeline(dayu,@"dyFilmSparseBlur")];[e setTexture:direction?horizontal:source atIndex:0];[e setTexture:direction?vertical:horizontal atIndex:1];[e setBytes:&direction length:4 atIndex:0];dispatch(e);}
|
||||
id<MTLComputeCommandEncoder>e=[commands computeCommandEncoder];[e setComputePipelineState:pipeline(dayu,@"dyFilmBloomEdges")];[e setTexture:vertical atIndex:0];[e setTexture:source atIndex:1];[e setTexture:edges atIndex:2];[e setBytes:&settings length:sizeof(settings) atIndex:0];dispatch(e);finish(commands);
|
||||
Floats actual=read(edges),expected=render(filter.outputImage);unsigned inside=0,border=0;for(unsigned y=0;y<H;y++)for(unsigned x=0;x<W;x++)if(expected[(y*W+x)*4+3]>0&&fabs(actual[(y*W+x)*4]-expected[(y*W+x)*4])>.01){if(x>=8&&x<W-8&&y>=8&&y<H-8)inside++;else border++;}fprintf(stderr,"bloom %.0f mismatches interior=%u border=%u\n",sensitivity,inside,border);check([NSString stringWithFormat:@"original-bloom-edge-sensitivity-%.0f",sensitivity],expected,actual,.00001);
|
||||
}
|
||||
for(unsigned seed:{0u,1u,7919u,0xffffffffu}){
|
||||
auto noise=[&](id<MTLLibrary>lib,NSString *name){id<MTLTexture>out=texture();id<MTLCommandBuffer>c=[queue commandBuffer];id<MTLComputeCommandEncoder>e=[c computeCommandEncoder];[e setComputePipelineState:pipeline(lib,name)];[e setTexture:out atIndex:0];[e setBytes:&seed length:4 atIndex:0];dispatch(e);finish(c);return out;};
|
||||
id<MTLTexture>ref=noise(original,@"BoxMullerPCG"),ours=noise(dayu,@"dyFilmNoise");check([NSString stringWithFormat:@"original-pcg-box-muller-%u",seed],read(ref),read(ours),.00002);
|
||||
for(float color:{0.f,.35f,1.f}){u.film.grainAmount=.5;u.film.grainSize=1;u.film.grainResponse=.4;u.film.grainColor=color;float corr=1-2*color,other=1-corr,norm=sqrtf(corr*corr+other*other);float params[9]={.4f,.6f,corr/norm,other/norm,corr/norm,other/norm,.025f,.025f,.025f};id<MTLTexture>referenceOutput=texture();id<MTLCommandBuffer>commands=[queue commandBuffer];id<MTLComputeCommandEncoder>encoder=[commands computeCommandEncoder];[encoder setComputePipelineState:pipeline(original,@"GrainFilter")];[encoder setTexture:codes atIndex:0];[encoder setTexture:ref atIndex:1];[encoder setTexture:referenceOutput atIndex:2];[encoder setBytes:params length:sizeof(params) atIndex:0];dispatch(encoder);finish(commands);Floats expected=read(referenceOutput);for(size_t i=0;i<expected.size()/4;i++)for(int k=0;k<3;k++){float a=expected[i*4+3];expected[i*4+k]=a>0?decode(expected[i*4+k]/a)*a:0;}check([NSString stringWithFormat:@"original-grain-%u-%.2f",seed,color],expected,point(dayu,source,ours,u,4),.0002);}
|
||||
}
|
||||
NSDictionary *result=@{@"pass":@(passed),@"checks":@(rows.count),@"gpu":gpu.name,@"referenceVersion":@"ColorFinale 2.16.2 (625)",@"scope":@"Independent installed-reference CI/Metal output versus authored production Metal point kernels; source grayscale/color/HDR/negative and fractional-alpha vectors; reference frame seed is explicit.",@"results":rows};NSData *json=[NSJSONSerialization dataWithJSONObject:result options:NSJSONWritingPrettyPrinted|NSJSONWritingSortedKeys error:nil];fwrite(json.bytes,1,json.length,stdout);puts("");return passed?0:1;
|
||||
}@catch(NSException *e){fprintf(stderr,"%s\n",e.reason.UTF8String);return 2;}}}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"status": "development-checkpoint",
|
||||
"baseline": "1.4.3 (33)",
|
||||
"nativePass": true,
|
||||
"checks": 346,
|
||||
"referenceComparison": {
|
||||
"pass": true,
|
||||
"checks": 38,
|
||||
"maxLinearRGBError": 0.0001327991485595703,
|
||||
"scope": "Independent installed-reference CI/Metal output versus authored production Metal point kernels; source grayscale/color/HDR/negative and fractional-alpha vectors; reference frame seed is explicit."
|
||||
},
|
||||
"formalInstallUnchanged": true
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
{
|
||||
"checks": 38,
|
||||
"gpu": "Apple M4",
|
||||
"pass": true,
|
||||
"referenceVersion": "ColorFinale 2.16.2 (625)",
|
||||
"results": [
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.364418029785156e-07,
|
||||
"name": "original-mixer-options-0",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.009766745554783e-08,
|
||||
"tolerance": 0.00015
|
||||
},
|
||||
{
|
||||
"different": 711,
|
||||
"maximum": 9.357929229736328e-05,
|
||||
"name": "original-mixer-options-1",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 1.0210391465638843e-05,
|
||||
"tolerance": 0.00015
|
||||
},
|
||||
{
|
||||
"different": 1024,
|
||||
"maximum": 3.0219554901123047e-05,
|
||||
"name": "original-mixer-options-2",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.728514607067402e-06,
|
||||
"tolerance": 0.00015
|
||||
},
|
||||
{
|
||||
"different": 1926,
|
||||
"maximum": 0.0001327991485595703,
|
||||
"name": "original-mixer-options-3",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 1.6614215417680232e-05,
|
||||
"tolerance": 0.00015
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 3.2782554626464844e-07,
|
||||
"name": "original-subtractive-1--0.40-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 4.7823322395760674e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 7.152557373046875e-07,
|
||||
"name": "original-subtractive-1--0.40-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.956378632743561e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.172325134277344e-07,
|
||||
"name": "original-subtractive-1-0.00-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.1398472939298314e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-subtractive-1-0.00-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.681635195836867e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 1.1324882507324219e-06,
|
||||
"name": "original-subtractive-1-0.65-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 8.271021843117258e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-subtractive-1-0.65-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.2075346060704435e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-subtractive-2--0.40-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 7.545293195362902e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 7.152557373046875e-07,
|
||||
"name": "original-subtractive-2--0.40-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 7.658601653684018e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.76837158203125e-07,
|
||||
"name": "original-subtractive-2-0.00-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.484374941182382e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 6.556510925292969e-07,
|
||||
"name": "original-subtractive-2-0.00-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 7.353807031200175e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.172325134277344e-07,
|
||||
"name": "original-subtractive-2-0.65-0.75",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.733134883076243e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.76837158203125e-07,
|
||||
"name": "original-subtractive-2-0.65-1.30",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.208684669307958e-08,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-halation-radius-1",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-halation-radius-5",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-halation-radius-20",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 0.00012
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-bloom-edge-sensitivity-20",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 1e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-bloom-edge-sensitivity-50",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 1e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-bloom-edge-sensitivity-80",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 1e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-pcg-box-muller-0",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 2e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-0-0.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.046748199252931e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.76837158203125e-07,
|
||||
"name": "original-grain-0-0.35",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.089447444002431e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-0-1.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.986695649443142e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-pcg-box-muller-1",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 2e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-1-0.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.02225669650087e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-1-0.35",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.095060998887888e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-1-1.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.095770382866378e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-pcg-box-muller-7919",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 2e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-7919-0.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.988679165537062e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.76837158203125e-07,
|
||||
"name": "original-grain-7919-0.35",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.788284349284968e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-7919-1.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 5.887719497020584e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 0,
|
||||
"name": "original-pcg-box-muller-4294967295",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 0,
|
||||
"tolerance": 2e-05
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-4294967295-0.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.088241691372352e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 5.960464477539062e-07,
|
||||
"name": "original-grain-4294967295-0.35",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.145202410341828e-08,
|
||||
"tolerance": 0.0002
|
||||
},
|
||||
{
|
||||
"different": 0,
|
||||
"maximum": 4.76837158203125e-07,
|
||||
"name": "original-grain-4294967295-1.00",
|
||||
"nonfinite": 0,
|
||||
"pass": true,
|
||||
"rms": 6.026303449280789e-08,
|
||||
"tolerance": 0.0002
|
||||
}
|
||||
],
|
||||
"scope": "Independent installed-reference CI/Metal output versus authored production Metal point kernels; source grayscale/color/HDR/negative and fractional-alpha vectors; reference frame seed is explicit."
|
||||
}
|
||||
@@ -378,6 +378,8 @@
|
||||
"-framework",
|
||||
Metal,
|
||||
"-framework",
|
||||
MetalPerformanceShaders,
|
||||
"-framework",
|
||||
QuartzCore,
|
||||
"-lcompression",
|
||||
"-lz",
|
||||
@@ -409,6 +411,8 @@
|
||||
"-framework",
|
||||
Metal,
|
||||
"-framework",
|
||||
MetalPerformanceShaders,
|
||||
"-framework",
|
||||
QuartzCore,
|
||||
"-lcompression",
|
||||
"-lz",
|
||||
@@ -435,6 +439,8 @@
|
||||
"-framework",
|
||||
Metal,
|
||||
"-framework",
|
||||
MetalPerformanceShaders,
|
||||
"-framework",
|
||||
QuartzCore,
|
||||
"-lcompression",
|
||||
"-lz",
|
||||
@@ -460,6 +466,8 @@
|
||||
"-framework",
|
||||
Metal,
|
||||
"-framework",
|
||||
MetalPerformanceShaders,
|
||||
"-framework",
|
||||
QuartzCore,
|
||||
"-lcompression",
|
||||
"-lz",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "DYFilmMath.h"
|
||||
#include "DYFilmTime.h"
|
||||
#import "DYDiagnostics.h"
|
||||
#import "DYModel.h"
|
||||
#import "DYRenderer.h"
|
||||
@@ -217,7 +219,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
NSWindow *interactionWindow=[[[NSWindow alloc]initWithContentRect:NSMakeRect(0,0,400,780) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]autorelease];interactionWindow.contentView=inspector;[inspector layoutSubtreeIfNeeded];
|
||||
NSArray *graphics=[inspector valueForKey:@"graphics"];NSView *wheel=nil;for(NSView *graphic in graphics)if([NSStringFromClass(graphic.class)isEqual:@"DYPrimaryBalanceWheel"])wheel=graphic;
|
||||
run.need(@"primary-balance-wheel-restored-and-palette-loaded",wheel&&[wheel valueForKey:@"wheel"]!=nil);
|
||||
BOOL merged=cards.count==12&&[cards[0][@"section"][@"key"]isEqual:@"primary"]&&[cards[1][@"section"][@"key"]isEqual:@"spider"];for(NSDictionary *card in cards)merged&=![@[@"input",@"output"]containsObject:card[@"section"][@"key"]];
|
||||
BOOL merged=cards.count==14&&[cards[0][@"section"][@"key"]isEqual:@"primary"]&&[cards[1][@"section"][@"key"]isEqual:@"spider"];for(NSDictionary *card in cards)merged&=![@[@"input",@"output"]containsObject:card[@"section"][@"key"]];
|
||||
NSDictionary *controls=[inspector valueForKey:@"controls"];for(NSDictionary *record in controls.allValues)merged&=![[record[@"descriptor"]objectForKey:@"key"]hasPrefix:@"cmbypass"];
|
||||
run.record(@"single-primary-card-no-bypass-checkboxes",merged);
|
||||
auto mouseFor=[&](NSView *view,NSEventType type,NSPoint point,NSEventModifierFlags flags=0,NSInteger clicks=1){return [NSEvent mouseEventWithType:type location:[view convertPoint:point toView:nil] modifierFlags:flags timestamp:0 windowNumber:interactionWindow.windowNumber context:nil eventNumber:0 clickCount:clicks pressure:type==NSEventTypeLeftMouseUp?0:1];};
|
||||
@@ -239,7 +241,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
run.record(@"spider-single-drag-spoke-following-and-pin",dragged.x[0]>initialMesh.x[0]&&dragged.x[1]>initialMesh.x[1]&&dragged.x[3]>initialMesh.x[3]&&dragged.x[4]==initialMesh.x[4]&&dragged.x[5]==initialMesh.x[5]&&dragged.pins[2]);
|
||||
run.record(@"spider-drag-one-host-undo-group",uiHost->_undoStarts==starts+1&&uiHost->_undoEnds==ends+1&&!uiHost->_undoActive);
|
||||
error=nil;NSData *spiderArchive=[NSKeyedArchiver archivedDataWithRootObject:spiderSaved requiringSecureCoding:YES error:&error];DYAssetState *decodedSpider=[NSKeyedUnarchiver unarchivedObjectOfClass:DYAssetState.class fromData:spiderArchive error:&error];run.record(@"spider-archive-retains-mesh-pins-and-lut-paths",decodedSpider&&[decodedSpider isEqual:spiderSaved],@{@"error":reason(error)});
|
||||
NSDictionary *snapshot=[inspector performSelector:@selector(presetSnapshot)];NSData *presetJSON=[NSJSONSerialization dataWithJSONObject:snapshot options:0 error:&error];NSDictionary *decodedPreset=[NSJSONSerialization JSONObjectWithData:presetJSON options:0 error:&error];run.record(@"complete-version-four-preset-includes-mesh",[decodedPreset[@"version"]isEqual:@4]&&[DYSpiderFromJSON(decodedPreset[@"spider"])isEqual:spiderSaved.spiderMesh]);
|
||||
NSDictionary *snapshot=[inspector performSelector:@selector(presetSnapshot)];NSData *presetJSON=[NSJSONSerialization dataWithJSONObject:snapshot options:0 error:&error];NSDictionary *decodedPreset=[NSJSONSerialization JSONObjectWithData:presetJSON options:0 error:&error];run.record(@"complete-version-five-preset-includes-mesh",[decodedPreset[@"version"]isEqual:@5]&&[DYSpiderFromJSON(decodedPreset[@"spider"])isEqual:spiderSaved.spiderMesh]);
|
||||
NSDictionary *portable=DYSpiderJSON(spiderSaved.spiderMesh,spiderSaved.spiderLinked);NSData *decodedPortable=DYSpiderFromJSON(portable);run.record(@"spider-json-preset-exact-roundtrip",[decodedPortable isEqual:spiderSaved.spiderMesh]);
|
||||
NSMutableDictionary *badJSON=[[portable mutableCopy]autorelease];badJSON[@"hues"]=@7;run.record(@"spider-json-rejects-unsupported-topology",!DYSpiderFromJSON(badJSON));auto corrupt=dragged;corrupt.x[0]=NAN;run.record(@"spider-archive-rejects-nonfinite-coordinates",!DYSpiderMeshIsValid([NSData dataWithBytes:&corrupt length:sizeof(corrupt)]));
|
||||
[disc changeHueCount:12 saturationCount:8];spiderSaved=DYReadAssets(uiHost,kCMTimeZero);auto dense=DYSpiderMesh(spiderSaved.spiderMesh);run.record(@"spider-independent-resolution-and-resample",dense.hues==12&&dense.rings==7&&fabs(dy::meshDelta(dense,0,.6).x)>0);
|
||||
@@ -419,6 +421,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
}
|
||||
#include "DYToolDiagnostics.inc.h"
|
||||
#include "DYToolInsertionDiagnostics.inc.h"
|
||||
#include "DYFilmDiagnostics.inc.h"
|
||||
#include "DYToolTrackingDiagnostics.inc.h"
|
||||
#include "DYToolCanvasDiagnostics.inc.h"
|
||||
#include "DYToolPenDiagnostics.inc.h"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
DYToolDocument *empty=[[[DYToolDocument alloc]init]autorelease];
|
||||
auto uploadFilm=[&](const Pixels& pixels){[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:pixels.data() bytesPerRow:width*8];};
|
||||
auto filmRender=[&](DYUniforms value,NSDictionary *tools,NSString *name){NSError *failure=nil;BOOL ok=[renderer renderSource:source destination:destination uniforms:value paths:@{} spider:nil tools:tools?:empty.document error:&failure];run.need(name,ok,@{@"error":reason(failure)});return read(destination,gpu);};
|
||||
uploadFilm(input);DYUniforms neutral=DYToolUniforms(@{@"type":@"mixer"});neutral.mixerSectionEnabled=1;
|
||||
Pixels before=filmRender(neutral,nil,@"film-neutral-production-render");
|
||||
run.record(@"new-tools-default-to-neutral",!DYChannelMixerActive(neutral)&&!DYFilmActive(defaults.film)&&DYToolTypes().count==14&&DYToolIsNeutral(DYNewTool(@"film"))&&DYToolIsNeutral(DYNewTool(@"mixer")));
|
||||
BOOL alpha=YES;for(size_t i=0;i<before.size()/4;i++)alpha&=before[i*4+3]==input[i*4+3];run.record(@"new-neutral-tools-preserve-existing-alpha",alpha);
|
||||
DYUniforms matrix=neutral;matrix.mixerRed=(DYFloat4){.8,.25,-.05,0};matrix.mixerBlue=(DYFloat4){.1,0,.9,0};
|
||||
Pixels mixed=filmRender(matrix,nil,@"channel-mixer-production-render");auto delta=difference(before,mixed);run.record(@"channel-mixer-affects-real-frame",delta.different>50&&delta.nonfinite==0,measure(delta));
|
||||
matrix.mixerSectionEnabled=0;Pixels bypass=filmRender(matrix,nil,@"channel-mixer-eye-bypass-render");run.record(@"channel-mixer-eye-exact-bypass",difference(before,bypass).maximum==0);
|
||||
matrix.mixerSectionEnabled=1;matrix.mixerMix=0;bypass=filmRender(matrix,nil,@"channel-mixer-zero-render");run.record(@"channel-mixer-zero-exact-bypass",difference(before,bypass).maximum==0);
|
||||
for(int stage=0;stage<5;stage++){
|
||||
DYUniforms value=neutral;value.film.enabled=1;
|
||||
if(stage==0){value.film.subtractiveEnabled=1;value.film.gammaCyan=1.4;value.film.gammaYellow=.8;value.film.density=.35;}
|
||||
if(stage==1){value.film.halationEnabled=1;value.film.scatter=4;value.film.boost=2;value.film.dyeTransmission=60;}
|
||||
if(stage==2){value.film.bloomEnabled=1;value.film.sensitivity=1;value.film.diffusion=3;value.film.intensity=75;}
|
||||
if(stage==3){value.film.grainEnabled=1;value.film.grainAmount=.7;value.film.grainColor=.35;value.film.grainSize=3;value.filmFrameKey=7;}
|
||||
if(stage==4){value.film.vignetteEnabled=1;value.film.vignetteIntensity=1;value.film.vignetteRadius=15;}
|
||||
Pixels after=filmRender(value,nil,[NSString stringWithFormat:@"film-stage-%d-production",stage]);Difference change=difference(before,after);BOOL sameAlpha=YES;for(size_t i=0;i<after.size()/4;i++)sameAlpha&=after[i*4+3]==before[i*4+3];run.record([NSString stringWithFormat:@"film-stage-%d-finite-active-alpha",stage],change.different>20&&change.nonfinite==0&&sameAlpha,measure(change));
|
||||
if(stage==3){Pixels repeat=filmRender(value,nil,@"grain-random-access-repeat");run.record(@"grain-identical-frozen-frame-is-bit-exact",difference(after,repeat).maximum==0);value.filmFrameKey=8;Pixels next=filmRender(value,nil,@"grain-next-frozen-frame");run.record(@"grain-frame-changes-noise",difference(after,next).different>100);}
|
||||
value.film.mix=0;bypass=filmRender(value,nil,[NSString stringWithFormat:@"film-stage-%d-zero-mix",stage]);run.record([NSString stringWithFormat:@"film-stage-%d-zero-is-exact",stage],difference(before,bypass).maximum==0);
|
||||
value.film.mix=1;value.film.enabled=0;bypass=filmRender(value,nil,[NSString stringWithFormat:@"film-stage-%d-eye-off",stage]);run.record([NSString stringWithFormat:@"film-stage-%d-eye-preserves-old-frame",stage],difference(before,bypass).maximum==0);
|
||||
}
|
||||
CMTime duration=CMTimeMake(1001,30000),origin=CMTimeMake(17,3);BOOL rational=YES;
|
||||
for(int i=-12;i<=12;i++){CMTime t=CMTimeAdd(origin,CMTimeMultiply(duration,i));rational&=DYFilmFrameIndex(t,duration,origin)==i;for(int hold=1;hold<=5;hold++)rational&=DYFilmFrameKey(i,hold,0)==(uint32_t)(int64_t)floor(double(i)/hold);}
|
||||
rational&=DYFilmFrameIndex(CMTimeMake(-1,1000000),duration,kCMTimeZero)==-1;
|
||||
run.record(@"grain-exact-ntsc-signed-frame-and-hold",rational);
|
||||
NSMutableDictionary *doc=DYMutablePlist(empty.document);NSMutableDictionary *mixer=(id)DYInsertTool(doc,@"mixer",@"base:mixer");mixer[@"values"][@"mixer01"]=@.3;
|
||||
NSMutableDictionary *film=(id)DYInsertTool(doc,@"film",mixer[@"id"]);film[@"values"][@"filmSubtractive"]=@1;film[@"values"][@"filmGammaCyan"]=@1.5;
|
||||
run.record(@"film-mixer-adjacent-schema-two-valid",DYValidToolDocument(doc)&&[[DYToolDisplayOrder(doc) objectAtIndex:13]isEqual:mixer[@"id"]]&&[[DYToolDisplayOrder(doc)objectAtIndex:14]isEqual:film[@"id"]]);
|
||||
Pixels layered=filmRender(neutral,doc,@"film-mixer-adjacent-render");run.record(@"film-mixer-adjacent-layers-affect-frame",difference(before,layered).different>50);
|
||||
NSMutableDictionary *mask=DYMutablePlist(DYNewMask(DYMaskRectangle));DYMaskParameters p=DYMaskAtTime(mask,kCMTimeZero);p.strength=0;mask[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];[mixer[@"masks"]addObject:mask];[film[@"masks"]addObject:DYMutablePlist(DYNewMask(DYMaskEllipse))];
|
||||
DYToolDocument *saved=[[[DYToolDocument alloc]init]autorelease];saved.document=doc;NSData *archive=[NSKeyedArchiver archivedDataWithRootObject:saved requiringSecureCoding:YES error:&error];DYToolDocument *restored=[NSKeyedUnarchiver unarchivedObjectOfClass:DYToolDocument.class fromData:archive error:&error];run.record(@"film-mixer-mask-archive-exact-roundtrip",[saved isEqual:restored]);
|
||||
NSMutableDictionary *baseMask=DYMutablePlist(empty.document);baseMask[@"baseMasks"][@"film"]=@[mask];DYUniforms masked=neutral;masked.film.enabled=1;masked.film.grainEnabled=1;masked.film.grainAmount=.5;Pixels zeroMask=filmRender(masked,baseMask,@"film-zero-mask-render");run.record(@"film-zero-mask-exact-source",difference(before,zeroMask).maximum==0);
|
||||
NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"film-mixer.cube"]];error=nil;
|
||||
BOOL rejected=![renderer exportLUT:cube uniforms:masked paths:@{} spider:nil tools:empty.document error:&error];run.record(@"grain-rejected-by-static-cube",rejected&&error!=nil);
|
||||
masked.film.grainEnabled=0;masked.film.subtractiveEnabled=1;masked.film.gammaAll=1.1;error=nil;run.record(@"pure-subtractive-cube-supported",[renderer exportLUT:cube uniforms:masked paths:@{} spider:nil tools:empty.document error:&error],@{@"error":reason(error)});
|
||||
masked=matrix;masked.mixerMix=1;error=nil;run.record(@"channel-mixer-cube-supported",[renderer exportLUT:cube uniforms:masked paths:@{} spider:nil tools:empty.document error:&error],@{@"error":reason(error)});
|
||||
uploadFilm(input);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Included after DYGrade.metal's sRGB boundary helpers.
|
||||
#include "DYFilmMath.h"
|
||||
struct DYFilmPass {int operation;float radius;uint frameKey;uint reserved;};
|
||||
kernel void dyFilmPoint(texture2d<float,access::read> source [[texture(0)]],texture2d<float,access::read> auxiliary [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],constant DYUniforms& uniforms [[buffer(0)]],constant DYFilmPass& pass [[buffer(1)]],uint2 pos [[thread_position_in_grid]]){
|
||||
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;
|
||||
float4 pixel=source.read(pos);if(!(pixel.a>0)){output.write(pixel,pos);return;}
|
||||
float3 c=pixel.rgb/pixel.a,result=c;DYFilmSettings film=uniforms.film;
|
||||
if(pass.operation==0)result=dyDecode(dyFilmMixer(dyEncode(c),uniforms));
|
||||
else if(pass.operation==1)result=dyDecode(dyFilmSubtractive(dyEncode(c),film));
|
||||
else if(pass.operation==2){float3 b=auxiliary.read(pos).rgb;float3 w=float3(film.boost,film.dyeTransmission/500.f,0);result=(c+b*w)/(1+w);}
|
||||
else if(pass.operation==3)result=c+auxiliary.read(pos).rgb;
|
||||
else if(pass.operation==4)result=dyDecode(dyFilmGrain(dyEncode(c),auxiliary.read(pos).rgb,film));
|
||||
else if(pass.operation==5){float4 filtered=auxiliary.read(pos);result=filtered.rgb/pixel.a;}
|
||||
float amount=pass.operation==0?uniforms.mixerMix:1;
|
||||
pixel.rgb=dyLimit((c*(1-amount)+result*amount)*pixel.a);output.write(pixel,pos);
|
||||
}
|
||||
kernel void dyFilmNoise(texture2d<float,access::write> output [[texture(0)]],constant uint& seed [[buffer(0)]],uint2 pos [[thread_position_in_grid]]){
|
||||
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;output.write(float4(dyFilmNormal(pos.x,pos.y,seed),1),pos);
|
||||
}
|
||||
// Separable form of the reference's sparse 5x5 prefilter: same 25 weighted
|
||||
// samples, followed by its 3x3 vector Sobel norm. Only two 5-tap passes.
|
||||
kernel void dyFilmSparseBlur(texture2d<float,access::sample> source [[texture(0)]],texture2d<float,access::write> output [[texture(1)]],constant int& vertical [[buffer(0)]],uint2 pos [[thread_position_in_grid]]){
|
||||
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;constexpr sampler f(coord::pixel,address::clamp_to_edge,filter::linear);
|
||||
float3 value=0;float total=0;float radius=2.5f;
|
||||
for(int i=-2;i<=2;i++){float weight=exp(-float(i*i)/(2*radius*radius));float2 delta=vertical?float2(0,i*radius):float2(i*radius,0);value+=source.sample(f,float2(pos)+.5f+delta).rgb*weight;total+=weight;}
|
||||
output.write(float4(value/total,1),pos);
|
||||
}
|
||||
inline float3 dyFilmBorderPrefilter(texture2d<float,access::sample> source,float2 coordinate){
|
||||
constexpr sampler f(coord::pixel,address::clamp_to_edge,filter::linear);float3 value=0;float sum=0;
|
||||
for(int x=-2;x<=2;x++)for(int y=-2;y<=2;y++){float weight=exp(-float(x*x+y*y)/12.5f);value+=source.sample(f,coordinate+float2(x,y)*2.5f).rgb*weight;sum+=weight;}return value/sum;
|
||||
}
|
||||
kernel void dyFilmBloomEdges(texture2d<float,access::sample> blurred [[texture(0)]],texture2d<float,access::sample> original [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],constant DYFilmSettings& film [[buffer(0)]],uint2 pos [[thread_position_in_grid]]){
|
||||
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;constexpr sampler f(coord::pixel,address::clamp_to_edge,filter::linear);
|
||||
float3 gx=0,gy=0;
|
||||
bool border=pos.x==0||pos.y==0||pos.x+1==output.get_width()||pos.y+1==output.get_height();
|
||||
for(int x=-1;x<=1;x++)for(int y=-1;y<=1;y++){float2 coordinate=float2(pos)+.5f+float2(x,y);float3 c=border?dyFilmBorderPrefilter(original,coordinate):blurred.sample(f,coordinate).rgb;gx+=c*float(y)*(x==0?2.f:1.f);gy+=c*float(x)*(y==0?2.f:1.f);}
|
||||
float magnitude=sqrt(dot(gx,gx)+dot(gy,gy)),a=original.read(pos).a;
|
||||
float strength=magnitude>=film.sensitivity/100.f?film.intensity/100.f:0;
|
||||
output.write(float4(float3(strength*a),a),pos);
|
||||
}
|
||||
kernel void dyFilmMix(texture2d<float,access::read> before [[texture(0)]],texture2d<float,access::read> after [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],constant float& amount [[buffer(0)]],uint2 pos [[thread_position_in_grid]]){
|
||||
if(pos.x>=output.get_width()||pos.y>=output.get_height())return;float4 a=before.read(pos),b=after.read(pos);output.write(float4(dyLimit(mix(a.rgb,b.rgb,amount)),a.a),pos);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
#include "DYUniforms.h"
|
||||
#include "SpiderCore/DYColorMath.h"
|
||||
// Re-expressed mathematical contracts from the local reference's AIR.
|
||||
// Research identities, operating domains and deviations: ColorFinaleFilmMixer.md.
|
||||
inline float dyFilmMax(float3 c){return c.x>c.y?(c.x>c.z?c.x:c.z):(c.y>c.z?c.y:c.z);}
|
||||
inline float dyFilmMin(float3 c){return c.x<c.y?(c.x<c.z?c.x:c.z):(c.y<c.z?c.y:c.z);}
|
||||
inline float dyFilmLuma(float3 c){return c.x*.2126f+c.y*.7152f+c.z*.0722f;}
|
||||
inline float dyFilmSat(float3 c){float m=dyFilmMax(c);return m!=0?(m-dyFilmMin(c))/m:0;}
|
||||
inline float3 dyFilmPositive(float3 c){for(int i=0;i<3;i++)if(c[i]<0)c[i]=0;return c;}
|
||||
inline bool DYChannelMixerActive(DYUniforms u){return u.mixerSectionEnabled>.5f&&u.mixerMix>0&&(u.mixerRed.x!=1||u.mixerRed.y!=0||u.mixerRed.z!=0||u.mixerGreen.x!=0||u.mixerGreen.y!=1||u.mixerGreen.z!=0||u.mixerBlue.x!=0||u.mixerBlue.y!=0||u.mixerBlue.z!=1);}
|
||||
inline float3 dyFilmMixer(float3 c,DYUniforms u){
|
||||
float3 r={c.x*u.mixerRed.x+c.y*u.mixerRed.y+c.z*u.mixerRed.z,c.x*u.mixerGreen.x+c.y*u.mixerGreen.y+c.z*u.mixerGreen.z,c.x*u.mixerBlue.x+c.y*u.mixerBlue.y+c.z*u.mixerBlue.z};
|
||||
if(u.mixerPreserveLuma>.5f){r=dyFilmPositive(r);float ratio=dyFilmLuma(c)/dyFilmLuma(r);if(!isfinite(ratio))ratio=1;r*=ratio;}
|
||||
if(u.mixerPreserveSaturation>.5f){float3 p=dyFilmPositive(r);float source=dyFilmSat(c),ratio=source/dyFilmSat(p);if(isfinite(ratio)){float y=dyFilmLuma(p);r=source==0?float3{y,y,y}:float3{y,y,y}*(1-ratio)+p*ratio;}}
|
||||
return r;
|
||||
}
|
||||
inline float dyFilmNorm(float3 c,int mode){
|
||||
if(mode==2)return dyFilmMax(c);
|
||||
if(mode==1)return (c.x+c.y+c.z)/3;
|
||||
if(mode==6){float3 e={exp(c.x*3),exp(c.y*3),exp(c.z*3)};return (e.x*c.x+e.y*c.y+e.z*c.z)/(e.x+e.y+e.z);}
|
||||
return dyFilmMax(c);
|
||||
}
|
||||
inline float3 dyFilmSubtractive(float3 input,DYFilmSettings p){
|
||||
float3 c=input;for(int i=0;i<3;i++)c[i]=dyClamp(c[i],0,1);
|
||||
float n=dyFilmNorm(c,int(p.densityMode));if(n<=0)return float3{0,0,0};
|
||||
float v=dyFilmNorm(c,int(p.valueMode));float weight=n*(1-p.density)+v*p.density;
|
||||
float gamma[3]={p.gammaAll*p.gammaCyan,p.gammaAll*p.gammaMagenta,p.gammaAll*p.gammaYellow};
|
||||
// Both UI density choices (mean/max), and softmax value, normalize white to 1.
|
||||
for(int i=0;i<3;i++)c[i]=dyClamp(weight*pow(c[i]/n,gamma[i]),0,1);
|
||||
return c;
|
||||
}
|
||||
inline DYUInt dyFilmPCG(DYUInt value){DYUInt state=value*747796405u+2891336453u;DYUInt word=((state>>((state>>28u)+4u))^state)*277803737u;return (word>>22u)^word;}
|
||||
inline float3 dyFilmNormal(DYUInt x,DYUInt y,DYUInt seed){
|
||||
DYUInt h=dyFilmPCG(dyFilmPCG(dyFilmPCG(x)^y)^seed);
|
||||
float u1=(float(dyFilmPCG(h^2769414579u)>>8)+.5f)/16777216.f;
|
||||
float u2=(float(dyFilmPCG(h^1675113877u)>>8)+.5f)/16777216.f;
|
||||
float u3=(float(dyFilmPCG(h^2135587861u)>>8)+.5f)/16777216.f;
|
||||
float u4=(float(dyFilmPCG(h^476689394u)>>8)+.5f)/16777216.f;
|
||||
float a=sqrt(-2*log(u1>1e-7f?u1:1e-7f)),b=sqrt(-2*log(u3>1e-7f?u3:1e-7f));
|
||||
return {a*cos(6.28318530718f*u2),a*sin(6.28318530718f*u2),b*cos(6.28318530718f*u4)};
|
||||
}
|
||||
inline float3 dyFilmGrain(float3 c,float3 noise,DYFilmSettings p){
|
||||
float corr=1-2*p.grainColor,other=1-corr,den=sqrt(corr*corr+other*other);
|
||||
float3 n={(corr*noise.y+other*noise.x)/den,noise.y,(corr*noise.y+other*noise.z)/den};
|
||||
float amount=.05f*p.grainAmount*((p.grainSize-1)*.5f+1),offset=p.grainResponse>=0?1-p.grainResponse:1;
|
||||
for(int i=0;i<3;i++){float response=p.grainResponse*c[i]+offset;if(response<0)response=0;c[i]+=n[i]*response*amount;}
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// All work uses the renderer instance's lock and frozen state. No vendor code
|
||||
// or vendor runtime is loaded by the product.
|
||||
- (BOOL)renderFilmTool:(NSString*)type source:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)u masks:(NSArray*)masks entry:(NSMutableDictionary*)entry error:(NSError**)error {
|
||||
BOOL mixer=[type isEqual:@"mixer"],active=mixer?DYChannelMixerActive(u):DYFilmActive(u.film);
|
||||
if(!active)return [self copyTile:source to:destination entry:entry error:error];
|
||||
id<MTLDevice>d=entry[@"device"];id<MTLTexture>before=[source metalTextureForDevice:d];
|
||||
if(!before)return fail(error,@"胶片输入纹理不可用");
|
||||
// At most two working, two auxiliary half-float textures and two float32
|
||||
// bloom prefilters. Allocate lazily; reuse between all five stages.
|
||||
uint64_t bytes=uint64_t(before.width)*before.height*(mixer?16:DYFilmBloomActive(u.film)?64:32);
|
||||
uint64_t budget=MIN(uint64_t(2)*1024*1024*1024,MAX(uint64_t(512)*1024*1024,d.recommendedMaxWorkingSetSize/3));
|
||||
if(bytes>budget)return fail(error,@"当前画面超过胶片处理内存预算,请降低工程分辨率后重试。");
|
||||
NSMutableArray *textures=[NSMutableArray array];id<MTLTexture>slots[6]={nil,nil,nil,nil,nil,nil};
|
||||
auto texture=[&](int slot)->id<MTLTexture>{if(!slots[slot]){MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:slot>=4?MTLPixelFormatRGBA32Float:MTLPixelFormatRGBA16Float width:before.width height:before.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;id<MTLTexture>t=[d newTextureWithDescriptor:desc];if(t){[textures addObject:t];slots[slot]=t;[t release];}}return slots[slot];};
|
||||
CIContext *context=entry[@"filmCIContext"];if(!context){context=[CIContext contextWithMTLDevice:d options:@{kCIContextWorkingColorSpace:NSNull.null,kCIContextOutputColorSpace:NSNull.null,kCIContextCacheIntermediates:@NO}];if(!context)return fail(error,@"胶片空间处理器不可用");entry[@"filmCIContext"]=context;}
|
||||
CGRect bounds=CGRectMake(0,0,before.width,before.height);id<MTLCommandBuffer>commands=[entry[@"queue"]commandBuffer];
|
||||
auto image=[&](id<MTLTexture>t){return [CIImage imageWithMTLTexture:t options:@{kCIImageColorSpace:NSNull.null}];};
|
||||
auto blur=[&](id<MTLTexture>input,id<MTLTexture>output,float radius,BOOL clamp){
|
||||
CIImage *ci=image(input);if(!ci)return NO;if(clamp)ci=[ci imageByClampingToExtent];
|
||||
ci=[[ci imageByApplyingFilter:@"CIGaussianBlur" withInputParameters:@{kCIInputRadiusKey:@(radius)}]imageByCroppingToRect:bounds];
|
||||
[context render:ci toMTLTexture:output commandBuffer:commands bounds:bounds colorSpace:nil];return YES;
|
||||
};
|
||||
auto encode=[&](NSString *name,id<MTLTexture>a,id<MTLTexture>b,id<MTLTexture>out,const void *data,NSUInteger length){
|
||||
id<MTLComputeCommandEncoder>ce=[commands computeCommandEncoder];[ce setComputePipelineState:entry[name]];[ce setTexture:a atIndex:0];if(b)[ce setTexture:b atIndex:1];[ce setTexture:out atIndex:b?2:1];if(data)[ce setBytes:data length:length atIndex:0];[ce dispatchThreads:MTLSizeMake(out.width,out.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];
|
||||
};
|
||||
id<MTLTexture>current=before;
|
||||
auto point=[&](int operation,id<MTLTexture>aux){id<MTLTexture>out=texture(current==slots[0]?1:0);if(!out)return NO;struct {int operation;float radius;unsigned frameKey,reserved;}pass={operation,0,u.filmFrameKey,0};id<MTLComputeCommandEncoder>ce=[commands computeCommandEncoder];[ce setComputePipelineState:entry[@"dyFilmPoint"]];[ce setTexture:current atIndex:0];[ce setTexture:aux?:current atIndex:1];[ce setTexture:out atIndex:2];[ce setBytes:&u length:sizeof(u) atIndex:0];[ce setBytes:&pass length:sizeof(pass) atIndex:1];[ce dispatchThreads:MTLSizeMake(out.width,out.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];current=out;return YES;};
|
||||
@try{
|
||||
if(mixer){if(!point(0,nil))return fail(error,@"无法分配通道混合缓冲区");}
|
||||
else {
|
||||
if(DYFilmSubActive(u.film)&&!point(1,nil))return fail(error,@"无法分配减色缓冲区");
|
||||
if(DYFilmHaloActive(u.film)){id<MTLTexture>aux=texture(2);if(!aux||!blur(current,aux,u.film.scatter,YES)||!point(2,aux))return fail(error,@"晕光空间处理失败");}
|
||||
if(DYFilmBloomActive(u.film)){
|
||||
id<MTLTexture>a=texture(4),b=texture(5),edges=texture(2),spread=texture(3);if(!a||!b||!edges||!spread)return fail(error,@"无法分配辉光缓冲区");
|
||||
int direction=0;encode(@"dyFilmSparseBlur",current,nil,a,&direction,sizeof(direction));direction=1;encode(@"dyFilmSparseBlur",a,nil,b,&direction,sizeof(direction));
|
||||
encode(@"dyFilmBloomEdges",b,current,edges,&u.film,sizeof(u.film));if(!blur(edges,spread,u.film.diffusion,NO)||!point(3,spread))return fail(error,@"辉光空间处理失败");
|
||||
}
|
||||
if(DYFilmGrainActive(u.film)){
|
||||
id<MTLTexture>noise=texture(2);if(!noise)return fail(error,@"无法分配颗粒缓冲区");
|
||||
id<MTLComputeCommandEncoder>ce=[commands computeCommandEncoder];[ce setComputePipelineState:entry[@"dyFilmNoise"]];[ce setTexture:noise atIndex:0];[ce setBytes:&u.filmFrameKey length:4 atIndex:0];[ce dispatchThreads:MTLSizeMake(noise.width,noise.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];
|
||||
if(u.film.grainSize>1){id<MTLTexture>smooth=texture(3);if(!smooth)return fail(error,@"无法分配颗粒扩散缓冲区");
|
||||
// Reference radius=2. Recover the same sigma search without frame state.
|
||||
double sigma=1,step=1;for(int iteration=0;iteration<20000;iteration++){double density=exp(-4/(sigma*sigma))/(sigma*sigma*6.283185307179586);if(.02/5<density){if(step<=.02)break;sigma-=step;step*=.1;}sigma+=step;if(sigma>1000){sigma=1;break;}}
|
||||
MPSImageGaussianBlur *gaussian=[[[MPSImageGaussianBlur alloc]initWithDevice:d sigma:float(sigma*u.film.grainSize/5)]autorelease];gaussian.edgeMode=MPSImageEdgeModeClamp;[gaussian encodeToCommandBuffer:commands sourceTexture:noise destinationTexture:smooth];noise=smooth;
|
||||
}
|
||||
if(!point(4,noise))return fail(error,@"颗粒处理失败");
|
||||
}
|
||||
if(DYFilmVignetteActive(u.film)){
|
||||
id<MTLTexture>aux=texture(2);if(!aux)return fail(error,@"无法分配暗角缓冲区");CIImage *ci=image(current);if(!ci)return fail(error,@"暗角输入不可用");
|
||||
ci=[ci imageByApplyingFilter:@"CIVignetteEffect" withInputParameters:@{kCIInputCenterKey:[CIVector vectorWithX:before.width*.5 Y:before.height*.5],kCIInputIntensityKey:@(u.film.vignetteIntensity),kCIInputRadiusKey:@(u.film.vignetteRadius/100.f*MAX(before.width,before.height)),@"inputFalloff":@(u.film.vignetteFalloff)}];[context render:ci toMTLTexture:aux commandBuffer:commands bounds:bounds colorSpace:nil];if(!point(5,aux))return fail(error,@"暗角处理失败");
|
||||
}
|
||||
if(u.film.mix<1){id<MTLTexture>out=texture(current==slots[0]?1:0);if(!out)return fail(error,@"无法分配胶片混合缓冲区");encode(@"dyFilmMix",before,current,out,&u.film.mix,4);current=out;}
|
||||
}
|
||||
// Finish the effect before the module's existing mask blend. Source and
|
||||
// result retain identical alpha, and an empty mask group means full coverage.
|
||||
if(masks.count){id<MTLTexture>out=texture(current==slots[0]?1:0);if(!out)return fail(error,@"无法分配胶片蒙版缓冲区");DYToolMaskHeader header{};header.section=(int)[DYToolTypes()indexOfObject:type];id<MTLBuffer>buffer=[self maskBuffer:@{type:masks} tile:source device:d header:&header];[self encodeBlend:before after:current output:out masks:buffer header:header entry:entry commands:commands];current=out;}
|
||||
[commands commit];[commands waitUntilCompleted];if(commands.status!=MTLCommandBufferStatusCompleted)return fail(error,commands.error.localizedDescription);
|
||||
DYExportTile *result=[[[DYExportTile alloc]initWithTexture:current registry:d.registryID]autorelease];[result setBounds:source.tilePixelBounds origin:source.imageOrigin];[result setPixelAspect:source.pixelAspect];return [self copyTile:result to:destination entry:entry error:error];
|
||||
}@catch(NSException *exception){return fail(error,[@"胶片处理失败:" stringByAppendingString:exception.reason?:@""]);}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#import <CoreMedia/CoreMedia.h>
|
||||
#include <stdint.h>
|
||||
// Exact signed rational floor. Freeze once in pluginState, never from wall time.
|
||||
inline int64_t DYFilmFrameIndex(CMTime time,CMTime duration,CMTime origin){
|
||||
if(!CMTIME_IS_NUMERIC(time))return 0;
|
||||
if(!CMTIME_IS_NUMERIC(duration)||duration.value<=0)duration=CMTimeMake(1,30);
|
||||
if(CMTIME_IS_NUMERIC(origin)&&origin.epoch==time.epoch)time=CMTimeSubtract(time,origin);
|
||||
__int128 n=(__int128)time.value*duration.timescale,d=(__int128)time.timescale*duration.value;
|
||||
if(d<=0)return 0;__int128 q=n/d;if(n<0&&n%d)q--;
|
||||
if(q>INT64_MAX)return INT64_MAX;if(q<INT64_MIN)return INT64_MIN;return (int64_t)q;
|
||||
}
|
||||
inline uint32_t DYFilmFrameKey(int64_t frame,float hold,float seed){
|
||||
int64_t divisor=(int64_t)llroundf(hold);if(divisor<1)divisor=1;if(divisor>5)divisor=5;
|
||||
int64_t value=frame/divisor;if(frame<0&&frame%divisor)value--;
|
||||
return (uint32_t)value+(uint32_t)llroundf(seed);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
// Host float parameters, appended after the complete 1.4.3 uniform prefix.
|
||||
typedef struct DYFilmSettings {
|
||||
float enabled,mix;
|
||||
float subtractiveEnabled,gammaAll,gammaCyan,gammaMagenta,gammaYellow,density,densityMode,valueMode;
|
||||
float halationEnabled,scatter,dyeTransmission,boost;
|
||||
float bloomEnabled,sensitivity,diffusion,intensity;
|
||||
float grainEnabled,grainAmount,grainSize,grainResponse,grainColor,grainHold,grainSeed;
|
||||
float vignetteEnabled,vignetteIntensity,vignetteRadius,vignetteFalloff;
|
||||
} DYFilmSettings;
|
||||
|
||||
inline bool DYFilmSubActive(DYFilmSettings p){return p.subtractiveEnabled>.5f&&(p.gammaAll!=1||p.gammaCyan!=1||p.gammaMagenta!=1||p.gammaYellow!=1||p.density!=0);}
|
||||
inline bool DYFilmHaloActive(DYFilmSettings p){return p.halationEnabled>.5f&&p.scatter>0&&(p.boost>0||p.dyeTransmission>0);}
|
||||
inline bool DYFilmBloomActive(DYFilmSettings p){return p.bloomEnabled>.5f&&p.intensity>0;}
|
||||
inline bool DYFilmGrainActive(DYFilmSettings p){return p.grainEnabled>.5f&&p.grainAmount>0&&p.grainSize>0;}
|
||||
inline bool DYFilmVignetteActive(DYFilmSettings p){return p.vignetteEnabled>.5f&&p.vignetteIntensity!=0;}
|
||||
inline bool DYFilmSpatialActive(DYFilmSettings p){return DYFilmHaloActive(p)||DYFilmBloomActive(p)||DYFilmGrainActive(p)||DYFilmVignetteActive(p);}
|
||||
inline bool DYFilmActive(DYFilmSettings p){return p.enabled>.5f&&p.mix>0&&(DYFilmSubActive(p)||DYFilmSpatialActive(p));}
|
||||
@@ -323,3 +323,5 @@ kernel void dyToolSkin(texture2d<float,access::read> before [[texture(0)]],textu
|
||||
}
|
||||
|
||||
fragment half4 dyToolCopyFragment(DYRaster in [[stage_in]],texture2d<half> source [[texture(0)]]){constexpr sampler f(coord::normalized,address::clamp_to_edge,filter::linear);return source.sample(f,in.uv);}
|
||||
|
||||
#include "DYFilmKernels.inc.h"
|
||||
@@ -204,7 +204,7 @@ static NSArray *DYPresentationSections(void) {
|
||||
for(NSString *key in @[@"temperature",@"tint",@"exposure",@"contrast",@"highlights",@"shadows",@"whites",@"blacks",@"texture",@"clarity",@"dehaze",@"vibrance",@"saturation",@"skinEnabled",@"copyAutoGrade"]){NSDictionary*d=byKey[key];if(d)[rows addObject:d];}
|
||||
base[@"rows"]=rows;base[@"extraEnabled"]=bySection[@"color"][@"enabled"];
|
||||
base[@"title"]=@"基础调整";
|
||||
return @[primary,bySection[@"spider"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"]];
|
||||
return @[primary,bySection[@"spider"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"],bySection[@"mixer"],bySection[@"film"]];
|
||||
}
|
||||
|
||||
|
||||
@@ -579,6 +579,9 @@ static NSImage *DYWheelImage(void) {
|
||||
if([key isEqual:@"levels"]||[key isEqual:@"balance"]) {
|
||||
NSSegmentedControl *tabs=[NSSegmentedControl segmentedControlWithLabels:[key isEqual:@"levels"]?@[@"RGB",@"红",@"绿",@"蓝"]:@[@"阴影",@"中间调",@"高光"] trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(tabChanged:)];tabs.identifier=key;tabs.selectedSegment=0;tabs.controlSize=NSControlSizeSmall;tabs.accessibilityLabel=[section[@"title"] stringByAppendingString:@"通道"];[card addSubview:tabs];[body addObject:tabs];
|
||||
}
|
||||
if([key isEqual:@"mixer"]||[key isEqual:@"film"]){
|
||||
NSSegmentedControl *tabs=[NSSegmentedControl segmentedControlWithLabels:[key isEqual:@"mixer"]?@[@"红输出",@"绿输出",@"蓝输出"]:@[@"减色",@"晕光",@"辉光",@"颗粒",@"暗角"] trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(tabChanged:)];tabs.identifier=key;tabs.selectedSegment=0;tabs.controlSize=NSControlSizeSmall;tabs.accessibilityLabel=[section[@"title"]stringByAppendingString:@"分组"];[card addSubview:tabs];[body addObject:tabs];
|
||||
}
|
||||
if([key isEqual:@"curve"]) {
|
||||
DYCurvePanel *graph=[[[DYCurvePanel alloc]initWithFrame:NSZeroRect]autorelease];graph.delegate=self;graph.identifier=@"curveGraph";[card addSubview:graph];[body addObject:graph];[_graphics addObject:graph];
|
||||
}
|
||||
@@ -677,6 +680,7 @@ static NSImage *DYWheelImage(void) {
|
||||
if([section isEqual:@"grading"]){int wheel=0,axis=0;if(sscanf(key.UTF8String,"grade%d_%d",&wheel,&axis)==2)return axis==2;}
|
||||
if([section isEqual:@"levels"]){int channel=0,axis=0;if(sscanf(key.UTF8String,"level%d_%d",&channel,&axis)==2)return channel==tab;}
|
||||
if([section isEqual:@"balance"]){int channel=0,axis=0;if(sscanf(key.UTF8String,"balance%d_%d",&channel,&axis)==2)return channel==tab;}
|
||||
if([section isEqual:@"mixer"]||[section isEqual:@"film"]){for(NSDictionary *d in DYToolSection(section)[@"rows"])if([d[@"key"]isEqual:key]){NSNumber *group=d[[section isEqual:@"mixer"]?@"mixerTab":@"filmTab"];return !group||group.intValue<0||group.intValue==tab;}}
|
||||
if([section isEqual:@"look"]){int slot=0;if(sscanf(key.UTF8String,"asset:look%d",&slot)==1)return slot<_visibleLooks;if([key isEqual:@"postLUTStrength"])return YES;int number=0;if(sscanf(key.UTF8String,"look%dStrength",&number)==1)return number-1<_visibleLooks;return NO;}
|
||||
return YES;
|
||||
}
|
||||
@@ -1065,7 +1069,7 @@ static NSImage *DYWheelImage(void) {
|
||||
DYUniforms effective;DYReadUniforms(_manager,t,&effective);values[@"cmConfigured"]=@(effective.cm.configured);values[@"blackWhiteMix"]=@(effective.cm.blackWhiteMix);
|
||||
DYAssetState *state=DYReadAssets(_manager,t);paths=[[state.paths copy]autorelease]?:@{};spider=DYSpiderJSON(state.spiderMesh,state.spiderLinked);NSData *toolData=[NSPropertyListSerialization dataWithPropertyList:DYReadTools(_manager,t).document format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil];tools=[toolData base64EncodedStringWithOptions:0];
|
||||
} @finally {[action endAction:self];}
|
||||
return @{@"format":@"com.dayu.color.preset",@"version":@4,@"values":values,@"paths":paths,@"spider":spider,@"tools":tools?:@""};
|
||||
return @{@"format":@"com.dayu.color.preset",@"version":@5,@"values":values,@"paths":paths,@"spider":spider,@"tools":tools?:@""};
|
||||
}
|
||||
- (void)savePreset:(id)sender {
|
||||
NSDictionary *snapshot=[self presetSnapshot];if(!snapshot)return;
|
||||
@@ -1080,7 +1084,7 @@ static NSImage *DYWheelImage(void) {
|
||||
NSError *error=nil;NSData *data=[NSData dataWithContentsOfURL:panel.URL options:0 error:&error];
|
||||
if(!data||data.length>32*1024*1024){[self showError:error.localizedDescription?:@"预设文件过大"];return;}
|
||||
id json=[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
||||
if(![json isKindOfClass:NSDictionary.class]||![json[@"format"] isEqual:@"com.dayu.color.preset"]||![@[@1,@2,@3,@4]containsObject:json[@"version"]]||![json[@"values"] isKindOfClass:NSDictionary.class]||![json[@"paths"] isKindOfClass:NSDictionary.class]){[self showError:@"这不是有效的大鱼调色预设。"];return;}
|
||||
if(![json isKindOfClass:NSDictionary.class]||![json[@"format"] isEqual:@"com.dayu.color.preset"]||![@[@1,@2,@3,@4,@5]containsObject:json[@"version"]]||![json[@"values"] isKindOfClass:NSDictionary.class]||![json[@"paths"] isKindOfClass:NSDictionary.class]){[self showError:@"这不是有效的大鱼调色预设。"];return;}
|
||||
NSDictionary *values=json[@"values"],*paths=json[@"paths"];NSData *mesh=[json[@"version"]integerValue]>=3?DYSpiderFromJSON(json[@"spider"]):nil;if([json[@"version"]integerValue]>=3&&!mesh){[self showError:@"预设包含无效蜘蛛盘,当前调色未修改。"];return;}
|
||||
NSDictionary *tools=[[[DYToolDocument alloc]init]autorelease].document;if([json[@"version"]integerValue]>=4){id encoded=json[@"tools"];NSData *binary=[encoded isKindOfClass:NSString.class]?[[[NSData alloc]initWithBase64EncodedString:encoded options:0]autorelease]:nil;tools=binary?[NSPropertyListSerialization propertyListWithData:binary options:NSPropertyListImmutable format:NULL error:nil]:nil;if(!DYValidToolDocument(tools)){[self showError:@"预设包含无效工具或蒙版,当前调色未修改。"];return;}}
|
||||
for(NSDictionary *d in DYDescriptors()) {
|
||||
@@ -1099,7 +1103,7 @@ static NSImage *DYWheelImage(void) {
|
||||
[action startAction:self];
|
||||
@try {
|
||||
CMTime t=action.currentTime;id<FxParameterSettingAPI_v6> set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
|
||||
for(NSDictionary *d in DYDescriptors())if(values[d[@"key"]])[set setFloatValue:[values[d[@"key"]] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];
|
||||
for(NSDictionary *d in DYDescriptors()){id value=values[d[@"key"]];if(!value&&[d[@"offset"]integerValue]>=1104)value=d[@"default"];if(value)[set setFloatValue:[value doubleValue] toParameter:[d[@"pid"]unsignedIntValue] atTime:t];}
|
||||
if([json[@"version"]isEqual:@1]&&!values[@"cmConfigured"]){[set setFloatValue:-1 toParameter:2236 atTime:t];[set setFloatValue:1 toParameter:2270 atTime:t];}
|
||||
DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=validPaths;assets.spiderMesh=mesh;assets.spiderLinked=mesh?[json[@"spider"][@"linked"]boolValue]:YES;DYWriteAssets(_manager,assets,t);DYWriteTools(_manager,tools,t);
|
||||
} @finally {[action endAction:self];}
|
||||
|
||||
@@ -155,6 +155,34 @@ static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{
|
||||
NSMutableArray*levels=[NSMutableArray array];for(int c=0;c<4;c++)for(int a=0;a<5;a++)[levels addObject:scalar([NSString stringWithFormat:@"level%d_%d",c,a],[NSString stringWithFormat:@"%@ %@",@[@"RGB",@"红",@"绿",@"蓝"][c],@[@"输入黑",@"伽马",@"输入白",@"输出黑",@"输出白"][a]],624+a*16+c*4,a==1?.1:0,a==1?10:255,a==1?1:(a==2||a==4)?255:0)];section(@"levels",@"色阶",608,levels);
|
||||
NSMutableArray*bw=[NSMutableArray array];for(int c=0;c<6;c++)[bw addObject:scalar([NSString stringWithFormat:@"bw%d",c],[NSString stringWithFormat:@"黑白 %@",@[@"红",@"黄",@"绿",@"青",@"蓝",@"洋红"][c]],c<4?720+c*4:736+(c-4)*4,0,200,((double[]){40,60,40,60,20,80})[c])];[bw addObject:scalar(@"bwHue",@"着色色相",744,0,360)];[bw addObject:scalar(@"bwSat",@"着色饱和度",748,0,100)];[bw insertObject:scalar(@"blackWhiteMix",@"黑白混合",offsetof(DYUniforms,cm)+offsetof(DYCMSettings,blackWhiteMix),0,1,0) atIndex:0];section(@"blackwhite",@"黑白混色",704,bw,1);
|
||||
NSMutableArray*balance=[NSMutableArray arrayWithObject:row(@"preserveLuma",@"保持明度",756,0,1,1,@"bool")];for(int c=0;c<3;c++)for(int a=0;a<3;a++)[balance addObject:scalar([NSString stringWithFormat:@"balance%d_%d",c,a],[NSString stringWithFormat:@"%@ %@",@[@"阴影",@"中间调",@"高光"][c],@[@"青 ↔ 红",@"洋红 ↔ 绿",@"黄 ↔ 蓝"][a]],768+c*16+a*4)];section(@"balance",@"色彩平衡",752,balance);
|
||||
NSMutableArray *mixer=[NSMutableArray array];
|
||||
for(int output=0;output<3;output++)for(int input=0;input<3;input++){
|
||||
NSMutableDictionary *d=[[scalar([NSString stringWithFormat:@"mixer%d%d",output,input],[NSString stringWithFormat:@"%@输出 ← %@输入",@[@"红",@"绿",@"蓝"][output],@[@"红",@"绿",@"蓝"][input]],offsetof(DYUniforms,mixerRed)+output*16+input*4,-2,2,output==input?1:0)mutableCopy]autorelease];
|
||||
d[@"mixerTab"]=@(output);[descriptors replaceObjectAtIndex:descriptors.count-1 withObject:d];[mixer addObject:d];
|
||||
}
|
||||
[mixer addObject:row(@"mixerPreserveLuma",@"保持亮度",offsetof(DYUniforms,mixerPreserveLuma),0,1,0,@"bool")];
|
||||
[mixer addObject:row(@"mixerPreserveSaturation",@"保持饱和度",offsetof(DYUniforms,mixerPreserveSaturation),0,1,0,@"bool")];
|
||||
[mixer addObject:scalar(@"mixerMix",@"通道混合强度",offsetof(DYUniforms,mixerMix),0,1,1)];
|
||||
section(@"mixer",@"通道混合器",offsetof(DYUniforms,mixerSectionEnabled),mixer);
|
||||
NSMutableArray *film=[NSMutableArray array];
|
||||
auto filmRow=[&](NSString *key,NSString *title,NSUInteger offset,double lo,double hi,double value,int tab,NSString *kind=@"float"){
|
||||
NSMutableDictionary *d=[[row(key,title,offsetof(DYUniforms,film)+offset,lo,hi,value,kind)mutableCopy]autorelease];d[@"filmTab"]=@(tab);[descriptors replaceObjectAtIndex:descriptors.count-1 withObject:d];[film addObject:d];return d;
|
||||
};
|
||||
#define FR(f,key,title,lo,hi,value,tab) filmRow(key,title,offsetof(DYFilmSettings,f),lo,hi,value,tab)
|
||||
#define FE(f,key,title,tab) filmRow(key,title,offsetof(DYFilmSettings,f),0,1,0,tab,@"bool")
|
||||
FR(mix,@"filmMix",@"胶片混合强度",0,1,1,-1);
|
||||
FE(subtractiveEnabled,@"filmSubtractive",@"启用减色",0);
|
||||
FR(gammaAll,@"filmGammaAll",@"整体减色",.25,4,1,0);FR(gammaCyan,@"filmGammaCyan",@"青色减色",.25,4,1,0);FR(gammaMagenta,@"filmGammaMagenta",@"洋红减色",.25,4,1,0);FR(gammaYellow,@"filmGammaYellow",@"黄色减色",.25,4,1,0);FR(density,@"filmDensity",@"密度",-1,1,0,0);
|
||||
NSMutableDictionary *density=FR(densityMode,@"filmDensityMode",@"密度模式",1,2,2,0);density[@"kind"]=@"popup";density[@"values"]=@[@2,@1];density[@"options"]=@[@"模式 1 · 最大值",@"模式 2 · 平均值"];
|
||||
row(@"filmValueMode",@"胶片亮度模型",offsetof(DYUniforms,film)+offsetof(DYFilmSettings,valueMode),6,6,6,@"float");
|
||||
FE(halationEnabled,@"filmHalation",@"启用晕光",1);FR(scatter,@"filmScatter",@"散射半径",0,100,5,1);FR(dyeTransmission,@"filmTransmission",@"染料透射",0,100,0,1);FR(boost,@"filmBoost",@"晕光增强",0,5,1,1);
|
||||
FE(bloomEnabled,@"filmBloom",@"启用辉光",2);FR(sensitivity,@"filmSensitivity",@"辉光灵敏度",0,100,50,2);FR(diffusion,@"filmDiffusion",@"辉光扩散",0,100,30,2);FR(intensity,@"filmIntensity",@"辉光强度",0,100,50,2);
|
||||
FE(grainEnabled,@"filmGrain",@"启用颗粒",3);FR(grainAmount,@"filmGrainAmount",@"颗粒数量",0,1,0,3);FR(grainSize,@"filmGrainSize",@"颗粒大小",1,20,1,3);FR(grainResponse,@"filmGrainResponse",@"胶片响应",-1,1,0,3);FR(grainColor,@"filmGrainColor",@"颜色变化",0,1,0,3);
|
||||
NSMutableDictionary *hold=FR(grainHold,@"filmGrainHold",@"颗粒帧保持",1,5,1,3);hold[@"kind"]=@"popup";hold[@"options"]=@[@"每帧更新",@"保持 2 帧",@"保持 3 帧",@"保持 4 帧",@"保持 5 帧"];hold[@"values"]=@[@1,@2,@3,@4,@5];FR(grainSeed,@"filmGrainSeed",@"颗粒种子",0,65535,0,3);
|
||||
FE(vignetteEnabled,@"filmVignette",@"启用暗角",4);FR(vignetteIntensity,@"filmVignetteIntensity",@"暗角强度",-2,2,1,4);FR(vignetteRadius,@"filmVignetteRadius",@"暗角半径",0,100,50,4);FR(vignetteFalloff,@"filmVignetteFalloff",@"暗角过渡",0,1,.5,4);
|
||||
section(@"film",@"胶片模拟",offsetof(DYUniforms,film)+offsetof(DYFilmSettings,enabled),film);
|
||||
#undef FR
|
||||
#undef FE
|
||||
});}
|
||||
NSArray<NSDictionary*> *DYSections(void){initialize();return sections;} NSArray<NSDictionary*> *DYDescriptors(void){initialize();return descriptors;}
|
||||
void DYDefaultUniforms(DYUniforms*u){memset(u,0,sizeof(*u));for(NSDictionary*r in DYDescriptors())if([r[@"offset"]integerValue]>=0)*(float*)((uint8_t*)u+[r[@"offset"]unsignedIntegerValue])=[r[@"default"]floatValue];u->primariesM0=(DYFloat3){1,0,0};u->primariesM1=(DYFloat3){0,1,0};u->primariesM2=(DYFloat3){0,0,1};}
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@
|
||||
#import "DYColorTables.h"
|
||||
#import "DYAutoGrade.h"
|
||||
#import "DYToolState.h"
|
||||
#include "DYFilmTime.h"
|
||||
#import <CoreImage/CoreImage.h>
|
||||
#import <os/log.h>
|
||||
#include "MaskCore/DYTracker.hpp"
|
||||
@@ -19,13 +20,13 @@
|
||||
#include "DYToolHostMethods.inc.h"
|
||||
- (instancetype)initWithAPIManager:(id<PROAPIAccessing>)manager{if((self=[super init])){_apiManager=manager;_renderer=[DYRenderer new];[self initializeToolHost];NSNotificationCenter*n=NSNotificationCenter.defaultCenter;[n addObserver:self selector:@selector(exportRequested:) name:@"DYExportLUT" object:manager];[n addObserver:self selector:@selector(autoRequested:) name:@"DYAutoGrade" object:manager];[n addObserver:self selector:@selector(autoRequested:) name:@"DYAutoWhiteBalance" object:manager];[n addObserver:self selector:@selector(whiteBalanceRequested:) name:@"DYWhiteBalanceColor" object:manager];}return self;}
|
||||
- (void)dealloc{[self tearDownToolHost];[NSNotificationCenter.defaultCenter removeObserver:self];[_renderer release];[super dealloc];}
|
||||
- (BOOL)properties:(NSDictionary**)p error:(NSError**)e{*p=@{kFxPropertyKey_MayRemapTime:@NO,kFxPropertyKey_PixelTransformSupport:@(kFxPixelTransform_ScaleTranslate),kFxPropertyKey_VariesWhenParamsAreStatic:@NO,kFxPropertyKey_DesiredProcessingColorInfo:@(kFxImageColorInfo_RGB_LINEAR),kFxPropertyKey_NeedsFullBuffer:@YES};return YES;}
|
||||
- (BOOL)properties:(NSDictionary**)p error:(NSError**)e{*p=@{kFxPropertyKey_MayRemapTime:@NO,kFxPropertyKey_PixelTransformSupport:@(kFxPixelTransform_ScaleTranslate),kFxPropertyKey_VariesWhenParamsAreStatic:@YES,kFxPropertyKey_DesiredProcessingColorInfo:@(kFxImageColorInfo_RGB_LINEAR),kFxPropertyKey_NeedsFullBuffer:@YES};return YES;}
|
||||
- (BOOL)addParametersWithError:(NSError**)e{return DYCreateParameters(_apiManager,e);}
|
||||
- (NSSet<Class>*)classesForCustomParameterID:(UInt32)pid{return pid==DYToolsParameterID?[NSSet setWithObjects:DYToolDocument.class,NSDictionary.class,NSArray.class,NSString.class,NSNumber.class,NSData.class,nil]:pid==DYAssetsParameterID?[NSSet setWithObjects:DYAssetState.class,NSDictionary.class,NSString.class,NSData.class,nil]:[NSSet setWithObjects:DYInspectorToken.class,NSDictionary.class,NSString.class,NSNumber.class,nil];}
|
||||
- (NSView*)createViewForParameterID:(UInt32)pid{[self scheduleToolCanvasRegistration];return pid==DYInspectorParameterID?[[DYInspector alloc]initWithAPIManager:_apiManager renderer:_renderer]:[[NSView alloc]initWithFrame:NSZeroRect];}
|
||||
- (BOOL)parameterChanged:(UInt32)pid atTime:(CMTime)t error:(NSError**)e{if(pid==DYToolsParameterID)[self adoptToolCanvasDocument:DYReadTools(_apiManager,t).document];if(pid==DYToolsParameterID||pid==2013||pid==2014||(pid>=2236&&pid<2400)||pid==DYAssetsParameterID)[_renderer invalidatePreview];dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self.apiManager];});return YES;}
|
||||
- (BOOL)pluginState:(NSData**)state atTime:(CMTime)t quality:(FxQuality)q error:(NSError**)e{
|
||||
DYUniforms u;DYReadUniforms(_apiManager,t,&u);DYAssetState*a=DYReadAssets(_apiManager,t);DYToolDocument *tools=DYReadTools(_apiManager,t);[self adoptToolCanvasDocument:tools.document];double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSDictionary*s=@{@"schema":@2,@"tools":DYToolRenderSnapshot(tools.document,t),@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{},@"spider":a.spiderMesh?:[NSData data]};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil;
|
||||
DYUniforms u;DYReadUniforms(_apiManager,t,&u);CMTime frameDuration=kCMTimeInvalid,origin=kCMTimeZero;id<FxTimingAPI_v4>timing=[_apiManager apiForProtocol:@protocol(FxTimingAPI_v4)];if([timing respondsToSelector:@selector(frameDuration:)])[timing frameDuration:&frameDuration];if([timing respondsToSelector:@selector(startTimeForEffect:)])[timing startTimeForEffect:&origin];int64_t frame=DYFilmFrameIndex(t,frameDuration,origin);u.filmFrameKey=DYFilmFrameKey(frame,u.film.grainHold,u.film.grainSeed);DYAssetState*a=DYReadAssets(_apiManager,t);DYToolDocument *tools=DYReadTools(_apiManager,t);[self adoptToolCanvasDocument:tools.document];double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSMutableDictionary *snapshot=DYMutablePlist(DYToolRenderSnapshot(tools.document,t));for(NSMutableDictionary *node in snapshot[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"])node[@"filmFrameKey"]=@(DYFilmFrameKey(frame,layer.film.grainHold,layer.film.grainSeed));}NSDictionary*s=@{@"schema":@2,@"tools":snapshot,@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{},@"spider":a.spiderMesh?:[NSData data]};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil;
|
||||
}
|
||||
- (BOOL)destinationImageRect:(FxRect*)rect sourceImages:(NSArray<FxImageTile*>*)src destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(!src.count)return NO;*rect=src[0].imagePixelBounds;return YES;}
|
||||
- (BOOL)sourceTileRect:(FxRect*)rect sourceImageIndex:(NSUInteger)i sourceImages:(NSArray<FxImageTile*>*)src destinationTileRect:(FxRect)dstRect destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(i>=src.count)return NO;*rect=src[i].imagePixelBounds;return YES;}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#import "DYModel.h"
|
||||
#include "DYSpiderState.h"
|
||||
#include "DYToolGPU.h"
|
||||
#include "DYFilmMath.h"
|
||||
#import <CoreImage/CoreImage.h>
|
||||
#import <MetalPerformanceShaders/MetalPerformanceShaders.h>
|
||||
#import "DYColorTables.h"
|
||||
#import "DYLUTLibrary.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
@@ -65,6 +68,7 @@ static void bypassIdleSkin(DYUniforms *u){
|
||||
}
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
#include "DYFilmRender.inc.h"
|
||||
#include "DYToolRender.inc.h"
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreview release];[_previewLock release];[super dealloc];}
|
||||
@@ -99,7 +103,7 @@ static void bypassIdleSkin(DYUniforms *u){
|
||||
NSURL*url=[[NSBundle bundleForClass:self.class]URLForResource:@"default" withExtension:@"metallib"];
|
||||
id<MTLLibrary>lib=[d newLibraryWithURL:url error:err];if(!lib){[d release];return nil;}
|
||||
id<MTLCommandQueue>q=[d newCommandQueue];entry=[NSMutableDictionary dictionaryWithDictionary:@{@"device":d,@"library":lib,@"queue":q,@"pipelines":[NSMutableDictionary dictionary]}];
|
||||
for(NSString*fn in @[@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyInputAnalysis",@"dyColorManagement",@"dyToolBlend",@"dyToolSkin"]){id<MTLFunction>f=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}id<MTLComputePipelineState>p=[d newComputePipelineStateWithFunction:f error:err];[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];}
|
||||
for(NSString*fn in @[@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyInputAnalysis",@"dyColorManagement",@"dyToolBlend",@"dyToolSkin",@"dyFilmPoint",@"dyFilmNoise",@"dyFilmSparseBlur",@"dyFilmBloomEdges",@"dyFilmMix"]){id<MTLFunction>f=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}id<MTLComputePipelineState>p=[d newComputePipelineStateWithFunction:f error:err];[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];}
|
||||
float identity[32];for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){int i=((z*2+y)*2+x)*4;identity[i]=x;identity[i+1]=y;identity[i+2]=z;identity[i+3]=1;}id<MTLTexture>neutral=texture3D(d,identity,2);if(!neutral){fail(err,@"无法分配中性 LUT");return nil;}entry[@"identity"]=neutral;
|
||||
// Preparing before the first frame may use registry 0. Reuse those pipelines
|
||||
// when the host subsequently supplies that device's actual registry ID.
|
||||
@@ -129,7 +133,7 @@ static void bypassIdleSkin(DYUniforms *u){
|
||||
id<MTLTexture>h=[_tables hslForDevice:d uniforms:u],w=[_tables whiteBalanceForDevice:d uniforms:u],g=[_tables gradingForDevice:d uniforms:u];if(!h||!w||!g){fail(err,_tables.lastError?:@"颜色查表构建失败");return nil;}[ts addObjectsFromArray:@[h,w,g]];return ts;
|
||||
}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{return [self renderSource:src destination:dst uniforms:u paths:paths spider:nil error:err];}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider error:(NSError**)err{return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:@{} error:err];}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider error:(NSError**)err{return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:nil error:err];}
|
||||
- (BOOL)renderLegacy:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider masks:(NSDictionary*)masks error:(NSError**)err{return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:masks stageFirst:-1 stageLast:-1 skinReference:nil originalReference:nil captureOriginal:nullptr suppressBlackWhite:NO error:err];}
|
||||
- (BOOL)renderLegacy:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider masks:(NSDictionary*)masks stageFirst:(NSInteger)stageFirst stageLast:(NSInteger)stageLast skinReference:(FxImageTile*)skinReference originalReference:(FxImageTile*)originalReference captureOriginal:(DYExportTile**)captureOriginal suppressBlackWhite:(BOOL)suppressBlackWhite error:(NSError**)err{@synchronized(self){@autoreleasepool{
|
||||
BOOL segmented=stageFirst>=0;if(segmented&&(stageFirst>stageLast||stageLast>11))return fail(err,@"原生工具分段范围无效");
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
BOOL found=NO;float low=1,high=1;for(NSDictionary *mask in node[@"masks"]){if(![mask[@"enabled"]boolValue])continue;DYMaskParameters p=DYMaskAtTime(mask,kCMTimeInvalid);float a=0,b=p.strength==0?0:1;NSInteger combine=[mask[@"combine"]integerValue];if(!found){low=combine==1?1-b:a;high=combine==1?1-a:b;found=YES;}else if(combine==1){low*=1-b;high*=1-a;}else if(combine==2){low*=a;high*=b;}else{low=1-(1-low)*(1-a);high=1-(1-high)*(1-b);}}
|
||||
if(found&&high==0)return [self copyTile:source to:destination entry:entry error:error];
|
||||
DYUniforms layer=DYToolUniforms(node);NSString *type=node[@"type"];
|
||||
if([type isEqual:@"mixer"]||[type isEqual:@"film"]){layer.filmFrameKey=[node[@"filmFrameKey"]unsignedIntValue];return [self renderFilmTool:type source:source destination:destination uniforms:layer masks:node[@"masks"] entry:entry error:error];}
|
||||
if(![type isEqual:@"skin"])return [self renderLegacy:source destination:destination uniforms:layer paths:node[@"paths"] spider:node[@"spider"] masks:@{type:node[@"masks"]} error:error];
|
||||
id<MTLDevice>d=entry[@"device"];id<MTLTexture>before=[source metalTextureForDevice:d],input=[original metalTextureForDevice:d],after=[destination metalTextureForDevice:d];
|
||||
id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dyToolSkin"]];[ce setTexture:before atIndex:0];[ce setTexture:input atIndex:1];[ce setTexture:after atIndex:2];[ce setBytes:&layer length:sizeof(layer) atIndex:0];[ce dispatchThreads:MTLSizeMake(after.width,after.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);
|
||||
@@ -40,10 +41,10 @@
|
||||
DYExportTile *blended=[[DYExportTile alloc]initWithTexture:blend registry:d.registryID];[blended setBounds:source.tilePixelBounds origin:source.imageOrigin];[blended setPixelAspect:source.pixelAspect];[blend release];if(ok)ok=[self copyTile:blended to:destination entry:entry error:error];else fail(error,cb.error.localizedDescription);[blended release];return ok;
|
||||
}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){@autoreleasepool{
|
||||
if(!tools)return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:@{} error:error];if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");
|
||||
if(!tools)tools=@{@"schema":@1,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");
|
||||
NSArray *layers=tools[@"layers"];BOOL active=NO,anchored=NO;for(NSDictionary *node in layers)if(!DYToolIsNeutral(node)){active=YES;anchored|=![DYToolRootAnchor(tools,node[@"id"])isEqual:@"tail"];}
|
||||
// No active extra tool keeps the exact historical fused path, including HDR.
|
||||
if(!active)return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];
|
||||
if(!active&&!DYChannelMixerActive(u)&&!DYFilmActive(u.film))return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];
|
||||
NSMutableDictionary *entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;id<MTLDevice>d=entry[@"device"];id<MTLTexture>input=[src metalTextureForDevice:d];if(!input)return fail(error,@"宿主图像纹理不可用");
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;
|
||||
DYExportTile *tile=nil,*skinReference=nil,*originalReference=nil;NSArray *order=DYToolDisplayOrder(tools);NSMutableDictionary *groups=[NSMutableDictionary dictionary];for(NSString *ID in order){NSDictionary *node=DYToolWithID(tools,ID);if(!node||DYToolIsNeutral(node))continue;NSString *root=DYToolRootAnchor(tools,ID);if(!groups[root])groups[root]=[NSMutableArray array];[groups[root]addObject:node];}
|
||||
@@ -88,12 +89,15 @@
|
||||
if(u.spiderSectionEnabled>.5&&u.spiderMix>0&&spider.length){DYUniforms sp=DYToolUniforms(@{@"type":@"spider"});sp.spiderSectionEnabled=u.spiderSectionEnabled;sp.spiderMix=u.spiderMix;DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配蜘蛛盘缓冲区");BOOL ok=[self renderLegacy:tile destination:next uniforms:sp paths:@{} spider:spider masks:@{@"spider":tools[@"baseMasks"][@"spider"]?:@[]} error:error];if(!ok){[next release];return NO;}replace(next);}
|
||||
if(!apply(@"base:spider"))return NO;
|
||||
}
|
||||
// New end-of-chain base tools do not move any historical color stages.
|
||||
for(NSString *type in @[@"mixer",@"film"]){BOOL enabled=[type isEqual:@"mixer"]?DYChannelMixerActive(u):DYFilmActive(u.film);if(enabled){DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配胶片工具缓冲区");BOOL ok=[self renderFilmTool:type source:tile destination:next uniforms:u masks:tools[@"baseMasks"][type]?:@[] entry:entry error:error];if(!ok){[next release];return NO;}replace(next);}if(!apply([@"base:" stringByAppendingString:type]))return NO;}
|
||||
// Schema 1 extra layers (and children inserted after those layers) retain
|
||||
// their old end-of-chain order. Saving does not silently migrate old looks.
|
||||
if(!apply(@"tail"))return NO;return [self copyTile:tile to:dst entry:entry error:error];
|
||||
}@finally{[originalReference release];[skinReference release];[tile release];}
|
||||
}}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){
|
||||
if(DYFilmActive(u.film)&&DYFilmSpatialActive(u.film))return fail(error,@"当前胶片含晕光、辉光、颗粒或暗角,无法完整保存到静态 Cube。请保存完整预设,或关闭这些处理后再导出。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"]&&DYFilmActive(layer.film)&&DYFilmSpatialActive(layer.film))return fail(error,@"新增胶片层含空间或时间处理,无法完整保存到静态 Cube。请保存完整预设。");}
|
||||
for(NSArray *masks in [tools[@"baseMasks"]allValues])if(masks.count)return fail(error,@"当前调色含空间蒙版或跟踪,Cube 无法保存这些信息。请先保存完整预设,或移除蒙版后导出。");for(NSDictionary *node in tools[@"layers"])if([node[@"masks"]count])return fail(error,@"新增工具含蒙版,无法完整导出为 Cube。请保存完整预设。");
|
||||
_toolDocument=tools;BOOL ok=NO;@try{ok=[self exportLUT:url uniforms:u paths:paths spider:spider error:error];}@finally{_toolDocument=nil;}return ok;
|
||||
}}
|
||||
@@ -1,9 +1,10 @@
|
||||
#import "DYToolState.h"
|
||||
#include "DYSpiderState.h"
|
||||
#include "DYFilmMath.h"
|
||||
#include <set>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
NSArray *DYToolTypes(void){return @[@"primary",@"spider",@"base",@"skin",@"look",@"hsl",@"curve",@"grading",@"primaries",@"levels",@"blackwhite",@"balance"];}
|
||||
NSArray *DYToolTypes(void){return @[@"primary",@"spider",@"base",@"skin",@"look",@"hsl",@"curve",@"grading",@"primaries",@"levels",@"blackwhite",@"balance",@"mixer",@"film"];}
|
||||
NSDictionary *DYToolSection(NSString *type){for(NSDictionary *s in DYSections())if([s[@"key"]isEqual:type])return s;return nil;}
|
||||
NSMutableDictionary *DYMutablePlist(NSDictionary *value){if(!value)return [NSMutableDictionary dictionary];NSData *data=[NSPropertyListSerialization dataWithPropertyList:value format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil];return [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainersAndLeaves format:NULL error:nil];}
|
||||
static NSDictionary *DYEmptyTools(){return @{@"schema":@1,@"layers":@[],@"baseMasks":@{}};}
|
||||
@@ -71,7 +72,7 @@ DYUniforms DYToolUniforms(NSDictionary *node){DYUniforms u;DYDefaultUniforms(&u)
|
||||
NSArray *parts=[type isEqual:@"primary"]?@[@"input",@"primary",@"output"]:[type isEqual:@"base"]?@[@"base",@"color"]:@[type];for(NSString *part in parts){NSDictionary *s=DYToolSection(part);for(NSDictionary *d in DYDescriptors())if([d[@"pid"]isEqual:s[@"enabled"]])*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])=1;}
|
||||
if([type isEqual:@"primary"]){u.primarySectionEnabled=1;u.cm.configured=1;u.cm.inputTransfer=u.cm.outputTransfer;u.cm.inputGamut=u.cm.outputGamut;}
|
||||
for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if(v&&[d[@"offset"]integerValue]>=0)*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])=v.floatValue;}return u;}
|
||||
BOOL DYToolIsNeutral(NSDictionary *node){NSString *type=node[@"type"];DYUniforms u=DYToolUniforms(node);NSDictionary *section=DYToolSection(type);BOOL enabled=YES;if([type isEqual:@"primary"])enabled=u.primarySectionEnabled>.5;else if([type isEqual:@"base"])enabled=u.baseSectionEnabled>.5||u.colorSectionEnabled>.5;else for(NSDictionary *d in DYDescriptors())if([d[@"pid"]isEqual:section[@"enabled"]])enabled=*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])>.5;if(!enabled)return YES;if([type isEqual:@"skin"])return u.skinProtection.y==0;if([node[@"type"]isEqual:@"spider"]&&[node[@"spider"]length]){auto mesh=DYSpiderMesh(node[@"spider"]);for(float v:dy::meshSamples(mesh))if(v!=0)return NO;}if([node[@"paths"]count])return NO;for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if(v&&v.floatValue!=[d[@"default"]floatValue])return NO;}return YES;}
|
||||
BOOL DYToolIsNeutral(NSDictionary *node){NSString *type=node[@"type"];DYUniforms u=DYToolUniforms(node);NSDictionary *section=DYToolSection(type);BOOL enabled=YES;if([type isEqual:@"primary"])enabled=u.primarySectionEnabled>.5;else if([type isEqual:@"base"])enabled=u.baseSectionEnabled>.5||u.colorSectionEnabled>.5;else for(NSDictionary *d in DYDescriptors())if([d[@"pid"]isEqual:section[@"enabled"]])enabled=*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])>.5;if(!enabled)return YES;if([type isEqual:@"mixer"])return !DYChannelMixerActive(u);if([type isEqual:@"film"])return !DYFilmActive(u.film);if([type isEqual:@"skin"])return u.skinProtection.y==0;if([node[@"type"]isEqual:@"spider"]&&[node[@"spider"]length]){auto mesh=DYSpiderMesh(node[@"spider"]);for(float v:dy::meshSamples(mesh))if(v!=0)return NO;}if([node[@"paths"]count])return NO;for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if(v&&v.floatValue!=[d[@"default"]floatValue])return NO;}return YES;}
|
||||
|
||||
@implementation DYToolManager {
|
||||
id<PROAPIAccessing> _host;NSString *_nodeID,*_type;NSInteger _depth;CMTime _time;NSMutableDictionary *_pending;DYInspectorToken *_token;
|
||||
|
||||
@@ -17,6 +17,7 @@ typedef uint32_t DYUInt;
|
||||
#endif
|
||||
|
||||
#include "DYColorManagement.h"
|
||||
#include "DYFilmTypes.h"
|
||||
|
||||
typedef struct DYUniforms {
|
||||
float exposure; // offset 0
|
||||
@@ -125,6 +126,11 @@ typedef struct DYUniforms {
|
||||
float primarySectionEnabled;
|
||||
float spiderSectionEnabled;
|
||||
float spiderMix;
|
||||
float legacyPadding;
|
||||
DYFloat4 mixerRed,mixerGreen,mixerBlue;
|
||||
float mixerSectionEnabled,mixerPreserveLuma,mixerPreserveSaturation,mixerMix;
|
||||
DYFilmSettings film;
|
||||
DYUInt filmFrameKey; // frozen render time, never an author parameter
|
||||
} DYUniforms;
|
||||
|
||||
typedef struct DYVertex2D { DYFloat2 position; DYFloat2 textureCoordinate; } DYVertex2D;
|
||||
@@ -141,6 +147,7 @@ typedef struct DYRenderOptions {
|
||||
#define DY_ABI_ASSERT _Static_assert
|
||||
#endif
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, cm) == 944, "DYUniforms must match recovered GPU ABI");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, mixerRed) == 1104, "complete 1.4.3 prefix stays fixed");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, exposure) == 0, "exposure offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, contrast) == 4, "contrast offset");
|
||||
DY_ABI_ASSERT(offsetof(DYUniforms, highlights) == 8, "highlights offset");
|
||||
|
||||
在新工单中引用
屏蔽一个用户