Files
Vulkan-Samples/shaders/texture_loading/glsl/point_line.frag
T
2025-09-22 00:33:03 +08:00

24 lines
677 B
GLSL

#version 450
layout(location = 0) in vec3 fragColor;
layout(location = 1) in float fragLinePosition;
layout(location = 0) out vec4 outColor;
void main() {
// 硬编码虚线参数
const float dashSize = 0.05;
const float gapSize = 0.05;
// 使用时间创建动画效果(需要GL_EXT_shader_realtime_clock_speed扩展)
// 或者使用一个简单的基于帧计数的方法
float time = float(gl_FragCoord.x + gl_FragCoord.y) * 0.01; // 简单的伪时间
float patternPosition = mod(fragLinePosition, dashSize + gapSize);
if (patternPosition > dashSize) {
discard;
}
outColor = vec4(fragColor, 1.0);
}