diff --git a/backend/src/glass/LiquidField.zig b/backend/src/glass/LiquidField.zig index b0d08cc3c..ab1199906 100644 --- a/backend/src/glass/LiquidField.zig +++ b/backend/src/glass/LiquidField.zig @@ -62,6 +62,189 @@ pub const Shape = struct { } }; +pub const max_seams = 4; + +pub const Seam = struct { + /// Vertical is x = at; horizontal is y = at, in physical window pixels. + axis: enum { vertical, horizontal }, + at: f32, + /// Extent along the line; null crosses the parent. Hosts precede nested seams. + span: ?[2]f32 = null, + gap: f32 = 0, + reach: f32, + + pub fn between(axis: @FieldType(Seam, "axis"), lo: f32, hi: f32, span: ?[2]f32, reach: f32) Seam { + return .{ .axis = axis, .at = (lo + hi) / 2, .gap = @max(hi - lo, 0), .span = span, .reach = reach }; + } +}; + +/// A shared material across the pieces, with directional edge lighting but no pointer light. +pub const Panel = struct { + rect: dvui.Rect.Physical, + /// Top-left, top-right, bottom-right, bottom-left. + radii: [4]f32 = @splat(0), + blur: f32 = 1, + lens: f32 = 1, + /// Borrowed until drawing completes; at most max_seams, hosts first. + seams: []const Seam, +}; + +const ResolvedSeam = struct { + span: [2]f32, + radius: f32, + ends: enum(u2) { start = 1, end = 2, both = 3 } = .both, + host: ?usize = null, +}; + +fn resolveSeam(p: Panel, i: usize) ResolvedSeam { + const seam = p.seams[i]; + std.debug.assert(seam.reach > 0 and seam.gap >= 0); + const lo = if (seam.axis == .vertical) p.rect.y else p.rect.x; + const hi = lo + if (seam.axis == .vertical) p.rect.h else p.rect.w; + const radius = @min(@reduce(.Min, @as(@Vector(4, f32), p.radii)), @min(p.rect.w, p.rect.h) / 2); + var r: ResolvedSeam = .{ .span = seam.span orelse .{ lo, hi }, .radius = radius }; + std.debug.assert(r.span[0] < r.span[1]); + for (p.seams[0..i], 0..) |host, j| { + if (host.axis == seam.axis) continue; + // Physical pixel coordinates computed by different layouts can differ by a few ulps. + const tolerance = 4 * std.math.floatEps(f32) * @max(1, @abs(host.at)); + const at_start = @abs(r.span[0] - host.at) <= tolerance; + if (!at_start and @abs(r.span[1] - host.at) > tolerance) continue; + r.host = j; + r.ends = if (at_start) .end else .start; + r.radius = std.math.lerp(radius, @min(radius, host.gap / 2), std.math.clamp(host.gap / host.reach, 0, 1)); + break; + } + return r; +} + +fn intersectRound(a: f32, b: f32, r: f32) f32 { + if (r == 0) return @max(a, b); + return @min(-r, @max(a, b)) + @sqrt(@max(r + a, 0) * @max(r + a, 0) + @max(r + b, 0) * @max(r + b, 0)); +} + +fn panelDistance(p: Panel, point: [2]f32, soft: f32, g: *[2]f32) f32 { + const c: [2]f32 = .{ p.rect.x + p.rect.w / 2, p.rect.y + p.rect.h / 2 }; + const half: [2]f32 = .{ p.rect.w / 2, p.rect.h / 2 }; + var rad = p.radii; + for (&rad) |*r| r.* = @min(r.*, @min(half[0], half[1])); + var d = if (soft > 0) softBox(point, c, half, soft, g) else roundBox(.{ point[0] - c[0], point[1] - c[1] }, half, rad, g); + for (p.seams, 0..) |seam, i| { + if (seam.gap == 0) continue; + const rs = resolveSeam(p, i); + const open = std.math.clamp(seam.gap / seam.reach, 0, 1); + const along = point[if (seam.axis == .vertical) 1 else 0]; + const v = point[if (seam.axis == .vertical) 0 else 1] - seam.at; + const half_gap = seam.gap / 2; + const len = rs.span[1] - rs.span[0]; + const advance = smoothstep(0, 0.6, open); // Pinch before the cut corners finish rounding. + var tip: f32 = 0; + var direction: f32 = 0; + if (rs.ends == .both) { + const u = along - (rs.span[0] + rs.span[1]) / 2; + tip = @max(len / 2 * (1 - advance) - @abs(u), 0); + direction = if (u < 0) 1 else -1; + } else { + const u = if (rs.ends == .start) along - rs.span[0] else rs.span[1] - along; + tip = @max(u - (len - half_gap) * advance, 0); + direction = if (rs.ends == .start) 1 else -1; + } + const length = @sqrt(v * v + tip * tip); + const slot = length - half_gap; + var slot_out: [2]f32 = .{ 0, 0 }; + if (length > 0) { + slot_out[if (seam.axis == .vertical) 0 else 1] = -v / length; + slot_out[if (seam.axis == .vertical) 1 else 0] = -tip * direction / length; + } + const radius = rs.radius * open; + const weights: [2]f32 = .{ @max(radius + d, 0), @max(radius - slot, 0) }; + const norm = @sqrt(weights[0] * weights[0] + weights[1] * weights[1]); + if (radius > 0 and norm > 0) { + g.* = .{ (weights[0] * g[0] + weights[1] * slot_out[0]) / norm, (weights[0] * g[1] + weights[1] * slot_out[1]) / norm }; + } else if (-slot > d) g.* = slot_out; + d = intersectRound(d, -slot, radius); + } + return d; +} + +/// Writes the layout rectangles and their corner radii into caller-owned out. +/// Asserts out can hold every piece (at most 1 + max_seams for non-crossing seams). +pub fn pieces(p: Panel, out: []Shape) []Shape { + std.debug.assert(p.seams.len <= max_seams and out.len > 0); + out[0] = .{ .rect = p.rect, .radii = p.radii, .blur = p.blur, .lens = p.lens }; + var n: usize = 1; + for (p.seams, 0..) |seam, si| { + const rs = resolveSeam(p, si); + const radius = rs.radius * std.math.clamp(seam.gap / seam.reach, 0, 1); + const count = n; + for (0..count) |i| { + const sh = out[i]; + const vertical = seam.axis == .vertical; + const lo = if (vertical) sh.rect.x else sh.rect.y; + const hi = lo + if (vertical) sh.rect.w else sh.rect.h; + const start = if (vertical) sh.rect.y else sh.rect.x; + const end = start + if (vertical) sh.rect.h else sh.rect.w; + if (seam.at <= lo or seam.at >= hi or end <= rs.span[0] or start >= rs.span[1]) continue; + std.debug.assert(n < out.len); + var a = sh; + var b = sh; + if (vertical) { + a.rect.w = @max(seam.at - seam.gap / 2 - lo, 0); + b.rect.x = seam.at + seam.gap / 2; + b.rect.w = @max(hi - b.rect.x, 0); + a.radii[1] = radius; + a.radii[2] = radius; + b.radii[0] = radius; + b.radii[3] = radius; + } else { + a.rect.h = @max(seam.at - seam.gap / 2 - lo, 0); + b.rect.y = seam.at + seam.gap / 2; + b.rect.h = @max(hi - b.rect.y, 0); + a.radii[2] = radius; + a.radii[3] = radius; + b.radii[0] = radius; + b.radii[1] = radius; + } + out[i] = a; + out[n] = b; + n += 1; + } + } + return out[0..n]; +} + +/// Strokes each piece and seam in physical pixels. Call after drawing the glass, in a frame. +pub fn drawOutlines(self: *const LiquidField, color: dvui.Color) void { + const opts: dvui.Path.StrokeOptions = .{ .thickness = 1.5, .color = .{ .color = color }, .closed = true }; + var storage: [1 << max_seams]Shape = undefined; + const parts = if (self.panel) |p| pieces(p, &storage) else self.shapes[0..self.len]; + for (parts) |part| part.rect.stroke(.{ + .tl = .round(part.radii[0]), + .tr = .round(part.radii[1]), + .br = .round(part.radii[2]), + .bl = .round(part.radii[3]), + }, opts); + if (self.panel) |p| for (p.seams, 0..) |seam, i| { + const rs = resolveSeam(p, i); + var path: dvui.Path.Builder = .init(dvui.currentWindow().lifo()); + defer path.deinit(); + for (rs.span) |end| path.addPoint(if (seam.axis == .vertical) .{ .x = seam.at, .y = end } else .{ .x = end, .y = seam.at }); + path.build().stroke(.{ .thickness = 1.5, .color = .{ .color = color } }); + }; +} + +fn shapeAt(self: *const LiquidField, i: usize) Shape { + if (i < self.len) return self.shapes[i]; + const p = self.panel.?; + return .{ .rect = p.rect, .radii = p.radii, .blur = p.blur, .lens = p.lens }; +} + +fn shapeCount(self: *const LiquidField) usize { + return self.len + @intFromBool(self.panel != null); +} + +/// Mutually exclusive with edge. Reserves one slot plus one per seam. +panel: ?Panel = null, shapes: [max_shapes]Shape = undefined, len: usize = 0, /// The place the glass belongs to: a view's card, rounded or square. Its outside is one more @@ -125,6 +308,10 @@ pub const Edge = struct { const edge_gap: f32 = 1; pub fn add(self: *LiquidField, shape: Shape) void { + if (self.panel) |p| { + std.debug.assert(p.seams.len <= max_seams); + if (self.len >= max_shapes - 1 - p.seams.len) return; + } if (self.len >= max_shapes - 1 and self.edge != null) return; if (self.len >= max_shapes) return; self.shapes[self.len] = shape; @@ -135,6 +322,7 @@ pub fn add(self: *LiquidField, shape: Shape) void { pub fn bounds(self: *const LiquidField) dvui.Rect.Physical { var r: dvui.Rect.Physical = .{}; for (self.shapes[0..self.len], 0..) |s, i| r = if (i == 0) s.rect else r.unionWith(s.rect); + if (self.panel) |p| r = if (self.len == 0) p.rect else r.unionWith(p.rect); return self.withReach(r); } @@ -161,7 +349,7 @@ pub const Clusters = struct { pub fn clusters(self: *const LiquidField) Clusters { var parent: [max_shapes]u8 = undefined; - for (0..self.len) |i| parent[i] = @intCast(i); + for (0..self.shapeCount()) |i| parent[i] = @intCast(i); const find = struct { fn f(p: *[max_shapes]u8, i: u8) u8 { var x = i; @@ -170,21 +358,24 @@ pub fn clusters(self: *const LiquidField) Clusters { } }.f; const reach = self.merge_px * 0.5; - for (0..self.len) |i| for (i + 1..self.len) |j| { - const a = self.shapes[i].rect.outsetAll(reach); - const b = self.shapes[j].rect.outsetAll(reach); - if (a.intersect(b).empty()) continue; + for (0..self.shapeCount()) |i| for (i + 1..self.shapeCount()) |j| { + const a = self.shapeAt(i).rect.outsetAll(reach); + const b = self.shapeAt(j).rect.outsetAll(reach); + // Tangent drops must share the panel group so its boundary can form a neck. + if (self.panel != null and (i == self.len or j == self.len)) { + if (a.x > b.x + b.w or b.x > a.x + a.w or a.y > b.y + b.h or b.y > a.y + a.h) continue; + } else if (a.intersect(b).empty()) continue; const ri = find(&parent, @intCast(i)); const rj = find(&parent, @intCast(j)); if (ri != rj) parent[rj] = ri; }; var out: Clusters = .{}; var n: u8 = 0; - for (0..self.len) |root| { + for (0..self.shapeCount()) |root| { if (find(&parent, @intCast(root)) != root) continue; out.first[out.count] = n; var size: u8 = 0; - for (0..self.len) |i| { + for (0..self.shapeCount()) |i| { if (find(&parent, @intCast(i)) != root) continue; out.order[n] = @intCast(i); n += 1; @@ -254,13 +445,14 @@ fn look(self: *const LiquidField) liquid_glass.Look { /// would be all rim. Every shape is glass whatever its size (`liquid_glass.fit`). fn rimScale(self: *const LiquidField, depth_px: f32) f32 { var f: f32 = 1; - for (self.shapes[0..self.len]) |sh| f = @min(f, liquid_glass.fit(sh.rect, depth_px)); + for (0..self.shapeCount()) |i| f = @min(f, liquid_glass.fit(self.shapeAt(i).rect, depth_px)); return self.scale * f; } /// The uniforms for drawing over `frost`, a picture of `covered`, the shapes in `order`: the /// field's own, so they are worked out with no window — what the window behind it is, `draw` adds. pub fn pack(self: *const LiquidField, covered: dvui.Rect.Physical, has_sharp: bool, order: []const u8) Uniforms { + std.debug.assert(self.panel == null or self.edge == null); const s = self.scale; const tint: [4]f32 = if (self.tint) |t| blk: { const a = @as(f32, @floatFromInt(t.a)) / 255; @@ -285,12 +477,12 @@ pub fn pack(self: *const LiquidField, covered: dvui.Rect.Physical, has_sharp: bo u.widths[1..4].* = lanes.widths; @memset(std.mem.asBytes(&u.shapes), 0); for (order, 0..) |i, slot| { - const sh = self.shapes[i]; + const sh = self.shapeAt(i); const r = sh.rect; u.shapes[slot] = .{ .{ r.x + r.w / 2, r.y + r.h / 2, r.w / 2, r.h / 2 }, sh.radii, - .{ sh.blur, sh.lens, sh.light, if (sh.round) 1 else 0 }, + .{ sh.blur, sh.lens, sh.light, if (i == self.len and self.panel != null) -1 else if (sh.round) 1 else 0 }, }; } if (self.edge) |e| { @@ -304,6 +496,25 @@ pub fn pack(self: *const LiquidField, covered: dvui.Rect.Physical, has_sharp: bo .{ first.blur, first.lens, 0, if (e.cut) 3 else 2 }, }; } + if (self.panel) |p| { + std.debug.assert(p.seams.len <= max_seams and self.len <= max_shapes - 1 - p.seams.len); + var open = false; + for (p.seams) |seam| open = open or seam.gap > 0; + const first = self.shapeAt(self.len); + u.shapes[max_shapes - 1] = .{ + .{ p.rect.x + p.rect.w / 2, p.rect.y + p.rect.h / 2, p.rect.w / 2, p.rect.h / 2 }, + p.radii, + .{ first.blur, first.lens, if (open) @floatFromInt(p.seams.len) else 0, 4 }, + }; + if (open) for (p.seams, 0..) |seam, i| { + const rs = resolveSeam(p, i); + u.shapes[max_shapes - 2 - i] = .{ + .{ if (seam.axis == .vertical) 0 else 1, seam.at, rs.span[0], rs.span[1] }, + .{ seam.gap, seam.reach, rs.radius, @floatFromInt(@backingInt(rs.ends)) }, + .{ if (rs.host) |h| @floatFromInt(h + 1) else 0, 0, 0, 0 }, + }; + }; + } return u; } @@ -421,8 +632,9 @@ pub fn applyLook(self: *const LiquidField, u: *Uniforms, l: glass_look.Look) voi u.widths = .{ l.edge_dark, lanes.widths[0], lanes.widths[1], lanes.widths[2] }; u.light = lanes.light; u.edge = lanes.edge; - for (u.shapes[0..self.len]) |*sh| sh[2][0] *= l.frost; - if (self.edge != null) u.shapes[max_shapes - 1][2][0] *= l.frost; + const count = self.shapeCount(); + for (u.shapes[0..count]) |*sh| sh[2][0] *= l.frost; + if (self.edge != null or self.panel != null) u.shapes[max_shapes - 1][2][0] *= l.frost; } /// Test seam: the testing backend has no glass program, so `ready` is false there and every @@ -450,12 +662,12 @@ pub fn ready() bool { /// covers, as a frost does, with an anti-aliased edge. False, having drawn nothing, where there /// is no program to draw with. pub fn draw(self: *const LiquidField, frost: dvui.Texture, covered: dvui.Rect.Physical, sharp: ?dvui.Texture) bool { - if (self.len == 0) return true; + if (self.shapeCount() == 0) return true; if (!enabled()) return false; const h = programs.hooks() orelse return false; const id = program.ready(h) orelse return false; const groups = self.clusters(); - var u = self.pack(covered, sharp != null, groups.order[0..self.len]); + var u = self.pack(covered, sharp != null, groups.order[0..self.shapeCount()]); // The window behind the glass, published for this frame. u.backdrop[0] = if (opaqueWindow() or self.solid) 1 else 0; // And the glass the app's look makes of it this frame (`core.material.publishLook`). @@ -483,7 +695,7 @@ pub fn draw(self: *const LiquidField, frost: dvui.Texture, covered: dvui.Rect.Ph /// until the frame ends. False, having queued nothing, where there is no glass program (`ready`): /// draw the picture some other way. pub fn drawPicture(self: *const LiquidField, picture: dvui.Texture, covered: dvui.Rect.Physical) bool { - if (self.len == 0) return true; + if (self.shapeCount() == 0) return true; if (!ready()) return false; const job = dvui.currentWindow().arena().create(PictureJob) catch return false; job.* = .{ .field = self.*, .picture = picture, .covered = covered }; @@ -501,7 +713,7 @@ pub fn drawPicture(self: *const LiquidField, picture: dvui.Texture, covered: dvu /// shapes' lenses. Apple's lens pulls only from inside the shape and needs none of it. pub fn pictureMargin(self: *const LiquidField) f32 { var lens: f32 = 0; - for (self.shapes[0..self.len]) |sh| lens = @max(lens, sh.lens); + for (0..self.shapeCount()) |i| lens = @max(lens, self.shapeAt(i).lens); return liquid_glass.margin(.{ .lens = lens, .refraction = self.refraction }, self.scale); } @@ -528,8 +740,8 @@ fn quads(self: *const LiquidField, groups: Clusters, glass: bool, frost: dvui.Te for (0..groups.count) |g| { const first = groups.first[g]; const n = groups.size[g]; - var r = self.shapes[groups.order[first]].rect; - for (groups.order[first..][0..n]) |i| r = r.unionWith(self.shapes[i].rect); + var r = self.shapeAt(groups.order[first]).rect; + for (groups.order[first..][0..n]) |i| r = r.unionWith(self.shapeAt(i).rect); r = self.withReach(r); if (r.empty()) continue; const col: dvui.Color.PMA = .{ .r = if (glass) 255 else 0, .g = first, .b = n, .a = 255 }; @@ -591,13 +803,15 @@ pub fn sampleWith(self: *const LiquidField, p: dvui.Point.Physical, l: glass_loo var al2: [2]f32 = @splat(0); const rim = self.rimScale(liquid_glass.depthPx(self.look(), self.scale)); const soft_k = liquid_glass.softness * rim; - for (self.shapes[0..self.len]) |sh| { + for (0..self.shapeCount()) |shape_index| { + const sh = self.shapeAt(shape_index); + const is_panel = shape_index == self.len and self.panel != null; const c: [2]f32 = .{ sh.rect.x + sh.rect.w / 2, sh.rect.y + sh.rect.h / 2 }; const half: [2]f32 = .{ sh.rect.w / 2, sh.rect.h / 2 }; var g: [2]f32 = undefined; const lim = @min(half[0], half[1]); const radii: [4]f32 = .{ @min(sh.radii[0], lim), @min(sh.radii[1], lim), @min(sh.radii[2], lim), @min(sh.radii[3], lim) }; - const d = roundBox(.{ p.x - c[0], p.y - c[1] }, half, radii, &g); + const d = if (is_panel) panelDistance(self.panel.?, .{ p.x, p.y }, 0, &g) else roundBox(.{ p.x - c[0], p.y - c[1] }, half, radii, &g); const mat: [3]f32 = .{ sh.blur, sh.lens, sh.light }; var al: [2]f32 = .{ 0, 0 }; if (lanes.edge[3] > 0) { @@ -621,7 +835,7 @@ pub fn sampleWith(self: *const LiquidField, p: dvui.Point.Physical, l: glass_loo al2 = al; } var o: [2]f32 = g; - const f = if (sh.round) d else softBox(.{ p.x, p.y }, c, half, soft_k, &o); + const f = if (is_panel) panelDistance(self.panel.?, .{ p.x, p.y }, soft_k, &o) else if (sh.round) d else softBox(.{ p.x, p.y }, c, half, soft_k, &o); if (f < f1) { f2 = f1; o2 = o1; @@ -751,7 +965,7 @@ fn alongEnd(p: [2]f32, box: [4]f32, rad: [4]f32, toward: [2]f32, ext: f32, ramp: /// Whether `p` is on the glass. pub fn hit(self: *const LiquidField, p: dvui.Point.Physical) bool { - return self.len > 0 and self.sample(p).d <= 0; + return self.shapeCount() > 0 and self.sample(p).d <= 0; } /// Signed distance to a box of half-size `b` at the origin with corner radii `r` (tl, tr, br, bl; diff --git a/backend/src/glass/liquid_field_tests.zig b/backend/src/glass/liquid_field_tests.zig index e904f0b7e..6383f5af6 100644 --- a/backend/src/glass/liquid_field_tests.zig +++ b/backend/src/glass/liquid_field_tests.zig @@ -251,3 +251,276 @@ test "rim_falloff shapes the fade, rim_extent ends it" { } } } + +const Seam = LiquidField.Seam; +const Panel = LiquidField.Panel; +const panel_rect: dvui.Rect.Physical = .{ .x = 0, .y = 0, .w = 400, .h = 120 }; + +fn panelField(seams: []const Seam) LiquidField { + return .{ .panel = .{ .rect = panel_rect, .radii = @splat(20), .seams = seams } }; +} + +fn parentField(rect: dvui.Rect.Physical, radius: f32) LiquidField { + var f: LiquidField = .{}; + f.add(.{ .rect = rect, .radii = @splat(radius) }); + return f; +} + +fn panelSample(f: *const LiquidField, x: f32, y: f32) Sample { + return f.sampleWith(.{ .x = x, .y = y }, dropLook()); +} + +fn checkPieces(f: *const LiquidField) !void { + var storage: [16]Shape = undefined; + const parts = LiquidField.pieces(f.panel.?, &storage); + var expected: LiquidField = .{}; + for (parts) |part| expected.add(part); + // The contour and its anti-aliasing band, including every cut corner. + for (0..129) |yi| for (0..409) |xi| { + const x = @as(f32, @floatFromInt(xi)) - 4; + const y = @as(f32, @floatFromInt(yi)) - 4; + const a = panelSample(f, x, y); + const b = panelSample(&expected, x, y); + if (@abs(a.d) <= 1 or @abs(b.d) <= 1) try testing.expectApproxEqAbs(b.d, a.d, 0.25); + }; +} + +/// The narrowest remaining neck across 32 parallel rays through the seam's centre. +fn neckWidth(f: *const LiquidField, at: f32, height: f32) f32 { + var width: f32 = height; + for (0..32) |ray| { + const x = at + (@as(f32, @floatFromInt(ray)) / 31 - 0.5) * 0.5; + var run: f32 = 0; + var longest: f32 = 0; + var y: f32 = 0; + while (y < height) : (y += 0.25) { + if (panelSample(f, x, y).coverage >= 0.5) { + run += 0.25; + longest = @max(longest, run); + } else run = 0; + } + width = @min(width, longest); + } + return width; +} + +fn checkNeck(nested: bool) !void { + var seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .reach = 12 }, + }; + if (!nested) seams[1].span = null; + var previous: f32 = if (nested) 60 else 120; + const total = previous; + for (0..61) |step| { + seams[1].gap = @as(f32, @floatFromInt(step)) / 60 * 12; + const f = panelField(if (nested) &seams else seams[1..]); + const width = neckWidth(&f, 200, total); + try testing.expect(width <= previous + 0.25); + try testing.expect(previous - width <= total * 0.15); + previous = width; + } + try testing.expectEqual(@as(f32, 0), previous); +} + +/// Opt-in headless evidence; ordinary test runs write no files. +fn dumpPanelCoverage() !void { + const destination = testing.environ.getAlloc(testing.allocator, "FIZZY_PANEL_DUMPS") catch |err| switch (err) { + error.EnvironmentVariableMissing => return, + else => return err, + }; + defer testing.allocator.free(destination); + var dir = try std.Io.Dir.cwd().openDir(testing.io, destination, .{}); + defer dir.close(testing.io); + const width = 408; + const height = 128; + const header = "P5\n408 128\n255\n"; + const bytes = try testing.allocator.alloc(u8, header.len + width * height); + defer testing.allocator.free(bytes); + @memcpy(bytes[0..header.len], header); + for (0..5) |step| { + const gap = @as(f32, @floatFromInt(step)) * 3; + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .gap = gap, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .gap = gap, .reach = 12 }, + }; + const f = panelField(&seams); + for (0..height) |y| for (0..width) |x| { + const coverage = panelSample(&f, @as(f32, @floatFromInt(x)) - 4, @as(f32, @floatFromInt(y)) - 4).coverage; + bytes[header.len + y * width + x] = @intFromFloat(coverage * 255); + }; + var name: [32]u8 = undefined; + const filename = try std.mem.print(&name, "panel-{d}.pgm", .{step}); + try dir.writeFile(testing.io, .{ .sub_path = filename, .data = bytes }); + } +} + +test "a closed panel is its parent" { + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 30, .reach = 12 }, + .{ .axis = .vertical, .at = 150, .reach = 12 }, + .{ .axis = .vertical, .at = 270, .span = .{ 0, 30 }, .reach = 12 }, + }; + const rect: dvui.Rect.Physical = .{ .x = 0, .y = 0, .w = 400, .h = 60 }; + const f: LiquidField = .{ .panel = .{ .rect = rect, .radii = @splat(30), .seams = &seams } }; + const parent = parentField(rect, 30); + for (0..69) |yi| for (0..409) |xi| { + const x = @as(f32, @floatFromInt(xi)) - 4; + const y = @as(f32, @floatFromInt(yi)) - 4; + const a = panelSample(&f, x, y); + const b = panelSample(&parent, x, y); + try testing.expectApproxEqAbs(b.coverage, a.coverage, 0.25); + try testing.expectApproxEqAbs(b.d, a.d, 0.25); + }; + const groups = f.clusters(); + try testing.expectEqual(@as(usize, 1), groups.count); + try testing.expectEqual(@as(u8, 1), groups.size[0]); + const uniforms = f.pack(rect, false, groups.order[0..1]); + try testing.expectEqual(@as(f32, 0), uniforms.shapes[15][2][2]); + try testing.expectEqual(@as(f32, 4), uniforms.shapes[15][2][3]); +} + +test "no bump at the seam while it opens" { + var seams = [_]Seam{.{ .axis = .vertical, .at = 200, .reach = 12 }}; + const parent = parentField(panel_rect, 20); + for (0..19) |step| { + seams[0].gap = @as(f32, @floatFromInt(step)) / 60 * 12; + const f = panelField(&seams); + for (0..41) |xi| { + const x = 180 + @as(f32, @floatFromInt(xi)); + try testing.expect(panelSample(&f, x, 0).d >= panelSample(&parent, x, 0).d - 0.01); + } + } +} + +test "a through seam's pieces are rounded rects" { + const seams = [_]Seam{.{ .axis = .vertical, .at = 200, .gap = 12, .reach = 12 }}; + const f = panelField(&seams); + try checkPieces(&f); +} + +test "the neck moves smoothly" { + try checkNeck(false); +} + +test "2D: closed is the parent" { + var seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .reach = 12 }, + }; + const parent = parentField(panel_rect, 20); + for ([_]f32{ 0, 1e-6 }) |gap| { + for (&seams) |*seam| seam.gap = gap; + const f = panelField(&seams); + for (0..129) |yi| for (0..409) |xi| { + const x = @as(f32, @floatFromInt(xi)) - 4; + const y = @as(f32, @floatFromInt(yi)) - 4; + try testing.expectApproxEqAbs(panelSample(&parent, x, y).d, panelSample(&f, x, y).d, 0.01); + }; + } +} + +test "2D: three rounded pieces" { + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .gap = 12, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .gap = 12, .reach = 12 }, + }; + const f = panelField(&seams); + try checkPieces(&f); + const groups = f.clusters(); + const u = f.pack(panel_rect, false, groups.order[0..1]); + try testing.expectEqual(@as(f32, 2), u.shapes[15][2][2]); + try testing.expectEqual([4]f32{ 12, 12, 6, 1 }, u.shapes[13][1]); + try testing.expectEqual(@as(f32, 1), u.shapes[13][2][0]); +} + +test "2D: pills part, the brief stays whole" { + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .gap = 12, .reach = 12 }, + }; + const f = panelField(&seams); + const parent = parentField(panel_rect, 20); + var storage: [8]Shape = undefined; + const parts = LiquidField.pieces(f.panel.?, &storage); + try testing.expectEqual(@as(f32, 20), parts[0].radii[2]); + // The half-pixel below the host belongs to the continuous antialiasing band. + for (0..120) |yi| for (0..401) |xi| { + const x: f32 = @floatFromInt(xi); + const y = 60.5 + @as(f32, @floatFromInt(yi)) * 0.5; + try testing.expectApproxEqAbs(panelSample(&parent, x, y).coverage, panelSample(&f, x, y).coverage, 0.001); + }; + try checkNeck(true); +} + +test "pieces() is the console's model" { + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .reach = 12 }, + Seam.between(.vertical, 197, 203, .{ 0, 60 }, 12), + }; + const f = panelField(&seams); + var storage: [8]Shape = undefined; + const parts = LiquidField.pieces(f.panel.?, &storage); + try testing.expectEqual(@as(usize, 3), parts.len); + try testing.expectEqual(@as(f32, 10), parts[0].radii[1]); + try testing.expectEqual(@as(f32, 10), parts[0].radii[2]); + try testing.expectEqual(@as(f32, 10), parts[2].radii[0]); + try testing.expectEqual(@as(f32, 10), parts[2].radii[3]); + var area: f32 = 0; + for (parts) |part| area += part.rect.w * part.rect.h; + try testing.expectEqual(@as(f32, 400 * 120 - 6 * 60), area); +} + +test "a drop still runs into a panel" { + var f = panelField(&.{}); + f.merge_px = 16; + f.add(Shape.circle(.{ .x = 200, .y = -18 }, 10)); + // At exactly half the merge width the quadratic minimum is tangent at coverage 0.5. + try testing.expectApproxEqAbs(@as(f32, 0.5), panelSample(&f, 200, -4).coverage, 0.001); + f.shapes[0].rect.y += 0.1; + try testing.expect(panelSample(&f, 200, -4).coverage > 0.5); + f.merge_px = 0; + try testing.expectEqual(@as(f32, 0), panelSample(&f, 200, -4).coverage); +} + +test "panel coverage evidence" { + try dumpPanelCoverage(); +} + +test "a drop cannot animate the panel material" { + var f = panelField(&.{}); + f.panel.?.blur = 0.7; + f.panel.?.lens = 0.8; + f.add(.{ .rect = .{ .x = 500, .y = 0, .w = 20, .h = 20 }, .blur = 0.1, .lens = 0.2 }); + const before = panelSample(&f, 100, 40); + f.shapes[0].blur = 0.9; + f.shapes[0].lens = 1.2; + const after = panelSample(&f, 100, 40); + try testing.expectEqual(before, after); + const groups = f.clusters(); + const u = f.pack(panel_rect, false, groups.order[0..2]); + try testing.expectApproxEqAbs(@as(f32, 0.7), u.shapes[15][2][0], 0.001); + try testing.expectApproxEqAbs(@as(f32, 0.8), u.shapes[15][2][1], 0.001); +} + +test "nested seam tolerates coordinate rounding" { + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .gap = 12, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60.000004 }, .gap = 12, .reach = 12 }, + }; + const f = panelField(&seams); + const u = f.pack(panel_rect, false, &.{0}); + try testing.expectEqual(@as(f32, 1), u.shapes[13][2][0]); + try testing.expectEqual(@as(f32, 1), u.shapes[13][1][3]); +} + +test "panel outlines draw in a frame" { + var window = try dvui.testing.init(.{ .allocator = testing.allocator }); + defer window.deinit(); + const seams = [_]Seam{ + .{ .axis = .horizontal, .at = 60, .gap = 12, .reach = 12 }, + .{ .axis = .vertical, .at = 200, .span = .{ 0, 60 }, .gap = 12, .reach = 12 }, + }; + const f = panelField(&seams); + f.drawOutlines(.white); +} diff --git a/backend/src/glass/shaders/compiled/dxil/liquid_glass.fragment.dxil b/backend/src/glass/shaders/compiled/dxil/liquid_glass.fragment.dxil index 427649d19..f96091527 100644 Binary files a/backend/src/glass/shaders/compiled/dxil/liquid_glass.fragment.dxil and b/backend/src/glass/shaders/compiled/dxil/liquid_glass.fragment.dxil differ diff --git a/backend/src/glass/shaders/compiled/glsl/liquid_glass.fragment.glsl b/backend/src/glass/shaders/compiled/glsl/liquid_glass.fragment.glsl index 0179fd59b..68627cf4f 100644 --- a/backend/src/glass/shaders/compiled/glsl/liquid_glass.fragment.glsl +++ b/backend/src/glass/shaders/compiled/glsl/liquid_glass.fragment.glsl @@ -12,348 +12,841 @@ layout(location = 0) out highp vec4 out_var_SV_Target0; void main() { - highp vec4 _1186; + highp vec4 _1712; do { - int _107 = int((vColor.y * 255.0) + 0.5); - int _112 = int((vColor.z * 255.0) + 0.5); - bool _136 = uData[5].y > 0.0; - highp vec2 _138; - highp float _141; - highp vec2 _143; - highp vec2 _145; - highp vec4 _147; - highp vec2 _149; - highp float _151; - highp float _153; - highp vec2 _155; - highp vec2 _157; - highp vec4 _159; - highp float _161; - highp float _163; - highp float _165; - _138 = vec2(0.0, 1.0); - _141 = 1000000000.0; - _143 = vec2(0.0); - _145 = vec2(0.0); - _147 = vec4(0.0); - _149 = vec2(0.0); - _151 = 1000000000.0; - _153 = 1000000000.0; - _155 = vec2(0.0); - _157 = vec2(0.0, 1.0); - _159 = vec4(0.0); - _161 = 1000000000.0; - _163 = 1000000000.0; - _165 = 1000000000.0; - highp vec2 _150; + int _110 = int((vColor.y * 255.0) + 0.5); + int _115 = int((vColor.z * 255.0) + 0.5); + bool _139 = uData[5].y > 0.0; + highp vec2 _141; + highp float _144; + highp vec2 _146; + highp vec2 _148; + highp vec4 _150; + highp vec2 _152; highp float _154; - highp vec2 _156; - highp vec4 _160; + highp float _156; + highp vec2 _158; + highp vec2 _160; + highp vec4 _162; highp float _164; highp float _166; - highp vec2 _139; - highp float _142; - highp vec2 _144; - highp vec2 _146; - highp vec4 _148; - highp float _152; - highp vec2 _158; - highp float _162; - int _167 = _107; + highp float _168; + _141 = vec2(0.0, 1.0); + _144 = 1000000000.0; + _146 = vec2(0.0); + _148 = vec2(0.0); + _150 = vec4(0.0); + _152 = vec2(0.0); + _154 = 1000000000.0; + _156 = 1000000000.0; + _158 = vec2(0.0); + _160 = vec2(0.0, 1.0); + _162 = vec4(0.0); + _164 = 1000000000.0; + _166 = 1000000000.0; + _168 = 1000000000.0; + highp vec2 _153; + highp float _157; + highp vec2 _159; + highp vec4 _163; + highp float _167; + highp float _169; + highp vec2 _142; + highp float _145; + highp vec2 _147; + highp vec2 _149; + highp vec4 _151; + highp float _155; + highp vec2 _161; + highp float _165; + int _170 = _110; for (;;) { - bool _176; - if (_167 < (_107 + _112)) + bool _179; + if (_170 < (_110 + _115)) { - _176 = _167 < 16; + _179 = _170 < 16; } else { - _176 = false; + _179 = false; } - if (_176) + if (_179) { - int _178 = 3 * _167; - int _179 = 11 + _178; - int _185 = _178 + 13; - highp float _190 = min(uData[_179 * 1 + 0].z, uData[_179 * 1 + 0].w); - highp vec4 _192 = min(uData[(_178 + 12) * 1 + 0], vec4(_190)); - highp vec2 _194 = vTextureCoord - uData[_179 * 1 + 0].xy; - highp float _196 = _194.x; - highp float _217; - if (_196 > 0.0) + int _181 = 3 * _170; + int _188 = _181 + 13; + bool _196; + if (uData[_188 * 1 + 0].w >= (-0.5)) { - highp float _208; - if (_194.y > 0.0) - { - _208 = _192.z; - } - else - { - _208 = _192.y; - } - _217 = _208; + _196 = uData[_188 * 1 + 0].w > 3.5; } else { - highp float _216; - if (_194.y > 0.0) - { - _216 = _192.w; - } - else - { - _216 = _192.x; - } - _217 = _216; + _196 = true; } - highp vec2 _221 = (abs(_194) - uData[_179 * 1 + 0].zw) + vec2(_217); - highp float _223 = (_196 < 0.0) ? (-1.0) : 1.0; - highp float _226 = (_194.y < 0.0) ? (-1.0) : 1.0; - highp float _228 = _221.x; - bool _234; - if (_228 > 0.0) + highp vec4 _206; + highp vec4 _207; + highp vec4 _208; + if (_196) { - _234 = _221.y > 0.0; + highp vec4 _204 = uData[58]; + _204.z = 0.0; + _206 = _204; + _207 = uData[56]; + _208 = uData[57]; } else { - _234 = false; + _206 = uData[_188 * 1 + 0]; + _207 = uData[(11 + _181) * 1 + 0]; + _208 = uData[(_181 + 12) * 1 + 0]; } - highp vec2 _248; - if (_234) + highp float _211 = min(_207.z, _207.w); + highp vec4 _213 = min(_208, vec4(_211)); + highp vec2 _498; + highp float _499; + if (_196) { - _248 = normalize(_221) * vec2(_223, _226); + highp vec4 _288 = min(uData[57], vec4(min(uData[56].z, uData[56].w))); + int _291 = int(uData[58].z); + highp vec2 _293 = vTextureCoord - uData[56].xy; + highp float _295 = _293.x; + highp float _316; + if (_295 > 0.0) + { + highp float _315; + if (_293.y > 0.0) + { + _315 = _288.z; + } + else + { + _315 = _288.y; + } + _316 = _315; + } + else + { + highp float _307; + if (_293.y > 0.0) + { + _307 = _288.w; + } + else + { + _307 = _288.x; + } + _316 = _307; + } + highp vec2 _320 = (abs(_293) - uData[56].zw) + vec2(_316); + highp float _322 = (_295 < 0.0) ? (-1.0) : 1.0; + highp float _325 = (_293.y < 0.0) ? (-1.0) : 1.0; + highp float _327 = _320.x; + bool _333; + if (_327 > 0.0) + { + _333 = _320.y > 0.0; + } + else + { + _333 = false; + } + highp vec2 _347; + if (_333) + { + _347 = normalize(_320) * vec2(_322, _325); + } + else + { + highp vec2 _344; + if (_327 > _320.y) + { + _344 = vec2(_322, 0.0); + } + else + { + _344 = vec2(0.0, _325); + } + _347 = _344; + } + highp vec2 _356; + highp float _359; + _356 = _347; + _359 = (min(max(_327, _320.y), 0.0) + length(max(_320, vec2(0.0)))) - _316; + highp vec2 _357; + highp float _360; + int _361 = 0; + for (;;) + { + bool _369; + if (_361 < _291) + { + _369 = _361 < 4; + } + else + { + _369 = false; + } + if (_369) + { + int _371 = 14 - _361; + int _372 = 3 * _371; + int _373 = 11 + _372; + int _376 = _372 + 12; + if (uData[_376 * 1 + 0].x == 0.0) + { + _357 = _356; + _360 = _359; + int _362 = _361 + 1; + _356 = _357; + _359 = _360; + _361 = _362; + continue; + } + highp float _385 = clamp(uData[_376 * 1 + 0].x / uData[_376 * 1 + 0].y, 0.0, 1.0); + bool _387 = uData[_373 * 1 + 0].x < 0.5; + highp float _395; + if (_387) + { + _395 = vTextureCoord.y; + } + else + { + _395 = vTextureCoord.x; + } + highp float _403; + if (_387) + { + _403 = vTextureCoord.x; + } + else + { + _403 = vTextureCoord.y; + } + highp float _405 = _403 - uData[_373 * 1 + 0].y; + highp float _406 = uData[_376 * 1 + 0].x * 0.5; + highp float _409 = uData[_373 * 1 + 0].w - uData[_373 * 1 + 0].z; + highp float _410 = smoothstep(0.0, 0.60000002384185791015625, _385); + highp float _439; + highp float _440; + if (uData[_376 * 1 + 0].w > 2.5) + { + highp float _430 = _395 - ((uData[_373 * 1 + 0].z + uData[_373 * 1 + 0].w) * 0.5); + _439 = (_430 < 0.0) ? 1.0 : (-1.0); + _440 = max(((_409 * 0.5) * (1.0 - _410)) - abs(_430), 0.0); + } + else + { + bool _416 = uData[_376 * 1 + 0].w < 1.5; + highp float _422; + if (_416) + { + _422 = _395 - uData[_373 * 1 + 0].z; + } + else + { + _422 = uData[_373 * 1 + 0].w - _395; + } + _439 = _416 ? 1.0 : (-1.0); + _440 = max(_422 - ((_409 - _406) * _410), 0.0); + } + highp float _442 = length(vec2(_405, _440)); + highp float _443 = _442 - _406; + highp vec2 _458; + if (_442 > 0.0) + { + highp vec2 _452 = vec2(-_405, (-_440) * _439) / vec2(_442); + highp vec2 _457; + if (uData[_373 * 1 + 0].x > 0.5) + { + _457 = _452.yx; + } + else + { + _457 = _452; + } + _458 = _457; + } + else + { + _458 = vec2(0.0); + } + highp float _460 = uData[_376 * 1 + 0].z * _385; + highp vec2 _464 = max(vec2(_460 + _359, _460 - _443), vec2(0.0)); + highp float _465 = length(_464); + bool _470; + if (_460 > 0.0) + { + _470 = _465 > 0.0; + } + else + { + _470 = false; + } + highp vec2 _485; + if (_470) + { + _485 = ((_356 * _464.x) + (_458 * _464.y)) / vec2(_465); + } + else + { + bvec2 _476 = bvec2((-_443) > _359); + _485 = vec2(_476.x ? _458.x : _356.x, _476.y ? _458.y : _356.y); + } + highp float _486 = -_443; + highp float _497; + do + { + if (_460 == 0.0) + { + _497 = max(_359, _486); + break; + } + _497 = min(-_460, max(_359, _486)) + _465; + break; + } while(false); + _357 = _485; + _360 = _497; + int _362 = _361 + 1; + _356 = _357; + _359 = _360; + _361 = _362; + continue; + } + else + { + break; + } + } + _498 = _356; + _499 = _359; } else { - highp vec2 _247; - if (_228 > _221.y) + highp vec2 _218 = vTextureCoord - _207.xy; + highp float _220 = _218.x; + highp float _241; + if (_220 > 0.0) + { + highp float _240; + if (_218.y > 0.0) + { + _240 = _213.z; + } + else + { + _240 = _213.y; + } + _241 = _240; + } + else + { + highp float _232; + if (_218.y > 0.0) + { + _232 = _213.w; + } + else + { + _232 = _213.x; + } + _241 = _232; + } + highp vec2 _245 = (abs(_218) - _207.zw) + vec2(_241); + highp float _247 = (_220 < 0.0) ? (-1.0) : 1.0; + highp float _250 = (_218.y < 0.0) ? (-1.0) : 1.0; + highp float _252 = _245.x; + bool _258; + if (_252 > 0.0) { - _247 = vec2(_223, 0.0); + _258 = _245.y > 0.0; } else { - _247 = vec2(0.0, _226); + _258 = false; } - _248 = _247; + highp vec2 _272; + if (_258) + { + _272 = normalize(_245) * vec2(_247, _250); + } + else + { + highp vec2 _269; + if (_252 > _245.y) + { + _269 = vec2(_247, 0.0); + } + else + { + _269 = vec2(0.0, _250); + } + _272 = _269; + } + _498 = _272; + _499 = (min(max(_252, _245.y), 0.0) + length(max(_245, vec2(0.0)))) - _241; } - highp float _255 = (min(max(_228, _221.y), 0.0) + length(max(_221, vec2(0.0)))) - _217; - highp vec2 _401; + highp vec2 _647; if (uData[10].w > 0.0) { - highp float _264 = (uData[9].x < 0.0) ? (-1.0) : 1.0; - highp float _267 = (uData[9].y < 0.0) ? (-1.0) : 1.0; - highp float _287; - if (_264 < 0.0) + highp float _508 = (uData[9].x < 0.0) ? (-1.0) : 1.0; + highp float _511 = (uData[9].y < 0.0) ? (-1.0) : 1.0; + highp float _531; + if (_508 < 0.0) { - highp float _279; - if (_267 < 0.0) + highp float _530; + if (_511 < 0.0) { - _279 = _192.x; + _530 = _213.x; } else { - _279 = _192.w; + _530 = _213.w; } - _287 = _279; + _531 = _530; } else { - highp float _286; - if (_267 < 0.0) + highp float _523; + if (_511 < 0.0) { - _286 = _192.y; + _523 = _213.y; } else { - _286 = _192.z; + _523 = _213.z; } - _287 = _286; + _531 = _523; } - highp vec2 _290 = max(uData[_179 * 1 + 0].zw - vec2(_287), vec2(0.0)); - highp vec2 _294 = (uData[_179 * 1 + 0].xy + (vec2(_264, _267) * _290)) + (uData[9].xy * _287); - highp vec2 _309; + highp vec2 _535 = max(_207.zw - vec2(_531), vec2(0.0)); + highp vec2 _540 = (_207.xy + (vec2(_508, _511) * _535)) + (uData[9].xy * _531); + highp vec2 _555; if (abs(uData[9].x) < 0.001000000047497451305389404296875) { - highp float _302 = _290.x; - highp vec2 _308 = _294; - _308.x = clamp(vTextureCoord.x, uData[_179 * 1 + 0].x - _302, uData[_179 * 1 + 0].x + _302) + (_287 * uData[9].x); - _309 = _308; + highp float _548 = _535.x; + highp vec2 _554 = _540; + _554.x = clamp(vTextureCoord.x, _207.x - _548, _207.x + _548) + (_531 * uData[9].x); + _555 = _554; } else { - _309 = _294; + _555 = _540; } - highp vec2 _324; + highp vec2 _570; if (abs(uData[9].y) < 0.001000000047497451305389404296875) { - highp float _317 = _290.y; - highp vec2 _323 = _309; - _323.y = clamp(vTextureCoord.y, uData[_179 * 1 + 0].y - _317, uData[_179 * 1 + 0].y + _317) + (_287 * uData[9].y); - _324 = _323; + highp float _563 = _535.y; + highp vec2 _569 = _555; + _569.y = clamp(vTextureCoord.y, _207.y - _563, _207.y + _563) + (_531 * uData[9].y); + _570 = _569; } else { - _324 = _309; + _570 = _555; } - highp float _327 = max(uData[10].w - max(uData[8].w, 1.0), 0.0); - highp vec2 _332 = -uData[9].xy; - highp float _333 = _332.x; - highp float _335 = (_333 < 0.0) ? (-1.0) : 1.0; - highp float _336 = _332.y; - highp float _338 = (_336 < 0.0) ? (-1.0) : 1.0; - highp float _358; - if (_335 < 0.0) + highp float _573 = max(uData[10].w - max(uData[8].w, 1.0), 0.0); + highp vec2 _578 = -uData[9].xy; + highp float _579 = _578.x; + highp float _581 = (_579 < 0.0) ? (-1.0) : 1.0; + highp float _582 = _578.y; + highp float _584 = (_582 < 0.0) ? (-1.0) : 1.0; + highp float _604; + if (_581 < 0.0) { - highp float _350; - if (_338 < 0.0) + highp float _603; + if (_584 < 0.0) { - _350 = _192.x; + _603 = _213.x; } else { - _350 = _192.w; + _603 = _213.w; } - _358 = _350; + _604 = _603; } else { - highp float _357; - if (_338 < 0.0) + highp float _596; + if (_584 < 0.0) { - _357 = _192.y; + _596 = _213.y; } else { - _357 = _192.z; + _596 = _213.z; } - _358 = _357; + _604 = _596; } - highp vec2 _361 = max(uData[_179 * 1 + 0].zw - vec2(_358), vec2(0.0)); - highp vec2 _365 = (uData[_179 * 1 + 0].xy + (vec2(_335, _338) * _361)) + (_332 * _358); - highp vec2 _380; - if (abs(_333) < 0.001000000047497451305389404296875) + highp vec2 _607 = max(_207.zw - vec2(_604), vec2(0.0)); + highp vec2 _611 = (_207.xy + (vec2(_581, _584) * _607)) + (_578 * _604); + highp vec2 _626; + if (abs(_579) < 0.001000000047497451305389404296875) { - highp float _373 = _361.x; - highp vec2 _379 = _365; - _379.x = clamp(vTextureCoord.x, uData[_179 * 1 + 0].x - _373, uData[_179 * 1 + 0].x + _373) + (_358 * _333); - _380 = _379; + highp float _619 = _607.x; + highp vec2 _625 = _611; + _625.x = clamp(vTextureCoord.x, _207.x - _619, _207.x + _619) + (_604 * _579); + _626 = _625; } else { - _380 = _365; + _626 = _611; } - highp vec2 _395; - if (abs(_336) < 0.001000000047497451305389404296875) + highp vec2 _641; + if (abs(_582) < 0.001000000047497451305389404296875) { - highp float _388 = _361.y; - highp vec2 _394 = _380; - _394.y = clamp(vTextureCoord.y, uData[_179 * 1 + 0].y - _388, uData[_179 * 1 + 0].y + _388) + (_358 * _336); - _395 = _394; + highp float _634 = _607.y; + highp vec2 _640 = _626; + _640.y = clamp(vTextureCoord.y, _207.y - _634, _207.y + _634) + (_604 * _582); + _641 = _640; } else { - _395 = _380; + _641 = _626; } - _401 = vec2(1.0 - smoothstep(_327, uData[10].w, length(vTextureCoord - _324)), 1.0 - smoothstep(_327, uData[10].w, length(vTextureCoord - _395))); + _647 = vec2(1.0 - smoothstep(_573, uData[10].w, length(vTextureCoord - _570)), 1.0 - smoothstep(_573, uData[10].w, length(vTextureCoord - _641))); } else { - _401 = vec2(0.0); + _647 = vec2(0.0); } - bool _402 = _255 < _163; - if (_402) + bool _648 = _499 < _166; + if (_648) { - _139 = _157; - _142 = _165; - _144 = _155; - _148 = _159; - _158 = uData[_179 * 1 + 0].yw; - _162 = _163; + _142 = _160; + _145 = _168; + _147 = _158; + _151 = _162; + _161 = _207.yw; + _165 = _166; } else { - bool _407 = _255 < _161; - highp vec2 _411; - if (_407) + bool _652 = _499 < _164; + highp vec2 _656; + if (_652) { - _411 = uData[_179 * 1 + 0].yw; + _656 = _207.yw; } else { - _411 = _138; + _656 = _141; } - bvec2 _413 = bvec2(_407); - bvec4 _415 = bvec4(_407); - _139 = _411; - _142 = _407 ? _190 : _141; - _144 = vec2(_413.x ? _401.x : _143.x, _413.y ? _401.y : _143.y); - _148 = vec4(_415.x ? uData[_185 * 1 + 0].x : _147.x, _415.y ? uData[_185 * 1 + 0].y : _147.y, _415.z ? uData[_185 * 1 + 0].z : _147.z, _415.w ? uData[_185 * 1 + 0].w : _147.w); - _158 = _157; - _162 = _407 ? _255 : _161; + bvec2 _658 = bvec2(_652); + bvec4 _660 = bvec4(_652); + _142 = _656; + _145 = _652 ? _211 : _144; + _147 = vec2(_658.x ? _647.x : _146.x, _658.y ? _647.y : _146.y); + _151 = vec4(_660.x ? _206.x : _150.x, _660.y ? _206.y : _150.y, _660.z ? _206.z : _150.z, _660.w ? _206.w : _150.w); + _161 = _160; + _165 = _652 ? _499 : _164; } - bvec2 _418 = bvec2(_402); - _156 = vec2(_418.x ? _401.x : _155.x, _418.y ? _401.y : _155.y); - bvec4 _419 = bvec4(_402); - _160 = vec4(_419.x ? uData[_185 * 1 + 0].x : _159.x, _419.y ? uData[_185 * 1 + 0].y : _159.y, _419.z ? uData[_185 * 1 + 0].z : _159.z, _419.w ? uData[_185 * 1 + 0].w : _159.w); - _164 = _402 ? _255 : _163; - _166 = _402 ? _190 : _165; - highp vec2 _464; - highp float _465; - if (uData[_185 * 1 + 0].w < 0.5) + bvec2 _664 = bvec2(_648); + _159 = vec2(_664.x ? _647.x : _158.x, _664.y ? _647.y : _158.y); + bvec4 _665 = bvec4(_648); + _163 = vec4(_665.x ? _206.x : _162.x, _665.y ? _206.y : _162.y, _665.z ? _206.z : _162.z, _665.w ? _206.w : _162.w); + _167 = _648 ? _499 : _166; + _169 = _648 ? _211 : _168; + highp vec2 _978; + highp float _979; + if (_196) { - highp float _430 = (vTextureCoord.x - uData[_179 * 1 + 0].x) + uData[_179 * 1 + 0].z; - highp float _432 = (uData[_179 * 1 + 0].x + uData[_179 * 1 + 0].z) - vTextureCoord.x; - highp float _437 = (vTextureCoord.y - uData[_179 * 1 + 0].y) + uData[_179 * 1 + 0].w; - highp float _439 = (uData[_179 * 1 + 0].y + uData[_179 * 1 + 0].w) - vTextureCoord.y; - highp float _443 = min(min(_430, _432), min(_437, _439)); - highp vec4 _448 = exp((vec4(_443) - vec4(_430, _432, _437, _439)) / vec4(uData[1].y)); - highp float _449 = _448.x; - highp float _450 = _448.y; - highp float _452 = _448.z; - highp float _454 = _448.w; - highp float _455 = ((_449 + _450) + _452) + _454; - _464 = vec2(_450 - _449, _454 - _452) / vec2(_455); - _465 = (uData[1].y * log(_455)) - _443; + highp vec4 _724 = min(uData[57], vec4(min(uData[56].z, uData[56].w))); + int _727 = int(uData[58].z); + highp vec2 _833; + highp float _834; + if (uData[1].y > 0.0) + { + highp float _799 = (vTextureCoord.x - uData[56].x) + uData[56].z; + highp float _801 = (uData[56].x + uData[56].z) - vTextureCoord.x; + highp float _806 = (vTextureCoord.y - uData[56].y) + uData[56].w; + highp float _808 = (uData[56].y + uData[56].w) - vTextureCoord.y; + highp float _812 = min(min(_799, _801), min(_806, _808)); + highp vec4 _817 = exp((vec4(_812) - vec4(_799, _801, _806, _808)) / vec4(uData[1].y)); + highp float _818 = _817.x; + highp float _819 = _817.y; + highp float _821 = _817.z; + highp float _823 = _817.w; + highp float _824 = ((_818 + _819) + _821) + _823; + _833 = vec2(_819 - _818, _823 - _821) / vec2(_824); + _834 = (uData[1].y * log(_824)) - _812; + } + else + { + highp vec2 _733 = vTextureCoord - uData[56].xy; + highp float _735 = _733.x; + highp float _756; + if (_735 > 0.0) + { + highp float _755; + if (_733.y > 0.0) + { + _755 = _724.z; + } + else + { + _755 = _724.y; + } + _756 = _755; + } + else + { + highp float _747; + if (_733.y > 0.0) + { + _747 = _724.w; + } + else + { + _747 = _724.x; + } + _756 = _747; + } + highp vec2 _760 = (abs(_733) - uData[56].zw) + vec2(_756); + highp float _762 = (_735 < 0.0) ? (-1.0) : 1.0; + highp float _765 = (_733.y < 0.0) ? (-1.0) : 1.0; + highp float _767 = _760.x; + bool _773; + if (_767 > 0.0) + { + _773 = _760.y > 0.0; + } + else + { + _773 = false; + } + highp vec2 _787; + if (_773) + { + _787 = normalize(_760) * vec2(_762, _765); + } + else + { + highp vec2 _784; + if (_767 > _760.y) + { + _784 = vec2(_762, 0.0); + } + else + { + _784 = vec2(0.0, _765); + } + _787 = _784; + } + _833 = _787; + _834 = (min(max(_767, _760.y), 0.0) + length(max(_760, vec2(0.0)))) - _756; + } + highp vec2 _836; + highp float _839; + _836 = _833; + _839 = _834; + highp vec2 _837; + highp float _840; + int _841 = 0; + for (;;) + { + bool _849; + if (_841 < _727) + { + _849 = _841 < 4; + } + else + { + _849 = false; + } + if (_849) + { + int _851 = 14 - _841; + int _852 = 3 * _851; + int _853 = 11 + _852; + int _856 = _852 + 12; + if (uData[_856 * 1 + 0].x == 0.0) + { + _837 = _836; + _840 = _839; + int _842 = _841 + 1; + _836 = _837; + _839 = _840; + _841 = _842; + continue; + } + highp float _865 = clamp(uData[_856 * 1 + 0].x / uData[_856 * 1 + 0].y, 0.0, 1.0); + bool _867 = uData[_853 * 1 + 0].x < 0.5; + highp float _875; + if (_867) + { + _875 = vTextureCoord.y; + } + else + { + _875 = vTextureCoord.x; + } + highp float _883; + if (_867) + { + _883 = vTextureCoord.x; + } + else + { + _883 = vTextureCoord.y; + } + highp float _885 = _883 - uData[_853 * 1 + 0].y; + highp float _886 = uData[_856 * 1 + 0].x * 0.5; + highp float _889 = uData[_853 * 1 + 0].w - uData[_853 * 1 + 0].z; + highp float _890 = smoothstep(0.0, 0.60000002384185791015625, _865); + highp float _919; + highp float _920; + if (uData[_856 * 1 + 0].w > 2.5) + { + highp float _910 = _875 - ((uData[_853 * 1 + 0].z + uData[_853 * 1 + 0].w) * 0.5); + _919 = (_910 < 0.0) ? 1.0 : (-1.0); + _920 = max(((_889 * 0.5) * (1.0 - _890)) - abs(_910), 0.0); + } + else + { + bool _896 = uData[_856 * 1 + 0].w < 1.5; + highp float _902; + if (_896) + { + _902 = _875 - uData[_853 * 1 + 0].z; + } + else + { + _902 = uData[_853 * 1 + 0].w - _875; + } + _919 = _896 ? 1.0 : (-1.0); + _920 = max(_902 - ((_889 - _886) * _890), 0.0); + } + highp float _922 = length(vec2(_885, _920)); + highp float _923 = _922 - _886; + highp vec2 _938; + if (_922 > 0.0) + { + highp vec2 _932 = vec2(-_885, (-_920) * _919) / vec2(_922); + highp vec2 _937; + if (uData[_853 * 1 + 0].x > 0.5) + { + _937 = _932.yx; + } + else + { + _937 = _932; + } + _938 = _937; + } + else + { + _938 = vec2(0.0); + } + highp float _940 = uData[_856 * 1 + 0].z * _865; + highp vec2 _944 = max(vec2(_940 + _839, _940 - _923), vec2(0.0)); + highp float _945 = length(_944); + bool _950; + if (_940 > 0.0) + { + _950 = _945 > 0.0; + } + else + { + _950 = false; + } + highp vec2 _965; + if (_950) + { + _965 = ((_836 * _944.x) + (_938 * _944.y)) / vec2(_945); + } + else + { + bvec2 _956 = bvec2((-_923) > _839); + _965 = vec2(_956.x ? _938.x : _836.x, _956.y ? _938.y : _836.y); + } + highp float _966 = -_923; + highp float _977; + do + { + if (_940 == 0.0) + { + _977 = max(_839, _966); + break; + } + _977 = min(-_940, max(_839, _966)) + _945; + break; + } while(false); + _837 = _965; + _840 = _977; + int _842 = _841 + 1; + _836 = _837; + _839 = _840; + _841 = _842; + continue; + } + else + { + break; + } + } + _978 = _836; + _979 = _839; } else { - _464 = _248; - _465 = _255; + highp vec2 _713; + highp float _714; + if (_206.w < 0.5) + { + highp float _679 = (vTextureCoord.x - _207.x) + _207.z; + highp float _681 = (_207.x + _207.z) - vTextureCoord.x; + highp float _686 = (vTextureCoord.y - _207.y) + _207.w; + highp float _688 = (_207.y + _207.w) - vTextureCoord.y; + highp float _692 = min(min(_679, _681), min(_686, _688)); + highp vec4 _697 = exp((vec4(_692) - vec4(_679, _681, _686, _688)) / vec4(uData[1].y)); + highp float _698 = _697.x; + highp float _699 = _697.y; + highp float _701 = _697.z; + highp float _703 = _697.w; + highp float _704 = ((_698 + _699) + _701) + _703; + _713 = vec2(_699 - _698, _703 - _701) / vec2(_704); + _714 = (uData[1].y * log(_704)) - _692; + } + else + { + _713 = _498; + _714 = _499; + } + _978 = _713; + _979 = _714; } - bool _466 = _465 < _153; - if (_466) + bool _980 = _979 < _156; + if (_980) { - _146 = _149; - _152 = _153; + _149 = _152; + _155 = _156; } else { - bool _470 = _465 < _151; - bvec2 _471 = bvec2(_470); - _146 = vec2(_471.x ? _464.x : _145.x, _471.y ? _464.y : _145.y); - _152 = _470 ? _465 : _151; + bool _984 = _979 < _154; + bvec2 _985 = bvec2(_984); + _149 = vec2(_985.x ? _978.x : _148.x, _985.y ? _978.y : _148.y); + _155 = _984 ? _979 : _154; } - bvec2 _474 = bvec2(_466); - _150 = vec2(_474.x ? _464.x : _149.x, _474.y ? _464.y : _149.y); - _154 = _466 ? _465 : _153; - _138 = _139; + bvec2 _988 = bvec2(_980); + _153 = vec2(_988.x ? _978.x : _152.x, _988.y ? _978.y : _152.y); + _157 = _980 ? _979 : _156; _141 = _142; - _143 = _144; - _145 = _146; - _147 = _148; - _149 = _150; - _151 = _152; - _153 = _154; - _155 = _156; - _157 = _158; - _159 = _160; - _161 = _162; - _163 = _164; - _165 = _166; - _167++; + _144 = _145; + _146 = _147; + _148 = _149; + _150 = _151; + _152 = _153; + _154 = _155; + _156 = _157; + _158 = _159; + _160 = _161; + _162 = _163; + _164 = _165; + _166 = _167; + _168 = _169; + _170++; continue; } else @@ -361,582 +854,608 @@ void main() break; } } - bool _480 = uData[58].w > 2.5; - bool _481 = uData[58].w > 1.5; - highp float _554; - highp vec2 _555; - if (_481) - { - highp vec2 _487 = vTextureCoord - uData[56].xy; - highp vec4 _493 = min(uData[57], vec4(min(uData[56].z, uData[56].w))); - highp float _494 = _487.x; - highp float _515; - if (_494 > 0.0) + bool _998; + if (uData[58].w > 2.5) + { + _998 = uData[58].w < 3.5; + } + else + { + _998 = false; + } + bool _999 = uData[58].w > 1.5; + bool _1003; + if (_999) + { + _1003 = uData[58].w < 3.5; + } + else + { + _1003 = false; + } + highp float _1076; + highp vec2 _1077; + if (_1003) + { + highp vec2 _1009 = vTextureCoord - uData[56].xy; + highp vec4 _1015 = min(uData[57], vec4(min(uData[56].z, uData[56].w))); + highp float _1016 = _1009.x; + highp float _1037; + if (_1016 > 0.0) { - highp float _506; - if (_487.y > 0.0) + highp float _1036; + if (_1009.y > 0.0) { - _506 = _493.z; + _1036 = _1015.z; } else { - _506 = _493.y; + _1036 = _1015.y; } - _515 = _506; + _1037 = _1036; } else { - highp float _514; - if (_487.y > 0.0) + highp float _1028; + if (_1009.y > 0.0) { - _514 = _493.w; + _1028 = _1015.w; } else { - _514 = _493.x; + _1028 = _1015.x; } - _515 = _514; + _1037 = _1028; } - highp vec2 _519 = (abs(_487) - uData[56].zw) + vec2(_515); - highp float _521 = (_494 < 0.0) ? (-1.0) : 1.0; - highp float _524 = (_487.y < 0.0) ? (-1.0) : 1.0; - highp float _526 = _519.x; - bool _532; - if (_526 > 0.0) + highp vec2 _1041 = (abs(_1009) - uData[56].zw) + vec2(_1037); + highp float _1043 = (_1016 < 0.0) ? (-1.0) : 1.0; + highp float _1046 = (_1009.y < 0.0) ? (-1.0) : 1.0; + highp float _1048 = _1041.x; + bool _1054; + if (_1048 > 0.0) { - _532 = _519.y > 0.0; + _1054 = _1041.y > 0.0; } else { - _532 = false; + _1054 = false; } - highp vec2 _546; - if (_532) + highp vec2 _1068; + if (_1054) { - _546 = normalize(_519) * vec2(_521, _524); + _1068 = normalize(_1041) * vec2(_1043, _1046); } else { - highp vec2 _545; - if (_526 > _519.y) + highp vec2 _1065; + if (_1048 > _1041.y) { - _545 = vec2(_521, 0.0); + _1065 = vec2(_1043, 0.0); } else { - _545 = vec2(0.0, _524); + _1065 = vec2(0.0, _1046); } - _546 = _545; + _1068 = _1065; } - _554 = (min(max(_526, _519.y), 0.0) + length(max(_519, vec2(0.0)))) - _515; - _555 = _546; + _1076 = (min(max(_1048, _1041.y), 0.0) + length(max(_1041, vec2(0.0)))) - _1037; + _1077 = _1068; + } + else + { + _1076 = -1000000000.0; + _1077 = vec2(0.0); + } + bool _1081; + if (_999) + { + _1081 = uData[58].w < 3.5; } else { - _554 = -1000000000.0; - _555 = vec2(0.0); + _1081 = false; } - bool _559; - if (_481) + bool _1085; + if (_1081) { - _559 = !_480; + _1085 = !_998; } else { - _559 = false; - } - highp vec2 _604; - highp vec2 _605; - highp float _606; - highp vec2 _607; - highp vec2 _608; - highp vec2 _609; - highp vec2 _610; - highp vec4 _611; - highp vec4 _612; - highp float _613; - highp float _614; - highp float _615; - highp float _616; - if (_559) - { - highp float _562 = 1.0 - _554; - bool _563 = _562 < _163; - highp vec2 _579; - highp vec2 _580; - highp float _581; - highp vec2 _582; - highp vec4 _583; - highp float _584; - if (_563) + _1085 = false; + } + highp vec2 _1130; + highp vec2 _1131; + highp float _1132; + highp vec2 _1133; + highp vec2 _1134; + highp vec2 _1135; + highp vec2 _1136; + highp vec4 _1137; + highp vec4 _1138; + highp float _1139; + highp float _1140; + highp float _1141; + highp float _1142; + if (_1085) + { + highp float _1088 = 1.0 - _1076; + bool _1089 = _1088 < _166; + highp vec2 _1105; + highp vec2 _1106; + highp float _1107; + highp vec2 _1108; + highp vec4 _1109; + highp float _1110; + if (_1089) { - _579 = _157; - _580 = uData[56].yw; - _581 = _165; - _582 = _155; - _583 = _159; - _584 = _163; + _1105 = _160; + _1106 = uData[56].yw; + _1107 = _168; + _1108 = _158; + _1109 = _162; + _1110 = _166; } else { - bool _568 = _562 < _161; - highp vec2 _572; - if (_568) + bool _1093 = _1088 < _164; + highp vec2 _1097; + if (_1093) { - _572 = uData[56].yw; + _1097 = uData[56].yw; } else { - _572 = _138; + _1097 = _141; } - bvec2 _574 = bvec2(_568); - bvec4 _576 = bvec4(_568); - _579 = _572; - _580 = _157; - _581 = _568 ? _165 : _141; - _582 = vec2(_574.x ? vec2(0.0).x : _143.x, _574.y ? vec2(0.0).y : _143.y); - _583 = vec4(_576.x ? uData[58].x : _147.x, _576.y ? uData[58].y : _147.y, _576.z ? uData[58].z : _147.z, _576.w ? uData[58].w : _147.w); - _584 = _568 ? _562 : _161; + bvec2 _1099 = bvec2(_1093); + bvec4 _1101 = bvec4(_1093); + _1105 = _1097; + _1106 = _160; + _1107 = _1093 ? _168 : _144; + _1108 = vec2(_1099.x ? vec2(0.0).x : _146.x, _1099.y ? vec2(0.0).y : _146.y); + _1109 = vec4(_1101.x ? uData[58].x : _150.x, _1101.y ? uData[58].y : _150.y, _1101.z ? uData[58].z : _150.z, _1101.w ? uData[58].w : _150.w); + _1110 = _1093 ? _1088 : _164; } - bvec2 _585 = bvec2(_563); - bvec4 _587 = bvec4(_563); - highp vec2 _590 = -_555; - bool _591 = _562 < _153; - highp vec2 _599; - highp float _600; - if (_591) + bvec2 _1111 = bvec2(_1089); + bvec4 _1113 = bvec4(_1089); + highp vec2 _1116 = -_1077; + bool _1117 = _1088 < _156; + highp vec2 _1125; + highp float _1126; + if (_1117) { - _599 = _149; - _600 = _153; + _1125 = _152; + _1126 = _156; } else { - bool _595 = _562 < _151; - bvec2 _596 = bvec2(_595); - _599 = vec2(_596.x ? _590.x : _145.x, _596.y ? _590.y : _145.y); - _600 = _595 ? _562 : _151; + bool _1121 = _1088 < _154; + bvec2 _1122 = bvec2(_1121); + _1125 = vec2(_1122.x ? _1116.x : _148.x, _1122.y ? _1116.y : _148.y); + _1126 = _1121 ? _1088 : _154; } - bvec2 _601 = bvec2(_591); - _604 = _579; - _605 = _580; - _606 = _581; - _607 = _582; - _608 = vec2(_585.x ? vec2(0.0).x : _155.x, _585.y ? vec2(0.0).y : _155.y); - _609 = _599; - _610 = vec2(_601.x ? _590.x : _149.x, _601.y ? _590.y : _149.y); - _611 = _583; - _612 = vec4(_587.x ? uData[58].x : _159.x, _587.y ? uData[58].y : _159.y, _587.z ? uData[58].z : _159.z, _587.w ? uData[58].w : _159.w); - _613 = _600; - _614 = _591 ? _562 : _153; - _615 = _584; - _616 = _563 ? _562 : _163; + bvec2 _1127 = bvec2(_1117); + _1130 = _1105; + _1131 = _1106; + _1132 = _1107; + _1133 = _1108; + _1134 = vec2(_1111.x ? vec2(0.0).x : _158.x, _1111.y ? vec2(0.0).y : _158.y); + _1135 = _1125; + _1136 = vec2(_1127.x ? _1116.x : _152.x, _1127.y ? _1116.y : _152.y); + _1137 = _1109; + _1138 = vec4(_1113.x ? uData[58].x : _162.x, _1113.y ? uData[58].y : _162.y, _1113.z ? uData[58].z : _162.z, _1113.w ? uData[58].w : _162.w); + _1139 = _1126; + _1140 = _1117 ? _1088 : _156; + _1141 = _1110; + _1142 = _1089 ? _1088 : _166; } else { - _604 = _138; - _605 = _157; - _606 = _141; - _607 = _143; - _608 = _155; - _609 = _145; - _610 = _149; - _611 = _147; - _612 = _159; - _613 = _151; - _614 = _153; - _615 = _161; - _616 = _163; - } - highp float _618 = max(uData[1].x, 9.9999997473787516355514526367188e-05); - highp float _623 = max(_618 - abs(_616 - _615), 0.0) / _618; - highp float _624 = _623 * _623; - highp float _625 = _624 * 0.5; - highp float _630; - if (_615 < _616) - { - _630 = 1.0 - _625; + _1130 = _141; + _1131 = _160; + _1132 = _144; + _1133 = _146; + _1134 = _158; + _1135 = _148; + _1136 = _152; + _1137 = _150; + _1138 = _162; + _1139 = _154; + _1140 = _156; + _1141 = _164; + _1142 = _166; + } + highp float _1144 = max(uData[1].x, 9.9999997473787516355514526367188e-05); + highp float _1149 = max(_1144 - abs(_1142 - _1141), 0.0) / _1144; + highp float _1150 = _1149 * _1149; + highp float _1151 = _1150 * 0.5; + highp float _1156; + if (_1141 < _1142) + { + _1156 = 1.0 - _1151; } else { - _630 = _625; + _1156 = _1151; } - highp float _634 = min(_616, _615) - ((_624 * _618) * 0.25); - highp float _639 = max(_618 - abs(_614 - _613), 0.0) / _618; - highp float _640 = _639 * _639; - highp float _641 = _640 * 0.5; - highp float _646; - if (_613 < _614) + highp float _1160 = min(_1142, _1141) - ((_1150 * _1144) * 0.25); + highp float _1165 = max(_1144 - abs(_1140 - _1139), 0.0) / _1144; + highp float _1166 = _1165 * _1165; + highp float _1167 = _1166 * 0.5; + highp float _1172; + if (_1139 < _1140) { - _646 = 1.0 - _641; + _1172 = 1.0 - _1167; } else { - _646 = _641; + _1172 = _1167; } - highp float _650 = min(_614, _613) - ((_640 * _618) * 0.25); - highp float _654; - if (_480) + highp float _1176 = min(_1140, _1139) - ((_1166 * _1144) * 0.25); + highp float _1180; + if (_998) { - _654 = max(_634, _554); + _1180 = max(_1160, _1076); } else { - _654 = _634; + _1180 = _1160; } - highp float _657 = clamp(0.5 - max(_654, _554), 0.0, 1.0); - if (_657 <= 0.0) + highp float _1183 = clamp(0.5 - max(_1180, _1076), 0.0, 1.0); + if (_1183 <= 0.0) { discard; } if (vColor.x < 0.5) { - _1186 = vec4(0.0, 0.0, 0.0, _657); + _1712 = vec4(0.0, 0.0, 0.0, _1183); break; } - highp vec4 _668 = mix(_612, _611, vec4(_630)); - highp vec2 _670 = mix(_610, _609, vec2(_646)); - bool _674; - if (_480) + highp vec4 _1194 = mix(_1138, _1137, vec4(_1156)); + highp vec2 _1196 = mix(_1136, _1135, vec2(_1172)); + bool _1200; + if (_998) { - _674 = _554 > _650; + _1200 = _1076 > _1176; } else { - _674 = false; - } - bvec2 _676 = bvec2(_674); - highp vec2 _677 = vec2(_676.x ? _555.x : _670.x, _676.y ? _555.y : _670.y); - highp vec2 _678 = vec2(_630); - highp vec2 _682 = mix(_608, _607, _678) * min(length(_677), 1.0); - highp float _684 = max(0.0, -(_674 ? _554 : _650)); - highp float _685 = -_684; - highp float _688 = exp(_685 / uData[1].z); - highp float _694 = _668.y; - highp float _728; - highp float _729; - highp vec2 _730; - if (_136) - { - highp float _702 = max(min(uData[5].y * mix(_165, _606, _630), uData[6].w), 1.0); - highp float _705 = clamp(1.0 - (_684 / _702), 0.0, 1.0); - highp float _710 = (((uData[5].z * _702) * _694) * _705) * _705; - _728 = _705; - _729 = _710; - _730 = clamp(((vTextureCoord - (_677 * _710)) - uData[0].xy) * uData[0].zw, vec2(0.0), vec2(1.0)); + _1200 = false; + } + bvec2 _1202 = bvec2(_1200); + highp vec2 _1203 = vec2(_1202.x ? _1077.x : _1196.x, _1202.y ? _1077.y : _1196.y); + highp vec2 _1204 = vec2(_1156); + highp vec2 _1208 = mix(_1134, _1133, _1204) * min(length(_1203), 1.0); + highp float _1210 = max(0.0, -(_1200 ? _1076 : _1176)); + highp float _1211 = -_1210; + highp float _1214 = exp(_1211 / uData[1].z); + highp float _1220 = _1194.y; + highp float _1254; + highp float _1255; + highp vec2 _1256; + if (_139) + { + highp float _1238 = max(min(uData[5].y * mix(_168, _1132, _1156), uData[6].w), 1.0); + highp float _1241 = clamp(1.0 - (_1210 / _1238), 0.0, 1.0); + highp float _1246 = (((uData[5].z * _1238) * _1220) * _1241) * _1241; + _1254 = _1241; + _1255 = _1246; + _1256 = clamp(((vTextureCoord - (_1203 * _1246)) - uData[0].xy) * uData[0].zw, vec2(0.0), vec2(1.0)); } else { - _728 = 0.0; - _729 = 0.0; - _730 = clamp(((vTextureCoord + (_677 * ((uData[2].x * _694) * _688))) - uData[0].xy) * uData[0].zw, vec2(0.0), vec2(1.0)); + _1254 = 0.0; + _1255 = 0.0; + _1256 = clamp(((vTextureCoord + (_1203 * ((uData[2].x * _1220) * _1214))) - uData[0].xy) * uData[0].zw, vec2(0.0), vec2(1.0)); } - highp vec4 _734 = textureLod(uSampler, _730, 0.0); - bool _736 = uData[4].w > 0.5; - highp vec4 _744; - if (_736) + highp vec4 _1260 = textureLod(uSampler, _1256, 0.0); + bool _1262 = uData[4].w > 0.5; + highp vec4 _1270; + if (_1262) { - _744 = textureLod(uTex1, _730, 0.0); + _1270 = textureLod(uTex1, _1256, 0.0); } else { - _744 = _734; + _1270 = _1260; } - bool _749; - if (_136) + bool _1275; + if (_139) { - _749 = uData[6].y > 0.0; + _1275 = uData[6].y > 0.0; } else { - _749 = false; + _1275 = false; } - bool _753; - if (_749) + bool _1279; + if (_1275) { - _753 = _729 > 0.5; + _1279 = _1255 > 0.5; } else { - _753 = false; - } - highp vec4 _814; - highp vec4 _815; - if (_753) - { - highp vec2 _761 = (_677 * ((_729 * 0.039999999105930328369140625) * uData[6].y)) * uData[0].zw; - highp vec2 _763 = clamp(_730 + _761, vec2(0.0), vec2(1.0)); - highp vec2 _765 = clamp(_730 - _761, vec2(0.0), vec2(1.0)); - highp vec4 _769 = textureLod(uSampler, _763, 0.0); - highp float _774 = _734.w; - highp float _775 = (_769.x / max(_769.w, 9.9999997473787516355514526367188e-05)) * _774; - highp vec4 _776 = _734; - _776.x = _775; - highp vec4 _780 = textureLod(uSampler, _765, 0.0); - highp float _785 = (_780.z / max(_780.w, 9.9999997473787516355514526367188e-05)) * _774; - _776.z = _785; - highp vec4 _813; - if (_736) + _1279 = false; + } + highp vec4 _1340; + highp vec4 _1341; + if (_1279) + { + highp vec2 _1287 = (_1203 * ((_1255 * 0.039999999105930328369140625) * uData[6].y)) * uData[0].zw; + highp vec2 _1289 = clamp(_1256 + _1287, vec2(0.0), vec2(1.0)); + highp vec2 _1291 = clamp(_1256 - _1287, vec2(0.0), vec2(1.0)); + highp vec4 _1295 = textureLod(uSampler, _1289, 0.0); + highp float _1300 = _1260.w; + highp float _1301 = (_1295.x / max(_1295.w, 9.9999997473787516355514526367188e-05)) * _1300; + highp vec4 _1302 = _1260; + _1302.x = _1301; + highp vec4 _1306 = textureLod(uSampler, _1291, 0.0); + highp float _1311 = (_1306.z / max(_1306.w, 9.9999997473787516355514526367188e-05)) * _1300; + _1302.z = _1311; + highp vec4 _1339; + if (_1262) { - highp vec4 _793 = textureLod(uTex1, _763, 0.0); - highp vec4 _800 = _744; - _800.x = (_793.x / max(_793.w, 9.9999997473787516355514526367188e-05)) * _744.w; - highp vec4 _804 = textureLod(uTex1, _765, 0.0); - _800.z = (_804.z / max(_804.w, 9.9999997473787516355514526367188e-05)) * _744.w; - _813 = _800; + highp vec4 _1321 = textureLod(uTex1, _1289, 0.0); + highp vec4 _1328 = _1270; + _1328.x = (_1321.x / max(_1321.w, 9.9999997473787516355514526367188e-05)) * _1270.w; + highp vec4 _1332 = textureLod(uTex1, _1291, 0.0); + _1328.z = (_1332.z / max(_1332.w, 9.9999997473787516355514526367188e-05)) * _1270.w; + _1339 = _1328; } else { - highp vec4 _811 = _744; - _811.x = _775; - _811.z = _785; - _813 = _811; + highp vec4 _1316 = _1270; + _1316.x = _1301; + _1316.z = _1311; + _1339 = _1316; } - _814 = _813; - _815 = _776; + _1340 = _1339; + _1341 = _1302; } else { - _814 = _744; - _815 = _734; + _1340 = _1270; + _1341 = _1260; } - bool _817 = uData[4].x > 1.5; - highp float _831; - if (_817) + bool _1343 = uData[4].x > 1.5; + highp float _1357; + if (_1343) { - _831 = uData[3].w; + _1357 = uData[3].w; } else { - highp float _830; + highp float _1355; if ((uData[6].x - 2.0 * trunc(uData[6].x / 2.0)) > 0.5) { - _830 = 1.0; + _1355 = 1.0; } else { - _830 = _815.w; + _1355 = _1341.w; } - _831 = _830; + _1357 = _1355; } - highp vec4 _840 = vec4(_815.xyz / vec3(max(_815.w, 9.9999997473787516355514526367188e-05)), 1.0); - highp vec4 _849 = vec4(_814.xyz / vec3(max(_814.w, 9.9999997473787516355514526367188e-05)), 1.0); - highp float _856; - if (_817) + highp vec4 _1366 = vec4(_1341.xyz / vec3(max(_1341.w, 9.9999997473787516355514526367188e-05)), 1.0); + highp vec4 _1375 = vec4(_1340.xyz / vec3(max(_1340.w, 9.9999997473787516355514526367188e-05)), 1.0); + highp float _1382; + if (_1343) { - _856 = 1.0; + _1382 = 1.0; } else { - _856 = (uData[4].z > 0.5) ? uData[4].x : 0.0; + _1382 = (uData[4].z > 0.5) ? uData[4].x : 0.0; } - bool _860; - if (_136) + bool _1386; + if (_139) { - _860 = !_817; + _1386 = !_1343; } else { - _860 = false; + _1386 = false; } - highp float _869; - if (_860) + highp float _1395; + if (_1386) { - _869 = _856 * (1.0 - ((_728 * _728) * (1.0 - smoothstep(0.800000011920928955078125, 1.0, _856)))); + _1395 = _1382 * (1.0 - ((_1254 * _1254) * (1.0 - smoothstep(0.800000011920928955078125, 1.0, _1382)))); } else { - _869 = _856; + _1395 = _1382; } - highp float _872 = 1.0 - _869; - highp float _880; - if (_136) + highp float _1398 = 1.0 - _1395; + highp float _1406; + if (_139) { - _880 = _728; + _1406 = _1254; } else { - _880 = _688 * _688; + _1406 = _1214 * _1214; } - highp float _883 = clamp(((uData[2].y * _694) * _880) * _872, 0.0, 1.0); - highp vec4 _889 = ((_849 * _883) + ((mix(_849, _840, vec4(clamp(_668.x, 0.0, 1.0))) * _872) * (1.0 - _883))) + (uData[3] * _869); - highp vec4 _932; - if (_817) + highp float _1409 = clamp(((uData[2].y * _1220) * _1406) * _1398, 0.0, 1.0); + highp vec4 _1415 = ((_1375 * _1409) + ((mix(_1375, _1366, vec4(clamp(_1194.x, 0.0, 1.0))) * _1398) * (1.0 - _1409))) + (uData[3] * _1395); + highp vec4 _1458; + if (_1343) { - _932 = vec4(uData[3].xyz / vec3(max(uData[3].w, 9.9999997473787516355514526367188e-05)), 1.0); + _1458 = vec4(uData[3].xyz / vec3(max(uData[3].w, 9.9999997473787516355514526367188e-05)), 1.0); } else { - highp vec4 _905 = _889 + (_840 * (1.0 - _889.w)); - highp vec4 _931; + highp vec4 _1422 = _1415 + (_1366 * (1.0 - _1415.w)); + highp vec4 _1448; if (uData[7].w < 1.0) { - highp vec3 _910 = _905.xyz; - highp float _911 = dot(_910, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); - highp float _912 = 0.60000002384185791015625 * uData[7].w; - highp float _914 = max(uData[7].w - _912, 9.9999997473787516355514526367188e-05); - highp float _926; - if (_911 <= _912) + highp vec3 _1427 = _1422.xyz; + highp float _1428 = dot(_1427, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + highp float _1429 = 0.60000002384185791015625 * uData[7].w; + highp float _1431 = max(uData[7].w - _1429, 9.9999997473787516355514526367188e-05); + highp float _1443; + if (_1428 <= _1429) { - _926 = _911; + _1443 = _1428; } else { - _926 = _912 + (_914 * (1.0 - exp((-(_911 - _912)) / _914))); + _1443 = _1429 + (_1431 * (1.0 - exp((-(_1428 - _1429)) / _1431))); } - highp vec3 _929 = _910 * (_926 / max(_911, 9.9999997473787516355514526367188e-05)); - _931 = vec4(_929.x, _929.y, _929.z, _905.w); + highp vec3 _1446 = _1427 * (_1443 / max(_1428, 9.9999997473787516355514526367188e-05)); + _1448 = vec4(_1446.x, _1446.y, _1446.z, _1422.w); } else { - _931 = _905; + _1448 = _1422; } - _932 = _931; + _1458 = _1448; } - highp float _935 = dot(_677, uData[9].xy); - highp float _936 = max(_935, 0.0); - highp float _938 = max(-_935, 0.0); - highp float _941 = abs(_935); - bool _945; - if (_136) + highp float _1461 = dot(_1203, uData[9].xy); + highp float _1462 = max(_1461, 0.0); + highp float _1464 = max(-_1461, 0.0); + highp float _1467 = abs(_1461); + bool _1471; + if (_139) { - _945 = uData[6].z > 0.0; + _1471 = uData[6].z > 0.0; } else { - _945 = false; + _1471 = false; } - bool _947 = uData[10].x > 0.0; - highp float _971; - if (_947) + bool _1473 = uData[10].x > 0.0; + highp float _1497; + if (_1473) { - _971 = 0.0; + _1497 = 0.0; } else { - highp float _970; - if (_945) + highp float _1496; + if (_1471) { - _970 = (uData[6].z * (1.0 - smoothstep(0.20000000298023223876953125, 0.699999988079071044921875, _941))) * exp((-max(0.0, -_654)) / (uData[2].z * 2.5)); + _1496 = (uData[6].z * (1.0 - smoothstep(0.20000000298023223876953125, 0.699999988079071044921875, _1467))) * exp((-max(0.0, -_1180)) / (uData[2].z * 2.5)); } else { - _970 = uData[8].x * (1.0 - smoothstep(0.0, uData[2].z * 0.625, -_654)); + _1496 = uData[8].x * (1.0 - smoothstep(0.0, uData[2].z * 0.625, -_1180)); } - _971 = _970; + _1497 = _1496; } - highp float _981; - if (_136) + highp float _1507; + if (_139) { - _981 = max((uData[5].w * _728) * _728, _971) * min(_694, 1.0); + _1507 = max((uData[5].w * _1254) * _1254, _1497) * min(_1220, 1.0); } else { - _981 = 0.0; + _1507 = 0.0; } - highp float _984 = _831 * (1.0 - _981); - highp vec4 _990 = vec4(_932.xyz * _984, _984 + _981); - highp float _1012; - if (_136) + highp float _1510 = _1357 * (1.0 - _1507); + highp vec4 _1516 = vec4(_1458.xyz * _1510, _1510 + _1507); + highp float _1538; + if (_139) { - highp float _1003; - if (_945) + highp float _1537; + if (_1471) { - _1003 = uData[6].z * max(smoothstep(0.75, 1.0, _941), max(_682.x, _682.y)); + _1537 = uData[6].z * max(smoothstep(0.75, 1.0, _1467), max(_1208.x, _1208.y)); } else { - _1003 = 0.25; + _1537 = 0.25; } - _1012 = _1003; + _1538 = _1537; } else { - _1012 = (0.449999988079071044921875 * ((_936 * sqrt(_936)) + ((0.75 * _938) * sqrt(_938)))) + 0.0599999986588954925537109375; + _1538 = (0.449999988079071044921875 * ((_1462 * sqrt(_1462)) + ((0.75 * _1464) * sqrt(_1464)))) + 0.0599999986588954925537109375; } - highp float _1039; - if (_945) + highp float _1565; + if (_1471) { - _1039 = exp((-max(0.0, -_654)) / (uData[2].z * 1.25)); + _1565 = exp((-max(0.0, -_1180)) / (uData[2].z * 1.25)); } else { - highp float _1038; - if (_136) + highp float _1559; + if (_139) { - highp float _1026 = -_654; - _1038 = smoothstep(uData[2].z * 0.3125, uData[2].z * 0.625, _1026) * (1.0 - smoothstep(uData[2].z * 1.5, uData[2].z * 2.0, _1026)); + highp float _1552 = -_1180; + _1559 = smoothstep(uData[2].z * 0.3125, uData[2].z * 0.625, _1552) * (1.0 - smoothstep(uData[2].z * 1.5, uData[2].z * 2.0, _1552)); } else { - _1038 = exp((-max(0.0, -_654)) / uData[2].z); + _1559 = exp((-max(0.0, -_1180)) / uData[2].z); } - _1039 = _1038; + _1565 = _1559; } - highp float _1051; - if (_947) + highp float _1577; + if (_1473) { - _1051 = 0.0; + _1577 = 0.0; } else { - highp float _1049; - if (_136) + highp float _1575; + if (_139) { - _1049 = 0.0; + _1575 = 0.0; } else { - _1049 = (0.039999999105930328369140625 * exp(_685 / uData[1].w)) * _936; + _1575 = (0.039999999105930328369140625 * exp(_1211 / uData[1].w)) * _1462; } - _1051 = (_1039 * _1012) + _1049; + _1577 = (_1565 * _1538) + _1575; } - highp vec2 _1052 = mix(_605, _604, _678); - highp float _1056 = _1052.y; - highp float _1062 = clamp((vTextureCoord.y - (_1052.x - _1056)) / max(2.0 * _1056, 9.9999997473787516355514526367188e-05), 0.0, 1.0); - highp float _1080; + highp vec2 _1578 = mix(_1131, _1130, _1204); + highp float _1582 = _1578.y; + highp float _1588 = clamp((vTextureCoord.y - (_1578.x - _1582)) / max(2.0 * _1582, 9.9999997473787516355514526367188e-05), 0.0, 1.0); + highp float _1606; if (uData[4].z > 0.5) { - _1080 = uData[4].y + ((uData[7].x + ((uData[7].y - uData[7].x) * _1062)) + (uData[7].z * (1.0 - smoothstep(0.0, 0.37999999523162841796875, _1062)))); + _1606 = uData[4].y + ((uData[7].x + ((uData[7].y - uData[7].x) * _1588)) + (uData[7].z * (1.0 - smoothstep(0.0, 0.37999999523162841796875, _1588)))); } else { - _1080 = 0.0; + _1606 = 0.0; } - highp vec3 _1090 = _990.xyz + vec3(clamp((_1080 + _668.z) + ((_694 * uData[2].w) * _1051), 0.0, 1.0)); - highp vec4 _1162; - if (_947) + highp vec3 _1616 = _1516.xyz + vec3(clamp((_1606 + _1194.z) + ((_1220 * uData[2].w) * _1577), 0.0, 1.0)); + highp vec4 _1688; + if (_1473) { - highp vec2 _1100; - if (dot(_677, _677) > 9.9999999392252902907785028219223e-09) + highp vec2 _1626; + if (dot(_1203, _1203) > 9.9999999392252902907785028219223e-09) { - _1100 = normalize(_677); + _1626 = normalize(_1203); } else { - _1100 = vec2(0.0); + _1626 = vec2(0.0); } - highp float _1101 = dot(_1100, uData[9].xy); - highp float _1103 = mix(8.0, 1.0, uData[9].z); - highp float _1111 = pow(max(_1101, 0.0), _1103) + (uData[9].w * pow(max(-_1101, 0.0), _1103)); - highp float _1112 = min(_694, 1.0); - highp float _1119 = -_654; - highp float _1121 = smoothstep(-0.5, 0.5, _1119); - highp float _1123 = -max(0.0, _1119); - highp vec3 _1160 = (_1090.xyz * (1.0 - (((uData[10].z * (1.0 - abs(_1101))) * (_1121 * exp(_1123 / max(uData[2].z * 2.5, 0.001000000047497451305389404296875)))) * _1112))) + vec3(_1112 * (((uData[10].x * max(_1111, max(_682.x, uData[9].w * _682.y))) * (_1121 * exp(_1123 / max(uData[8].y, 0.001000000047497451305389404296875)))) + ((uData[10].y * _1111) * (smoothstep(uData[8].y - 0.5, uData[8].y + 0.5, _1119) * exp((-max(0.0, _1119 - uData[8].y)) / max(uData[8].z, 0.001000000047497451305389404296875)))))); - _1162 = vec4(_1160.x, _1160.y, _1160.z, _990.w); + highp float _1627 = dot(_1626, uData[9].xy); + highp float _1629 = mix(8.0, 1.0, uData[9].z); + highp float _1637 = pow(max(_1627, 0.0), _1629) + (uData[9].w * pow(max(-_1627, 0.0), _1629)); + highp float _1638 = min(_1220, 1.0); + highp float _1645 = -_1180; + highp float _1647 = smoothstep(-0.5, 0.5, _1645); + highp float _1649 = -max(0.0, _1645); + highp vec3 _1686 = (_1616.xyz * (1.0 - (((uData[10].z * (1.0 - abs(_1627))) * (_1647 * exp(_1649 / max(uData[2].z * 2.5, 0.001000000047497451305389404296875)))) * _1638))) + vec3(_1638 * (((uData[10].x * max(_1637, max(_1208.x, uData[9].w * _1208.y))) * (_1647 * exp(_1649 / max(uData[8].y, 0.001000000047497451305389404296875)))) + ((uData[10].y * _1637) * (smoothstep(uData[8].y - 0.5, uData[8].y + 0.5, _1645) * exp((-max(0.0, _1645 - uData[8].y)) / max(uData[8].z, 0.001000000047497451305389404296875)))))); + _1688 = vec4(_1686.x, _1686.y, _1686.z, _1516.w); } else { - _1162 = vec4(_1090.x, _1090.y, _1090.z, _990.w); + _1688 = vec4(_1616.x, _1616.y, _1616.z, _1516.w); } - highp vec4 _1163 = clamp(_1162, vec4(0.0), vec4(1.0)); - highp float _1170 = max(_1163.w, max(_1163.x, max(_1163.y, _1163.z))); - highp vec4 _1171 = _1163; - _1171.w = _1170; - highp vec3 _1182 = _1171.xyz + vec3(((fract(52.98291778564453125 * fract(dot(vTextureCoord, vec2(0.067110560834407806396484375, 0.005837149918079376220703125)))) - 0.5) * uData[5].x) * _1170); - _1186 = clamp(vec4(_1182.x, _1182.y, _1182.z, _1171.w), vec4(0.0), vec4(1.0)) * _657; + highp vec4 _1689 = clamp(_1688, vec4(0.0), vec4(1.0)); + highp float _1696 = max(_1689.w, max(_1689.x, max(_1689.y, _1689.z))); + highp vec4 _1697 = _1689; + _1697.w = _1696; + highp vec3 _1708 = _1697.xyz + vec3(((fract(52.98291778564453125 * fract(dot(vTextureCoord, vec2(0.067110560834407806396484375, 0.005837149918079376220703125)))) - 0.5) * uData[5].x) * _1696); + _1712 = clamp(vec4(_1708.x, _1708.y, _1708.z, _1697.w), vec4(0.0), vec4(1.0)) * _1183; break; } while(false); - out_var_SV_Target0 = _1186; + out_var_SV_Target0 = _1712; } diff --git a/backend/src/glass/shaders/compiled/msl/liquid_glass.fragment.msl b/backend/src/glass/shaders/compiled/msl/liquid_glass.fragment.msl index 858737e21..4c82089c0 100644 --- a/backend/src/glass/shaders/compiled/msl/liquid_glass.fragment.msl +++ b/backend/src/glass/shaders/compiled/msl/liquid_glass.fragment.msl @@ -22,342 +22,833 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], texture2d Frost [[texture(0)]], texture2d Sharp [[texture(1)]], sampler FrostSampler [[sampler(0)]], sampler SharpSampler [[sampler(1)]]) { main0_out out = {}; - float4 _1186; + float4 _1712; do { - int _107 = int((in.in_var_COLOR.y * 255.0) + 0.5); - int _112 = int((in.in_var_COLOR.z * 255.0) + 0.5); - bool _136 = Uniforms.uData[5].y > 0.0; - float2 _138; - float _141; - float2 _143; - float2 _145; - float4 _147; - float2 _149; - float _151; - float _153; - float2 _155; - float2 _157; - float4 _159; - float _161; - float _163; - float _165; - _138 = float2(0.0, 1.0); - _141 = 1000000000.0; - _143 = float2(0.0); - _145 = float2(0.0); - _147 = float4(0.0); - _149 = float2(0.0); - _151 = 1000000000.0; - _153 = 1000000000.0; - _155 = float2(0.0); - _157 = float2(0.0, 1.0); - _159 = float4(0.0); - _161 = 1000000000.0; - _163 = 1000000000.0; - _165 = 1000000000.0; - float2 _150; + int _110 = int((in.in_var_COLOR.y * 255.0) + 0.5); + int _115 = int((in.in_var_COLOR.z * 255.0) + 0.5); + bool _139 = Uniforms.uData[5].y > 0.0; + float2 _141; + float _144; + float2 _146; + float2 _148; + float4 _150; + float2 _152; float _154; - float2 _156; - float4 _160; + float _156; + float2 _158; + float2 _160; + float4 _162; float _164; float _166; - float2 _139; - float _142; - float2 _144; - float2 _146; - float4 _148; - float _152; - float2 _158; - float _162; - int _167 = _107; + float _168; + _141 = float2(0.0, 1.0); + _144 = 1000000000.0; + _146 = float2(0.0); + _148 = float2(0.0); + _150 = float4(0.0); + _152 = float2(0.0); + _154 = 1000000000.0; + _156 = 1000000000.0; + _158 = float2(0.0); + _160 = float2(0.0, 1.0); + _162 = float4(0.0); + _164 = 1000000000.0; + _166 = 1000000000.0; + _168 = 1000000000.0; + float2 _153; + float _157; + float2 _159; + float4 _163; + float _167; + float _169; + float2 _142; + float _145; + float2 _147; + float2 _149; + float4 _151; + float _155; + float2 _161; + float _165; + int _170 = _110; for (;;) { - bool _176; - if (_167 < (_107 + _112)) + bool _179; + if (_170 < (_110 + _115)) { - _176 = _167 < 16; + _179 = _170 < 16; } else { - _176 = false; + _179 = false; } - if (_176) + if (_179) { - int _178 = 3 * _167; - int _179 = 11 + _178; - int _185 = _178 + 13; - float _190 = precise::min(Uniforms.uData[_179].z, Uniforms.uData[_179].w); - float4 _192 = precise::min(Uniforms.uData[_178 + 12], float4(_190)); - float2 _194 = in.in_var_TEXCOORD0 - Uniforms.uData[_179].xy; - float _196 = _194.x; - float _217; - if (_196 > 0.0) + int _181 = 3 * _170; + int _188 = _181 + 13; + bool _196; + if ((isunordered(Uniforms.uData[_188].w, (-0.5)) || Uniforms.uData[_188].w >= (-0.5))) { - float _208; - if (_194.y > 0.0) - { - _208 = _192.z; - } - else - { - _208 = _192.y; - } - _217 = _208; + _196 = Uniforms.uData[_188].w > 3.5; } else { - float _216; - if (_194.y > 0.0) - { - _216 = _192.w; - } - else - { - _216 = _192.x; - } - _217 = _216; + _196 = true; } - float2 _221 = (abs(_194) - Uniforms.uData[_179].zw) + float2(_217); - float _223 = (_196 < 0.0) ? (-1.0) : 1.0; - float _226 = (_194.y < 0.0) ? (-1.0) : 1.0; - float _228 = _221.x; - bool _234; - if (_228 > 0.0) + float4 _206; + float4 _207; + float4 _208; + if (_196) { - _234 = _221.y > 0.0; + float4 _204 = Uniforms.uData[58]; + _204.z = 0.0; + _206 = _204; + _207 = Uniforms.uData[56]; + _208 = Uniforms.uData[57]; } else { - _234 = false; + _206 = Uniforms.uData[_188]; + _207 = Uniforms.uData[11 + _181]; + _208 = Uniforms.uData[_181 + 12]; } - float2 _248; - if (_234) + float _211 = precise::min(_207.z, _207.w); + float4 _213 = precise::min(_208, float4(_211)); + float2 _498; + float _499; + if (_196) { - _248 = fast::normalize(_221) * float2(_223, _226); + float4 _288 = precise::min(Uniforms.uData[57], float4(precise::min(Uniforms.uData[56].z, Uniforms.uData[56].w))); + int _291 = int(Uniforms.uData[58].z); + float2 _293 = in.in_var_TEXCOORD0 - Uniforms.uData[56].xy; + float _295 = _293.x; + float _316; + if (_295 > 0.0) + { + float _315; + if (_293.y > 0.0) + { + _315 = _288.z; + } + else + { + _315 = _288.y; + } + _316 = _315; + } + else + { + float _307; + if (_293.y > 0.0) + { + _307 = _288.w; + } + else + { + _307 = _288.x; + } + _316 = _307; + } + float2 _320 = (abs(_293) - Uniforms.uData[56].zw) + float2(_316); + float _322 = (_295 < 0.0) ? (-1.0) : 1.0; + float _325 = (_293.y < 0.0) ? (-1.0) : 1.0; + float _327 = _320.x; + bool _333; + if (_327 > 0.0) + { + _333 = _320.y > 0.0; + } + else + { + _333 = false; + } + float2 _347; + if (_333) + { + _347 = fast::normalize(_320) * float2(_322, _325); + } + else + { + float2 _344; + if (_327 > _320.y) + { + _344 = float2(_322, 0.0); + } + else + { + _344 = float2(0.0, _325); + } + _347 = _344; + } + float2 _356; + float _359; + _356 = _347; + _359 = (precise::min(precise::max(_327, _320.y), 0.0) + length(precise::max(_320, float2(0.0)))) - _316; + float2 _357; + float _360; + int _361 = 0; + for (;;) + { + bool _369; + if (_361 < _291) + { + _369 = _361 < 4; + } + else + { + _369 = false; + } + if (_369) + { + int _371 = 14 - _361; + int _372 = 3 * _371; + int _373 = 11 + _372; + int _376 = _372 + 12; + if (Uniforms.uData[_376].x == 0.0) + { + _357 = _356; + _360 = _359; + int _362 = _361 + 1; + _356 = _357; + _359 = _360; + _361 = _362; + continue; + } + float _385 = fast::clamp(Uniforms.uData[_376].x / Uniforms.uData[_376].y, 0.0, 1.0); + bool _387 = Uniforms.uData[_373].x < 0.5; + float _395; + if (_387) + { + _395 = in.in_var_TEXCOORD0.y; + } + else + { + _395 = in.in_var_TEXCOORD0.x; + } + float _403; + if (_387) + { + _403 = in.in_var_TEXCOORD0.x; + } + else + { + _403 = in.in_var_TEXCOORD0.y; + } + float _405 = _403 - Uniforms.uData[_373].y; + float _406 = Uniforms.uData[_376].x * 0.5; + float _409 = Uniforms.uData[_373].w - Uniforms.uData[_373].z; + float _410 = smoothstep(0.0, 0.60000002384185791015625, _385); + float _439; + float _440; + if (Uniforms.uData[_376].w > 2.5) + { + float _430 = _395 - ((Uniforms.uData[_373].z + Uniforms.uData[_373].w) * 0.5); + _439 = (_430 < 0.0) ? 1.0 : (-1.0); + _440 = precise::max(((_409 * 0.5) * (1.0 - _410)) - abs(_430), 0.0); + } + else + { + bool _416 = Uniforms.uData[_376].w < 1.5; + float _422; + if (_416) + { + _422 = _395 - Uniforms.uData[_373].z; + } + else + { + _422 = Uniforms.uData[_373].w - _395; + } + _439 = _416 ? 1.0 : (-1.0); + _440 = precise::max(_422 - ((_409 - _406) * _410), 0.0); + } + float _442 = length(float2(_405, _440)); + float _443 = _442 - _406; + float2 _458; + if (_442 > 0.0) + { + float2 _452 = float2(-_405, (-_440) * _439) / float2(_442); + float2 _457; + if (Uniforms.uData[_373].x > 0.5) + { + _457 = _452.yx; + } + else + { + _457 = _452; + } + _458 = _457; + } + else + { + _458 = float2(0.0); + } + float _460 = Uniforms.uData[_376].z * _385; + float2 _464 = precise::max(float2(_460 + _359, _460 - _443), float2(0.0)); + float _465 = length(_464); + bool _470; + if (_460 > 0.0) + { + _470 = _465 > 0.0; + } + else + { + _470 = false; + } + float2 _485; + if (_470) + { + _485 = ((_356 * _464.x) + (_458 * _464.y)) / float2(_465); + } + else + { + _485 = select(_356, _458, bool2((-_443) > _359)); + } + float _486 = -_443; + float _497; + do + { + if (_460 == 0.0) + { + _497 = precise::max(_359, _486); + break; + } + _497 = precise::min(-_460, precise::max(_359, _486)) + _465; + break; + } while(false); + _357 = _485; + _360 = _497; + int _362 = _361 + 1; + _356 = _357; + _359 = _360; + _361 = _362; + continue; + } + else + { + break; + } + } + _498 = _356; + _499 = _359; } else { - float2 _247; - if (_228 > _221.y) + float2 _218 = in.in_var_TEXCOORD0 - _207.xy; + float _220 = _218.x; + float _241; + if (_220 > 0.0) + { + float _240; + if (_218.y > 0.0) + { + _240 = _213.z; + } + else + { + _240 = _213.y; + } + _241 = _240; + } + else + { + float _232; + if (_218.y > 0.0) + { + _232 = _213.w; + } + else + { + _232 = _213.x; + } + _241 = _232; + } + float2 _245 = (abs(_218) - _207.zw) + float2(_241); + float _247 = (_220 < 0.0) ? (-1.0) : 1.0; + float _250 = (_218.y < 0.0) ? (-1.0) : 1.0; + float _252 = _245.x; + bool _258; + if (_252 > 0.0) { - _247 = float2(_223, 0.0); + _258 = _245.y > 0.0; } else { - _247 = float2(0.0, _226); + _258 = false; } - _248 = _247; + float2 _272; + if (_258) + { + _272 = fast::normalize(_245) * float2(_247, _250); + } + else + { + float2 _269; + if (_252 > _245.y) + { + _269 = float2(_247, 0.0); + } + else + { + _269 = float2(0.0, _250); + } + _272 = _269; + } + _498 = _272; + _499 = (precise::min(precise::max(_252, _245.y), 0.0) + length(precise::max(_245, float2(0.0)))) - _241; } - float _255 = (precise::min(precise::max(_228, _221.y), 0.0) + length(precise::max(_221, float2(0.0)))) - _217; - float2 _401; + float2 _647; if (Uniforms.uData[10].w > 0.0) { - float _264 = (Uniforms.uData[9].x < 0.0) ? (-1.0) : 1.0; - float _267 = (Uniforms.uData[9].y < 0.0) ? (-1.0) : 1.0; - float _287; - if (_264 < 0.0) + float _508 = (Uniforms.uData[9].x < 0.0) ? (-1.0) : 1.0; + float _511 = (Uniforms.uData[9].y < 0.0) ? (-1.0) : 1.0; + float _531; + if (_508 < 0.0) { - float _279; - if (_267 < 0.0) + float _530; + if (_511 < 0.0) { - _279 = _192.x; + _530 = _213.x; } else { - _279 = _192.w; + _530 = _213.w; } - _287 = _279; + _531 = _530; } else { - float _286; - if (_267 < 0.0) + float _523; + if (_511 < 0.0) { - _286 = _192.y; + _523 = _213.y; } else { - _286 = _192.z; + _523 = _213.z; } - _287 = _286; + _531 = _523; } - float2 _290 = precise::max(Uniforms.uData[_179].zw - float2(_287), float2(0.0)); - float2 _294 = (Uniforms.uData[_179].xy + (float2(_264, _267) * _290)) + (Uniforms.uData[9].xy * _287); - float2 _309; + float2 _535 = precise::max(_207.zw - float2(_531), float2(0.0)); + float2 _540 = (_207.xy + (float2(_508, _511) * _535)) + (Uniforms.uData[9].xy * _531); + float2 _555; if (abs(Uniforms.uData[9].x) < 0.001000000047497451305389404296875) { - float _302 = _290.x; - float2 _308 = _294; - _308.x = fast::clamp(in.in_var_TEXCOORD0.x, Uniforms.uData[_179].x - _302, Uniforms.uData[_179].x + _302) + (_287 * Uniforms.uData[9].x); - _309 = _308; + float _548 = _535.x; + float2 _554 = _540; + _554.x = fast::clamp(in.in_var_TEXCOORD0.x, _207.x - _548, _207.x + _548) + (_531 * Uniforms.uData[9].x); + _555 = _554; } else { - _309 = _294; + _555 = _540; } - float2 _324; + float2 _570; if (abs(Uniforms.uData[9].y) < 0.001000000047497451305389404296875) { - float _317 = _290.y; - float2 _323 = _309; - _323.y = fast::clamp(in.in_var_TEXCOORD0.y, Uniforms.uData[_179].y - _317, Uniforms.uData[_179].y + _317) + (_287 * Uniforms.uData[9].y); - _324 = _323; + float _563 = _535.y; + float2 _569 = _555; + _569.y = fast::clamp(in.in_var_TEXCOORD0.y, _207.y - _563, _207.y + _563) + (_531 * Uniforms.uData[9].y); + _570 = _569; } else { - _324 = _309; + _570 = _555; } - float _327 = precise::max(Uniforms.uData[10].w - precise::max(Uniforms.uData[8].w, 1.0), 0.0); - float2 _332 = -Uniforms.uData[9].xy; - float _333 = _332.x; - float _335 = (_333 < 0.0) ? (-1.0) : 1.0; - float _336 = _332.y; - float _338 = (_336 < 0.0) ? (-1.0) : 1.0; - float _358; - if (_335 < 0.0) + float _573 = precise::max(Uniforms.uData[10].w - precise::max(Uniforms.uData[8].w, 1.0), 0.0); + float2 _578 = -Uniforms.uData[9].xy; + float _579 = _578.x; + float _581 = (_579 < 0.0) ? (-1.0) : 1.0; + float _582 = _578.y; + float _584 = (_582 < 0.0) ? (-1.0) : 1.0; + float _604; + if (_581 < 0.0) { - float _350; - if (_338 < 0.0) + float _603; + if (_584 < 0.0) { - _350 = _192.x; + _603 = _213.x; } else { - _350 = _192.w; + _603 = _213.w; } - _358 = _350; + _604 = _603; } else { - float _357; - if (_338 < 0.0) + float _596; + if (_584 < 0.0) { - _357 = _192.y; + _596 = _213.y; } else { - _357 = _192.z; + _596 = _213.z; } - _358 = _357; + _604 = _596; } - float2 _361 = precise::max(Uniforms.uData[_179].zw - float2(_358), float2(0.0)); - float2 _365 = (Uniforms.uData[_179].xy + (float2(_335, _338) * _361)) + (_332 * _358); - float2 _380; - if (abs(_333) < 0.001000000047497451305389404296875) + float2 _607 = precise::max(_207.zw - float2(_604), float2(0.0)); + float2 _611 = (_207.xy + (float2(_581, _584) * _607)) + (_578 * _604); + float2 _626; + if (abs(_579) < 0.001000000047497451305389404296875) { - float _373 = _361.x; - float2 _379 = _365; - _379.x = fast::clamp(in.in_var_TEXCOORD0.x, Uniforms.uData[_179].x - _373, Uniforms.uData[_179].x + _373) + (_358 * _333); - _380 = _379; + float _619 = _607.x; + float2 _625 = _611; + _625.x = fast::clamp(in.in_var_TEXCOORD0.x, _207.x - _619, _207.x + _619) + (_604 * _579); + _626 = _625; } else { - _380 = _365; + _626 = _611; } - float2 _395; - if (abs(_336) < 0.001000000047497451305389404296875) + float2 _641; + if (abs(_582) < 0.001000000047497451305389404296875) { - float _388 = _361.y; - float2 _394 = _380; - _394.y = fast::clamp(in.in_var_TEXCOORD0.y, Uniforms.uData[_179].y - _388, Uniforms.uData[_179].y + _388) + (_358 * _336); - _395 = _394; + float _634 = _607.y; + float2 _640 = _626; + _640.y = fast::clamp(in.in_var_TEXCOORD0.y, _207.y - _634, _207.y + _634) + (_604 * _582); + _641 = _640; } else { - _395 = _380; + _641 = _626; } - _401 = float2(1.0 - smoothstep(_327, Uniforms.uData[10].w, length(in.in_var_TEXCOORD0 - _324)), 1.0 - smoothstep(_327, Uniforms.uData[10].w, length(in.in_var_TEXCOORD0 - _395))); + _647 = float2(1.0 - smoothstep(_573, Uniforms.uData[10].w, length(in.in_var_TEXCOORD0 - _570)), 1.0 - smoothstep(_573, Uniforms.uData[10].w, length(in.in_var_TEXCOORD0 - _641))); } else { - _401 = float2(0.0); + _647 = float2(0.0); } - bool _402 = _255 < _163; - if (_402) + bool _648 = _499 < _166; + if (_648) { - _139 = _157; - _142 = _165; - _144 = _155; - _148 = _159; - _158 = Uniforms.uData[_179].yw; - _162 = _163; + _142 = _160; + _145 = _168; + _147 = _158; + _151 = _162; + _161 = _207.yw; + _165 = _166; } else { - bool _407 = _255 < _161; - float2 _411; - if (_407) + bool _652 = _499 < _164; + float2 _656; + if (_652) { - _411 = Uniforms.uData[_179].yw; + _656 = _207.yw; } else { - _411 = _138; + _656 = _141; } - _139 = _411; - _142 = _407 ? _190 : _141; - _144 = select(_143, _401, bool2(_407)); - _148 = select(_147, Uniforms.uData[_185], bool4(_407)); - _158 = _157; - _162 = _407 ? _255 : _161; + _142 = _656; + _145 = _652 ? _211 : _144; + _147 = select(_146, _647, bool2(_652)); + _151 = select(_150, _206, bool4(_652)); + _161 = _160; + _165 = _652 ? _499 : _164; } - _156 = select(_155, _401, bool2(_402)); - _160 = select(_159, Uniforms.uData[_185], bool4(_402)); - _164 = _402 ? _255 : _163; - _166 = _402 ? _190 : _165; - float2 _464; - float _465; - if (Uniforms.uData[_185].w < 0.5) + _159 = select(_158, _647, bool2(_648)); + _163 = select(_162, _206, bool4(_648)); + _167 = _648 ? _499 : _166; + _169 = _648 ? _211 : _168; + float2 _978; + float _979; + if (_196) { - float _430 = (in.in_var_TEXCOORD0.x - Uniforms.uData[_179].x) + Uniforms.uData[_179].z; - float _432 = (Uniforms.uData[_179].x + Uniforms.uData[_179].z) - in.in_var_TEXCOORD0.x; - float _437 = (in.in_var_TEXCOORD0.y - Uniforms.uData[_179].y) + Uniforms.uData[_179].w; - float _439 = (Uniforms.uData[_179].y + Uniforms.uData[_179].w) - in.in_var_TEXCOORD0.y; - float _443 = precise::min(precise::min(_430, _432), precise::min(_437, _439)); - float4 _448 = exp((float4(_443) - float4(_430, _432, _437, _439)) / float4(Uniforms.uData[1].y)); - float _449 = _448.x; - float _450 = _448.y; - float _452 = _448.z; - float _454 = _448.w; - float _455 = ((_449 + _450) + _452) + _454; - _464 = float2(_450 - _449, _454 - _452) / float2(_455); - _465 = (Uniforms.uData[1].y * log(_455)) - _443; + float4 _724 = precise::min(Uniforms.uData[57], float4(precise::min(Uniforms.uData[56].z, Uniforms.uData[56].w))); + int _727 = int(Uniforms.uData[58].z); + float2 _833; + float _834; + if (Uniforms.uData[1].y > 0.0) + { + float _799 = (in.in_var_TEXCOORD0.x - Uniforms.uData[56].x) + Uniforms.uData[56].z; + float _801 = (Uniforms.uData[56].x + Uniforms.uData[56].z) - in.in_var_TEXCOORD0.x; + float _806 = (in.in_var_TEXCOORD0.y - Uniforms.uData[56].y) + Uniforms.uData[56].w; + float _808 = (Uniforms.uData[56].y + Uniforms.uData[56].w) - in.in_var_TEXCOORD0.y; + float _812 = precise::min(precise::min(_799, _801), precise::min(_806, _808)); + float4 _817 = exp((float4(_812) - float4(_799, _801, _806, _808)) / float4(Uniforms.uData[1].y)); + float _818 = _817.x; + float _819 = _817.y; + float _821 = _817.z; + float _823 = _817.w; + float _824 = ((_818 + _819) + _821) + _823; + _833 = float2(_819 - _818, _823 - _821) / float2(_824); + _834 = (Uniforms.uData[1].y * log(_824)) - _812; + } + else + { + float2 _733 = in.in_var_TEXCOORD0 - Uniforms.uData[56].xy; + float _735 = _733.x; + float _756; + if (_735 > 0.0) + { + float _755; + if (_733.y > 0.0) + { + _755 = _724.z; + } + else + { + _755 = _724.y; + } + _756 = _755; + } + else + { + float _747; + if (_733.y > 0.0) + { + _747 = _724.w; + } + else + { + _747 = _724.x; + } + _756 = _747; + } + float2 _760 = (abs(_733) - Uniforms.uData[56].zw) + float2(_756); + float _762 = (_735 < 0.0) ? (-1.0) : 1.0; + float _765 = (_733.y < 0.0) ? (-1.0) : 1.0; + float _767 = _760.x; + bool _773; + if (_767 > 0.0) + { + _773 = _760.y > 0.0; + } + else + { + _773 = false; + } + float2 _787; + if (_773) + { + _787 = fast::normalize(_760) * float2(_762, _765); + } + else + { + float2 _784; + if (_767 > _760.y) + { + _784 = float2(_762, 0.0); + } + else + { + _784 = float2(0.0, _765); + } + _787 = _784; + } + _833 = _787; + _834 = (precise::min(precise::max(_767, _760.y), 0.0) + length(precise::max(_760, float2(0.0)))) - _756; + } + float2 _836; + float _839; + _836 = _833; + _839 = _834; + float2 _837; + float _840; + int _841 = 0; + for (;;) + { + bool _849; + if (_841 < _727) + { + _849 = _841 < 4; + } + else + { + _849 = false; + } + if (_849) + { + int _851 = 14 - _841; + int _852 = 3 * _851; + int _853 = 11 + _852; + int _856 = _852 + 12; + if (Uniforms.uData[_856].x == 0.0) + { + _837 = _836; + _840 = _839; + int _842 = _841 + 1; + _836 = _837; + _839 = _840; + _841 = _842; + continue; + } + float _865 = fast::clamp(Uniforms.uData[_856].x / Uniforms.uData[_856].y, 0.0, 1.0); + bool _867 = Uniforms.uData[_853].x < 0.5; + float _875; + if (_867) + { + _875 = in.in_var_TEXCOORD0.y; + } + else + { + _875 = in.in_var_TEXCOORD0.x; + } + float _883; + if (_867) + { + _883 = in.in_var_TEXCOORD0.x; + } + else + { + _883 = in.in_var_TEXCOORD0.y; + } + float _885 = _883 - Uniforms.uData[_853].y; + float _886 = Uniforms.uData[_856].x * 0.5; + float _889 = Uniforms.uData[_853].w - Uniforms.uData[_853].z; + float _890 = smoothstep(0.0, 0.60000002384185791015625, _865); + float _919; + float _920; + if (Uniforms.uData[_856].w > 2.5) + { + float _910 = _875 - ((Uniforms.uData[_853].z + Uniforms.uData[_853].w) * 0.5); + _919 = (_910 < 0.0) ? 1.0 : (-1.0); + _920 = precise::max(((_889 * 0.5) * (1.0 - _890)) - abs(_910), 0.0); + } + else + { + bool _896 = Uniforms.uData[_856].w < 1.5; + float _902; + if (_896) + { + _902 = _875 - Uniforms.uData[_853].z; + } + else + { + _902 = Uniforms.uData[_853].w - _875; + } + _919 = _896 ? 1.0 : (-1.0); + _920 = precise::max(_902 - ((_889 - _886) * _890), 0.0); + } + float _922 = length(float2(_885, _920)); + float _923 = _922 - _886; + float2 _938; + if (_922 > 0.0) + { + float2 _932 = float2(-_885, (-_920) * _919) / float2(_922); + float2 _937; + if (Uniforms.uData[_853].x > 0.5) + { + _937 = _932.yx; + } + else + { + _937 = _932; + } + _938 = _937; + } + else + { + _938 = float2(0.0); + } + float _940 = Uniforms.uData[_856].z * _865; + float2 _944 = precise::max(float2(_940 + _839, _940 - _923), float2(0.0)); + float _945 = length(_944); + bool _950; + if (_940 > 0.0) + { + _950 = _945 > 0.0; + } + else + { + _950 = false; + } + float2 _965; + if (_950) + { + _965 = ((_836 * _944.x) + (_938 * _944.y)) / float2(_945); + } + else + { + _965 = select(_836, _938, bool2((-_923) > _839)); + } + float _966 = -_923; + float _977; + do + { + if (_940 == 0.0) + { + _977 = precise::max(_839, _966); + break; + } + _977 = precise::min(-_940, precise::max(_839, _966)) + _945; + break; + } while(false); + _837 = _965; + _840 = _977; + int _842 = _841 + 1; + _836 = _837; + _839 = _840; + _841 = _842; + continue; + } + else + { + break; + } + } + _978 = _836; + _979 = _839; } else { - _464 = _248; - _465 = _255; + float2 _713; + float _714; + if (_206.w < 0.5) + { + float _679 = (in.in_var_TEXCOORD0.x - _207.x) + _207.z; + float _681 = (_207.x + _207.z) - in.in_var_TEXCOORD0.x; + float _686 = (in.in_var_TEXCOORD0.y - _207.y) + _207.w; + float _688 = (_207.y + _207.w) - in.in_var_TEXCOORD0.y; + float _692 = precise::min(precise::min(_679, _681), precise::min(_686, _688)); + float4 _697 = exp((float4(_692) - float4(_679, _681, _686, _688)) / float4(Uniforms.uData[1].y)); + float _698 = _697.x; + float _699 = _697.y; + float _701 = _697.z; + float _703 = _697.w; + float _704 = ((_698 + _699) + _701) + _703; + _713 = float2(_699 - _698, _703 - _701) / float2(_704); + _714 = (Uniforms.uData[1].y * log(_704)) - _692; + } + else + { + _713 = _498; + _714 = _499; + } + _978 = _713; + _979 = _714; } - bool _466 = _465 < _153; - if (_466) + bool _980 = _979 < _156; + if (_980) { - _146 = _149; - _152 = _153; + _149 = _152; + _155 = _156; } else { - bool _470 = _465 < _151; - _146 = select(_145, _464, bool2(_470)); - _152 = _470 ? _465 : _151; + bool _984 = _979 < _154; + _149 = select(_148, _978, bool2(_984)); + _155 = _984 ? _979 : _154; } - _150 = select(_149, _464, bool2(_466)); - _154 = _466 ? _465 : _153; - _138 = _139; + _153 = select(_152, _978, bool2(_980)); + _157 = _980 ? _979 : _156; _141 = _142; - _143 = _144; - _145 = _146; - _147 = _148; - _149 = _150; - _151 = _152; - _153 = _154; - _155 = _156; - _157 = _158; - _159 = _160; - _161 = _162; - _163 = _164; - _165 = _166; - _167++; + _144 = _145; + _146 = _147; + _148 = _149; + _150 = _151; + _152 = _153; + _154 = _155; + _156 = _157; + _158 = _159; + _160 = _161; + _162 = _163; + _164 = _165; + _166 = _167; + _168 = _169; + _170++; continue; } else @@ -365,575 +856,601 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Unifo break; } } - bool _480 = Uniforms.uData[58].w > 2.5; - bool _481 = Uniforms.uData[58].w > 1.5; - float _554; - float2 _555; - if (_481) - { - float2 _487 = in.in_var_TEXCOORD0 - Uniforms.uData[56].xy; - float4 _493 = precise::min(Uniforms.uData[57], float4(precise::min(Uniforms.uData[56].z, Uniforms.uData[56].w))); - float _494 = _487.x; - float _515; - if (_494 > 0.0) + bool _998; + if (Uniforms.uData[58].w > 2.5) + { + _998 = Uniforms.uData[58].w < 3.5; + } + else + { + _998 = false; + } + bool _999 = Uniforms.uData[58].w > 1.5; + bool _1003; + if (_999) + { + _1003 = Uniforms.uData[58].w < 3.5; + } + else + { + _1003 = false; + } + float _1076; + float2 _1077; + if (_1003) + { + float2 _1009 = in.in_var_TEXCOORD0 - Uniforms.uData[56].xy; + float4 _1015 = precise::min(Uniforms.uData[57], float4(precise::min(Uniforms.uData[56].z, Uniforms.uData[56].w))); + float _1016 = _1009.x; + float _1037; + if (_1016 > 0.0) { - float _506; - if (_487.y > 0.0) + float _1036; + if (_1009.y > 0.0) { - _506 = _493.z; + _1036 = _1015.z; } else { - _506 = _493.y; + _1036 = _1015.y; } - _515 = _506; + _1037 = _1036; } else { - float _514; - if (_487.y > 0.0) + float _1028; + if (_1009.y > 0.0) { - _514 = _493.w; + _1028 = _1015.w; } else { - _514 = _493.x; + _1028 = _1015.x; } - _515 = _514; + _1037 = _1028; } - float2 _519 = (abs(_487) - Uniforms.uData[56].zw) + float2(_515); - float _521 = (_494 < 0.0) ? (-1.0) : 1.0; - float _524 = (_487.y < 0.0) ? (-1.0) : 1.0; - float _526 = _519.x; - bool _532; - if (_526 > 0.0) + float2 _1041 = (abs(_1009) - Uniforms.uData[56].zw) + float2(_1037); + float _1043 = (_1016 < 0.0) ? (-1.0) : 1.0; + float _1046 = (_1009.y < 0.0) ? (-1.0) : 1.0; + float _1048 = _1041.x; + bool _1054; + if (_1048 > 0.0) { - _532 = _519.y > 0.0; + _1054 = _1041.y > 0.0; } else { - _532 = false; + _1054 = false; } - float2 _546; - if (_532) + float2 _1068; + if (_1054) { - _546 = fast::normalize(_519) * float2(_521, _524); + _1068 = fast::normalize(_1041) * float2(_1043, _1046); } else { - float2 _545; - if (_526 > _519.y) + float2 _1065; + if (_1048 > _1041.y) { - _545 = float2(_521, 0.0); + _1065 = float2(_1043, 0.0); } else { - _545 = float2(0.0, _524); + _1065 = float2(0.0, _1046); } - _546 = _545; + _1068 = _1065; } - _554 = (precise::min(precise::max(_526, _519.y), 0.0) + length(precise::max(_519, float2(0.0)))) - _515; - _555 = _546; + _1076 = (precise::min(precise::max(_1048, _1041.y), 0.0) + length(precise::max(_1041, float2(0.0)))) - _1037; + _1077 = _1068; + } + else + { + _1076 = -1000000000.0; + _1077 = float2(0.0); + } + bool _1081; + if (_999) + { + _1081 = Uniforms.uData[58].w < 3.5; } else { - _554 = -1000000000.0; - _555 = float2(0.0); + _1081 = false; } - bool _559; - if (_481) + bool _1085; + if (_1081) { - _559 = !_480; + _1085 = !_998; } else { - _559 = false; - } - float2 _604; - float2 _605; - float _606; - float2 _607; - float2 _608; - float2 _609; - float2 _610; - float4 _611; - float4 _612; - float _613; - float _614; - float _615; - float _616; - if (_559) - { - float _562 = 1.0 - _554; - bool _563 = _562 < _163; - float2 _579; - float2 _580; - float _581; - float2 _582; - float4 _583; - float _584; - if (_563) + _1085 = false; + } + float2 _1130; + float2 _1131; + float _1132; + float2 _1133; + float2 _1134; + float2 _1135; + float2 _1136; + float4 _1137; + float4 _1138; + float _1139; + float _1140; + float _1141; + float _1142; + if (_1085) + { + float _1088 = 1.0 - _1076; + bool _1089 = _1088 < _166; + float2 _1105; + float2 _1106; + float _1107; + float2 _1108; + float4 _1109; + float _1110; + if (_1089) { - _579 = _157; - _580 = Uniforms.uData[56].yw; - _581 = _165; - _582 = _155; - _583 = _159; - _584 = _163; + _1105 = _160; + _1106 = Uniforms.uData[56].yw; + _1107 = _168; + _1108 = _158; + _1109 = _162; + _1110 = _166; } else { - bool _568 = _562 < _161; - float2 _572; - if (_568) + bool _1093 = _1088 < _164; + float2 _1097; + if (_1093) { - _572 = Uniforms.uData[56].yw; + _1097 = Uniforms.uData[56].yw; } else { - _572 = _138; + _1097 = _141; } - _579 = _572; - _580 = _157; - _581 = _568 ? _165 : _141; - _582 = select(_143, float2(0.0), bool2(_568)); - _583 = select(_147, Uniforms.uData[58], bool4(_568)); - _584 = _568 ? _562 : _161; + _1105 = _1097; + _1106 = _160; + _1107 = _1093 ? _168 : _144; + _1108 = select(_146, float2(0.0), bool2(_1093)); + _1109 = select(_150, Uniforms.uData[58], bool4(_1093)); + _1110 = _1093 ? _1088 : _164; } - float2 _590 = -_555; - bool _591 = _562 < _153; - float2 _599; - float _600; - if (_591) + float2 _1116 = -_1077; + bool _1117 = _1088 < _156; + float2 _1125; + float _1126; + if (_1117) { - _599 = _149; - _600 = _153; + _1125 = _152; + _1126 = _156; } else { - bool _595 = _562 < _151; - _599 = select(_145, _590, bool2(_595)); - _600 = _595 ? _562 : _151; + bool _1121 = _1088 < _154; + _1125 = select(_148, _1116, bool2(_1121)); + _1126 = _1121 ? _1088 : _154; } - _604 = _579; - _605 = _580; - _606 = _581; - _607 = _582; - _608 = select(_155, float2(0.0), bool2(_563)); - _609 = _599; - _610 = select(_149, _590, bool2(_591)); - _611 = _583; - _612 = select(_159, Uniforms.uData[58], bool4(_563)); - _613 = _600; - _614 = _591 ? _562 : _153; - _615 = _584; - _616 = _563 ? _562 : _163; + _1130 = _1105; + _1131 = _1106; + _1132 = _1107; + _1133 = _1108; + _1134 = select(_158, float2(0.0), bool2(_1089)); + _1135 = _1125; + _1136 = select(_152, _1116, bool2(_1117)); + _1137 = _1109; + _1138 = select(_162, Uniforms.uData[58], bool4(_1089)); + _1139 = _1126; + _1140 = _1117 ? _1088 : _156; + _1141 = _1110; + _1142 = _1089 ? _1088 : _166; } else { - _604 = _138; - _605 = _157; - _606 = _141; - _607 = _143; - _608 = _155; - _609 = _145; - _610 = _149; - _611 = _147; - _612 = _159; - _613 = _151; - _614 = _153; - _615 = _161; - _616 = _163; - } - float _618 = precise::max(Uniforms.uData[1].x, 9.9999997473787516355514526367188e-05); - float _623 = precise::max(_618 - abs(_616 - _615), 0.0) / _618; - float _624 = _623 * _623; - float _625 = _624 * 0.5; - float _630; - if (_615 < _616) - { - _630 = 1.0 - _625; + _1130 = _141; + _1131 = _160; + _1132 = _144; + _1133 = _146; + _1134 = _158; + _1135 = _148; + _1136 = _152; + _1137 = _150; + _1138 = _162; + _1139 = _154; + _1140 = _156; + _1141 = _164; + _1142 = _166; + } + float _1144 = precise::max(Uniforms.uData[1].x, 9.9999997473787516355514526367188e-05); + float _1149 = precise::max(_1144 - abs(_1142 - _1141), 0.0) / _1144; + float _1150 = _1149 * _1149; + float _1151 = _1150 * 0.5; + float _1156; + if (_1141 < _1142) + { + _1156 = 1.0 - _1151; } else { - _630 = _625; + _1156 = _1151; } - float _634 = precise::min(_616, _615) - ((_624 * _618) * 0.25); - float _639 = precise::max(_618 - abs(_614 - _613), 0.0) / _618; - float _640 = _639 * _639; - float _641 = _640 * 0.5; - float _646; - if (_613 < _614) + float _1160 = precise::min(_1142, _1141) - ((_1150 * _1144) * 0.25); + float _1165 = precise::max(_1144 - abs(_1140 - _1139), 0.0) / _1144; + float _1166 = _1165 * _1165; + float _1167 = _1166 * 0.5; + float _1172; + if (_1139 < _1140) { - _646 = 1.0 - _641; + _1172 = 1.0 - _1167; } else { - _646 = _641; + _1172 = _1167; } - float _650 = precise::min(_614, _613) - ((_640 * _618) * 0.25); - float _654; - if (_480) + float _1176 = precise::min(_1140, _1139) - ((_1166 * _1144) * 0.25); + float _1180; + if (_998) { - _654 = precise::max(_634, _554); + _1180 = precise::max(_1160, _1076); } else { - _654 = _634; + _1180 = _1160; } - float _657 = fast::clamp(0.5 - precise::max(_654, _554), 0.0, 1.0); - if (_657 <= 0.0) + float _1183 = fast::clamp(0.5 - precise::max(_1180, _1076), 0.0, 1.0); + if (_1183 <= 0.0) { discard_fragment(); } if (in.in_var_COLOR.x < 0.5) { - _1186 = float4(0.0, 0.0, 0.0, _657); + _1712 = float4(0.0, 0.0, 0.0, _1183); break; } - float4 _668 = mix(_612, _611, float4(_630)); - bool _674; - if (_480) + float4 _1194 = mix(_1138, _1137, float4(_1156)); + bool _1200; + if (_998) { - _674 = _554 > _650; + _1200 = _1076 > _1176; } else { - _674 = false; - } - float2 _677 = select(mix(_610, _609, float2(_646)), _555, bool2(_674)); - float2 _678 = float2(_630); - float2 _682 = mix(_608, _607, _678) * precise::min(length(_677), 1.0); - float _684 = precise::max(0.0, -(_674 ? _554 : _650)); - float _685 = -_684; - float _688 = exp(_685 / Uniforms.uData[1].z); - float _694 = _668.y; - float _728; - float _729; - float2 _730; - if (_136) - { - float _702 = precise::max(precise::min(Uniforms.uData[5].y * mix(_165, _606, _630), Uniforms.uData[6].w), 1.0); - float _705 = fast::clamp(1.0 - (_684 / _702), 0.0, 1.0); - float _710 = (((Uniforms.uData[5].z * _702) * _694) * _705) * _705; - _728 = _705; - _729 = _710; - _730 = fast::clamp(((in.in_var_TEXCOORD0 - (_677 * _710)) - Uniforms.uData[0].xy) * Uniforms.uData[0].zw, float2(0.0), float2(1.0)); + _1200 = false; + } + float2 _1203 = select(mix(_1136, _1135, float2(_1172)), _1077, bool2(_1200)); + float2 _1204 = float2(_1156); + float2 _1208 = mix(_1134, _1133, _1204) * precise::min(length(_1203), 1.0); + float _1210 = precise::max(0.0, -(_1200 ? _1076 : _1176)); + float _1211 = -_1210; + float _1214 = exp(_1211 / Uniforms.uData[1].z); + float _1220 = _1194.y; + float _1254; + float _1255; + float2 _1256; + if (_139) + { + float _1238 = precise::max(precise::min(Uniforms.uData[5].y * mix(_168, _1132, _1156), Uniforms.uData[6].w), 1.0); + float _1241 = fast::clamp(1.0 - (_1210 / _1238), 0.0, 1.0); + float _1246 = (((Uniforms.uData[5].z * _1238) * _1220) * _1241) * _1241; + _1254 = _1241; + _1255 = _1246; + _1256 = fast::clamp(((in.in_var_TEXCOORD0 - (_1203 * _1246)) - Uniforms.uData[0].xy) * Uniforms.uData[0].zw, float2(0.0), float2(1.0)); } else { - _728 = 0.0; - _729 = 0.0; - _730 = fast::clamp(((in.in_var_TEXCOORD0 + (_677 * ((Uniforms.uData[2].x * _694) * _688))) - Uniforms.uData[0].xy) * Uniforms.uData[0].zw, float2(0.0), float2(1.0)); + _1254 = 0.0; + _1255 = 0.0; + _1256 = fast::clamp(((in.in_var_TEXCOORD0 + (_1203 * ((Uniforms.uData[2].x * _1220) * _1214))) - Uniforms.uData[0].xy) * Uniforms.uData[0].zw, float2(0.0), float2(1.0)); } - float4 _734 = Frost.sample(FrostSampler, _730, level(0.0)); - bool _736 = Uniforms.uData[4].w > 0.5; - float4 _744; - if (_736) + float4 _1260 = Frost.sample(FrostSampler, _1256, level(0.0)); + bool _1262 = Uniforms.uData[4].w > 0.5; + float4 _1270; + if (_1262) { - _744 = Sharp.sample(SharpSampler, _730, level(0.0)); + _1270 = Sharp.sample(SharpSampler, _1256, level(0.0)); } else { - _744 = _734; + _1270 = _1260; } - bool _749; - if (_136) + bool _1275; + if (_139) { - _749 = Uniforms.uData[6].y > 0.0; + _1275 = Uniforms.uData[6].y > 0.0; } else { - _749 = false; + _1275 = false; } - bool _753; - if (_749) + bool _1279; + if (_1275) { - _753 = _729 > 0.5; + _1279 = _1255 > 0.5; } else { - _753 = false; - } - float4 _814; - float4 _815; - if (_753) - { - float2 _761 = (_677 * ((_729 * 0.039999999105930328369140625) * Uniforms.uData[6].y)) * Uniforms.uData[0].zw; - float2 _763 = fast::clamp(_730 + _761, float2(0.0), float2(1.0)); - float2 _765 = fast::clamp(_730 - _761, float2(0.0), float2(1.0)); - float4 _769 = Frost.sample(FrostSampler, _763, level(0.0)); - float _774 = _734.w; - float _775 = (_769.x / precise::max(_769.w, 9.9999997473787516355514526367188e-05)) * _774; - float4 _776 = _734; - _776.x = _775; - float4 _780 = Frost.sample(FrostSampler, _765, level(0.0)); - float _785 = (_780.z / precise::max(_780.w, 9.9999997473787516355514526367188e-05)) * _774; - _776.z = _785; - float4 _813; - if (_736) + _1279 = false; + } + float4 _1340; + float4 _1341; + if (_1279) + { + float2 _1287 = (_1203 * ((_1255 * 0.039999999105930328369140625) * Uniforms.uData[6].y)) * Uniforms.uData[0].zw; + float2 _1289 = fast::clamp(_1256 + _1287, float2(0.0), float2(1.0)); + float2 _1291 = fast::clamp(_1256 - _1287, float2(0.0), float2(1.0)); + float4 _1295 = Frost.sample(FrostSampler, _1289, level(0.0)); + float _1300 = _1260.w; + float _1301 = (_1295.x / precise::max(_1295.w, 9.9999997473787516355514526367188e-05)) * _1300; + float4 _1302 = _1260; + _1302.x = _1301; + float4 _1306 = Frost.sample(FrostSampler, _1291, level(0.0)); + float _1311 = (_1306.z / precise::max(_1306.w, 9.9999997473787516355514526367188e-05)) * _1300; + _1302.z = _1311; + float4 _1339; + if (_1262) { - float4 _793 = Sharp.sample(SharpSampler, _763, level(0.0)); - float4 _800 = _744; - _800.x = (_793.x / precise::max(_793.w, 9.9999997473787516355514526367188e-05)) * _744.w; - float4 _804 = Sharp.sample(SharpSampler, _765, level(0.0)); - _800.z = (_804.z / precise::max(_804.w, 9.9999997473787516355514526367188e-05)) * _744.w; - _813 = _800; + float4 _1321 = Sharp.sample(SharpSampler, _1289, level(0.0)); + float4 _1328 = _1270; + _1328.x = (_1321.x / precise::max(_1321.w, 9.9999997473787516355514526367188e-05)) * _1270.w; + float4 _1332 = Sharp.sample(SharpSampler, _1291, level(0.0)); + _1328.z = (_1332.z / precise::max(_1332.w, 9.9999997473787516355514526367188e-05)) * _1270.w; + _1339 = _1328; } else { - float4 _811 = _744; - _811.x = _775; - _811.z = _785; - _813 = _811; + float4 _1316 = _1270; + _1316.x = _1301; + _1316.z = _1311; + _1339 = _1316; } - _814 = _813; - _815 = _776; + _1340 = _1339; + _1341 = _1302; } else { - _814 = _744; - _815 = _734; + _1340 = _1270; + _1341 = _1260; } - bool _817 = Uniforms.uData[4].x > 1.5; - float _831; - if (_817) + bool _1343 = Uniforms.uData[4].x > 1.5; + float _1357; + if (_1343) { - _831 = Uniforms.uData[3].w; + _1357 = Uniforms.uData[3].w; } else { - float _830; + float _1355; if (fmod(Uniforms.uData[6].x, 2.0) > 0.5) { - _830 = 1.0; + _1355 = 1.0; } else { - _830 = _815.w; + _1355 = _1341.w; } - _831 = _830; + _1357 = _1355; } - float4 _840 = float4(_815.xyz / float3(precise::max(_815.w, 9.9999997473787516355514526367188e-05)), 1.0); - float4 _849 = float4(_814.xyz / float3(precise::max(_814.w, 9.9999997473787516355514526367188e-05)), 1.0); - float _856; - if (_817) + float4 _1366 = float4(_1341.xyz / float3(precise::max(_1341.w, 9.9999997473787516355514526367188e-05)), 1.0); + float4 _1375 = float4(_1340.xyz / float3(precise::max(_1340.w, 9.9999997473787516355514526367188e-05)), 1.0); + float _1382; + if (_1343) { - _856 = 1.0; + _1382 = 1.0; } else { - _856 = (Uniforms.uData[4].z > 0.5) ? Uniforms.uData[4].x : 0.0; + _1382 = (Uniforms.uData[4].z > 0.5) ? Uniforms.uData[4].x : 0.0; } - bool _860; - if (_136) + bool _1386; + if (_139) { - _860 = !_817; + _1386 = !_1343; } else { - _860 = false; + _1386 = false; } - float _869; - if (_860) + float _1395; + if (_1386) { - _869 = _856 * (1.0 - ((_728 * _728) * (1.0 - smoothstep(0.800000011920928955078125, 1.0, _856)))); + _1395 = _1382 * (1.0 - ((_1254 * _1254) * (1.0 - smoothstep(0.800000011920928955078125, 1.0, _1382)))); } else { - _869 = _856; + _1395 = _1382; } - float _872 = 1.0 - _869; - float _880; - if (_136) + float _1398 = 1.0 - _1395; + float _1406; + if (_139) { - _880 = _728; + _1406 = _1254; } else { - _880 = _688 * _688; + _1406 = _1214 * _1214; } - float _883 = fast::clamp(((Uniforms.uData[2].y * _694) * _880) * _872, 0.0, 1.0); - float4 _889 = ((_849 * _883) + ((mix(_849, _840, float4(fast::clamp(_668.x, 0.0, 1.0))) * _872) * (1.0 - _883))) + (Uniforms.uData[3] * _869); - float4 _932; - if (_817) + float _1409 = fast::clamp(((Uniforms.uData[2].y * _1220) * _1406) * _1398, 0.0, 1.0); + float4 _1415 = ((_1375 * _1409) + ((mix(_1375, _1366, float4(fast::clamp(_1194.x, 0.0, 1.0))) * _1398) * (1.0 - _1409))) + (Uniforms.uData[3] * _1395); + float4 _1458; + if (_1343) { - _932 = float4(Uniforms.uData[3].xyz / float3(precise::max(Uniforms.uData[3].w, 9.9999997473787516355514526367188e-05)), 1.0); + _1458 = float4(Uniforms.uData[3].xyz / float3(precise::max(Uniforms.uData[3].w, 9.9999997473787516355514526367188e-05)), 1.0); } else { - float4 _905 = _889 + (_840 * (1.0 - _889.w)); - float4 _931; + float4 _1422 = _1415 + (_1366 * (1.0 - _1415.w)); + float4 _1448; if (Uniforms.uData[7].w < 1.0) { - float3 _910 = _905.xyz; - float _911 = dot(_910, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); - float _912 = 0.60000002384185791015625 * Uniforms.uData[7].w; - float _914 = precise::max(Uniforms.uData[7].w - _912, 9.9999997473787516355514526367188e-05); - float _926; - if (_911 <= _912) + float3 _1427 = _1422.xyz; + float _1428 = dot(_1427, float3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + float _1429 = 0.60000002384185791015625 * Uniforms.uData[7].w; + float _1431 = precise::max(Uniforms.uData[7].w - _1429, 9.9999997473787516355514526367188e-05); + float _1443; + if (_1428 <= _1429) { - _926 = _911; + _1443 = _1428; } else { - _926 = _912 + (_914 * (1.0 - exp((-(_911 - _912)) / _914))); + _1443 = _1429 + (_1431 * (1.0 - exp((-(_1428 - _1429)) / _1431))); } - float3 _929 = _910 * (_926 / precise::max(_911, 9.9999997473787516355514526367188e-05)); - _931 = float4(_929.x, _929.y, _929.z, _905.w); + float3 _1446 = _1427 * (_1443 / precise::max(_1428, 9.9999997473787516355514526367188e-05)); + _1448 = float4(_1446.x, _1446.y, _1446.z, _1422.w); } else { - _931 = _905; + _1448 = _1422; } - _932 = _931; + _1458 = _1448; } - float _935 = dot(_677, Uniforms.uData[9].xy); - float _936 = precise::max(_935, 0.0); - float _938 = precise::max(-_935, 0.0); - float _941 = abs(_935); - bool _945; - if (_136) + float _1461 = dot(_1203, Uniforms.uData[9].xy); + float _1462 = precise::max(_1461, 0.0); + float _1464 = precise::max(-_1461, 0.0); + float _1467 = abs(_1461); + bool _1471; + if (_139) { - _945 = Uniforms.uData[6].z > 0.0; + _1471 = Uniforms.uData[6].z > 0.0; } else { - _945 = false; + _1471 = false; } - bool _947 = Uniforms.uData[10].x > 0.0; - float _971; - if (_947) + bool _1473 = Uniforms.uData[10].x > 0.0; + float _1497; + if (_1473) { - _971 = 0.0; + _1497 = 0.0; } else { - float _970; - if (_945) + float _1496; + if (_1471) { - _970 = (Uniforms.uData[6].z * (1.0 - smoothstep(0.20000000298023223876953125, 0.699999988079071044921875, _941))) * exp((-precise::max(0.0, -_654)) / (Uniforms.uData[2].z * 2.5)); + _1496 = (Uniforms.uData[6].z * (1.0 - smoothstep(0.20000000298023223876953125, 0.699999988079071044921875, _1467))) * exp((-precise::max(0.0, -_1180)) / (Uniforms.uData[2].z * 2.5)); } else { - _970 = Uniforms.uData[8].x * (1.0 - smoothstep(0.0, Uniforms.uData[2].z * 0.625, -_654)); + _1496 = Uniforms.uData[8].x * (1.0 - smoothstep(0.0, Uniforms.uData[2].z * 0.625, -_1180)); } - _971 = _970; + _1497 = _1496; } - float _981; - if (_136) + float _1507; + if (_139) { - _981 = precise::max((Uniforms.uData[5].w * _728) * _728, _971) * precise::min(_694, 1.0); + _1507 = precise::max((Uniforms.uData[5].w * _1254) * _1254, _1497) * precise::min(_1220, 1.0); } else { - _981 = 0.0; + _1507 = 0.0; } - float _984 = _831 * (1.0 - _981); - float4 _990 = float4(_932.xyz * _984, _984 + _981); - float _1012; - if (_136) + float _1510 = _1357 * (1.0 - _1507); + float4 _1516 = float4(_1458.xyz * _1510, _1510 + _1507); + float _1538; + if (_139) { - float _1003; - if (_945) + float _1537; + if (_1471) { - _1003 = Uniforms.uData[6].z * precise::max(smoothstep(0.75, 1.0, _941), precise::max(_682.x, _682.y)); + _1537 = Uniforms.uData[6].z * precise::max(smoothstep(0.75, 1.0, _1467), precise::max(_1208.x, _1208.y)); } else { - _1003 = 0.25; + _1537 = 0.25; } - _1012 = _1003; + _1538 = _1537; } else { - _1012 = (0.449999988079071044921875 * ((_936 * sqrt(_936)) + ((0.75 * _938) * sqrt(_938)))) + 0.0599999986588954925537109375; + _1538 = (0.449999988079071044921875 * ((_1462 * sqrt(_1462)) + ((0.75 * _1464) * sqrt(_1464)))) + 0.0599999986588954925537109375; } - float _1039; - if (_945) + float _1565; + if (_1471) { - _1039 = exp((-precise::max(0.0, -_654)) / (Uniforms.uData[2].z * 1.25)); + _1565 = exp((-precise::max(0.0, -_1180)) / (Uniforms.uData[2].z * 1.25)); } else { - float _1038; - if (_136) + float _1559; + if (_139) { - float _1026 = -_654; - _1038 = smoothstep(Uniforms.uData[2].z * 0.3125, Uniforms.uData[2].z * 0.625, _1026) * (1.0 - smoothstep(Uniforms.uData[2].z * 1.5, Uniforms.uData[2].z * 2.0, _1026)); + float _1552 = -_1180; + _1559 = smoothstep(Uniforms.uData[2].z * 0.3125, Uniforms.uData[2].z * 0.625, _1552) * (1.0 - smoothstep(Uniforms.uData[2].z * 1.5, Uniforms.uData[2].z * 2.0, _1552)); } else { - _1038 = exp((-precise::max(0.0, -_654)) / Uniforms.uData[2].z); + _1559 = exp((-precise::max(0.0, -_1180)) / Uniforms.uData[2].z); } - _1039 = _1038; + _1565 = _1559; } - float _1051; - if (_947) + float _1577; + if (_1473) { - _1051 = 0.0; + _1577 = 0.0; } else { - float _1049; - if (_136) + float _1575; + if (_139) { - _1049 = 0.0; + _1575 = 0.0; } else { - _1049 = (0.039999999105930328369140625 * exp(_685 / Uniforms.uData[1].w)) * _936; + _1575 = (0.039999999105930328369140625 * exp(_1211 / Uniforms.uData[1].w)) * _1462; } - _1051 = (_1039 * _1012) + _1049; + _1577 = (_1565 * _1538) + _1575; } - float2 _1052 = mix(_605, _604, _678); - float _1056 = _1052.y; - float _1062 = fast::clamp((in.in_var_TEXCOORD0.y - (_1052.x - _1056)) / precise::max(2.0 * _1056, 9.9999997473787516355514526367188e-05), 0.0, 1.0); - float _1080; + float2 _1578 = mix(_1131, _1130, _1204); + float _1582 = _1578.y; + float _1588 = fast::clamp((in.in_var_TEXCOORD0.y - (_1578.x - _1582)) / precise::max(2.0 * _1582, 9.9999997473787516355514526367188e-05), 0.0, 1.0); + float _1606; if (Uniforms.uData[4].z > 0.5) { - _1080 = Uniforms.uData[4].y + ((Uniforms.uData[7].x + ((Uniforms.uData[7].y - Uniforms.uData[7].x) * _1062)) + (Uniforms.uData[7].z * (1.0 - smoothstep(0.0, 0.37999999523162841796875, _1062)))); + _1606 = Uniforms.uData[4].y + ((Uniforms.uData[7].x + ((Uniforms.uData[7].y - Uniforms.uData[7].x) * _1588)) + (Uniforms.uData[7].z * (1.0 - smoothstep(0.0, 0.37999999523162841796875, _1588)))); } else { - _1080 = 0.0; + _1606 = 0.0; } - float3 _1090 = _990.xyz + float3(fast::clamp((_1080 + _668.z) + ((_694 * Uniforms.uData[2].w) * _1051), 0.0, 1.0)); - float4 _1162; - if (_947) + float3 _1616 = _1516.xyz + float3(fast::clamp((_1606 + _1194.z) + ((_1220 * Uniforms.uData[2].w) * _1577), 0.0, 1.0)); + float4 _1688; + if (_1473) { - float2 _1100; - if (dot(_677, _677) > 9.9999999392252902907785028219223e-09) + float2 _1626; + if (dot(_1203, _1203) > 9.9999999392252902907785028219223e-09) { - _1100 = fast::normalize(_677); + _1626 = fast::normalize(_1203); } else { - _1100 = float2(0.0); + _1626 = float2(0.0); } - float _1101 = dot(_1100, Uniforms.uData[9].xy); - float _1103 = mix(8.0, 1.0, Uniforms.uData[9].z); - float _1111 = powr(precise::max(_1101, 0.0), _1103) + (Uniforms.uData[9].w * powr(precise::max(-_1101, 0.0), _1103)); - float _1112 = precise::min(_694, 1.0); - float _1119 = -_654; - float _1121 = smoothstep(-0.5, 0.5, _1119); - float _1123 = -precise::max(0.0, _1119); - float3 _1160 = (_1090.xyz * (1.0 - (((Uniforms.uData[10].z * (1.0 - abs(_1101))) * (_1121 * exp(_1123 / precise::max(Uniforms.uData[2].z * 2.5, 0.001000000047497451305389404296875)))) * _1112))) + float3(_1112 * (((Uniforms.uData[10].x * precise::max(_1111, precise::max(_682.x, Uniforms.uData[9].w * _682.y))) * (_1121 * exp(_1123 / precise::max(Uniforms.uData[8].y, 0.001000000047497451305389404296875)))) + ((Uniforms.uData[10].y * _1111) * (smoothstep(Uniforms.uData[8].y - 0.5, Uniforms.uData[8].y + 0.5, _1119) * exp((-precise::max(0.0, _1119 - Uniforms.uData[8].y)) / precise::max(Uniforms.uData[8].z, 0.001000000047497451305389404296875)))))); - _1162 = float4(_1160.x, _1160.y, _1160.z, _990.w); + float _1627 = dot(_1626, Uniforms.uData[9].xy); + float _1629 = mix(8.0, 1.0, Uniforms.uData[9].z); + float _1637 = powr(precise::max(_1627, 0.0), _1629) + (Uniforms.uData[9].w * powr(precise::max(-_1627, 0.0), _1629)); + float _1638 = precise::min(_1220, 1.0); + float _1645 = -_1180; + float _1647 = smoothstep(-0.5, 0.5, _1645); + float _1649 = -precise::max(0.0, _1645); + float3 _1686 = (_1616.xyz * (1.0 - (((Uniforms.uData[10].z * (1.0 - abs(_1627))) * (_1647 * exp(_1649 / precise::max(Uniforms.uData[2].z * 2.5, 0.001000000047497451305389404296875)))) * _1638))) + float3(_1638 * (((Uniforms.uData[10].x * precise::max(_1637, precise::max(_1208.x, Uniforms.uData[9].w * _1208.y))) * (_1647 * exp(_1649 / precise::max(Uniforms.uData[8].y, 0.001000000047497451305389404296875)))) + ((Uniforms.uData[10].y * _1637) * (smoothstep(Uniforms.uData[8].y - 0.5, Uniforms.uData[8].y + 0.5, _1645) * exp((-precise::max(0.0, _1645 - Uniforms.uData[8].y)) / precise::max(Uniforms.uData[8].z, 0.001000000047497451305389404296875)))))); + _1688 = float4(_1686.x, _1686.y, _1686.z, _1516.w); } else { - _1162 = float4(_1090.x, _1090.y, _1090.z, _990.w); + _1688 = float4(_1616.x, _1616.y, _1616.z, _1516.w); } - float4 _1163 = fast::clamp(_1162, float4(0.0), float4(1.0)); - float _1170 = precise::max(_1163.w, precise::max(_1163.x, precise::max(_1163.y, _1163.z))); - float4 _1171 = _1163; - _1171.w = _1170; - float3 _1182 = _1171.xyz + float3(((fract(52.98291778564453125 * fract(dot(in.in_var_TEXCOORD0, float2(0.067110560834407806396484375, 0.005837149918079376220703125)))) - 0.5) * Uniforms.uData[5].x) * _1170); - _1186 = fast::clamp(float4(_1182.x, _1182.y, _1182.z, _1171.w), float4(0.0), float4(1.0)) * _657; + float4 _1689 = fast::clamp(_1688, float4(0.0), float4(1.0)); + float _1696 = precise::max(_1689.w, precise::max(_1689.x, precise::max(_1689.y, _1689.z))); + float4 _1697 = _1689; + _1697.w = _1696; + float3 _1708 = _1697.xyz + float3(((fract(52.98291778564453125 * fract(dot(in.in_var_TEXCOORD0, float2(0.067110560834407806396484375, 0.005837149918079376220703125)))) - 0.5) * Uniforms.uData[5].x) * _1696); + _1712 = fast::clamp(float4(_1708.x, _1708.y, _1708.z, _1697.w), float4(0.0), float4(1.0)) * _1183; break; } while(false); - out.out_var_SV_Target0 = _1186; + out.out_var_SV_Target0 = _1712; return out; } diff --git a/backend/src/glass/shaders/compiled/spv/liquid_glass.fragment.spv b/backend/src/glass/shaders/compiled/spv/liquid_glass.fragment.spv index 06defbd7a..d36a063dd 100644 Binary files a/backend/src/glass/shaders/compiled/spv/liquid_glass.fragment.spv and b/backend/src/glass/shaders/compiled/spv/liquid_glass.fragment.spv differ diff --git a/backend/src/glass/shaders/liquid_glass.fragment.hlsl b/backend/src/glass/shaders/liquid_glass.fragment.hlsl index 75e378cb2..115ec45f3 100644 --- a/backend/src/glass/shaders/liquid_glass.fragment.hlsl +++ b/backend/src/glass/shaders/liquid_glass.fragment.hlsl @@ -79,6 +79,57 @@ float smin(float a, float b, float k, out float m) return min(a, b) - h * h * k * 0.25; } +// Rounded intersection (hg_sdf fOpIntersectionRound); it stays within both operands. +float intersectRound(float a, float b, float r) +{ + if (r == 0.0) return max(a, b); + return min(-r, max(a, b)) + length(max(float2(r + a, r + b), 0.0)); +} + +float panelDistance(float2 p, float soft, out float2 g) +{ + float4 box = uData[G + 3 * (MAX_SHAPES - 1)]; + float4 rad = min(uData[G + 3 * (MAX_SHAPES - 1) + 1], (float4)min(box.z, box.w)); + int count = int(uData[G + 3 * (MAX_SHAPES - 1) + 2].z); + float d = soft > 0.0 ? softBox(p, box, soft, g) : sdRoundBox(p - box.xy, box.zw, rad, g); + for (int i = 0; i < count && i < 4; i++) { + float4 seam = uData[G + 3 * (MAX_SHAPES - 2 - i)]; + float4 params = uData[G + 3 * (MAX_SHAPES - 2 - i) + 1]; + if (params.x == 0.0) continue; + float open = clamp(params.x / params.y, 0.0, 1.0); + float along = seam.x < 0.5 ? p.y : p.x; + float v = (seam.x < 0.5 ? p.x : p.y) - seam.y; + float h = params.x / 2.0; + float len = seam.w - seam.z; + float advance = smoothstep(0.0, 0.6, open); + float tip; + float direction; + if (params.w > 2.5) { + float u = along - (seam.z + seam.w) / 2.0; + tip = max(len / 2.0 * (1.0 - advance) - abs(u), 0.0); + direction = u < 0.0 ? 1.0 : -1.0; + } else { + float u = params.w < 1.5 ? along - seam.z : seam.w - along; + tip = max(u - (len - h) * advance, 0.0); + direction = params.w < 1.5 ? 1.0 : -1.0; + } + float lenSlot = length(float2(v, tip)); + float slot = lenSlot - h; + float2 slotOut = float2(0.0, 0.0); + if (lenSlot > 0.0) { + slotOut = float2(-v, -tip * direction) / lenSlot; + if (seam.x > 0.5) slotOut = slotOut.yx; + } + float radius = params.z * open; + float2 weights = max(float2(radius + d, radius - slot), 0.0); + float norm = length(weights); + if (radius > 0.0 && norm > 0.0) g = (weights.x * g + weights.y * slotOut) / norm; + else if (-slot > d) g = slotOut; + d = intersectRound(d, -slot, radius); + } + return d; +} + // A soft step in at `a`, then a fall over `w`: the lit edge's line and glow along the inside of // the outline (`x` the depth inside it). float band(float x, float a, float w) @@ -140,16 +191,27 @@ float4 main(PSInput input) : SV_Target0 float4 s0 = uData[G + 3 * i]; float4 s1 = uData[G + 3 * i + 1]; float4 s2 = uData[G + 3 * i + 2]; + bool panel = s2.w < -0.5 || s2.w > 3.5; + if (panel) { + s0 = uData[G + 3 * (MAX_SHAPES - 1)]; + s1 = uData[G + 3 * (MAX_SHAPES - 1) + 1]; + s2 = uData[G + 3 * (MAX_SHAPES - 1) + 2]; + s2.z = 0.0; + } float2 g; float4 rad = min(s1, (float4)min(s0.z, s0.w)); - float d = sdRoundBox(p - s0.xy, s0.zw, rad, g); + float d; + if (panel) d = panelDistance(p, 0.0, g); + else d = sdRoundBox(p - s0.xy, s0.zw, rad, g); float hs = min(s0.z, s0.w); float2 al = float2(0.0, 0.0); if (g10.w > 0.0) al = float2(alongEnd(p, s0, rad, g9.xy, g10.w, g8.w), alongEnd(p, s0, rad, -g9.xy, g10.w, g8.w)); if (d < d1) { d2 = d1; m2 = m1; h2 = h1; y2 = y1; al2 = al1; d1 = d; m1 = s2; h1 = hs; y1 = s0.yw; al1 = al; } else if (d < d2) { d2 = d; m2 = s2; h2 = hs; y2 = s0.yw; al2 = al; } float2 o; float f = d; - if (s2.w < 0.5) { + if (panel) { + f = panelDistance(p, g1.y, o); + } else if (s2.w < 0.5) { f = softBox(p, s0, g1.y, o); } else { o = g; @@ -166,14 +228,14 @@ float4 main(PSInput input) : SV_Target0 float2 placeOut = float2(0.0, 0.0); float4 e0 = uData[G + 3 * (MAX_SHAPES - 1)]; float4 e2 = uData[G + 3 * (MAX_SHAPES - 1) + 2]; - bool cutEdge = e2.w > 2.5; - if (e2.w > 1.5) { + bool cutEdge = e2.w > 2.5 && e2.w < 3.5; + if (e2.w > 1.5 && e2.w < 3.5) { float4 e1 = uData[G + 3 * (MAX_SHAPES - 1) + 1]; float2 ge; inPlace = sdRoundBox(p - e0.xy, e0.zw, min(e1, (float4)min(e0.z, e0.w)), ge); placeOut = ge; } - if (e2.w > 1.5 && !cutEdge) { + if (e2.w > 1.5 && e2.w < 3.5 && !cutEdge) { float2 ge = placeOut; float d = EDGE_GAP - inPlace; float hs = h1; diff --git a/docs/images/panel-seam-coverage.png b/docs/images/panel-seam-coverage.png new file mode 100644 index 000000000..240acc610 Binary files /dev/null and b/docs/images/panel-seam-coverage.png differ