29 lines
1.1 KiB
Text
29 lines
1.1 KiB
Text
shader_type spatial;
|
|
render_mode blend_mix, depth_draw_opaque, cull_disabled, shadows_disabled, unshaded;
|
|
|
|
// A location printed on the playmat: a rounded rectangle with a tinted fill and an edge line.
|
|
// One material serves every tile; the owner tint and glow are instance uniforms.
|
|
|
|
uniform vec2 size = vec2(5.6, 2.05);
|
|
uniform float radius = 0.2;
|
|
uniform float edge_width = 0.07;
|
|
|
|
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;
|
|
|
|
void fragment() {
|
|
vec2 p = (UV - 0.5) * size;
|
|
vec2 q = abs(p) - (size * 0.5 - vec2(radius));
|
|
float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
|
|
if (d > 0.0) {
|
|
discard;
|
|
}
|
|
float w = edge_width * (1.0 + glow * 0.8);
|
|
float edge = 1.0 - smoothstep(w * 0.5, w, -d);
|
|
vec4 c = mix(fill_color, edge_color, edge);
|
|
// 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;
|
|
}
|