| 1 | """Exhaustive edge-case parameter matrix suites (Merge, HDR, masks, color/blur, warps, 3D, misc, paint, aspect).""" |
| 2 | |
| 3 | from typing import Dict, List, Tuple |
| 4 | |
| 5 | from .assets import ( |
| 6 | build_switch_chain, |
| 7 | linear_spline, |
| 8 | lut_bezier, |
| 9 | make_comp, |
| 10 | make_loader, |
| 11 | make_saver, |
| 12 | ensure_dirs, |
| 13 | ) |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | def build_matrix_merge_modes(assets: Dict[str, str]): |
| 19 | """Sweeps all Merge ApplyModes, Operators, SubtractiveAdditive, AlphaGain/Gain, BurnIn, Edges, mismatched res, EffectMask.""" |
| 20 | nodes = [ |
| 21 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 22 | make_loader("FGLoader", assets["fg"], post_mult=1), |
| 23 | make_loader("SmallLoader", assets["small"], post_mult=1), |
| 24 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 25 | \t\tBlueBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.15, }, TopLeftGreen = Input { Value = 0.25, }, TopLeftBlue = Input { Value = 0.55, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 26 | \t\tMaskEll = EllipseMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, Width = Input { Value = 0.55, }, Height = Input { Value = 0.45, }, SoftEdge = Input { Value = 0.04, }, }, },""", |
| 27 | ] |
| 28 | cases: List[Tuple[int, str, str]] = [] |
| 29 | f = 0 |
| 30 | |
| 31 | def add_case(label: str, fg: str, bg: str, extra: str, over_blue: bool = False) -> None: |
| 32 | nonlocal f |
| 33 | mname = f"M_{f}" |
| 34 | nodes.append( |
| 35 | f"""\t\t{mname} = Merge {{ |
| 36 | \t\t\tInputs = {{ |
| 37 | \t\t\t\tBackground = Input {{ SourceOp = "{bg}", Source = "Output", }}, |
| 38 | \t\t\t\tForeground = Input {{ SourceOp = "{fg}", Source = "Output", }}, |
| 39 | \t\t\t\tPerformDepthMerge = Input {{ Value = 0, }}, |
| 40 | \t\t\t\t{extra} |
| 41 | \t\t\t}}, |
| 42 | \t\t}},""" |
| 43 | ) |
| 44 | out_name = mname |
| 45 | if over_blue: |
| 46 | oname = f"Vis_{f}" |
| 47 | nodes.append( |
| 48 | f"""\t\t{oname} = Merge {{ |
| 49 | \t\t\tInputs = {{ |
| 50 | \t\t\t\tBackground = Input {{ SourceOp = "BlueBG", Source = "Output", }}, |
| 51 | \t\t\t\tForeground = Input {{ SourceOp = "{mname}", Source = "Output", }}, |
| 52 | \t\t\t}}, |
| 53 | \t\t}},""" |
| 54 | ) |
| 55 | out_name = oname |
| 56 | cases.append((f, label, out_name)) |
| 57 | f += 1 |
| 58 | |
| 59 | apply_modes = [ |
| 60 | "Normal", "Screen", "Multiply", "Dissolve", "Soft Light", "Hard Light", |
| 61 | "Darken", "Lighten", "Color Dodge", "Color Burn", "Difference", "Exclusion", |
| 62 | "Overlay", "Sub", |
| 63 | ] |
| 64 | for am in apply_modes: |
| 65 | add_case(f"ApplyMode={am}", "FGLoader", "ColorLoader", f'Size = Input {{ Value = 0.85, }}, ApplyMode = Input {{ Value = FuID {{ "{am}" }}, }},') |
| 66 | |
| 67 | operators = ["Over", "In", "Held Out", "Atop", "XOr", "Conjoint", "Disjoint"] |
| 68 | for op in operators: |
| 69 | add_case(f"Operator={op}", "FGLoader", "ColorLoader", f'Operator = Input {{ Value = FuID {{ "{op}" }}, }},', over_blue=True) |
| 70 | |
| 71 | for sa in (0.0, 0.5, 1.0): |
| 72 | add_case(f"SubAdd={sa}", "FGLoader", "ColorLoader", f"SubtractiveAdditive = Input {{ Value = {sa}, }},") |
| 73 | |
| 74 | for ag in (0.0, 0.5, 1.5): |
| 75 | add_case(f"Gain={ag}", "FGLoader", "ColorLoader", f"Gain = Input {{ Value = {ag}, }},") |
| 76 | add_case("AlphaGain=0.5", "FGLoader", "ColorLoader", "AlphaGain = Input { Value = 0.5, },") |
| 77 | |
| 78 | add_case("BurnIn=0.6", "FGLoader", "ColorLoader", "BurnIn = Input { Value = 0.6, },") |
| 79 | |
| 80 | for ed in (0, 1, 2, 3): |
| 81 | add_case( |
| 82 | f"Edges={ed}", |
| 83 | "SmallLoader", |
| 84 | "ColorLoader", |
| 85 | f"Center = Input {{ Value = {{ 0.78, 0.72 }}, }}, Size = Input {{ Value = 0.55, }}, Angle = Input {{ Value = 22, }}, Edges = Input {{ Value = {ed}, }},", |
| 86 | ) |
| 87 | |
| 88 | add_case("Mismatch_SmallOverColor", "SmallLoader", "ColorLoader", "Size = Input { Value = 0.8, }, Angle = Input { Value = 20, },") |
| 89 | add_case("Mismatch_ColorOverSmall", "ColorLoader", "SmallLoader", "Size = Input { Value = 0.5, }, Angle = Input { Value = -15, },", over_blue=True) |
| 90 | |
| 91 | for inv in (0, 1): |
| 92 | for mbm in (0, 1): |
| 93 | add_case( |
| 94 | f"Mask_inv{inv}_mbm{mbm}", |
| 95 | "FGLoader", |
| 96 | "ColorLoader", |
| 97 | f'EffectMask = Input {{ SourceOp = "MaskEll", Source = "Mask", }}, ApplyMaskInverted = Input {{ Value = {inv}, }}, MultiplyByMask = Input {{ Value = {mbm}, }},', |
| 98 | ) |
| 99 | |
| 100 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "MM") |
| 101 | nodes.extend(sw_nodes) |
| 102 | nodes.append(make_saver(out_op, "matrix_merge_modes")) |
| 103 | comp_path = ensure_dirs() / "comps" / "matrix_merge_modes.comp" |
| 104 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 105 | return comp_path, "matrix_merge_modes", [(c[0], c[1]) for c in cases] |
| 106 | |
| 107 | |
| 108 | def build_matrix_hdr_depth(assets: Dict[str, str]): |
| 109 | """Tests BitDepth (int8/int16/float16/float32), HDR > 1.0, negative values, PreDividePostMultiply=0/1.""" |
| 110 | nodes = [ |
| 111 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 112 | make_loader("FGLoader", assets["fg"], post_mult=1), |
| 113 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 114 | \t\tDarkBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.1, }, TopLeftGreen = Input { Value = 0.12, }, TopLeftBlue = Input { Value = 0.16, }, TopLeftAlpha = Input { Value = 1, }, }, },""", |
| 115 | ] |
| 116 | cases: List[Tuple[int, str, str]] = [] |
| 117 | f = 0 |
| 118 | |
| 119 | for d_code, d_name in ((1, "int8"), (2, "int16"), (3, "float16"), (4, "float32")): |
| 120 | cd = f"CD_{f}" |
| 121 | up = f"Up_{f}" |
| 122 | bl = f"Bl_{f}" |
| 123 | dn = f"Dn_{f}" |
| 124 | nodes.append(f'\t\t{cd} = ChangeDepth {{ Inputs = {{ Input = Input {{ SourceOp = "ColorLoader", Source = "Output", }}, Depth = Input {{ Value = {d_code}, }}, }}, }},') |
| 125 | nodes.append(f'\t\t{up} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{cd}", Source = "Output", }}, Gain = Input {{ Value = 2.5, }}, }}, }},') |
| 126 | nodes.append(f'\t\t{bl} = Blur {{ Inputs = {{ Input = Input {{ SourceOp = "{up}", Source = "Output", }}, XBlurSize = Input {{ Value = 8.0, }}, }}, }},') |
| 127 | nodes.append(f'\t\t{dn} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{bl}", Source = "Output", }}, Gain = Input {{ Value = 0.4, }}, }}, }},') |
| 128 | cases.append((f, f"HDR_Depth={d_name}_Gain2.5_Blur_Gain0.4", dn)) |
| 129 | f += 1 |
| 130 | |
| 131 | # Negative value roundtrip across depths |
| 132 | for d_code, d_name in ((1, "int8"), (3, "float16"), (4, "float32")): |
| 133 | cd = f"CDN_{f}" |
| 134 | sub = f"Sub_{f}" |
| 135 | bl = f"BlN_{f}" |
| 136 | add = f"Add_{f}" |
| 137 | nodes.append(f'\t\t{cd} = ChangeDepth {{ Inputs = {{ Input = Input {{ SourceOp = "ColorLoader", Source = "Output", }}, Depth = Input {{ Value = {d_code}, }}, }}, }},') |
| 138 | nodes.append(f'\t\t{sub} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{cd}", Source = "Output", }}, Brightness = Input {{ Value = -0.4, }}, }}, }},') |
| 139 | nodes.append(f'\t\t{bl} = Blur {{ Inputs = {{ Input = Input {{ SourceOp = "{sub}", Source = "Output", }}, XBlurSize = Input {{ Value = 5.0, }}, }}, }},') |
| 140 | nodes.append(f'\t\t{add} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{bl}", Source = "Output", }}, Brightness = Input {{ Value = 0.4, }}, }}, }},') |
| 141 | cases.append((f, f"NegValues_Depth={d_name}", add)) |
| 142 | f += 1 |
| 143 | |
| 144 | # Background native Depth=3/4 HDR |
| 145 | for d_code, d_name in ((3, "float16"), (4, "float32")): |
| 146 | bg = f"BG_{f}" |
| 147 | up = f"BUp_{f}" |
| 148 | dn = f"BDn_{f}" |
| 149 | nodes.append(f'\t\t{bg} = Background {{ Inputs = {{ Width = Input {{ Value = 256, }}, Height = Input {{ Value = 256, }}, Depth = Input {{ Value = {d_code}, }}, Type = Input {{ Value = FuID {{ "Horizontal" }}, }}, TopLeftRed = Input {{ Value = 0.8, }}, TopLeftGreen = Input {{ Value = 0.2, }}, TopLeftBlue = Input {{ Value = 0.1, }}, TopLeftAlpha = Input {{ Value = 1, }}, TopRightRed = Input {{ Value = 0.1, }}, TopRightGreen = Input {{ Value = 0.7, }}, TopRightBlue = Input {{ Value = 0.9, }}, }}, }},') |
| 150 | nodes.append(f'\t\t{up} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{bg}", Source = "Output", }}, Gain = Input {{ Value = 3.0, }}, }}, }},') |
| 151 | nodes.append(f'\t\t{dn} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "{up}", Source = "Output", }}, Gain = Input {{ Value = 0.333333, }}, }}, }},') |
| 152 | cases.append((f, f"BG_Depth={d_name}_HDR", dn)) |
| 153 | f += 1 |
| 154 | |
| 155 | # PreDividePostMultiply = 0 / 1 on semi-transparent FGLoader merged over DarkBG |
| 156 | for pd in (0, 1): |
| 157 | bc = f"BCPD_{f}" |
| 158 | m = f"MPD_{f}" |
| 159 | nodes.append(f'\t\t{bc} = BrightnessContrast {{ Inputs = {{ Input = Input {{ SourceOp = "FGLoader", Source = "Output", }}, Gain = Input {{ Value = 1.6, }}, Gamma = Input {{ Value = 0.7, }}, Brightness = Input {{ Value = 0.15, }}, PreDividePostMultiply = Input {{ Value = {pd}, }}, }}, }},') |
| 160 | nodes.append(f'\t\t{m} = Merge {{ Inputs = {{ Background = Input {{ SourceOp = "DarkBG", Source = "Output", }}, Foreground = Input {{ SourceOp = "{bc}", Source = "Output", }}, }}, }},') |
| 161 | cases.append((f, f"BC_PreDiv={pd}", m)) |
| 162 | f += 1 |
| 163 | |
| 164 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "HD") |
| 165 | nodes.extend(sw_nodes) |
| 166 | nodes.append(make_saver(out_op, "matrix_hdr_depth")) |
| 167 | comp_path = ensure_dirs() / "comps" / "matrix_hdr_depth.comp" |
| 168 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 169 | return comp_path, "matrix_hdr_depth", [(c[0], c[1]) for c in cases] |
| 170 | |
| 171 | |
| 172 | def build_matrix_masks(assets: Dict[str, str]): |
| 173 | """Chained multi-mask graphs (EllipseMask -> RectangleMask -> PolylineMask) testing all PaintModes, SoftEdge, BorderWidth, Invert, Level.""" |
| 174 | nodes = [ |
| 175 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 176 | \t\tWhiteFG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.95, }, TopLeftGreen = Input { Value = 0.75, }, TopLeftBlue = Input { Value = 0.25, }, TopLeftAlpha = Input { Value = 1, }, }, },""", |
| 177 | ] |
| 178 | cases: List[Tuple[int, str, str]] = [] |
| 179 | f = 0 |
| 180 | |
| 181 | paint_modes = ["Merge", "Add", "Subtract", "Minimum", "Maximum", "Average", "Multiply", "Replace", "Invert"] |
| 182 | for pm in paint_modes: |
| 183 | e = f"Ell_{f}" |
| 184 | r = f"Rect_{f}" |
| 185 | p = f"Poly_{f}" |
| 186 | m = f"Op_{f}" |
| 187 | nodes.append(f'\t\t{e} = EllipseMask {{ Inputs = {{ MaskWidth = Input {{ Value = 256, }}, MaskHeight = Input {{ Value = 256, }}, Center = Input {{ Value = {{ 0.42, 0.50 }}, }}, Width = Input {{ Value = 0.50, }}, Height = Input {{ Value = 0.45, }}, SoftEdge = Input {{ Value = 0.03, }}, }}, }},') |
| 188 | nodes.append(f'\t\t{r} = RectangleMask {{ Inputs = {{ EffectMask = Input {{ SourceOp = "{e}", Source = "Mask", }}, PaintMode = Input {{ Value = FuID {{ "{pm}" }}, }}, MaskWidth = Input {{ Value = 256, }}, MaskHeight = Input {{ Value = 256, }}, Center = Input {{ Value = {{ 0.58, 0.55 }}, }}, Width = Input {{ Value = 0.42, }}, Height = Input {{ Value = 0.42, }}, SoftEdge = Input {{ Value = 0.02, }}, Level = Input {{ Value = 0.8, }}, }}, }},') |
| 189 | nodes.append( |
| 190 | f"""\t\t{p} = PolylineMask {{ |
| 191 | \t\t\tInputs = {{ |
| 192 | \t\t\t\tEffectMask = Input {{ SourceOp = "{r}", Source = "Mask", }}, |
| 193 | \t\t\t\tPaintMode = Input {{ Value = FuID {{ "{pm}" }}, }}, |
| 194 | \t\t\t\tMaskWidth = Input {{ Value = 256, }}, |
| 195 | \t\t\t\tMaskHeight = Input {{ Value = 256, }}, |
| 196 | \t\t\t\tSoftEdge = Input {{ Value = 0.02, }}, |
| 197 | \t\t\t\tPolyline = Input {{ |
| 198 | \t\t\t\t\tValue = Polyline {{ |
| 199 | \t\t\t\t\t\tClosed = true, |
| 200 | \t\t\t\t\t\tPoints = {{ |
| 201 | \t\t\t\t\t\t\t{{ Linear = true, X = -0.25, Y = -0.25, RX = 0.16, RY = 0 }}, |
| 202 | \t\t\t\t\t\t\t{{ Linear = true, X = 0.25, Y = -0.15, LX = -0.16, LY = 0, RX = -0.08, RY = 0.14 }}, |
| 203 | \t\t\t\t\t\t\t{{ Linear = true, X = 0.0, Y = 0.28, LX = 0.08, LY = -0.14 }}, |
| 204 | \t\t\t\t\t\t}}, |
| 205 | \t\t\t\t\t}}, |
| 206 | \t\t\t\t}}, |
| 207 | \t\t\t}}, |
| 208 | \t\t}},""" |
| 209 | ) |
| 210 | nodes.append(f'\t\t{m} = Merge {{ Inputs = {{ Background = Input {{ SourceOp = "BlackBG", Source = "Output", }}, Foreground = Input {{ SourceOp = "WhiteFG", Source = "Output", }}, EffectMask = Input {{ SourceOp = "{p}", Source = "Mask", }}, }}, }},') |
| 211 | cases.append((f, f"MaskChain_PaintMode={pm}", m)) |
| 212 | f += 1 |
| 213 | |
| 214 | # BorderWidth, Solid=0/1, SoftEdge, Invert, Level edge cases |
| 215 | extra_masks = [ |
| 216 | ("Rect_Border0.05_Solid0", 'RectangleMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, Width = Input { Value = 0.5, }, Height = Input { Value = 0.5, }, Solid = Input { Value = 0, }, BorderWidth = Input { Value = 0.05, }, }, }'), |
| 217 | ("Ell_Border0.04_Soft0.03_Inv1", 'EllipseMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, Width = Input { Value = 0.45, }, Height = Input { Value = 0.35, }, Angle = Input { Value = 25, }, Solid = Input { Value = 1, }, BorderWidth = Input { Value = 0.04, }, SoftEdge = Input { Value = 0.03, }, Invert = Input { Value = 1, }, Level = Input { Value = 0.65, }, }, }'), |
| 218 | ("Rect_Corner0.35_Soft0.08_Box", 'RectangleMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, Width = Input { Value = 0.6, }, Height = Input { Value = 0.45, }, CornerRadius = Input { Value = 0.35, }, SoftEdge = Input { Value = 0.08, }, Filter = Input { Value = FuID { "Box" }, }, }, }'), |
| 219 | ("Poly_Invert1_Level0.6_Soft0.05", 'PolylineMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, SoftEdge = Input { Value = 0.05, }, Invert = Input { Value = 1, }, Level = Input { Value = 0.6, }, Polyline = Input { Value = Polyline { Closed = true, Points = { { Linear = true, X = -0.3, Y = -0.2 }, { Linear = true, X = 0.3, Y = -0.2 }, { Linear = true, X = 0.0, Y = 0.3 } } }, }, }, }'), |
| 220 | ] |
| 221 | for label, mdef in extra_masks: |
| 222 | mk = f"Mk_{f}" |
| 223 | m = f"Op_{f}" |
| 224 | nodes.append(f"\t\t{mk} = {mdef},") |
| 225 | nodes.append(f'\t\t{m} = Merge {{ Inputs = {{ Background = Input {{ SourceOp = "BlackBG", Source = "Output", }}, Foreground = Input {{ SourceOp = "WhiteFG", Source = "Output", }}, EffectMask = Input {{ SourceOp = "{mk}", Source = "Mask", }}, }}, }},') |
| 226 | cases.append((f, label, m)) |
| 227 | f += 1 |
| 228 | |
| 229 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "MK") |
| 230 | nodes.extend(sw_nodes) |
| 231 | nodes.append(make_saver(out_op, "matrix_masks")) |
| 232 | comp_path = ensure_dirs() / "comps" / "matrix_masks.comp" |
| 233 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 234 | return comp_path, "matrix_masks", [(c[0], c[1]) for c in cases] |
| 235 | |
| 236 | |
| 237 | def build_matrix_color_blur(assets: Dict[str, str]): |
| 238 | """ColorCorrector, ColorCurves, HueCurves, GamutConvert, ChannelBoolean, Blur, Glow, SoftGlow, DirectionalBlur.""" |
| 239 | nodes = [ |
| 240 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 241 | make_loader("FGLoader", assets["fg"], post_mult=1), |
| 242 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 243 | \t\tDarkBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.12, }, TopLeftGreen = Input { Value = 0.12, }, TopLeftBlue = Input { Value = 0.18, }, TopLeftAlpha = Input { Value = 1, }, }, },""", |
| 244 | lut_bezier("CC_Red", [(0.0, 0.0), (0.3, 0.55), (0.7, 0.45), (1.0, 0.95)]), |
| 245 | lut_bezier("CC_Green", [(0.0, 0.08), (0.5, 0.42), (1.0, 1.0)]), |
| 246 | lut_bezier("CC_Blue", [(0.0, 0.0), (0.5, 0.72), (1.0, 0.85)]), |
| 247 | lut_bezier("CC_Alpha", [(0.0, 0.0), (0.5, 0.85), (1.0, 1.0)]), |
| 248 | lut_bezier("HC_Hue", [(0, 1.25), (2, 0.85), (4, 1.15), (6, 1.25)]), |
| 249 | lut_bezier("HC_Sat", [(0, 1.0), (1, 0.3), (3, 1.7), (5, 0.6), (6, 1.0)]), |
| 250 | lut_bezier("HC_Lum", [(0, 1.0), (2, 0.6), (4, 1.4), (6, 1.0)]), |
| 251 | lut_bezier("HC_RSup", [(0, 0.5), (2, 1.0), (6, 0.5)]), |
| 252 | ] |
| 253 | cases: List[Tuple[int, str, str]] = [] |
| 254 | f = 0 |
| 255 | |
| 256 | def add_op(label: str, kind: str, in_port: str, src: str, extra: str, over_dark: bool = False) -> None: |
| 257 | nonlocal f |
| 258 | opn = f"Op_{f}" |
| 259 | nodes.append( |
| 260 | f"""\t\t{opn} = {kind} {{ |
| 261 | \t\t\tInputs = {{ |
| 262 | \t\t\t\t{in_port} = Input {{ SourceOp = "{src}", Source = "Output", }}, |
| 263 | \t\t\t\t{extra} |
| 264 | \t\t\t}}, |
| 265 | \t\t}},""" |
| 266 | ) |
| 267 | out_n = opn |
| 268 | if over_dark: |
| 269 | vn = f"Vis_{f}" |
| 270 | nodes.append(f'\t\t{vn} = Merge {{ Inputs = {{ Background = Input {{ SourceOp = "DarkBG", Source = "Output", }}, Foreground = Input {{ SourceOp = "{opn}", Source = "Output", }}, }}, }},') |
| 271 | out_n = vn |
| 272 | cases.append((f, label, out_n)) |
| 273 | f += 1 |
| 274 | |
| 275 | # ColorCorrector: SMH + Wheel Hue/Sat/Tint + PreDividePostMultiply |
| 276 | add_op("CC_SMH_Wheel_PreDiv1", "ColorCorrector", "Input", "FGLoader", "WheelHue1 = Input { Value = 0.18, }, WheelSaturation1 = Input { Value = 1.35, }, WheelTintAngle1 = Input { Value = -0.35, }, WheelTintLength1 = Input { Value = 0.65, }, ShadowsRGBGain = Input { Value = 0.7, }, MidtonesRGBGamma = Input { Value = 1.35, }, HighlightsRGBGain = Input { Value = 1.3, }, PreDividePostMultiply = Input { Value = 1, },", over_dark=True) |
| 277 | add_op("CC_SMH_TintMode0", "ColorCorrector", "Input", "ColorLoader", "WheelTintAngle2 = Input { Value = 0.25, }, WheelTintLength2 = Input { Value = 0.7, }, WheelHue3 = Input { Value = -0.2, }, WheelSaturation4 = Input { Value = 1.6, }, TintMode = Input { Value = 0, },") |
| 278 | add_op("CC_SMH_TintMode1", "ColorCorrector", "Input", "ColorLoader", "WheelTintAngle1 = Input { Value = -0.25, }, WheelTintLength1 = Input { Value = 0.8, }, WheelSaturation1 = Input { Value = 1.4, }, TintMode = Input { Value = 1, },") |
| 279 | |
| 280 | # ColorCurves & HueCurves |
| 281 | add_op("ColorCurves_RGBA_PreDiv1", "ColorCurves", "Input", "ColorLoader", 'Red = Input { SourceOp = "CC_Red", Source = "Value", }, Green = Input { SourceOp = "CC_Green", Source = "Value", }, Blue = Input { SourceOp = "CC_Blue", Source = "Value", }, Alpha = Input { SourceOp = "CC_Alpha", Source = "Value", }, PreDividePostMultiply = Input { Value = 1, },', over_dark=True) |
| 282 | add_op("HueCurves_Multi", "HueCurves", "Input", "ColorLoader", 'Hue = Input { SourceOp = "HC_Hue", Source = "Value", }, Sat = Input { SourceOp = "HC_Sat", Source = "Value", }, Lum = Input { SourceOp = "HC_Lum", Source = "Value", }, RedSuppress = Input { SourceOp = "HC_RSup", Source = "Value", },') |
| 283 | |
| 284 | # GamutConvert |
| 285 | add_op("Gamut_sRGB_to_Linear", "GamutConvert", "Input", "ColorLoader", 'SourceSpace = Input { Value = FuID { "sRGB" }, }, OutputSpace = Input { Value = FuID { "NoChange" }, }, RemoveGamma = Input { Value = 1, }, AddGamma = Input { Value = 0, },') |
| 286 | add_op("Gamut_Linear_to_sRGB", "GamutConvert", "Input", "ColorLoader", 'SourceSpace = Input { Value = FuID { "NoChange" }, }, OutputSpace = Input { Value = FuID { "sRGB" }, }, RemoveGamma = Input { Value = 0, }, AddGamma = Input { Value = 1, },') |
| 287 | add_op("Gamut_Rec709_to_sRGB", "GamutConvert", "Input", "ColorLoader", 'SourceSpace = Input { Value = FuID { "Rec709" }, }, OutputSpace = Input { Value = FuID { "sRGB" }, }, RemoveGamma = Input { Value = 1, }, AddGamma = Input { Value = 1, },') |
| 288 | |
| 289 | # ChannelBoolean: Add/Sub/Mul/Div/Copy/Min/Max/Negative/Solid |
| 290 | cb_ops = [ |
| 291 | ("CB_Copy_BGR", 0, 'ToRed = Input { Value = 2, }, ToGreen = Input { Value = 1, }, ToBlue = Input { Value = 0, },'), |
| 292 | ("CB_Add", 1, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 293 | ("CB_Sub", 2, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 294 | ("CB_Mul", 6, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 295 | ("CB_Div", 7, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 296 | ("CB_Max", 8, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 297 | ("CB_Min", 9, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 298 | ("CB_Negative", 10, 'Foreground = Input { SourceOp = "FGLoader", Source = "Output", },'), |
| 299 | ("CB_Solid", 11, ''), |
| 300 | ] |
| 301 | for label, op_code, extra in cb_ops: |
| 302 | add_op(label, "ChannelBoolean", "Background", "ColorLoader", f"Operation = Input {{ Value = {op_code}, }}, {extra}") |
| 303 | |
| 304 | # Blur (Gaussian, Box, FastGaussian + unlocked X/Y) |
| 305 | add_op("Blur_Gaussian_XY", "Blur", "Input", "ColorLoader", 'Filter = Input { Value = FuID { "Gaussian" }, }, LockBlurXY = Input { Value = 0, }, XBlurSize = Input { Value = 16.0, }, YBlurSize = Input { Value = 3.0, },') |
| 306 | add_op("Blur_Box_12", "Blur", "Input", "ColorLoader", 'Filter = Input { Value = FuID { "Box" }, }, XBlurSize = Input { Value = 12.0, },') |
| 307 | add_op("Blur_FastGauss_XY", "Blur", "Input", "ColorLoader", 'Filter = Input { Value = FuID { "Fast Gaussian" }, }, LockBlurXY = Input { Value = 0, }, XBlurSize = Input { Value = 4.0, }, YBlurSize = Input { Value = 20.0, },') |
| 308 | |
| 309 | # Glow, SoftGlow, DirectionalBlur |
| 310 | add_op("Glow_UnlockedXY", "Glow", "Input", "FGLoader", "LockGlowSize = Input { Value = 0, }, XGlowSize = Input { Value = 18.0, }, YGlowSize = Input { Value = 3.0, }, Glow = Input { Value = 0.78, },", over_dark=True) |
| 311 | add_op("SoftGlow_UnlockedXY_Thresh", "SoftGlow", "Input", "ColorLoader", "LockGlowSize = Input { Value = 0, }, XGlowSize = Input { Value = 16.0, }, YGlowSize = Input { Value = 4.0, }, Gain = Input { Value = 2.2, }, Threshold = Input { Value = 0.45, },") |
| 312 | add_op("DirBlur_Centered_Glow", "DirectionalBlur", "Input", "ColorLoader", "Type = Input { Value = 2, }, Length = Input { Value = 0.08, }, Angle = Input { Value = 35.0, }, Glow = Input { Value = 0.35, }, Center = Input { Value = { 0.4, 0.6 }, },") |
| 313 | |
| 314 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "CB") |
| 315 | nodes.extend(sw_nodes) |
| 316 | nodes.append(make_saver(out_op, "matrix_color_blur")) |
| 317 | comp_path = ensure_dirs() / "comps" / "matrix_color_blur.comp" |
| 318 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 319 | return comp_path, "matrix_color_blur", [(c[0], c[1]) for c in cases] |
| 320 | |
| 321 | |
| 322 | def build_matrix_warps_shapes(assets: Dict[str, str]): |
| 323 | """Transform (Edges=0/1/2/3, Pivot, Angle, Aspect), DVE, CornerPositioner, Displace, Drip, Dent, Vortex, sRender+s*.""" |
| 324 | nodes = [ |
| 325 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 326 | make_loader("BumpLoader", assets["bump"], post_mult=1), |
| 327 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, },""", |
| 328 | ] |
| 329 | cases: List[Tuple[int, str, str]] = [] |
| 330 | f = 0 |
| 331 | |
| 332 | for ed in (0, 1, 2, 3): |
| 333 | opn = f"Op_{f}" |
| 334 | nodes.append(f'\t\t{opn} = Transform {{ Inputs = {{ Input = Input {{ SourceOp = "ColorLoader", Source = "Output", }}, Center = Input {{ Value = {{ 0.72, 0.65 }}, }}, Pivot = Input {{ Value = {{ 0.25, 0.35 }}, }}, Size = Input {{ Value = 0.80, }}, Aspect = Input {{ Value = 1.35, }}, Angle = Input {{ Value = 28.0, }}, Edges = Input {{ Value = {ed}, }}, }}, }},') |
| 335 | cases.append((f, f"Transform_Edges={ed}_Pivot_Aspect", opn)) |
| 336 | f += 1 |
| 337 | |
| 338 | warps = [ |
| 339 | ("DVE_3D_Pivot", "DVE", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, XRotation = Input { Value = 32, }, YRotation = Input { Value = -35, }, ZRotation = Input { Value = 18, }, ZMove = Input { Value = 1.35, }, Pivot = Input { Value = { 0.3, 0.6 }, }, Center = Input { Value = { 0.45, 0.55 }, },'), |
| 340 | ("CornerPositioner_Quad", "CornerPositioner", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, TopLeft = Input { Value = { 0.15, 0.88 }, }, TopRight = Input { Value = { 0.92, 0.78 }, }, BottomLeft = Input { Value = { 0.08, 0.12 }, }, BottomRight = Input { Value = { 0.82, 0.22 }, },'), |
| 341 | ("Displace_Radial_Light", "Displace", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Foreground = Input { SourceOp = "BumpLoader", Source = "Output", }, Type = Input { Value = 0, }, RefractionStrength = Input { Value = 0.12, }, Spread = Input { Value = 0.25, }, LightPower = Input { Value = 0.6, },'), |
| 342 | ("Displace_XY_Offset", "Displace", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Foreground = Input { SourceOp = "BumpLoader", Source = "Output", }, Type = Input { Value = 1, }, XOffset = Input { Value = -0.5, }, YOffset = Input { Value = -0.5, }, XRefraction = Input { Value = 0.10, }, YRefraction = Input { Value = 0.08, },'), |
| 343 | ("Drip_Concentric", "Drip", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Center = Input { Value = { 0.45, 0.55 }, }, Strength = Input { Value = 1.0, }, Amplitude = Input { Value = 0.10, }, Frequency = Input { Value = 5.0, }, Phase = Input { Value = 0.4, }, Shape = Input { Value = 0, },'), |
| 344 | ("Dent_Bulge", "Dent", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Center = Input { Value = { 0.5, 0.5 }, }, Size = Input { Value = 0.65, }, Strength = Input { Value = 0.75, }, Type = Input { Value = 0, },'), |
| 345 | ("Dent_Pinch", "Dent", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Center = Input { Value = { 0.45, 0.55 }, }, Size = Input { Value = 0.60, }, Strength = Input { Value = 0.70, }, Type = Input { Value = 2, },'), |
| 346 | ("Vortex_Swirl", "Vortex", 'Input = Input { SourceOp = "ColorLoader", Source = "Output", }, Center = Input { Value = { 0.4, 0.6 }, }, Size = Input { Value = 0.65, }, Angle = Input { Value = 2.4, }, Power = Input { Value = 2.2, },'), |
| 347 | ] |
| 348 | for label, kind, inputs in warps: |
| 349 | opn = f"Op_{f}" |
| 350 | nodes.append(f"\t\t{opn} = {kind} {{ Inputs = {{ {inputs} }}, }},") |
| 351 | cases.append((f, label, opn)) |
| 352 | f += 1 |
| 353 | |
| 354 | # sRender + sNGon / sRectangle / sEllipse / sTransform / sMerge / sBoolean / sOutline |
| 355 | nodes.append( |
| 356 | """\t\tS_NGon = sNGon { Inputs = { Sides = Input { Value = 5, }, Width = Input { Value = 0.45, }, Height = Input { Value = 0.45, }, Red = Input { Value = 0.95, }, Green = Input { Value = 0.3, }, Blue = Input { Value = 0.2, }, }, }, |
| 357 | \t\tS_Rect = sRectangle { Inputs = { Width = Input { Value = 0.35, }, Height = Input { Value = 0.35, }, CornerRadius = Input { Value = 0.08, }, ["Translate.X"] = Input { Value = 0.18, }, Red = Input { Value = 0.2, }, Green = Input { Value = 0.85, }, Blue = Input { Value = 0.4, }, }, }, |
| 358 | \t\tS_Ell = sEllipse { Inputs = { Width = Input { Value = 0.32, }, Height = Input { Value = 0.24, }, ["Translate.X"] = Input { Value = -0.15, }, ["Translate.Y"] = Input { Value = 0.15, }, Red = Input { Value = 0.25, }, Green = Input { Value = 0.55, }, Blue = Input { Value = 0.98, }, }, }, |
| 359 | \t\tS_XF = sTransform { Inputs = { Input = Input { SourceOp = "S_NGon", Source = "Output", }, XOffset = Input { Value = -0.15, }, YOffset = Input { Value = -0.10, }, ZRotation = Input { Value = 25.0, }, XSize = Input { Value = 0.85, }, YSize = Input { Value = 0.85, }, }, }, |
| 360 | \t\tS_Merge = sMerge { Inputs = { Input1 = Input { SourceOp = "S_XF", Source = "Output", }, Input2 = Input { SourceOp = "S_Rect", Source = "Output", }, }, }, |
| 361 | \t\tS_BoolSub = sBoolean { Inputs = { Operation = Input { Value = FuID { "Subtract" }, }, Input1 = Input { SourceOp = "S_Rect", Source = "Output", }, Input2 = Input { SourceOp = "S_Ell", Source = "Output", }, }, }, |
| 362 | \t\tS_BoolXor = sBoolean { Inputs = { Operation = Input { Value = FuID { "Xor" }, }, Input1 = Input { SourceOp = "S_NGon", Source = "Output", }, Input2 = Input { SourceOp = "S_Rect", Source = "Output", }, }, }, |
| 363 | \t\tS_Outl = sOutline { Inputs = { Input = Input { SourceOp = "S_Ell", Source = "Output", }, Thickness = Input { Value = 0.03, }, }, },""" |
| 364 | ) |
| 365 | for label, s_src in [ |
| 366 | ("sRender_NGon_XF_Merge", "S_Merge"), |
| 367 | ("sRender_sBoolean_Sub", "S_BoolSub"), |
| 368 | ("sRender_sBoolean_Xor", "S_BoolXor"), |
| 369 | ("sRender_sOutline_Ell", "S_Outl"), |
| 370 | ]: |
| 371 | opn = f"Op_{f}" |
| 372 | nodes.append(f'\t\t{opn} = sRender {{ Inputs = {{ Width = Input {{ Value = 256, }}, Height = Input {{ Value = 256, }}, Input = Input {{ SourceOp = "{s_src}", Source = "Output", }}, }}, }},') |
| 373 | cases.append((f, label, opn)) |
| 374 | f += 1 |
| 375 | |
| 376 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "WS") |
| 377 | nodes.extend(sw_nodes) |
| 378 | nodes.append(make_saver(out_op, "matrix_warps_shapes")) |
| 379 | comp_path = ensure_dirs() / "comps" / "matrix_warps_shapes.comp" |
| 380 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 381 | return comp_path, "matrix_warps_shapes", [(c[0], c[1]) for c in cases] |
| 382 | |
| 383 | |
| 384 | def build_matrix_3d(assets: Dict[str, str]): |
| 385 | """Cube3D, SurfaceFBXMesh, TextureTransformOperator, BumpMap, LightPoint (Linear/Quad), LightSpot, Duplicate3D, Displace3D, Override3D, ReplaceMaterial3D.""" |
| 386 | nodes = [ |
| 387 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 388 | make_loader("BumpLoader", assets["bump"], post_mult=1), |
| 389 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 390 | \t\tCamBase = Camera3D { Inputs = { ["Transform3DOp.Translate.Z"] = Input { Value = 4.2, }, AoV = Input { Value = 35.0, }, FilmGate = Input { Value = FuID { "User" }, }, ApertureW = Input { Value = 1.0, }, ApertureH = Input { Value = 1.0, }, }, }, |
| 391 | \t\tAmbLow = LightAmbient { Inputs = { Intensity = Input { Value = 0.20, }, }, },""", |
| 392 | ] |
| 393 | cases: List[Tuple[int, str, str]] = [] |
| 394 | f = 0 |
| 395 | |
| 396 | def add_3d(label: str, scene_nodes: List[str], merge_inputs: str, lighting: int = 1) -> None: |
| 397 | nonlocal f |
| 398 | nodes.extend(scene_nodes) |
| 399 | m3d = f"M3D_{f}" |
| 400 | rnd = f"Op_{f}" |
| 401 | nodes.append(f"\t\t{m3d} = Merge3D {{ Inputs = {{ {merge_inputs} SceneInput9 = Input {{ SourceOp = \"CamBase\", Source = \"Output\", }}, }}, }},") |
| 402 | nodes.append(f'\t\t{rnd} = Renderer3D {{ Inputs = {{ Width = Input {{ Value = 256, }}, Height = Input {{ Value = 256, }}, ["RendererSoftware.LightingEnabled"] = Input {{ Value = {lighting}, }}, SceneInput = Input {{ SourceOp = "{m3d}", Source = "Output", }}, }}, }},') |
| 403 | cases.append((f, label, rnd)) |
| 404 | f += 1 |
| 405 | |
| 406 | # 0: Cube3D textured |
| 407 | add_3d( |
| 408 | "Cube3D_Textured", |
| 409 | [ |
| 410 | '\t\tTex0 = Texture2DOperator { Inputs = { Input = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 411 | '\t\tCube0 = Cube3D { Inputs = { ["SurfaceCubeInputs.Size"] = Input { Value = 1.4, }, ["Transform3DOp.Rotate.X"] = Input { Value = 25, }, ["Transform3DOp.Rotate.Y"] = Input { Value = 35, }, MaterialInput = Input { SourceOp = "Tex0", Source = "MaterialOutput", }, }, },', |
| 412 | ], |
| 413 | 'SceneInput1 = Input { SourceOp = "Cube0", Source = "Output", },', |
| 414 | lighting=0, |
| 415 | ) |
| 416 | |
| 417 | # 1: SurfaceFBXMesh (cube.obj) |
| 418 | add_3d( |
| 419 | "SurfaceFBXMesh_OBJ", |
| 420 | [ |
| 421 | '\t\tTex1 = Texture2DOperator { Inputs = { Input = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 422 | f'\t\tFbx1 = SurfaceFBXMesh {{ Inputs = {{ ImportFile = Input {{ Value = "{assets["cube_obj"]}", }}, ["Transform3DOp.Scale.X"] = Input {{ Value = 1.5, }}, ["Transform3DOp.Scale.Y"] = Input {{ Value = 1.5, }}, ["Transform3DOp.Scale.Z"] = Input {{ Value = 1.5, }}, ["Transform3DOp.Rotate.X"] = Input {{ Value = 25, }}, ["Transform3DOp.Rotate.Y"] = Input {{ Value = -35, }}, MaterialInput = Input {{ SourceOp = "Tex1", Source = "MaterialOutput", }}, }}, }},', |
| 423 | ], |
| 424 | 'SceneInput1 = Input { SourceOp = "Fbx1", Source = "Output", },', |
| 425 | lighting=0, |
| 426 | ) |
| 427 | |
| 428 | # 2: TextureTransformOperator |
| 429 | add_3d( |
| 430 | "TextureTransformOperator", |
| 431 | [ |
| 432 | '\t\tTex2 = Texture2DOperator { Inputs = { Input = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 433 | '\t\tTexXf2 = TextureTransformOperator { Inputs = { MaterialInput = Input { SourceOp = "Tex2", Source = "MaterialOutput", }, ["TranslationOffset.X"] = Input { Value = 0.25, }, ["TranslationOffset.Y"] = Input { Value = -0.15, }, ["Scale.X"] = Input { Value = 2.0, }, ["Scale.Y"] = Input { Value = 2.0, }, ["Rotation.Z"] = Input { Value = 30.0, }, WrapMode = Input { Value = FuID { "Wrap" }, }, }, },', |
| 434 | '\t\tPl2 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfacePlaneInputs" }, }, ["SurfacePlaneInputs.Width"] = Input { Value = 2.2, }, ["SurfacePlaneInputs.Height"] = Input { Value = 2.2, }, MaterialInput = Input { SourceOp = "TexXf2", Source = "MaterialOutput", }, }, },', |
| 435 | ], |
| 436 | 'SceneInput1 = Input { SourceOp = "Pl2", Source = "Output", },', |
| 437 | lighting=0, |
| 438 | ) |
| 439 | |
| 440 | # 3: BumpMap + MtlBlinn + LightPoint |
| 441 | add_3d( |
| 442 | "BumpMap_MtlBlinn", |
| 443 | [ |
| 444 | '\t\tBm3 = BumpMap { Inputs = { Input = Input { SourceOp = "BumpLoader", Source = "Output", }, HeightScale = Input { Value = 4.0, }, }, },', |
| 445 | '\t\tMtl3 = MtlBlinn { Inputs = { ["Diffuse.Color.Red"] = Input { Value = 0.3, }, ["Diffuse.Color.Green"] = Input { Value = 0.7, }, ["Diffuse.Color.Blue"] = Input { Value = 0.95, }, ["Specular.Intensity"] = Input { Value = 1.0, }, ["Specular.Exponent"] = Input { Value = 28.0, }, ["Bumpmap.Material"] = Input { SourceOp = "Bm3", Source = "MaterialOutput", }, }, },', |
| 446 | '\t\tSph3 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfaceSphereInputs" }, }, ["SurfaceSphereInputs.Radius"] = Input { Value = 1.0, }, MaterialInput = Input { SourceOp = "Mtl3", Source = "MaterialOutput", }, }, },', |
| 447 | '\t\tPt3 = LightPoint { Inputs = { ["Transform3DOp.Translate.X"] = Input { Value = 2.2, }, ["Transform3DOp.Translate.Y"] = Input { Value = 1.8, }, ["Transform3DOp.Translate.Z"] = Input { Value = 2.8, }, Intensity = Input { Value = 1.4, }, }, },', |
| 448 | ], |
| 449 | 'SceneInput1 = Input { SourceOp = "Sph3", Source = "Output", }, SceneInput2 = Input { SourceOp = "Pt3", Source = "Output", }, SceneInput3 = Input { SourceOp = "AmbLow", Source = "Output", },', |
| 450 | lighting=1, |
| 451 | ) |
| 452 | |
| 453 | # 4 & 5: LightPoint Linear (DecayType=1) and Quadratic (DecayType=2) |
| 454 | for decay_t, d_name in ((1, "Linear"), (2, "Quadratic")): |
| 455 | add_3d( |
| 456 | f"LightPoint_Decay={d_name}", |
| 457 | [ |
| 458 | f'\t\tMtl_{f} = MtlBlinn {{ Inputs = {{ ["Diffuse.Color.Red"] = Input {{ Value = 0.9, }}, ["Diffuse.Color.Green"] = Input {{ Value = 0.85, }}, ["Diffuse.Color.Blue"] = Input {{ Value = 0.75, }}, }}, }},', |
| 459 | f'\t\tPl_{f} = Shape3D {{ Inputs = {{ Shape = Input {{ Value = FuID {{ "SurfacePlaneInputs" }}, }}, ["SurfacePlaneInputs.Width"] = Input {{ Value = 2.8, }}, ["SurfacePlaneInputs.Height"] = Input {{ Value = 2.8, }}, MaterialInput = Input {{ SourceOp = "Mtl_{f}", Source = "MaterialOutput", }}, }}, }},', |
| 460 | f'\t\tPt_{f} = LightPoint {{ Inputs = {{ ["Transform3DOp.Translate.X"] = Input {{ Value = 0.8, }}, ["Transform3DOp.Translate.Y"] = Input {{ Value = 0.5, }}, ["Transform3DOp.Translate.Z"] = Input {{ Value = 1.6, }}, Intensity = Input {{ Value = 3.5, }}, DecayType = Input {{ Value = {decay_t}, }}, }}, }},', |
| 461 | ], |
| 462 | f'SceneInput1 = Input {{ SourceOp = "Pl_{f}", Source = "Output", }}, SceneInput2 = Input {{ SourceOp = "Pt_{f}", Source = "Output", }}, SceneInput3 = Input {{ SourceOp = "AmbLow", Source = "Output", }},', |
| 463 | lighting=1, |
| 464 | ) |
| 465 | |
| 466 | # 6: LightSpot |
| 467 | add_3d( |
| 468 | "LightSpot_ConePenumbra", |
| 469 | [ |
| 470 | '\t\tMtl6 = MtlCookTorrance { Inputs = { ["Diffuse.Color.Red"] = Input { Value = 0.95, }, ["Diffuse.Color.Green"] = Input { Value = 0.75, }, ["Diffuse.Color.Blue"] = Input { Value = 0.45, }, ["Specular.Roughness"] = Input { Value = 0.3, }, }, },', |
| 471 | '\t\tPl6 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfacePlaneInputs" }, }, ["SurfacePlaneInputs.Width"] = Input { Value = 3.0, }, ["SurfacePlaneInputs.Height"] = Input { Value = 3.0, }, MaterialInput = Input { SourceOp = "Mtl6", Source = "MaterialOutput", }, }, },', |
| 472 | '\t\tSp6 = LightSpot { Inputs = { ["Transform3DOp.Translate.X"] = Input { Value = -0.5, }, ["Transform3DOp.Translate.Z"] = Input { Value = 2.5, }, ["Transform3DOp.Rotate.Y"] = Input { Value = -10, }, ConeAngle = Input { Value = 35.0, }, PenumbraAngle = Input { Value = 12.0, }, Intensity = Input { Value = 1.8, }, DecayType = Input { Value = 1, }, }, },', |
| 473 | ], |
| 474 | 'SceneInput1 = Input { SourceOp = "Pl6", Source = "Output", }, SceneInput2 = Input { SourceOp = "Sp6", Source = "Output", }, SceneInput3 = Input { SourceOp = "AmbLow", Source = "Output", },', |
| 475 | lighting=1, |
| 476 | ) |
| 477 | |
| 478 | # 7: Duplicate3D |
| 479 | add_3d( |
| 480 | "Duplicate3D_5x", |
| 481 | [ |
| 482 | '\t\tBox7 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfaceCubeInputs" }, }, ["SurfaceCubeInputs.Size"] = Input { Value = 0.35, }, ["Transform3DOp.Translate.X"] = Input { Value = -1.1, }, ["MtlStdInputs.Diffuse.Color.Red"] = Input { Value = 0.95, }, ["MtlStdInputs.Diffuse.Color.Green"] = Input { Value = 0.45, }, ["MtlStdInputs.Diffuse.Color.Blue"] = Input { Value = 0.15, }, }, },', |
| 483 | '\t\tDup7 = Duplicate3D { Inputs = { SceneInput = Input { SourceOp = "Box7", Source = "Output", }, FirstCopy = Input { Value = 0, }, LastCopy = Input { Value = 4, }, ["Translate.X"] = Input { Value = 0.55, }, ["Rotate.Z"] = Input { Value = 18.0, }, }, },', |
| 484 | ], |
| 485 | 'SceneInput1 = Input { SourceOp = "Dup7", Source = "Output", },', |
| 486 | lighting=0, |
| 487 | ) |
| 488 | |
| 489 | # 8: Displace3D |
| 490 | add_3d( |
| 491 | "Displace3D_Bump", |
| 492 | [ |
| 493 | '\t\tPl8 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfacePlaneInputs" }, }, ["SurfacePlaneInputs.Width"] = Input { Value = 2.0, }, ["SurfacePlaneInputs.Height"] = Input { Value = 2.0, }, ["SurfacePlaneInputs.SubdivisionWidth"] = Input { Value = 32, }, ["SurfacePlaneInputs.SubdivisionHeight"] = Input { Value = 32, }, ["Transform3DOp.Rotate.X"] = Input { Value = -38.0, }, MaterialInput = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 494 | '\t\tDisp8 = Displace3D { Inputs = { SceneInput = Input { SourceOp = "Pl8", Source = "Output", }, Input = Input { SourceOp = "BumpLoader", Source = "Output", }, Scale = Input { Value = 0.6, }, }, },', |
| 495 | ], |
| 496 | 'SceneInput1 = Input { SourceOp = "Disp8", Source = "Output", },', |
| 497 | lighting=0, |
| 498 | ) |
| 499 | |
| 500 | # 9: Override3D (hide + material override) |
| 501 | add_3d( |
| 502 | "Override3D_Hide_MatOvr", |
| 503 | [ |
| 504 | '\t\tSph9L = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfaceSphereInputs" }, }, ["SurfaceSphereInputs.Radius"] = Input { Value = 0.55, }, ["Transform3DOp.Translate.X"] = Input { Value = -0.7, }, ["MtlStdInputs.Diffuse.Color.Red"] = Input { Value = 0.9, }, ["MtlStdInputs.Diffuse.Color.Green"] = Input { Value = 0.2, }, ["MtlStdInputs.Diffuse.Color.Blue"] = Input { Value = 0.2, }, }, },', |
| 505 | '\t\tOvr9Hide = Override3D { Inputs = { SceneInput = Input { SourceOp = "Sph9L", Source = "Output", }, ["Visibility.DoVisible"] = Input { Value = 1, }, ["Visibility.IsVisible"] = Input { Value = 0, }, }, },', |
| 506 | '\t\tSph9R = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfaceSphereInputs" }, }, ["SurfaceSphereInputs.Radius"] = Input { Value = 0.55, }, ["Transform3DOp.Translate.X"] = Input { Value = 0.7, }, }, },', |
| 507 | '\t\tTex9 = Texture2DOperator { Inputs = { Input = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 508 | '\t\tOvr9Mat = Override3D { Inputs = { SceneInput = Input { SourceOp = "Sph9R", Source = "Output", }, ["Material.DoMaterial"] = Input { Value = 1, }, MaterialInput = Input { SourceOp = "Tex9", Source = "MaterialOutput", }, }, },', |
| 509 | ], |
| 510 | 'SceneInput1 = Input { SourceOp = "Ovr9Hide", Source = "Output", }, SceneInput2 = Input { SourceOp = "Ovr9Mat", Source = "Output", },', |
| 511 | lighting=0, |
| 512 | ) |
| 513 | |
| 514 | # 10: ReplaceMaterial3D |
| 515 | add_3d( |
| 516 | "ReplaceMaterial3D_Cook", |
| 517 | [ |
| 518 | '\t\tTex10 = Texture2DOperator { Inputs = { Input = Input { SourceOp = "ColorLoader", Source = "Output", }, }, },', |
| 519 | '\t\tMtl10 = MtlCookTorrance { Inputs = { ["Diffuse.Color.Material"] = Input { SourceOp = "Tex10", Source = "MaterialOutput", }, ["Specular.Roughness"] = Input { Value = 0.25, }, }, },', |
| 520 | '\t\tSph10 = Shape3D { Inputs = { Shape = Input { Value = FuID { "SurfaceSphereInputs" }, }, ["SurfaceSphereInputs.Radius"] = Input { Value = 1.0, }, }, },', |
| 521 | '\t\tRep10 = ReplaceMaterial3D { Inputs = { SceneInput = Input { SourceOp = "Sph10", Source = "Output", }, MaterialInput = Input { SourceOp = "Mtl10", Source = "MaterialOutput", }, }, },', |
| 522 | '\t\tPt10 = LightPoint { Inputs = { ["Transform3DOp.Translate.X"] = Input { Value = 2.0, }, ["Transform3DOp.Translate.Y"] = Input { Value = 1.5, }, ["Transform3DOp.Translate.Z"] = Input { Value = 3.0, }, Intensity = Input { Value = 1.2, }, }, },', |
| 523 | ], |
| 524 | 'SceneInput1 = Input { SourceOp = "Rep10", Source = "Output", }, SceneInput2 = Input { SourceOp = "Pt10", Source = "Output", }, SceneInput3 = Input { SourceOp = "AmbLow", Source = "Output", },', |
| 525 | lighting=1, |
| 526 | ) |
| 527 | |
| 528 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "D3D") |
| 529 | nodes.extend(sw_nodes) |
| 530 | nodes.append(make_saver(out_op, "matrix_3d")) |
| 531 | comp_path = ensure_dirs() / "comps" / "matrix_3d.comp" |
| 532 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 533 | return comp_path, "matrix_3d", [(c[0], c[1]) for c in cases] |
| 534 | |
| 535 | |
| 536 | def build_matrix_misc(assets: Dict[str, str]): |
| 537 | """CustomTool (multi-input, getr1b, Setup1, Intermediate1, if), TimeSpeed, Switch, tool-level SourceOp instancing.""" |
| 538 | nodes = [ |
| 539 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 540 | make_loader("FGLoader", assets["fg"], post_mult=1), |
| 541 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 542 | \t\t-- CustomTool 0: Setup1, Intermediate1, if, getr1b, Image2 |
| 543 | \t\tOp_0 = Custom { |
| 544 | \t\t\tInputs = { |
| 545 | \t\t\t\tImage1 = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 546 | \t\t\t\tImage2 = Input { SourceOp = "FGLoader", Source = "Output", }, |
| 547 | \t\t\t\tNumberIn1 = Input { Value = 0.65, }, |
| 548 | \t\t\t\tPointIn1 = Input { Value = { 0.45, 0.55 }, }, |
| 549 | \t\t\t\tSetup1 = Input { Value = "1 - n1", }, |
| 550 | \t\t\t\tIntermediate1 = Input { Value = "max(0, 1 - dist(x, y, p1x, p1y) * 2)", }, |
| 551 | \t\t\t\tRedExpression = Input { Value = "if(x > p1x, getr1b(x - 0.1, y + 0.05), r2 * i1 + s1 * 0.2)", }, |
| 552 | \t\t\t\tGreenExpression = Input { Value = "if(y > p1y, g1 * i1, g2 + n1 * 0.1)", }, |
| 553 | \t\t\t\tBlueExpression = Input { Value = "b1 * (1 - i1) + b2 * i1", }, |
| 554 | \t\t\t\tAlphaExpression = Input { Value = "1", }, |
| 555 | \t\t\t}, |
| 556 | \t\t}, |
| 557 | \t\t-- TimeSpeed (frames 1 & 2 evaluate animated Transform at Speed=2.0, Delay=0.5) |
| 558 | \t\tXfAnim = Transform { |
| 559 | \t\t\tInputs = { |
| 560 | \t\t\t\tInput = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 561 | \t\t\t\tAngle = Input { SourceOp = "TS_Angle", Source = "Value", }, |
| 562 | \t\t\t\tSize = Input { Value = 0.8, }, |
| 563 | \t\t\t}, |
| 564 | \t\t}, |
| 565 | \t\tOp_1 = TimeSpeed { |
| 566 | \t\t\tInputs = { |
| 567 | \t\t\t\tInput = Input { SourceOp = "XfAnim", Source = "Output", }, |
| 568 | \t\t\t\tSpeed = Input { Value = 2.0, }, |
| 569 | \t\t\t\tDelay = Input { Value = 0.5, }, |
| 570 | \t\t\t}, |
| 571 | \t\t}, |
| 572 | \t\t-- Switch (Fusion 21 native Source=0/1 with Input0/Input1) |
| 573 | \t\tOp_2 = Switch { |
| 574 | \t\t\tInputs = { |
| 575 | \t\t\t\tSource = Input { Value = 0, }, |
| 576 | \t\t\t\tInput0 = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 577 | \t\t\t\tInput1 = Input { SourceOp = "FGLoader", Source = "Output", }, |
| 578 | \t\t\t}, |
| 579 | \t\t}, |
| 580 | \t\tOp_3 = Switch { |
| 581 | \t\t\tInputs = { |
| 582 | \t\t\t\tSource = Input { Value = 1, }, |
| 583 | \t\t\t\tInput0 = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 584 | \t\t\t\tInput1 = Input { SourceOp = "FGLoader", Source = "Output", }, |
| 585 | \t\t\t}, |
| 586 | \t\t}, |
| 587 | \t\t-- Tool-level SourceOp instancing |
| 588 | \t\tMasterCC = ColorCorrector { |
| 589 | \t\t\tInputs = { |
| 590 | \t\t\t\tInput = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 591 | \t\t\t\tWheelHue1 = Input { Value = 0.25, }, |
| 592 | \t\t\t\tWheelSaturation1 = Input { Value = 1.45, }, |
| 593 | \t\t\t\tMasterRGBGain = Input { Value = 1.35, }, |
| 594 | \t\t\t\tMasterRGBGamma = Input { Value = 0.85, }, |
| 595 | \t\t\t}, |
| 596 | \t\t}, |
| 597 | \t\tOp_4 = ColorCorrector { |
| 598 | \t\t\tSourceOp = "MasterCC", |
| 599 | \t\t\tInputs = { |
| 600 | \t\t\t\tInput = Input { SourceOp = "FGLoader", Source = "Output", }, |
| 601 | \t\t\t\tWheelHue1 = Input {}, |
| 602 | \t\t\t\tMasterRGBGain = Input { Value = 0.8, }, |
| 603 | \t\t\t}, |
| 604 | \t\t}, |
| 605 | \t\tOp_5 = Merge { |
| 606 | \t\t\tInputs = { |
| 607 | \t\t\t\tBackground = Input { SourceOp = "BlackBG", Source = "Output", }, |
| 608 | \t\t\t\tForeground = Input { SourceOp = "Op_4", Source = "Output", }, |
| 609 | \t\t\t}, |
| 610 | \t\t},""", |
| 611 | linear_spline("TS_Angle", {0: 0.0, 4: 180.0}), |
| 612 | ] |
| 613 | cases = [ |
| 614 | (0, "CustomTool_multi_getr1b_Setup_Inter_if", "Op_0"), |
| 615 | (1, "TimeSpeed_f1_Speed2_Delay0.5", "Op_1"), |
| 616 | (2, "TimeSpeed_f2_Speed2_Delay0.5", "Op_1"), |
| 617 | (3, "Switch_Source0_Input0", "Op_2"), |
| 618 | (4, "Switch_Source1_Input1", "Op_3"), |
| 619 | (5, "SourceOp_Instance_ColorCorrector", "Op_5"), |
| 620 | ] |
| 621 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "MS") |
| 622 | nodes.extend(sw_nodes) |
| 623 | nodes.append(make_saver(out_op, "matrix_misc")) |
| 624 | comp_path = ensure_dirs() / "comps" / "matrix_misc.comp" |
| 625 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 626 | return comp_path, "matrix_misc", [(c[0], c[1]) for c in cases] |
| 627 | |
| 628 | |
| 629 | def build_matrix_paint(assets: Dict[str, str]): |
| 630 | """Paint (PolylineStroke + WriteOnStart/End, BrushControls.Size/Softness, ApplyControls Color/Opacity, PaintApplyColor/Erase), Multistroke, PaintMask.""" |
| 631 | nodes = [ |
| 632 | make_loader("ColorLoader", assets["color"], post_mult=1), |
| 633 | """\t\tBlackBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 634 | \t\tDarkBG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.08, }, TopLeftGreen = Input { Value = 0.10, }, TopLeftBlue = Input { Value = 0.14, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 635 | \t\tWhiteFG = Background { Inputs = { Width = Input { Value = 256, }, Height = Input { Value = 256, }, TopLeftRed = Input { Value = 0.95, }, TopLeftGreen = Input { Value = 0.72, }, TopLeftBlue = Input { Value = 0.22, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 636 | \t\tMaskEll = EllipseMask { Inputs = { MaskWidth = Input { Value = 256, }, MaskHeight = Input { Value = 256, }, Width = Input { Value = 0.65, }, Height = Input { Value = 0.55, }, SoftEdge = Input { Value = 0.03, }, }, },""", |
| 637 | ] |
| 638 | cases: List[Tuple[int, str, str]] = [] |
| 639 | f = 0 |
| 640 | |
| 641 | # 0: PolylineStroke SoftBrush basic |
| 642 | nodes.append( |
| 643 | """\t\tPS_0 = PolylineStroke { |
| 644 | \t\t\tBrushes = { "SoftBrush" }, |
| 645 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 646 | \t\t\tInputs = { |
| 647 | \t\t\t\tBrushControls = Input { Value = 1, }, |
| 648 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 649 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.08, }, |
| 650 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 0.5, }, |
| 651 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.95, }, |
| 652 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.40, }, |
| 653 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 0.12, }, |
| 654 | \t\t\t\t["PaintApplyColor.Opacity"] = Input { Value = 1.0, }, |
| 655 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 656 | \t\t\t\t\t{ X = -0.35, Y = -0.25, RX = 0.15, RY = 0.25 }, |
| 657 | \t\t\t\t\t{ X = 0.35, Y = 0.25, LX = -0.15, LY = -0.25 }, |
| 658 | \t\t\t\t} }, }, |
| 659 | \t\t\t}, |
| 660 | \t\t}, |
| 661 | \t\tOp_0 = Paint { |
| 662 | \t\t\tInputs = { |
| 663 | \t\t\t\tInput = Input { SourceOp = "DarkBG", Source = "Output", }, |
| 664 | \t\t\t\tPaint = Input { SourceOp = "PS_0", Source = "Out", }, |
| 665 | \t\t\t}, |
| 666 | \t\t},""" |
| 667 | ) |
| 668 | cases.append((f, "Paint_Polyline_SoftBrush_0.5", "Op_0")) |
| 669 | f += 1 |
| 670 | |
| 671 | # 1: PolylineStroke SoftBrush Softness=1.0, Opacity=0.75 |
| 672 | nodes.append( |
| 673 | """\t\tPS_1 = PolylineStroke { |
| 674 | \t\t\tBrushes = { "SoftBrush" }, |
| 675 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 676 | \t\t\tInputs = { |
| 677 | \t\t\t\tBrushControls = Input { Value = 1, }, |
| 678 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 679 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.14, }, |
| 680 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 1.0, }, |
| 681 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.20, }, |
| 682 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.90, }, |
| 683 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 0.45, }, |
| 684 | \t\t\t\t["PaintApplyColor.Opacity"] = Input { Value = 0.75, }, |
| 685 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 686 | \t\t\t\t\t{ Linear = true, X = -0.32, Y = 0.22 }, |
| 687 | \t\t\t\t\t{ Linear = true, X = 0.0, Y = -0.20 }, |
| 688 | \t\t\t\t\t{ Linear = true, X = 0.32, Y = 0.18 }, |
| 689 | \t\t\t\t} }, }, |
| 690 | \t\t\t}, |
| 691 | \t\t}, |
| 692 | \t\tOp_1 = Paint { |
| 693 | \t\t\tInputs = { |
| 694 | \t\t\t\tInput = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 695 | \t\t\t\tPaint = Input { SourceOp = "PS_1", Source = "Out", }, |
| 696 | \t\t\t}, |
| 697 | \t\t},""" |
| 698 | ) |
| 699 | cases.append((f, "Paint_Polyline_Soft1_Opacity0.75", "Op_1")) |
| 700 | f += 1 |
| 701 | |
| 702 | # 2: PolylineStroke CircleBrush + WriteOnStart/WriteOnEnd |
| 703 | nodes.append( |
| 704 | """\t\tPS_2 = PolylineStroke { |
| 705 | \t\t\tBrushes = { "CircleBrush" }, |
| 706 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 707 | \t\t\tInputs = { |
| 708 | \t\t\t\tBrushControls = Input { Value = 1, }, |
| 709 | \t\t\t\tBrushShape = Input { Value = FuID { "CircleBrush" }, }, |
| 710 | \t\t\t\t["CircleBrush.Size"] = Input { Value = 0.10, }, |
| 711 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.95, }, |
| 712 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.20, }, |
| 713 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 0.85, }, |
| 714 | \t\t\t\t["PaintApplyColor.Opacity"] = Input { Value = 0.90, }, |
| 715 | \t\t\t\tWriteOnStart = Input { Value = 0.20, }, |
| 716 | \t\t\t\tWriteOnEnd = Input { Value = 0.75, }, |
| 717 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 718 | \t\t\t\t\t{ X = -0.35, Y = 0.0, RX = 0.12, RY = 0.30 }, |
| 719 | \t\t\t\t\t{ X = 0.35, Y = 0.0, LX = -0.12, LY = -0.30 }, |
| 720 | \t\t\t\t} }, }, |
| 721 | \t\t\t}, |
| 722 | \t\t}, |
| 723 | \t\tOp_2 = Paint { |
| 724 | \t\t\tInputs = { |
| 725 | \t\t\t\tInput = Input { SourceOp = "DarkBG", Source = "Output", }, |
| 726 | \t\t\t\tPaint = Input { SourceOp = "PS_2", Source = "Out", }, |
| 727 | \t\t\t}, |
| 728 | \t\t},""" |
| 729 | ) |
| 730 | cases.append((f, "Paint_CircleBrush_WriteOn_0.2_0.75", "Op_2")) |
| 731 | f += 1 |
| 732 | |
| 733 | # 3: PolylineStroke Color -> Erase chain |
| 734 | nodes.append( |
| 735 | """\t\tPS_3a = PolylineStroke { |
| 736 | \t\t\tBrushes = { "CircleBrush" }, |
| 737 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 738 | \t\t\tInputs = { |
| 739 | \t\t\t\tBrushShape = Input { Value = FuID { "CircleBrush" }, }, |
| 740 | \t\t\t\t["CircleBrush.Size"] = Input { Value = 0.16, }, |
| 741 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.95, }, |
| 742 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.95, }, |
| 743 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 0.20, }, |
| 744 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 745 | \t\t\t\t\t{ Linear = true, X = -0.35, Y = 0.0 }, |
| 746 | \t\t\t\t\t{ Linear = true, X = 0.35, Y = 0.0 }, |
| 747 | \t\t\t\t} }, }, |
| 748 | \t\t\t}, |
| 749 | \t\t}, |
| 750 | \t\tPS_3b = PolylineStroke { |
| 751 | \t\t\tBrushes = { "SoftBrush" }, |
| 752 | \t\t\tApplyModes = { "PaintApplyErase" }, |
| 753 | \t\t\tInputs = { |
| 754 | \t\t\t\tPaint = Input { SourceOp = "PS_3a", Source = "Out", }, |
| 755 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 756 | \t\t\t\tApplyMode = Input { Value = FuID { "PaintApplyErase" }, }, |
| 757 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.09, }, |
| 758 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 0.4, }, |
| 759 | \t\t\t\t["PaintApplyErase.Opacity"] = Input { Value = 1.0, }, |
| 760 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 761 | \t\t\t\t\t{ Linear = true, X = 0.0, Y = -0.30 }, |
| 762 | \t\t\t\t\t{ Linear = true, X = 0.0, Y = 0.30 }, |
| 763 | \t\t\t\t} }, }, |
| 764 | \t\t\t}, |
| 765 | \t\t}, |
| 766 | \t\tOp_3 = Paint { |
| 767 | \t\t\tInputs = { |
| 768 | \t\t\t\tInput = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 769 | \t\t\t\tPaint = Input { SourceOp = "PS_3b", Source = "Out", }, |
| 770 | \t\t\t}, |
| 771 | \t\t},""" |
| 772 | ) |
| 773 | cases.append((f, "Paint_Color_Then_Erase", "Op_3")) |
| 774 | f += 1 |
| 775 | |
| 776 | # 4: Multistroke with Time/Frames/Duration & per-stroke Params overrides (tested at frame 4) |
| 777 | nodes.append( |
| 778 | """\t\tMS_4 = Multistroke { |
| 779 | \t\t\tBrushes = { "SoftBrush", "CircleBrush" }, |
| 780 | \t\t\tApplyModes = { "PaintApplyColor", "PaintApplyErase" }, |
| 781 | \t\t\tInputs = { |
| 782 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 783 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.09, }, |
| 784 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 0.5, }, |
| 785 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.25, }, |
| 786 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.75, }, |
| 787 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 1.0, }, |
| 788 | \t\t\t}, |
| 789 | \t\t\tStrokes = { |
| 790 | \t\t\t\t{ |
| 791 | \t\t\t\t\tTime = 0, |
| 792 | \t\t\t\t\tFrames = 10, |
| 793 | \t\t\t\t\tParams = { |
| 794 | \t\t\t\t\t\tDuration = { Value = 10 }, |
| 795 | \t\t\t\t\t\t["SoftBrush.Size"] = { Value = 0.09 }, |
| 796 | \t\t\t\t\t\t["PaintApplyColor.Red"] = { Value = 0.25 }, |
| 797 | \t\t\t\t\t\t["PaintApplyColor.Green"] = { Value = 0.75 }, |
| 798 | \t\t\t\t\t\t["PaintApplyColor.Blue"] = { Value = 1.0 }, |
| 799 | \t\t\t\t\t}, |
| 800 | \t\t\t\t\t{ X = -0.35, Y = -0.20, T = 0 }, |
| 801 | \t\t\t\t\t{ X = 0.35, Y = 0.20, T = 10 }, |
| 802 | \t\t\t\t}, |
| 803 | \t\t\t\t{ |
| 804 | \t\t\t\t\tTime = 3, |
| 805 | \t\t\t\t\tFrames = 4, |
| 806 | \t\t\t\t\tParams = { |
| 807 | \t\t\t\t\t\tDuration = { Value = 4 }, |
| 808 | \t\t\t\t\t\t["SoftBrush.Size"] = { Value = 0.12 }, |
| 809 | \t\t\t\t\t\t["PaintApplyColor.Red"] = { Value = 1.0 }, |
| 810 | \t\t\t\t\t\t["PaintApplyColor.Green"] = { Value = 0.2 }, |
| 811 | \t\t\t\t\t\t["PaintApplyColor.Blue"] = { Value = 0.2 }, |
| 812 | \t\t\t\t\t\t["PaintApplyColor.Opacity"] = { Value = 0.8 }, |
| 813 | \t\t\t\t\t}, |
| 814 | \t\t\t\t\t{ X = -0.30, Y = 0.25, T = 0 }, |
| 815 | \t\t\t\t\t{ X = 0.30, Y = -0.25, T = 10 }, |
| 816 | \t\t\t\t}, |
| 817 | \t\t\t\t{ |
| 818 | \t\t\t\t\tTime = 0, |
| 819 | \t\t\t\t\tFrames = 2, |
| 820 | \t\t\t\t\tParams = { Duration = { Value = 2 }, }, |
| 821 | \t\t\t\t\t{ X = 0.0, Y = 0.0, T = 0 }, |
| 822 | \t\t\t\t}, |
| 823 | \t\t\t}, |
| 824 | \t\t}, |
| 825 | \t\tOp_4 = Paint { |
| 826 | \t\t\tInputs = { |
| 827 | \t\t\t\tInput = Input { SourceOp = "DarkBG", Source = "Output", }, |
| 828 | \t\t\t\tPaint = Input { SourceOp = "MS_4", Source = "Out", }, |
| 829 | \t\t\t}, |
| 830 | \t\t},""" |
| 831 | ) |
| 832 | cases.append((f, "Paint_Multistroke_Timed_Params", "Op_4")) |
| 833 | f += 1 |
| 834 | |
| 835 | # 5: PaintMask with SoftEdge + Level |
| 836 | nodes.append( |
| 837 | """\t\tPS_5 = PolylineStroke { |
| 838 | \t\t\tBrushes = { "SoftBrush" }, |
| 839 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 840 | \t\t\tInputs = { |
| 841 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 842 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.12, }, |
| 843 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 0.5, }, |
| 844 | \t\t\t\t["PaintApplyColor.Opacity"] = Input { Value = 0.85, }, |
| 845 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 846 | \t\t\t\t\t{ X = -0.30, Y = -0.25, RX = 0.20, RY = 0.0 }, |
| 847 | \t\t\t\t\t{ X = 0.30, Y = 0.25, LX = -0.20, LY = 0.0 }, |
| 848 | \t\t\t\t} }, }, |
| 849 | \t\t\t}, |
| 850 | \t\t}, |
| 851 | \t\tPM_5 = PaintMask { |
| 852 | \t\t\tInputs = { |
| 853 | \t\t\t\tMaskWidth = Input { Value = 256, }, |
| 854 | \t\t\t\tMaskHeight = Input { Value = 256, }, |
| 855 | \t\t\t\tSoftEdge = Input { Value = 0.02, }, |
| 856 | \t\t\t\tLevel = Input { Value = 0.9, }, |
| 857 | \t\t\t\tPaint = Input { SourceOp = "PS_5", Source = "Out", }, |
| 858 | \t\t\t}, |
| 859 | \t\t}, |
| 860 | \t\tOp_5 = Merge { |
| 861 | \t\t\tInputs = { |
| 862 | \t\t\t\tBackground = Input { SourceOp = "BlackBG", Source = "Output", }, |
| 863 | \t\t\t\tForeground = Input { SourceOp = "WhiteFG", Source = "Output", }, |
| 864 | \t\t\t\tEffectMask = Input { SourceOp = "PM_5", Source = "Mask", }, |
| 865 | \t\t\t}, |
| 866 | \t\t},""" |
| 867 | ) |
| 868 | cases.append((f, "PaintMask_SoftEdge_Level", "Op_5")) |
| 869 | f += 1 |
| 870 | |
| 871 | # 6: PaintMask with Erase + Invert=1 |
| 872 | nodes.append( |
| 873 | """\t\tPS_6a = PolylineStroke { |
| 874 | \t\t\tBrushes = { "CircleBrush" }, |
| 875 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 876 | \t\t\tInputs = { |
| 877 | \t\t\t\tBrushShape = Input { Value = FuID { "CircleBrush" }, }, |
| 878 | \t\t\t\t["CircleBrush.Size"] = Input { Value = 0.18, }, |
| 879 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 880 | \t\t\t\t\t{ Linear = true, X = -0.32, Y = 0.0 }, |
| 881 | \t\t\t\t\t{ Linear = true, X = 0.32, Y = 0.0 }, |
| 882 | \t\t\t\t} }, }, |
| 883 | \t\t\t}, |
| 884 | \t\t}, |
| 885 | \t\tPS_6b = PolylineStroke { |
| 886 | \t\t\tBrushes = { "CircleBrush" }, |
| 887 | \t\t\tApplyModes = { "PaintApplyErase" }, |
| 888 | \t\t\tInputs = { |
| 889 | \t\t\t\tPaint = Input { SourceOp = "PS_6a", Source = "Out", }, |
| 890 | \t\t\t\tBrushShape = Input { Value = FuID { "CircleBrush" }, }, |
| 891 | \t\t\t\tApplyMode = Input { Value = FuID { "PaintApplyErase" }, }, |
| 892 | \t\t\t\t["CircleBrush.Size"] = Input { Value = 0.08, }, |
| 893 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 894 | \t\t\t\t\t{ Linear = true, X = 0.0, Y = -0.25 }, |
| 895 | \t\t\t\t\t{ Linear = true, X = 0.0, Y = 0.25 }, |
| 896 | \t\t\t\t} }, }, |
| 897 | \t\t\t}, |
| 898 | \t\t}, |
| 899 | \t\tPM_6 = PaintMask { |
| 900 | \t\t\tInputs = { |
| 901 | \t\t\t\tMaskWidth = Input { Value = 256, }, |
| 902 | \t\t\t\tMaskHeight = Input { Value = 256, }, |
| 903 | \t\t\t\tInvert = Input { Value = 1, }, |
| 904 | \t\t\t\tPaint = Input { SourceOp = "PS_6b", Source = "Out", }, |
| 905 | \t\t\t}, |
| 906 | \t\t}, |
| 907 | \t\tOp_6 = Merge { |
| 908 | \t\t\tInputs = { |
| 909 | \t\t\t\tBackground = Input { SourceOp = "BlackBG", Source = "Output", }, |
| 910 | \t\t\t\tForeground = Input { SourceOp = "WhiteFG", Source = "Output", }, |
| 911 | \t\t\t\tEffectMask = Input { SourceOp = "PM_6", Source = "Mask", }, |
| 912 | \t\t\t}, |
| 913 | \t\t},""" |
| 914 | ) |
| 915 | cases.append((f, "PaintMask_Erase_Invert1", "Op_6")) |
| 916 | f += 1 |
| 917 | |
| 918 | # 7: Paint with Blend=0.6 + EffectMask (dedicated PolylineStroke so Fusion does not share PS_0) |
| 919 | nodes.append( |
| 920 | """\t\tPS_7 = PolylineStroke { |
| 921 | \t\t\tBrushes = { "SoftBrush" }, |
| 922 | \t\t\tApplyModes = { "PaintApplyColor" }, |
| 923 | \t\t\tInputs = { |
| 924 | \t\t\t\tBrushControls = Input { Value = 1, }, |
| 925 | \t\t\t\tBrushShape = Input { Value = FuID { "SoftBrush" }, }, |
| 926 | \t\t\t\t["SoftBrush.Size"] = Input { Value = 0.08, }, |
| 927 | \t\t\t\t["SoftBrush.Softness"] = Input { Value = 0.5, }, |
| 928 | \t\t\t\t["PaintApplyColor.Red"] = Input { Value = 0.95, }, |
| 929 | \t\t\t\t["PaintApplyColor.Green"] = Input { Value = 0.40, }, |
| 930 | \t\t\t\t["PaintApplyColor.Blue"] = Input { Value = 0.12, }, |
| 931 | \t\t\t\t["PaintApplyColor.Opacity"] = Input { Value = 1.0, }, |
| 932 | \t\t\t\tPolyline = Input { Value = Polyline { Points = { |
| 933 | \t\t\t\t\t{ X = -0.35, Y = -0.25, RX = 0.15, RY = 0.25 }, |
| 934 | \t\t\t\t\t{ X = 0.35, Y = 0.25, LX = -0.15, LY = -0.25 }, |
| 935 | \t\t\t\t} }, }, |
| 936 | \t\t\t}, |
| 937 | \t\t}, |
| 938 | \t\tOp_7 = Paint { |
| 939 | \t\t\tInputs = { |
| 940 | \t\t\t\tBlend = Input { Value = 0.6, }, |
| 941 | \t\t\t\tInput = Input { SourceOp = "ColorLoader", Source = "Output", }, |
| 942 | \t\t\t\tPaint = Input { SourceOp = "PS_7", Source = "Out", }, |
| 943 | \t\t\t\tEffectMask = Input { SourceOp = "MaskEll", Source = "Mask", }, |
| 944 | \t\t\t}, |
| 945 | \t\t},""" |
| 946 | ) |
| 947 | cases.append((f, "Paint_Blend0.6_EffectMask", "Op_7")) |
| 948 | f += 1 |
| 949 | |
| 950 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "PT") |
| 951 | nodes.extend(sw_nodes) |
| 952 | nodes.append(make_saver(out_op, "matrix_paint")) |
| 953 | comp_path = ensure_dirs() / "comps" / "matrix_paint.comp" |
| 954 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1)) |
| 955 | return comp_path, "matrix_paint", [(c[0], c[1]) for c in cases] |
| 956 | |
| 957 | |
| 958 | ASPECT_SIZES = ((320, 180), (180, 320), (321, 181)) |
| 959 | |
| 960 | _ASPECT_SETUP = """\t\tBlackBG = Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 961 | \t\tWhiteFG = Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, TopLeftRed = Input { Value = 0.95, }, TopLeftGreen = Input { Value = 0.75, }, TopLeftBlue = Input { Value = 0.25, }, TopLeftAlpha = Input { Value = 1, }, }, }, |
| 962 | \t\tSmallFG = Background { Inputs = { Width = Input { Value = @HW@, }, Height = Input { Value = @HH@, }, TopLeftRed = Input { Value = 0.2, }, TopLeftGreen = Input { Value = 0.8, }, TopLeftBlue = Input { Value = 0.5, }, TopLeftAlpha = Input { Value = 1, }, }, },""" |
| 963 | |
| 964 | _ASPECT_CASES = ( |
| 965 | ("BG_Horizontal", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Horizontal" }, }, TopLeftRed = Input { Value = 0.9, }, TopLeftGreen = Input { Value = 0.2, }, TopLeftBlue = Input { Value = 0.1, }, TopLeftAlpha = Input { Value = 1, }, TopRightRed = Input { Value = 0.1, }, TopRightGreen = Input { Value = 0.3, }, TopRightBlue = Input { Value = 0.9, }, TopRightAlpha = Input { Value = 1, }, }, }'), |
| 966 | ("BG_Vertical", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Vertical" }, }, TopLeftRed = Input { Value = 0.9, }, TopLeftGreen = Input { Value = 0.2, }, TopLeftBlue = Input { Value = 0.1, }, TopLeftAlpha = Input { Value = 1, }, BottomLeftRed = Input { Value = 0.1, }, BottomLeftGreen = Input { Value = 0.3, }, BottomLeftBlue = Input { Value = 0.9, }, BottomLeftAlpha = Input { Value = 1, }, }, }'), |
| 967 | ("BG_FourCorner", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Corner" }, }, TopLeftRed = Input { Value = 1, }, TopLeftAlpha = Input { Value = 1, }, TopRightGreen = Input { Value = 1, }, TopRightAlpha = Input { Value = 1, }, BottomLeftBlue = Input { Value = 1, }, BottomLeftAlpha = Input { Value = 1, }, BottomRightRed = Input { Value = 1, }, BottomRightGreen = Input { Value = 1, }, BottomRightAlpha = Input { Value = 1, }, }, }'), |
| 968 | ("EllipseMask_Circle", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', |
| 969 | 'EllipseMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Width = Input { Value = 0.5, }, Height = Input { Value = 0.5, }, SoftEdge = Input { Value = 0.02, }, }, }'), |
| 970 | ("EllipseMask_Rotated", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', |
| 971 | 'EllipseMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Center = Input { Value = { 0.4, 0.55 }, }, Width = Input { Value = 0.6, }, Height = Input { Value = 0.3, }, Angle = Input { Value = 30, }, BorderWidth = Input { Value = 0.01, }, }, }'), |
| 972 | ("RectangleMask_Rounded", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', |
| 973 | 'RectangleMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Width = Input { Value = 0.6, }, Height = Input { Value = 0.4, }, CornerRadius = Input { Value = 0.1, }, SoftEdge = Input { Value = 0.02, }, }, }'), |
| 974 | ("RectangleMask_Rotated", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', |
| 975 | 'RectangleMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Center = Input { Value = { 0.55, 0.45 }, }, Width = Input { Value = 0.5, }, Height = Input { Value = 0.3, }, Angle = Input { Value = -25, }, }, }'), |
| 976 | ("Transform_Rotation", 'Transform { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, Angle = Input { Value = 30, }, Size = Input { Value = 0.7, }, }, }'), |
| 977 | ("Transform_Rotation_Aspect", 'Transform { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, Center = Input { Value = { 0.6, 0.45 }, }, Pivot = Input { Value = { 0.3, 0.6 }, }, Angle = Input { Value = 28, }, Aspect = Input { Value = 1.5, }, Size = Input { Value = 0.8, }, }, }'), |
| 978 | ("Merge_Center_Size_Angle", 'Merge { Inputs = { Background = Input { SourceOp = "Grad", Source = "Output", }, Foreground = Input { SourceOp = "SmallFG", Source = "Output", }, Center = Input { Value = { 0.65, 0.4 }, }, Size = Input { Value = 0.8, }, Angle = Input { Value = 35, }, }, }'), |
| 979 | ("DVE_Rotation", 'DVE { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, XRotation = Input { Value = 25, }, YRotation = Input { Value = -30, }, ZRotation = Input { Value = 15, }, ZMove = Input { Value = 1.2, }, }, }'), |
| 980 | ("TextPlus_Centered", 'TextPlus { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Font = Input { Value = "Liberation Sans", }, Style = Input { Value = "Regular", }, StyledText = Input { Value = "Aspect 321", }, Size = Input { Value = 0.18, }, Center = Input { Value = { 0.5, 0.5 }, }, }, }'), |
| 981 | ) |
| 982 | |
| 983 | |
| 984 | def _build_matrix_aspect(w: int, h: int): |
| 985 | """Non-square and odd-dimension canvases: gradients, masks, Transform/Merge/DVE geometry and TextPlus at WxH.""" |
| 986 | sub = {"@W@": str(w), "@H@": str(h), "@HW@": str(w // 2), "@HH@": str(h // 2)} |
| 987 | |
| 988 | def fill(text: str) -> str: |
| 989 | for k, v in sub.items(): |
| 990 | text = text.replace(k, v) |
| 991 | return text |
| 992 | |
| 993 | nodes = [ |
| 994 | fill(_ASPECT_SETUP), |
| 995 | fill(f'\t\tGrad = {_ASPECT_CASES[0][1]},'), |
| 996 | ] |
| 997 | cases: List[Tuple[int, str, str]] = [] |
| 998 | for f, (label, body, *mask) in enumerate(_ASPECT_CASES): |
| 999 | if mask: |
| 1000 | nodes.append(fill(f"\t\tMask_{f} = {mask[0]},")) |
| 1001 | body = body.replace("@MASK@", f"Mask_{f}") |
| 1002 | nodes.append(fill(f"\t\tOp_{f} = {body},")) |
| 1003 | cases.append((f, label, f"Op_{f}")) |
| 1004 | |
| 1005 | prefix = f"matrix_aspect_{w}x{h}" |
| 1006 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "AS") |
| 1007 | nodes.extend(sw_nodes) |
| 1008 | nodes.append(make_saver(out_op, prefix)) |
| 1009 | comp_path = ensure_dirs() / "comps" / f"{prefix}.comp" |
| 1010 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1, w=w, h=h)) |
| 1011 | return comp_path, prefix, [(c[0], c[1]) for c in cases] |
| 1012 | |
| 1013 | |
| 1014 | MATRIX_BUILDERS = { |
| 1015 | "matrix_merge_modes": build_matrix_merge_modes, |
| 1016 | "matrix_hdr_depth": build_matrix_hdr_depth, |
| 1017 | "matrix_masks": build_matrix_masks, |
| 1018 | "matrix_color_blur": build_matrix_color_blur, |
| 1019 | "matrix_warps_shapes": build_matrix_warps_shapes, |
| 1020 | "matrix_3d": build_matrix_3d, |
| 1021 | "matrix_misc": build_matrix_misc, |
| 1022 | "matrix_paint": build_matrix_paint, |
| 1023 | **{ |
| 1024 | f"matrix_aspect_{w}x{h}": (lambda assets, w=w, h=h: _build_matrix_aspect(w, h)) |
| 1025 | for w, h in ASPECT_SIZES |
| 1026 | }, |
| 1027 | } |
| 1028 | |
| 1029 | |