mosaicmap/app/glsl/radar/frag.glsl
2025-08-26 14:44:00 +08:00

47 lines
1.3 KiB
GLSL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#version 300 es
precision highp float;
uniform sampler2D u_tex;
uniform sampler2D u_lut;
uniform float u_opacity;
in vec2 lonlat;
out vec4 fragColor;
const float PI = 3.141592653589793;
const vec4 bound = vec4(65.24686922, 13.12169419,
138.85867996, 55.34323806);
void main() {
vec2 uv = vec2(
(lonlat.x - bound.x) / (bound.z - bound.x), // 经度映射到 u
1.0 - (lonlat.y - bound.y) / (bound.w - bound.y) // 纬度映射到 v
);
// 调试:可以取消注释下面的行来可视化坐标
// fragColor = vec4(uv.x, 0.0, 0.0, 1.0); return; // UV坐标可视化
// 显示原始经纬度值归一化到0-1范围用于可视化
// fragColor = vec4((lonlat.x - 60.0)/100.0, (lonlat.y + 10.0)/70.0, 0.0, 1.0);
// return; // 经纬度可视化
if(any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) {
discard;
}
vec4 texColor = texture(u_tex, uv);
if (texColor.r <= 0.0196 || texColor.r > 0.29411) {
discard;
}
float value = texColor.r * 3.4;
value = clamp(value, 0.0, 1.0);
float alpha = smoothstep(0.07, 0.12, value) * 0.9;
if (alpha <= 0.001) discard;
vec4 lutColor = texture(u_lut, vec2(value, 0.5));
fragColor = vec4(lutColor.rgb, alpha * u_opacity);
}