阿斯蒂芬

This commit is contained in:
xsl
2025-09-22 00:33:03 +08:00
parent ded9642c4d
commit 51616af8ce
4 changed files with 47 additions and 0 deletions
@@ -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);
}
Binary file not shown.
@@ -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;
}
Binary file not shown.