diff --git a/crates/nodes/src/function/compile.rs b/crates/nodes/src/function/compile.rs index 781d26cf..b7d576c4 100644 --- a/crates/nodes/src/function/compile.rs +++ b/crates/nodes/src/function/compile.rs @@ -140,6 +140,12 @@ fn compile_nested(graph: &FunctionGraph, seed: u32, depth: usize, remaining: &mu inputs.push(index); } + if matches!(node.op.as_str(), "vector2" | "vector3" | "vector4" | "ivector2" | "ivector3" | "ivector4") + && ports.first().is_some_and(|(_, input)| input.is_none()) + { + // Connected components occupy the leading lanes. The inferred zero operand pads the end. + inputs.reverse(); + } inputs }; diff --git a/crates/nodes/src/function/unconnected.test.rs b/crates/nodes/src/function/unconnected.test.rs index 35f7da5b..5c528863 100644 --- a/crates/nodes/src/function/unconnected.test.rs +++ b/crates/nodes/src/function/unconnected.test.rs @@ -47,17 +47,20 @@ fn unconnected_typed_operations_use_their_operand_types() { } #[test] -fn partially_connected_vectors_fill_only_the_missing_components() { - for (operation, first, last, expected) in [ - ("vector3", Some(Value::Float2([0.25, 0.75])), None, Value::Float3([0.25, 0.75, 0.0])), - ("vector4", None, Some(Value::Float2([0.25, 0.75])), Value::Float4([0.0, 0.0, 0.25, 0.75])), - ("ivector4", Some(Value::Int(7)), None, Value::Int4([7, 0, 0, 0])), +fn vector_constructors_place_a_single_connected_operand_in_the_leading_lanes() { + for (operation, input, expected) in [ + ("vector2", Value::Float(-0.375), Value::Float2([-0.375, 0.0])), + ("vector3", Value::Float2([0.25, 0.75]), Value::Float3([0.25, 0.75, 0.0])), + ("vector4", Value::Float2([0.25, 0.75]), Value::Float4([0.25, 0.75, 0.0, 0.0])), + ("vector4", Value::Float3([0.375, -0.6875, 0.25]), Value::Float4([0.375, -0.6875, 0.25, 0.0])), + ("ivector2", Value::Int(-23), Value::Int2([-23, 0])), + ("ivector3", Value::Int(17), Value::Int3([17, 0, 0])), + ("ivector4", Value::Int(7), Value::Int4([7, 0, 0, 0])), + ("ivector4", Value::Int2([17, -23]), Value::Int4([17, -23, 0, 0])), ] { let mut graph = FunctionGraph::default(); - let inputs = [first.map(|value| graph.add_constant(value)), last.map(|value| graph.add_constant(value))]; - let id = graph.add(operation, &[], None); - graph.nodes.last_mut().unwrap().inputs = inputs.to_vec(); - graph.output = Some(id); + let source = graph.add_constant(input); + graph.output = Some(graph.add(operation, &[], None)); let variables = Default::default(); let context = EvaluationContext { image_formats: &[], @@ -69,7 +72,11 @@ fn partially_connected_vectors_fill_only_the_missing_components() { variables: &variables, }; - assert_eq!(compile(&graph, 0).unwrap().evaluate(&context, &mut EvaluationState::default()), Ok(expected), "{operation}"); + for inputs in [[None, Some(source)], [Some(source), None]] { + graph.nodes.last_mut().unwrap().inputs = inputs.to_vec(); + let value = compile(&graph, 0).unwrap().evaluate(&context, &mut EvaluationState::default()).unwrap(); + assert_eq!(value, expected, "{operation} {inputs:?}"); + } } } diff --git a/docs/parity-fixes.md b/docs/parity-fixes.md index 9a73eda1..ba618685 100644 --- a/docs/parity-fixes.md +++ b/docs/parity-fixes.md @@ -59,6 +59,27 @@ The first pass classifies all 546 roots: 166 Parity and 380 Too hard. These meas ## 2026-11-23 root comparisons +### Single connected operands in vector constructors + +In an original Value Processor, construct float and integer vectors of widths two, three and four. For each width try every smaller operand width in the first port alone, the second port alone and both ports. Use (.375, −.6875, .25) or (17, −23, 5), taking the leading values for the first connected operand and the reversed list for the second operand in the two-wire controls. Repeat the 36 graphs at 16² and 32², seeds 79 and 197. With a single connection its components occupy the leading lanes and the remaining lanes are zero. For example, connecting (17, −23) only to the second port of an integer vector of width three returns (17, −23, 0). + +| Comparison | Previous exact / total | Previous maximum error | Current exact / total | Current maximum error | +|---|---:|---:|---:|---:| +| Float vectors, whole typed values | 24/36 | 1.0625 | 36/36 | 0 | +| Integer vectors, whole typed values | 24/36 | 40 | 36/36 | 0 | +| Five saved graphs, whole typed values | 4/10 | 40 | 10/10 | 0 | +| Pixel Processor, first port empty | 0/8,192 | 1.99861372 | 8,192/8,192 | 0 | +| Pixel Processor, second port empty | 8,192/8,192 | 0 | 8,192/8,192 | 0 | +| FX-Map, first port empty, F32 and F16 | 0/384 | .625 | 384/384 | 0 | +| FX-Map, first port empty, U16 | 0/128 | 20,480 | 128/128 | 0 | +| FX-Map, zero input, U8 | 128/128 | 0 | 128/128 | 0 | + +Reopen five ordinary MaterialCraft saves in both applications. Use float widths three and four with the second port wired to a scalar or triple, integer width three with a pair on the second port, and integer width four with a scalar on the first port or both ports wired to pairs. The reference reproduced all ten original typed values. The same change in the function compiler applies to freshly authored graphs and reopened files. + +For the pixel controls use the [signed procedural F32 fields](#packed-products-in-the-second-endpoint-of-a-pixel-interpolation) at 64×32 and 32×64, seeds 435071 and 435090. Pack the sampled red channel alone in a pair and append (.1875,.875), or pack that constant pair alone in a four-vector. Repeat with each input port. For the FX-Map, expose a scalar on the second port of a pair in the root square's opacity expression and select its first or second component. Render at 16×8 with zero background and roughness. In order use F32 (.625, first), F32 (.625, second), F16 (.3125, first), U16 (.3125, second) and U8 (0, first), seeds 458151 + 29j starting at j = 0. + +The range covers physically disconnected ports. A separate pair with two wires still differs when its leading wire reads an undeclared variable and the other carries a nonzero value. Scanning the reachable expressions in all 546 root graph bodies found zero one-wire vector constructors with the leading port disconnected. Called function bodies were outside that scan. The root count stays at 479. The regression failed on the preceding compiler. All 401 node release tests, formatting, strict workspace Clippy, dependency layers and WebAssembly passed. + ### Dense Quadrant traversal and reference worker counts Construct a grayscale FX-Map with a .0625 background, zero roughness, overall opacity 1, both regions (0,1,0,1), center culling enabled and wrapping disabled. Start at (.5,.5). At each subdivision link all four children to the next empty Quadrant. At the last level draw additive squares of size (1.75,2.25), rotation zero and luminosity `rand(.0625) + .0625 * $pos.x`. In the returning-offset version move the root branch by (1.25,0) and the final stamp by (−1.25,0). In the narrow version change only the size to (.375,1.25). Use seeds 441151 + 31j, with j from zero to three in the column order below. diff --git a/docs/sbs-root-nodes.md b/docs/sbs-root-nodes.md index 8bbfea53..f61f53d5 100644 --- a/docs/sbs-root-nodes.md +++ b/docs/sbs-root-nodes.md @@ -37,6 +37,8 @@ Statuses: **Not checked**, **In progress**, **Parity** (exact pixels or typed va The first pass covered all **546 roots**, with **166 Parity** and **380 Too hard**. The current inventory has **479 Parity**, **67 In progress** and **0 Too hard**. The November 17–23 comparisons include raw counts, output formats and remaining differences. [November 17 measurements](parity-fixes.md#2026-11-17-root-comparisons) · [November 18 measurements](parity-fixes.md#2026-11-18-root-comparisons) · [November 19 measurements](parity-fixes.md#2026-11-19-root-comparisons) · [November 20 measurements](parity-fixes.md#2026-11-20-root-comparisons) · [November 21 measurements](parity-fixes.md#2026-11-21-root-comparisons) · [November 22 measurements](parity-fixes.md#2026-11-22-root-comparisons) · [November 23 measurements](parity-fixes.md#2026-11-23-root-comparisons) +A vector with one connected operand now matches 72/72 original typed values, 10/10 reopened values and 17,024/17,024 Pixel Processor and FX-Map pixels. The scan of root graph bodies found no reachable one-wire vector with its first port disconnected. [Vector construction and saved-file measurements](parity-fixes.md#single-connected-operands-in-vector-constructors) + Panorama Plane Light matches 212,736/212,736 pixels across 32 original settings and 41,472/41,472 after reopening. [Interpolation probes and whole-root counts](parity-fixes.md#packed-products-in-the-second-endpoint-of-a-pixel-interpolation) The eighth specular pass in the second package (root 408) matches all 143,300 original pixels at 38 settings, all 16,704 pixels after reopening and all 81,920 intermediate F32 pixels in the environment and material controls. [Whole-root measurements](parity-fixes.md#whole-and-reopened-eighth-specular-passes)