shader_type spatial; render_mode blend_mix, cull_back, diffuse_burley, specular_schlick_ggx; // The playmat as dark glass with a neon grid inlay (gameplay-plan.md §B1). The grid is drawn in // world space from the board layout (GameTable sets `pitch` and `origin` from BoardLayout), so its // lines run between the locations instead of along the mat's UVs. The mat's edge is a neon rim. uniform vec3 glass_color : source_color = vec3(0.010, 0.020, 0.026); uniform float roughness : hint_range(0.0, 1.0) = 0.3; uniform vec4 line_color : source_color = vec4(0.133, 0.827, 0.933, 1.0); // Major grid: half a column pitch across, a row pitch deep; origin is a major crossing. uniform vec2 pitch = vec2(2.96, 2.18); uniform vec2 origin = vec2(0.0, 1.09); // Minor lines per major cell. uniform float minor = 4.0; uniform float major_width = 0.018; uniform float minor_width = 0.008; uniform float major_energy = 1.25; uniform float minor_energy = 0.28; // Half the mat's size, for the rim. uniform vec2 half_size = vec2(9.144, 7.62); uniform float rim_energy = 2.6; varying vec3 world_pos; varying vec3 world_normal; void vertex() { world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; world_normal = normalize((MODEL_MATRIX * vec4(NORMAL, 0.0)).xyz); } float grid_line(vec2 p, vec2 cell, float width) { vec2 g = abs(fract(p / cell + 0.5) - 0.5) * cell; vec2 aa = fwidth(p) * 1.25; vec2 l = 1.0 - smoothstep(vec2(width) - aa, vec2(width) + aa, g); return max(l.x, l.y); } void fragment() { vec2 p = world_pos.xz - origin; float top = step(0.5, world_normal.y); float major_l = grid_line(p, pitch, major_width); float minor_l = grid_line(p, pitch / minor, minor_width) * (1.0 - major_l); float edge_d = min(half_size.x - abs(world_pos.x), half_size.y - abs(world_pos.z)); float rim = 1.0 - smoothstep(0.0, 0.07, edge_d); float band = (1.0 - smoothstep(0.0, 0.9, edge_d)) * 0.22; ALBEDO = glass_color; ROUGHNESS = roughness; METALLIC = 0.25; SPECULAR = 0.4; vec3 e = line_color.rgb * (major_l * major_energy + minor_l * minor_energy) * top; e += line_color.rgb * (rim * rim_energy + band * top); // The sides are all rim. e += line_color.rgb * (1.0 - top) * 0.9; EMISSION = e; }