From 5126582accd4af607184946200f5a937ff8d6b69 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 10 Mar 2026 21:52:38 +0000 Subject: Replace hacky m4 shader preprocessing with proper glslang version --- gfx/gl/shaders/networkCommon.glsl | 52 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'gfx/gl/shaders/networkCommon.glsl') diff --git a/gfx/gl/shaders/networkCommon.glsl b/gfx/gl/shaders/networkCommon.glsl index 7aa911d..faa95ec 100644 --- a/gfx/gl/shaders/networkCommon.glsl +++ b/gfx/gl/shaders/networkCommon.glsl @@ -1,3 +1,6 @@ +#ifndef NETWORK_COMMON_INCLUDED +#define NETWORK_COMMON_INCLUDED + uniform vec3[10] profile; uniform float[10] texturePos; uniform uint profileLength; @@ -23,27 +26,32 @@ segDist(const ivec3 a, const ivec3 b) return min(viewPointDist(a), viewPointDist(b)); } -ifelse( - TYPE, .geom, - // Begin: Geometry shader only function - void doVertex(const ivec3 end, const uint v, const float texY, const mat2 rot) { - ivec3 vpos = end + ivec3(rot * profile[v].xy, profile[v].z); - rposition = vpos - viewPoint; - gl_Position = viewProjection * vec4(rposition, 1); - texCoord = vec2(texturePos[v], texY); - EmitVertex(); - } +#ifdef GL_GEOMETRY_SHADER // Begin: Geometry shader only function + +void +doVertex(const ivec3 end, const uint v, const float texY, const mat2 rot) +{ + ivec3 vpos = end + ivec3(rot * profile[v].xy, profile[v].z); + rposition = vpos - viewPoint; + gl_Position = viewProjection * vec4(rposition, 1); + texCoord = vec2(texturePos[v], texY); + EmitVertex(); +} - void doSeg(const float dist, const ivec3 apos, const ivec3 bpos, const float atexY, const float btexY, - const mat2 arot, const mat2 brot) { - if (dist < clipDistance) { - uint vstep = (dist < flatDistance) ? 1u : profileLength - 1u; - for (uint v = 0u; v < profileLength; v += vstep) { - doVertex(bpos, v, btexY, brot); - doVertex(apos, v, atexY, arot); - } - EndPrimitive(); - } +void +doSeg(const float dist, const ivec3 apos, const ivec3 bpos, const float atexY, const float btexY, const mat2 arot, + const mat2 brot) +{ + if (dist < clipDistance) { + uint vstep = (dist < flatDistance) ? 1u : profileLength - 1u; + for (uint v = 0u; v < profileLength; v += vstep) { + doVertex(bpos, v, btexY, brot); + doVertex(apos, v, atexY, arot); } - // End: Geometry shader only function -) + EndPrimitive(); + } +} + +#endif // End: Geometry shader only function + +#endif -- cgit v1.3