#version 450 // Static-map model fragment stage: sample the shared texture array and apply // the same directional sun the terrain uses. Cut-out props (trees, fences) // carry an alpha mask in their diffuse texture; discard the transparent texels // so the ground shows through. layout(binding = 0) uniform sampler2DArray atlas; layout(push_constant) uniform Push { vec4 cam_pos; vec4 fwd; vec4 right; vec4 up; vec4 sun; } pc; layout(location = 0) in vec2 in_uv; layout(location = 1) in vec3 in_normal; layout(location = 2) flat in float in_layer; layout(location = 0) out vec4 out_color; void main() { int layers = textureSize(atlas, 0).z; int layer = clamp(int(in_layer + 0.5), 0, layers - 1); vec4 tex = texture(atlas, vec3(in_uv, float(layer))); if (tex.a < 0.5) discard; vec3 n = normalize(in_normal); if (!gl_FrontFacing) n = -n; float lambert = max(0.0, dot(n, normalize(pc.sun.xyz))); float ambient = pc.sun.w; vec3 lit = tex.rgb * (ambient + (1.0 - ambient) * lambert); out_color = vec4(lit, 1.0); }