From 51616af8ce9009476ab0d4961fe400325e7eb693 Mon Sep 17 00:00:00 2001 From: xiangsilian Date: Mon, 22 Sep 2025 00:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=BF=E6=96=AF=E8=92=82=E8=8A=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shaders/texture_loading/glsl/point_line.frag | 24 ++++++++++++++++++ .../texture_loading/glsl/point_line.frag.spv | Bin 0 -> 1176 bytes shaders/texture_loading/glsl/point_line.vert | 23 +++++++++++++++++ .../texture_loading/glsl/point_line.vert.spv | Bin 0 -> 1928 bytes 4 files changed, 47 insertions(+) create mode 100644 shaders/texture_loading/glsl/point_line.frag create mode 100644 shaders/texture_loading/glsl/point_line.frag.spv create mode 100644 shaders/texture_loading/glsl/point_line.vert create mode 100644 shaders/texture_loading/glsl/point_line.vert.spv 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 0000000000000000000000000000000000000000..171c1c9fd5e943065a28be9a65ddb68dc6a3ff00 GIT binary patch literal 1176 zcmYk4NpBND5QQtTCyPTiva#dH>;a1dAS5sdMc~Uw3E~HgEPIGXn#@@C1c@6QIP!-$ zat>#H3J8J3``X=+TPju6>sMV>Z>Bcenm3!VC0n+(P0qT_3Nc}G&UfQ?aeG`1+K(PT zgt1~ZM})I#i&mG%j(b_b#ggoT?1t>NY)yRb)kslIubX{Waorl$jg#)dK{tM#^oPS_ zTz$;bB+rU88DyihUu7Rscned!tmx+_gK0t}#&m!31@)-1V^y0)+Jl*n^5o5^ceG!Y zqd~xT6byS+m5z$Ta-3CJS%^RH=6^48tXa-3+*^^`t30Xp%e)*--ih3v@B`S@4D`fS zW#njbO@?md=tIsSN2`!;NF{XIb&8pbw-wI`YdWhtJ<$|wNA-(7MvJEMhCIE%pZT15 zz_yg1lW)p6dp=*Dq^^ENF5luL}@mokFPc8cK zui!(@KSBOVEOz4ip&QzCRKqN5GVs7TuNV&c1kQ$H@XvaOnoSvX;9oqp?QwK`q3M_f zEWB}1F`9n${L6~L&=o$jf(8B+#bDpWN8jr*Fm(SV{;oXdkM`iMDFZ_j;=fXn7>qa3 v_>K&H-})Kuc}(sM+w<7W6n5WZ=zl0h`MwWi)WheV@5CN_Z|?r7|5Mq2RHa`L literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..dcb8f9b38f2aa5cf0042699ea2df92cf2f94019d GIT binary patch literal 1928 zcmZ9MTT>H35QRrV61;(kTvWsbyrXynL@gCXD?FqsSd_k|AlXnuZFW#>6XUutX(Y!K)HEBk~7;&X^uT=M{tKFozy0-oV z#keV?LNpWRTO|viS7I7#&S9vHiBL=FDOcpKewnexJ|p?F-23>{f+q&+Ex^|KlEBHKdv1d zskUBKOk)b0P8=PvJB~NCqoyC^IPTrI{x@yPET~h)^bR8VC9@#^FsSeP@mD`i{O@Q= z8IMma>e|Fcq1bY&=ZuuMVX|j`>ZRliVw|Pec3?XnZ8zBu8~!jx*NOFlU>M^*o_JPK zfArmk!y{9UIke*a!|f=D;#4=9&c%iUhF&ovG*!*uB-@yZ>eEN=wWDt1vx>4EeLAc! zk-2n=TNY-yJl>tp1E0==BX3LQ@;E!62R@w#N8YilqI)u0J}-PjJ8yzpkVik82z$# z&VWY`WY`qsPpZMV-H5_$^S2IrIOHyS^98OeST_ky*WwhWT8U!8^?r`DmDz z(@e{U|E)UY%*e=tcX@O2$z!fA@2Y%wmv>D*x$tjwW9|p%^o#Q0!1VOCjCp+4xxD#q z#%UXJ_cD&YINkk>qd&Xq06lmhBOg6+=K4!@iLJ;u8x8Ma&W~iCj9zh9Fgka)r}CLC qF=h@Xml>|fJQ=+p4rcDenc=34cQIS)@wS&Tc=UV+!2dMuP1%1$M2R&3 literal 0 HcmV?d00001