diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-22 02:25:47 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-22 02:25:47 +0000 |
commit | 961f69d8cda0364c04ec98efc70a6f21e0a091e6 (patch) | |
tree | bffeb04832ea6615cc9d3908a6de1c8fb01e9bd6 /gfx/gl/shaders | |
parent | Add missing support for glUniform simple span of numbers (diff) | |
download | ilt-961f69d8cda0364c04ec98efc70a6f21e0a091e6.tar.bz2 ilt-961f69d8cda0364c04ec98efc70a6f21e0a091e6.tar.xz ilt-961f69d8cda0364c04ec98efc70a6f21e0a091e6.zip |
Bind the network profile in as uniforms
Makes the network shaders generic to network type
Diffstat (limited to 'gfx/gl/shaders')
-rw-r--r-- | gfx/gl/shaders/networkCommon.glsl | 17 | ||||
-rw-r--r-- | gfx/gl/shaders/networkCurve.gs | 2 |
2 files changed, 7 insertions, 12 deletions
diff --git a/gfx/gl/shaders/networkCommon.glsl b/gfx/gl/shaders/networkCommon.glsl index e1811bc..7b55cad 100644 --- a/gfx/gl/shaders/networkCommon.glsl +++ b/gfx/gl/shaders/networkCommon.glsl @@ -1,11 +1,6 @@ -const float RAIL_HEIGHT = 250; -const vec3[] profile = vec3[]( // - vec3(-1900.F, 0.F, 0.F), // - vec3(-608.F, 0.F, RAIL_HEIGHT), // - vec3(0, 0.F, RAIL_HEIGHT * .7F), // - vec3(608.F, 0.F, RAIL_HEIGHT), // - vec3(1900.F, 0.F, 0.F)); -const float[profile.length()] texturePos = float[](0, 0.34, 0.5, 0.65, 1); +uniform vec3[10] profile; +uniform float[10] texturePos; +uniform uint profileLength; uniform mat4 viewProjection; uniform ivec3 viewPoint; @@ -25,7 +20,7 @@ segDist(const ivec3 a, const ivec3 b) ifelse( TYPE, .gs, // Begin: Geometry shader only function - void doVertex(const ivec3 end, const int v, const float texY, const mat2 rot) { + void doVertex(const ivec3 end, const uint v, const float texY, const mat2 rot) { rposition = vec3(rot * profile[v].xy, profile[v].z); ivec3 vpos = end + ivec3(rposition); gl_Position = viewProjection * vec4(vpos - viewPoint, 1); @@ -36,8 +31,8 @@ ifelse( 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) { - int vstep = (dist < flatDistance) ? 1 : profile.length() - 1; - for (int v = 0; v < profile.length(); v += vstep) { + 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); } diff --git a/gfx/gl/shaders/networkCurve.gs b/gfx/gl/shaders/networkCurve.gs index 619625f..7cb6c42 100644 --- a/gfx/gl/shaders/networkCurve.gs +++ b/gfx/gl/shaders/networkCurve.gs @@ -25,7 +25,7 @@ void main() { float segs = clamp( - round(reps[0] * radius[0] / 1000), 4, floor(GL_MAX_GEOMETRY_OUTPUT_VERTICES / (profile.length() * 2))); + round(reps[0] * radius[0] / 1000), 4, floor(uint(GL_MAX_GEOMETRY_OUTPUT_VERTICES) / (profileLength * 2u))); vec3 arcstep = vec3((bangle[0] - aangle[0]), // angle reps[0], // texture (bpos[0].z - apos[0].z)) // height |