mosaicmap/app/glsl/timeline/frag.glsl
2025-07-18 21:32:46 +08:00

44 lines
930 B
GLSL

#version 300 es
precision mediump float;
layout(std140) uniform Uniforms {
float startDate;
float endDate;
float currentDate;
float radius;
float d;
float padding1; // 填充以对齐到8字节边界
vec2 viewportSize;
};
struct Instant {
vec2 position;
vec4 color;
};
in Instant i_instant;
out vec4 FragColor;
float sdVesica(vec2 p, float r, float d)
{
p = abs(p);
float b = sqrt(r*r-d*d); // can delay this sqrt by rewriting the comparison
return ((p.y-b)*d > p.x*b) ? length(p-vec2(0.0,b))*sign(d)
: length(p-vec2(-d,0.0))-r;
}
void main() {
vec2 p = gl_FragCoord.xy - i_instant.position;
float sdf = sdVesica(p, radius, d);
// 简化逻辑:内部完全不透明,外部丢弃
if (sdf > 0.0) {
discard;
}
// 测试:固定颜色确保能看到
FragColor = vec4(1.0, 1.0, 1.0, 1.0); // 纯白色
}