diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-10 21:52:38 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-10 21:52:38 +0000 |
| commit | 5126582accd4af607184946200f5a937ff8d6b69 (patch) | |
| tree | 4418890fee58c4ae2a7ada8e41bdfa46df897157 /gfx/gl/shaders/networkCommon.glsl | |
| parent | Refactor glMappedBufferWriter into a DSA wrapper for std::span (diff) | |
| download | ilt-5126582accd4af607184946200f5a937ff8d6b69.tar.bz2 ilt-5126582accd4af607184946200f5a937ff8d6b69.tar.xz ilt-5126582accd4af607184946200f5a937ff8d6b69.zip | |
Replace hacky m4 shader preprocessing with proper glslang version
Diffstat (limited to 'gfx/gl/shaders/networkCommon.glsl')
| -rw-r--r-- | gfx/gl/shaders/networkCommon.glsl | 52 |
1 files changed, 30 insertions, 22 deletions
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 |
