// Image overlay shader — textured quad with per-vertex opacity.
//
// Draws a georeferenced image overlay as a textured quadrilateral in
// world space. The vertex shader transforms from camera-relative
// world-space positions to clip space; the fragment shader samples the
// image texture and applies per-vertex opacity.
struct Uniforms {
view_proj: mat4x4<f32>,
fog_color: vec4<f32>,
eye_pos: vec4<f32>,
fog_params: vec4<f32>,
};
@group(0) @binding(0) var<uniform> u: Uniforms;
@group(1) @binding(0) var img_texture: texture_2d<f32>;
@group(1) @binding(1) var img_sampler: sampler;
struct VertexInput {
@location(0) position: vec3<f32>,
@location(1) uv: vec2<f32>,
@location(2) opacity: f32,
};
struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
@location(0) tex_coord: vec2<f32>,
@location(1) opacity: f32,
};
@vertex
fn vs_main(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
out.clip_position = u.view_proj * vec4<f32>(in.position, 1.0);
out.tex_coord = in.uv;
out.opacity = in.opacity;
return out;
}
@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let color = textureSample(img_texture, img_sampler, in.tex_coord);
return vec4<f32>(color.rgb, color.a * in.opacity);
}