shader_type spatial; render_mode blend_mix, depth_draw_opaque, cull_disabled, shadows_disabled, unshaded; // A location printed on the playmat, drawn as a socket in the cards' style (gameplay-plan.md §B2): // a chamfered octagon like the cards' frames, a dim interior, an inset second line, brighter ticks // on the chamfers and the owner's pattern (stripes for South, dots for North) as a cue beside the // color. One material serves every tile and every printed card spot; the owner tint, pattern and // glow are instance uniforms. uniform vec2 size = vec2(5.6, 2.05); // The corner cut, in world units. uniform float chamfer = 0.22; uniform float edge_width = 0.07; // The faint second line inside the edge, as a fraction of the edge's alpha; 0 for none. uniform float inner_line = 0.45; // Pattern pitch and size, in world units. uniform float stripe_pitch = 0.3; uniform float dot_pitch = 0.32; instance uniform vec4 fill_color : source_color = vec4(1.0, 1.0, 1.0, 0.06); instance uniform vec4 edge_color : source_color = vec4(1.0, 1.0, 1.0, 0.45); // Highlights (legal targets, the combat) light up the edge. instance uniform float glow = 0.0; // The owner's pattern: 0 none, 1 stripes (South), 2 dots (North). instance uniform float pattern = 0.0; // Signed distance to a chamfered rectangle: exact inside, which is all the bands need. float sd_octagon(vec2 p, vec2 half_size, float c, out bool on_chamfer) { vec2 q = abs(p); float box = max(q.x - half_size.x, q.y - half_size.y); float diag = (q.x + q.y - (half_size.x + half_size.y - c)) * 0.70710678; on_chamfer = diag > box; return max(box, diag); } void fragment() { vec2 p = (UV - 0.5) * size; bool on_chamfer; float d = sd_octagon(p, size * 0.5, chamfer, on_chamfer); if (d > 0.0) { discard; } float px = fwidth(d); float w = edge_width * (1.0 + glow * 0.8); // The chamfers carry a thicker tick, like the corner ticks on the cards. float ew = on_chamfer ? w * 1.9 : w; float edge = 1.0 - smoothstep(ew - px, ew + px, -d); float inner_d = abs(-d - w * 2.6); float inner = (1.0 - smoothstep(w * 0.18 - px, w * 0.18 + px, inner_d)) * inner_line; vec4 fill = fill_color; if (pattern > 0.5) { float on = 0.0; if (pattern < 1.5) { float t = fract((p.x + p.y) / stripe_pitch); float aa = fwidth((p.x + p.y) / stripe_pitch); on = smoothstep(0.62 - aa, 0.62 + aa, t) * (1.0 - smoothstep(0.86 - aa, 0.86 + aa, t)); } else { vec2 cell = fract(p / dot_pitch) - 0.5; float r = length(cell) * dot_pitch; float aa = fwidth(r); on = 1.0 - smoothstep(0.045 - aa, 0.045 + aa, r); } // Keep the pattern off the frame so the edge reads cleanly. on *= smoothstep(w * 3.0, w * 4.5, -d); fill = mix(fill, vec4(edge_color.rgb, max(fill.a, edge_color.a * 0.32)), on * 0.75); } vec4 c = mix(fill, edge_color, max(edge, inner * edge_color.a)); c.a = max(c.a, fill.a); // Unshaded, so the print reads the same under any light; glow brightens the edge for bloom. ALBEDO = c.rgb * (1.0 + glow * edge * 1.5) + fill_color.rgb * glow * 0.1; ALPHA = c.a; }