diff --git a/shaders/texture_loading/glsl/point_line.frag b/shaders/texture_loading/glsl/point_line.frag new file mode 100644 index 0000000..ffb68b9 --- /dev/null +++ b/shaders/texture_loading/glsl/point_line.frag @@ -0,0 +1,24 @@ +#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); +} \ No newline at end of file diff --git a/shaders/texture_loading/glsl/point_line.frag.spv b/shaders/texture_loading/glsl/point_line.frag.spv new file mode 100644 index 0000000..171c1c9 Binary files /dev/null and b/shaders/texture_loading/glsl/point_line.frag.spv differ diff --git a/shaders/texture_loading/glsl/point_line.vert b/shaders/texture_loading/glsl/point_line.vert new file mode 100644 index 0000000..216473c --- /dev/null +++ b/shaders/texture_loading/glsl/point_line.vert @@ -0,0 +1,23 @@ +#version 450 + +layout(location = 0) in vec3 inPosition; +layout(location = 1) in vec3 inColor; + +layout(location = 0) out vec3 fragColor; +layout(location = 1) out float fragLinePosition; // 用于虚线计算 + +layout(binding = 0) uniform UniformBufferObject { + mat4 proj; + mat4 model; + mat4 view; +} ubo; + +void main() { + mat4 mvp = ubo.proj * ubo.view * ubo.model; + gl_Position = mvp * vec4(inPosition, 1.0); + fragColor = inColor; + gl_PointSize = 2.0; + + // 硬编码虚线参数:使用模型空间的X坐标,你可以根据需要调整 + fragLinePosition = inPosition.x; +} \ No newline at end of file diff --git a/shaders/texture_loading/glsl/point_line.vert.spv b/shaders/texture_loading/glsl/point_line.vert.spv new file mode 100644 index 0000000..dcb8f9b Binary files /dev/null and b/shaders/texture_loading/glsl/point_line.vert.spv differ