| author | |
| committer | |
| log | db8e9f2e18b100438979c989ef5c3d034553b645 |
| tree | 54109983625a28d93395ee4297470127085aea6e |
| parent | 14e22369e3f506ad7b29957d0a30b3a1c485f2d3 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
- sBoolean: Fusion only accepts Union/Intersection/Subtract/Xor (default
Intersection); any other Operation renders empty (repro_seed_125/122 were
"Intersect" -> black in Fusion, not a Vortex bug). A missing Input2 passes
Input1 through in the boolean's own color; a missing Input1 renders empty.
- Dent Type=1 (Sine): new_r = r - Strength * (1 - r / R), measured against
Fusion on a gradient plate (repro_seed_120 1.6% -> 0.2%).
- Transform: implement InvertTransform (samples through the forward map).
11_everyone_knows Transform3/Transform1 residual traces to WandMask
RangeSoftEdge (masks.rs), not Transform: Transform with a plain mask
matches Fusion.
Assisted-by: claude-sonnet-5.54 files changed, 158 insertions(+), 59 deletions(-)
crates/engine/src/eval/shapes_warp.rs+105-49| ... | @@ -175,25 +175,17 @@ fn eval_first_num( | ... | @@ -175,25 +175,17 @@ fn eval_first_num( |
| 175 | default | 175 | default |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | fn parse_bool_op(comp: &Comp, node: &Node, time: f64, expr: &ExprEngine) -> ShapeBoolOp { | 178 | /// Fusion accepts exactly `Union | Intersection | Subtract | Xor` (default `Intersection`); any other value renders empty. |
| 179 | if let Some(s) = node.static_str("Operation") { | 179 | fn parse_bool_op(node: &Node) -> Option<ShapeBoolOp> { |
| 180 | let low = s.to_ascii_lowercase(); | 180 | if !node.inputs.contains_key("Operation") { |
| 181 | if low.contains("inter") { | 181 | return Some(ShapeBoolOp::Intersect); |
| 182 | return ShapeBoolOp::Intersect; | ||
| 183 | } | ||
| 184 | if low.contains("sub") || low.contains("diff") { | ||
| 185 | return ShapeBoolOp::Subtract; | ||
| 186 | } | ||
| 187 | if low.contains("xor") { | ||
| 188 | return ShapeBoolOp::Xor; | ||
| 189 | } | ||
| 190 | return ShapeBoolOp::Union; | ||
| 191 | } | 182 | } |
| 192 | match comp.eval_number(node, "Operation", time, 0.0, expr).round() as i32 { | 183 | match node.static_str("Operation")? { |
| 193 | 1 => ShapeBoolOp::Intersect, | 184 | "Union" => Some(ShapeBoolOp::Union), |
| 194 | 2 => ShapeBoolOp::Subtract, | 185 | "Intersection" => Some(ShapeBoolOp::Intersect), |
| 195 | 3 => ShapeBoolOp::Xor, | 186 | "Subtract" => Some(ShapeBoolOp::Subtract), |
| 196 | _ => ShapeBoolOp::Union, | 187 | "Xor" => Some(ShapeBoolOp::Xor), |
| 188 | _ => None, | ||
| 197 | } | 189 | } |
| 198 | } | 190 | } |
| 199 | 191 | ||
| ... | @@ -375,42 +367,31 @@ fn collect_shape_tree( | ... | @@ -375,42 +367,31 @@ fn collect_shape_tree( |
| 375 | collect_shape_tree(comp, src_id, time, expr, parent_xform, Some((thickness, join, cap)), depth + 1) | 367 | collect_shape_tree(comp, src_id, time, expr, parent_xform, Some((thickness, join, cap)), depth + 1) |
| 376 | } | 368 | } |
| 377 | "sBoolean" => { | 369 | "sBoolean" => { |
| 378 | let op = parse_bool_op(comp, node, time, expr); | ||
| 379 | let r = comp.eval_number(node, "Red", time, 1.0, expr) as f32; | 370 | let r = comp.eval_number(node, "Red", time, 1.0, expr) as f32; |
| 380 | let g = comp.eval_number(node, "Green", time, 1.0, expr) as f32; | 371 | let g = comp.eval_number(node, "Green", time, 1.0, expr) as f32; |
| 381 | let b_col = comp.eval_number(node, "Blue", time, 1.0, expr) as f32; | 372 | let b_col = comp.eval_number(node, "Blue", time, 1.0, expr) as f32; |
| 382 | let a_col = comp.eval_number(node, "Alpha", time, 1.0, expr) as f32; | 373 | let a_col = comp.eval_number(node, "Alpha", time, 1.0, expr) as f32; |
| 383 | let color = [r, g, b_col, a_col]; | 374 | let color = [r, g, b_col, a_col]; |
| 384 | let a = node | 375 | let child = |port: &str| { |
| 385 | .connected_node("Input1") | 376 | node.connected_node(port) |
| 386 | .or_else(|| node.connected_node("Input")) | 377 | .and_then(|s| comp.find_node(s)) |
| 387 | .and_then(|s| comp.find_node(s)) | 378 | .and_then(|id| { |
| 388 | .and_then(|id| { | 379 | collect_shape_tree(comp, id, time, expr, parent_xform, outline_override, depth + 1) |
| 389 | collect_shape_tree(comp, id, time, expr, parent_xform, outline_override, depth + 1) | 380 | }) |
| 390 | }); | 381 | }; |
| 391 | let b = node | 382 | let a = child("Input1").or_else(|| child("Input"))?; |
| 392 | .connected_node("Input2") | 383 | // Input2 absent passes Input1 through (recolored) whatever the operation; Input1 absent renders empty. |
| 393 | .and_then(|s| comp.find_node(s)) | 384 | let (op, b) = match (parse_bool_op(node), child("Input2")) { |
| 394 | .and_then(|id| { | 385 | (_, None) => (ShapeBoolOp::Union, ShapeTree::Group(Vec::new())), |
| 395 | collect_shape_tree(comp, id, time, expr, parent_xform, outline_override, depth + 1) | 386 | (Some(op), Some(b)) => (op, b), |
| 396 | }); | 387 | (None, Some(_)) => return None, |
| 397 | match (a, b) { | 388 | }; |
| 398 | (Some(ta), Some(tb)) => Some(ShapeTree::Boolean { | 389 | Some(ShapeTree::Boolean { |
| 399 | op, | 390 | op, |
| 400 | color, | 391 | color, |
| 401 | a: Box::new(ta), | 392 | a: Box::new(a), |
| 402 | b: Box::new(tb), | 393 | b: Box::new(b), |
| 403 | }), | 394 | }) |
| 404 | (Some(ta), None) => match op { | ||
| 405 | ShapeBoolOp::Intersect => None, | ||
| 406 | _ => Some(ta), | ||
| 407 | }, | ||
| 408 | (None, Some(tb)) => match op { | ||
| 409 | ShapeBoolOp::Union | ShapeBoolOp::Xor => Some(tb), | ||
| 410 | _ => None, | ||
| 411 | }, | ||
| 412 | (None, None) => None, | ||
| 413 | } | ||
| 414 | } | 395 | } |
| 415 | "PipeRouter" | "Fuse.Wireless" => { | 396 | "PipeRouter" | "Fuse.Wireless" => { |
| 416 | let src_id = node | 397 | let src_id = node |
| ... | @@ -1756,6 +1737,81 @@ mod tests { | ... | @@ -1756,6 +1737,81 @@ mod tests { |
| 1756 | assert_eq!(&px_xor[ngon_only..ngon_only + 4], &[255, 255, 255, 255]); | 1737 | assert_eq!(&px_xor[ngon_only..ngon_only + 4], &[255, 255, 255, 255]); |
| 1757 | } | 1738 | } |
| 1758 | 1739 | ||
| 1740 | #[test] | ||
| 1741 | fn test_dent_sine_falls_off_linearly_from_strength_at_center() { | ||
| 1742 | let src = r#"Composition { | ||
| 1743 | CurrentTime = 0, RenderRange = { 0, 0 }, GlobalRange = { 0, 0 }, | ||
| 1744 | Tools = ordered() { | ||
| 1745 | BG1 = Background { Inputs = { Width = Input { Value = 128, }, Height = Input { Value = 128, }, | ||
| 1746 | Type = Input { Value = FuID { "Horizontal" }, }, | ||
| 1747 | TopLeftRed = Input { Value = 1, }, TopLeftGreen = Input { Value = 0, }, TopLeftBlue = Input { Value = 0, }, TopLeftAlpha = Input { Value = 1, }, | ||
| 1748 | TopRightRed = Input { Value = 0, }, TopRightGreen = Input { Value = 1, }, TopRightBlue = Input { Value = 0, }, TopRightAlpha = Input { Value = 1, }, }, }, | ||
| 1749 | Dent1 = Dent { Inputs = { Input = Input { SourceOp = "BG1", Source = "Output", }, | ||
| 1750 | Center = Input { Value = { 0.5, 0.5 }, }, Size = Input { Value = 0.5, }, | ||
| 1751 | Strength = Input { Value = 0.5, }, Type = Input { Value = 1, }, }, }, | ||
| 1752 | }, | ||
| 1753 | }"#; | ||
| 1754 | let comp = Comp::from_fusion_str(src).unwrap(); | ||
| 1755 | let Ok(mut eng) = Engine::new_headless() else { | ||
| 1756 | return; | ||
| 1757 | }; | ||
| 1758 | let (tex, _) = eng.evaluate(&comp, comp.find_node("Dent1").unwrap(), 0.0); | ||
| 1759 | let px = eng.readback_rgba(&tex).unwrap(); | ||
| 1760 | // x=72 (r=0.066 of the 0.25 radius): new_r = r - 0.5 * (1 - r / R) = -0.30 -> source at x=0.20, | ||
| 1761 | // so the gradient reads ~80% red / ~20% green. | ||
| 1762 | let i = (64 * 128 + 72) * 4; | ||
| 1763 | assert!(px[i].abs_diff(204) < 8 && px[i + 1].abs_diff(51) < 8, "got {:?}", &px[i..i + 4]); | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | #[test] | ||
| 1767 | fn test_s_boolean_operation_names_and_missing_inputs() { | ||
| 1768 | let boolean = |name: &str, op: &str, inputs: &str| { | ||
| 1769 | format!( | ||
| 1770 | r#"{name} = sBoolean {{ Inputs = {{ {op} {inputs} }}, }}, | ||
| 1771 | R{name} = sRender {{ Inputs = {{ Width = Input {{ Value = 128, }}, Height = Input {{ Value = 128, }}, | ||
| 1772 | Input = Input {{ SourceOp = "{name}", Source = "Output", }}, }}, }},"# | ||
| 1773 | ) | ||
| 1774 | }; | ||
| 1775 | let both = r#"Input1 = Input { SourceOp = "Rect", Source = "Output", }, Input2 = Input { SourceOp = "Ell", Source = "Output", },"#; | ||
| 1776 | let first = r#"Input1 = Input { SourceOp = "Rect", Source = "Output", },"#; | ||
| 1777 | let second = r#"Input2 = Input { SourceOp = "Ell", Source = "Output", },"#; | ||
| 1778 | let fu = |v: &str| format!(r#"Operation = Input {{ Value = FuID {{ "{v}" }}, }},"#); | ||
| 1779 | let src = format!( | ||
| 1780 | r#"Composition {{ CurrentTime = 0, RenderRange = {{ 0, 0 }}, GlobalRange = {{ 0, 0 }}, Tools = ordered() {{ | ||
| 1781 | Rect = sRectangle {{ Inputs = {{ Width = Input {{ Value = 0.5, }}, Height = Input {{ Value = 0.2, }}, | ||
| 1782 | Red = Input {{ Value = 1, }}, Green = Input {{ Value = 0, }}, Blue = Input {{ Value = 0, }}, }}, }}, | ||
| 1783 | Ell = sEllipse {{ Inputs = {{ Width = Input {{ Value = 0.3, }}, Height = Input {{ Value = 0.3, }}, }}, }}, | ||
| 1784 | {} {} {} {} {} {} | ||
| 1785 | }} }}"#, | ||
| 1786 | boolean("Inter", &fu("Intersection"), both), | ||
| 1787 | boolean("Default", "", both), | ||
| 1788 | boolean("Unknown", &fu("Intersect"), both), | ||
| 1789 | boolean("SubFirst", &fu("Subtract"), first), | ||
| 1790 | boolean("SubSecond", &fu("Subtract"), second), | ||
| 1791 | boolean("UnionBoth", &fu("Union"), both), | ||
| 1792 | ); | ||
| 1793 | let comp = Comp::from_fusion_str(&src).unwrap(); | ||
| 1794 | let Ok(mut eng) = Engine::new_headless() else { | ||
| 1795 | return; | ||
| 1796 | }; | ||
| 1797 | let mut px = |name: &str, x: usize| { | ||
| 1798 | let (tex, _) = eng.evaluate(&comp, comp.find_node(&format!("R{name}")).unwrap(), 0.0); | ||
| 1799 | let rgba = eng.readback_rgba(&tex).unwrap(); | ||
| 1800 | let i = (64 * 128 + x) * 4; | ||
| 1801 | [rgba[i], rgba[i + 1], rgba[i + 2], rgba[i + 3]] | ||
| 1802 | }; | ||
| 1803 | let white = [255; 4]; | ||
| 1804 | let empty = [0; 4]; | ||
| 1805 | // x=64 is inside both shapes, x=90 is inside only the rectangle. | ||
| 1806 | assert_eq!(px("Inter", 64), white); | ||
| 1807 | assert_eq!(px("Inter", 90), empty); | ||
| 1808 | assert_eq!(px("Default", 64), white, "Operation defaults to Intersection"); | ||
| 1809 | assert_eq!(px("Unknown", 64), empty, "unrecognized operation names render nothing"); | ||
| 1810 | assert_eq!(px("SubFirst", 90), white, "a missing Input2 passes Input1 through in the boolean's own color"); | ||
| 1811 | assert_eq!(px("SubSecond", 64), empty, "a missing Input1 renders nothing"); | ||
| 1812 | assert_eq!(px("UnionBoth", 90), white); | ||
| 1813 | } | ||
| 1814 | |||
| 1759 | #[test] | 1815 | #[test] |
| 1760 | fn test_perspective_positioner_and_s_grid() { | 1816 | fn test_perspective_positioner_and_s_grid() { |
| 1761 | let src = r#"{ | 1817 | let src = r#"{ |
crates/engine/src/eval/transform.rs+34-2| ... | @@ -595,9 +595,10 @@ impl Engine { | ... | @@ -595,9 +595,10 @@ impl Engine { |
| 595 | let angle = (comp.eval_number(node, "Angle", time, 0.0, &self.expr) as f32).to_radians(); | 595 | let angle = (comp.eval_number(node, "Angle", time, 0.0, &self.expr) as f32).to_radians(); |
| 596 | let flip_h = comp.eval_number(node, "FlipHoriz", time, 0.0, &self.expr) as f32; | 596 | let flip_h = comp.eval_number(node, "FlipHoriz", time, 0.0, &self.expr) as f32; |
| 597 | let flip_v = comp.eval_number(node, "FlipVert", time, 0.0, &self.expr) as f32; | 597 | let flip_v = comp.eval_number(node, "FlipVert", time, 0.0, &self.expr) as f32; |
| 598 | let invert = comp.eval_number(node, "InvertTransform", time, 0.0, &self.expr) > 0.5; | ||
| 598 | let mut edges = comp.eval_number(node, "Edges", time, 0.0, &self.expr) as f32; | 599 | let mut edges = comp.eval_number(node, "Edges", time, 0.0, &self.expr) as f32; |
| 599 | let edges_i = edges.round() as i32; | 600 | let edges_i = edges.round() as i32; |
| 600 | if edges_i == 0 || edges_i == 2 { | 601 | if !invert && (edges_i == 0 || edges_i == 2) { |
| 601 | let has_up_roi = src.edge_mode.is_some() | 602 | let has_up_roi = src.edge_mode.is_some() |
| 602 | || upstream_infinite_edge_mode(comp, src_id, time, &self.expr).is_some(); | 603 | || upstream_infinite_edge_mode(comp, src_id, time, &self.expr).is_some(); |
| 603 | if has_up_roi { | 604 | if has_up_roi { |
| ... | @@ -640,7 +641,7 @@ impl Engine { | ... | @@ -640,7 +641,7 @@ impl Engine { |
| 640 | u.p[1] = [sx, sy, angle, edges]; | 641 | u.p[1] = [sx, sy, angle, edges]; |
| 641 | u.p[2] = [flip_h, flip_v, blend, if mask.is_some() { 1.0 } else { 0.0 }]; | 642 | u.p[2] = [flip_h, flip_v, blend, if mask.is_some() { 1.0 } else { 0.0 }]; |
| 642 | let mbm = comp.eval_number(node, "MultiplyByMask", time, 0.0, &self.expr) > 0.5; | 643 | let mbm = comp.eval_number(node, "MultiplyByMask", time, 0.0, &self.expr) > 0.5; |
| 643 | u.p[3] = [if mask_inv { 1.0 } else { 0.0 }, nearest, if mbm { 1.0 } else { 0.0 }, 0.0]; | 644 | u.p[3] = [if mask_inv { 1.0 } else { 0.0 }, nearest, if mbm { 1.0 } else { 0.0 }, if invert { 1.0 } else { 0.0 }]; |
| 644 | if src.has_dod() { | 645 | if src.has_dod() { |
| 645 | u.p[4] = [ | 646 | u.p[4] = [ |
| 646 | src.origin[0] as f32, | 647 | src.origin[0] as f32, |
| ... | @@ -1597,4 +1598,35 @@ mod tests { | ... | @@ -1597,4 +1598,35 @@ mod tests { |
| 1597 | assert_eq!(px(1, 2, 2), [0, 0], "outside the mask is zeroed"); | 1598 | assert_eq!(px(1, 2, 2), [0, 0], "outside the mask is zeroed"); |
| 1598 | assert_eq!(px(1, 32, 32), [255, 255], "inside the mask is kept"); | 1599 | assert_eq!(px(1, 32, 32), [255, 255], "inside the mask is kept"); |
| 1599 | } | 1600 | } |
| 1601 | |||
| 1602 | #[test] | ||
| 1603 | fn transform_invert_transform_shifts_the_opposite_way() { | ||
| 1604 | let src = |invert: u8| { | ||
| 1605 | format!( | ||
| 1606 | r#"Composition {{ CurrentTime = 0, RenderRange = {{ 0, 0 }}, GlobalRange = {{ 0, 0 }}, Tools = ordered() {{ | ||
| 1607 | BG = Background {{ Inputs = {{ Width = Input {{ Value = 64, }}, Height = Input {{ Value = 64, }}, | ||
| 1608 | Type = Input {{ Value = FuID {{ "Horizontal" }}, }}, | ||
| 1609 | TopLeftRed = Input {{ Value = 1, }}, TopLeftGreen = Input {{ Value = 0, }}, TopLeftBlue = Input {{ Value = 0, }}, TopLeftAlpha = Input {{ Value = 1, }}, | ||
| 1610 | TopRightRed = Input {{ Value = 0, }}, TopRightGreen = Input {{ Value = 1, }}, TopRightBlue = Input {{ Value = 0, }}, TopRightAlpha = Input {{ Value = 1, }}, }}, }}, | ||
| 1611 | XF = Transform {{ Inputs = {{ InvertTransform = Input {{ Value = {invert}, }}, | ||
| 1612 | Center = Input {{ Value = {{ 0.75, 0.5 }}, }}, Input = Input {{ SourceOp = "BG", Source = "Output", }}, }}, }}, | ||
| 1613 | }} }}"# | ||
| 1614 | ) | ||
| 1615 | }; | ||
| 1616 | if Engine::new_headless().is_err() { | ||
| 1617 | return; | ||
| 1618 | } | ||
| 1619 | let mid_row = |invert: u8| { | ||
| 1620 | let mut eng = Engine::new_headless().unwrap(); | ||
| 1621 | let comp = Comp::from_fusion_str(&src(invert)).unwrap(); | ||
| 1622 | let (tex, _) = eng.evaluate(&comp, comp.find_node("XF").unwrap(), 0.0); | ||
| 1623 | let rgba = eng.readback_rgba(&tex).unwrap(); | ||
| 1624 | let i = (32 * 64 + 32) * 4; | ||
| 1625 | [rgba[i], rgba[i + 1]] | ||
| 1626 | }; | ||
| 1627 | let [r, g] = mid_row(0); | ||
| 1628 | assert!(r > g + 60, "Center +0.25 moves the left (red) side under the middle: {r} {g}"); | ||
| 1629 | let [r, g] = mid_row(1); | ||
| 1630 | assert!(g > r + 60, "InvertTransform pulls the right (green) side under the middle: {r} {g}"); | ||
| 1631 | } | ||
| 1600 | } | 1632 | } |
crates/engine/src/shaders/archive_fx.wgsl+2-2| ... | @@ -86,8 +86,8 @@ fn dent_op(@builtin(global_invocation_id) gid: vec3<u32>) { | ... | @@ -86,8 +86,8 @@ fn dent_op(@builtin(global_invocation_id) gid: vec3<u32>) { |
| 86 | // Dent: linear radial displacement (signed across center) | 86 | // Dent: linear radial displacement (signed across center) |
| 87 | new_r = r - strength * (radius - r); | 87 | new_r = r - strength * (radius - r); |
| 88 | } else if (dent_type == 1) { | 88 | } else if (dent_type == 1) { |
| 89 | // Type 1: pi-scaled linear radial displacement | 89 | // Sine: linear falloff from `strength` frame-widths at the center to 0 at the radius |
| 90 | new_r = r - 3.14159265359 * strength * (radius - r); | 90 | new_r = r - strength * (1.0 - t); |
| 91 | } else if (dent_type == 2) { | 91 | } else if (dent_type == 2) { |
| 92 | // Pinch: power-law radial pinch/expand | 92 | // Pinch: power-law radial pinch/expand |
| 93 | let p = select(1.0 / max(1.0 - strength, 0.05), 1.0 + strength, strength >= 0.0); | 93 | let p = select(1.0 / max(1.0 - strength, 0.05), 1.0 + strength, strength >= 0.0); |
crates/engine/src/shaders/transform.wgsl+17-6| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // p[0] = (center.x, center.y, pivot.x, pivot.y) | 3 | // p[0] = (center.x, center.y, pivot.x, pivot.y) |
| 4 | // p[1] = (size_x, size_y, angle_rad, edges) | 4 | // p[1] = (size_x, size_y, angle_rad, edges) |
| 5 | // p[2] = (flip_h, flip_v, blend, has_mask) | 5 | // p[2] = (flip_h, flip_v, blend, has_mask) |
| 6 | // p[3] = (mask_invert, nearest, multiply_by_mask, 0) | 6 | // p[3] = (mask_invert, nearest, multiply_by_mask, invert_transform) |
| 7 | // ============================================================================ | 7 | // ============================================================================ |
| 8 | @compute @workgroup_size(8, 8) | 8 | @compute @workgroup_size(8, 8) |
| 9 | fn transform_op(@builtin(global_invocation_id) gid: vec3<u32>) { | 9 | fn transform_op(@builtin(global_invocation_id) gid: vec3<u32>) { |
| ... | @@ -21,13 +21,24 @@ fn transform_op(@builtin(global_invocation_id) gid: vec3<u32>) { | ... | @@ -21,13 +21,24 @@ fn transform_op(@builtin(global_invocation_id) gid: vec3<u32>) { |
| 21 | 21 | ||
| 22 | // Forward in Fusion: p' = R(angle) * S(sx, sy) * (p - pivot) + pivot + (center - 0.5) | 22 | // Forward in Fusion: p' = R(angle) * S(sx, sy) * (p - pivot) + pivot + (center - 0.5) |
| 23 | let shift = center - vec2<f32>(0.5); | 23 | let shift = center - vec2<f32>(0.5); |
| 24 | let rel_px = (fu - pivot - shift) * fdims; | ||
| 25 | let c = cos(angle); | 24 | let c = cos(angle); |
| 26 | let s = sin(angle); | 25 | let s = sin(angle); |
| 27 | let unrot = vec2<f32>(rel_px.x * c + rel_px.y * s, -rel_px.x * s + rel_px.y * c); | 26 | var src_fu: vec2<f32>; |
| 28 | var src_fu = vec2<f32>(unrot.x / sx, unrot.y / sy) / fdims + pivot; | 27 | if (u.p[3].w > 0.5) { |
| 29 | if (u.p[2].x > 0.5) { src_fu.x = 1.0 - src_fu.x; } | 28 | // InvertTransform samples through the forward map instead of its inverse (flips apply first). |
| 30 | if (u.p[2].y > 0.5) { src_fu.y = 1.0 - src_fu.y; } | 29 | var p = fu; |
| 30 | if (u.p[2].x > 0.5) { p.x = 1.0 - p.x; } | ||
| 31 | if (u.p[2].y > 0.5) { p.y = 1.0 - p.y; } | ||
| 32 | let scaled = (p - pivot) * fdims * vec2<f32>(sx, sy); | ||
| 33 | let rot = vec2<f32>(scaled.x * c - scaled.y * s, scaled.x * s + scaled.y * c); | ||
| 34 | src_fu = rot / fdims + pivot + shift; | ||
| 35 | } else { | ||
| 36 | let rel_px = (fu - pivot - shift) * fdims; | ||
| 37 | let unrot = vec2<f32>(rel_px.x * c + rel_px.y * s, -rel_px.x * s + rel_px.y * c); | ||
| 38 | src_fu = vec2<f32>(unrot.x / sx, unrot.y / sy) / fdims + pivot; | ||
| 39 | if (u.p[2].x > 0.5) { src_fu.x = 1.0 - src_fu.x; } | ||
| 40 | if (u.p[2].y > 0.5) { src_fu.y = 1.0 - src_fu.y; } | ||
| 41 | } | ||
| 31 | 42 | ||
| 32 | let nearest = u.p[3].y > 0.5; | 43 | let nearest = u.p[3].y > 0.5; |
| 33 | let orig = sample_dod_edges_mode(src_a, fu, 0, u.p[4], nearest); | 44 | let orig = sample_dod_edges_mode(src_a, fu, 0, u.p[4], nearest); |