diff --git a/core/src/render/shader/prelude.wgsl b/core/src/render/shader/prelude.wgsl index 2b98a50..469e231 100644 --- a/core/src/render/shader/prelude.wgsl +++ b/core/src/render/shader/prelude.wgsl @@ -37,10 +37,13 @@ const MOVE_NONE: u32 = 4294967295u; // resolve a deep one the same way. const CHAIN_LIMIT: u32 = 64u; +// Written the way `UiScalar::within` writes it rather than as `mix`, so the +// CPU and the shader compose a position with the same arithmetic and answer +// the same thing about where a widget is. fn scalar_within(s: UiScalar, p: UiSpan) -> UiScalar { return UiScalar( - mix(p.start.rel, p.end.rel, s.rel), - s.px + mix(p.start.px, p.end.px, s.rel), + p.start.rel + (p.end.rel - p.start.rel) * s.rel, + s.px + (p.start.px + (p.end.px - p.start.px) * s.rel), ); }