From c7af64b7061c59c987958d0830838f1c05caeb29 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 19 Jan 2024 00:23:56 +0000 Subject: Render rail network using new shaders Non-functional, totally unimplemented at this stage --- gfx/gl/shaders/networkStraight.gs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 gfx/gl/shaders/networkStraight.gs (limited to 'gfx/gl/shaders/networkStraight.gs') diff --git a/gfx/gl/shaders/networkStraight.gs b/gfx/gl/shaders/networkStraight.gs new file mode 100644 index 0000000..c2bfe3f --- /dev/null +++ b/gfx/gl/shaders/networkStraight.gs @@ -0,0 +1,15 @@ +#version 330 core + +flat in ivec3 apos[]; +flat in ivec3 bpos[]; +flat in mat2 rot[]; +flat in float reps[]; +flat in float dist[]; + +layout(points) in; +layout(triangle_strip, max_vertices = 20) out; + +void +main() +{ +} -- cgit v1.2.3 From 7f852de673bb687c5721c6a74367278f8ba62f56 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Jan 2024 12:05:53 +0000 Subject: Implement complete network straight part shader --- gfx/gl/shaders/networkStraight.gs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'gfx/gl/shaders/networkStraight.gs') diff --git a/gfx/gl/shaders/networkStraight.gs b/gfx/gl/shaders/networkStraight.gs index c2bfe3f..ccd456a 100644 --- a/gfx/gl/shaders/networkStraight.gs +++ b/gfx/gl/shaders/networkStraight.gs @@ -1,5 +1,14 @@ #version 330 core +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); + flat in ivec3 apos[]; flat in ivec3 bpos[]; flat in mat2 rot[]; @@ -7,9 +16,36 @@ flat in float reps[]; flat in float dist[]; layout(points) in; -layout(triangle_strip, max_vertices = 20) out; +layout(triangle_strip, max_vertices = 10) out; + +uniform mat4 viewProjection; +uniform ivec3 viewPoint; + +uniform int clipDistance = 5000000; +uniform int flatDistance = 1000000; + +out vec2 texCoord; +out vec3 rposition; + +void +doEnd(const ivec3 end, int v, float texY) +{ + rposition = vec3(rot[0] * profile[v].xy, profile[v].z); + ivec3 vpos = end + ivec3(rposition); + gl_Position = viewProjection * vec4(vpos - viewPoint, 1); + texCoord = vec2(texturePos[v], texY); + EmitVertex(); +} void main() { + if (dist[0] < clipDistance) { + int vstep = (dist[0] < flatDistance) ? 1 : profile.length() - 1; + for (int v = 0; v < profile.length(); v += vstep) { + doEnd(bpos[0], v, reps[0]); + doEnd(apos[0], v, 0); + } + EndPrimitive(); + } } -- cgit v1.2.3 From d1d1a4e349f18cd36406f75170dad87fbad2722a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Jan 2024 13:00:49 +0000 Subject: Common code between straight/curve network geometry shaders --- gfx/gl/shaders/networkStraight.gs | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'gfx/gl/shaders/networkStraight.gs') diff --git a/gfx/gl/shaders/networkStraight.gs b/gfx/gl/shaders/networkStraight.gs index ccd456a..51df5fb 100644 --- a/gfx/gl/shaders/networkStraight.gs +++ b/gfx/gl/shaders/networkStraight.gs @@ -1,14 +1,5 @@ #version 330 core -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); - flat in ivec3 apos[]; flat in ivec3 bpos[]; flat in mat2 rot[]; @@ -17,35 +8,10 @@ flat in float dist[]; layout(points) in; layout(triangle_strip, max_vertices = 10) out; - -uniform mat4 viewProjection; -uniform ivec3 viewPoint; - -uniform int clipDistance = 5000000; -uniform int flatDistance = 1000000; - -out vec2 texCoord; -out vec3 rposition; - -void -doEnd(const ivec3 end, int v, float texY) -{ - rposition = vec3(rot[0] * profile[v].xy, profile[v].z); - ivec3 vpos = end + ivec3(rposition); - gl_Position = viewProjection * vec4(vpos - viewPoint, 1); - texCoord = vec2(texturePos[v], texY); - EmitVertex(); -} +include(`networkCommon.glsl') void main() { - if (dist[0] < clipDistance) { - int vstep = (dist[0] < flatDistance) ? 1 : profile.length() - 1; - for (int v = 0; v < profile.length(); v += vstep) { - doEnd(bpos[0], v, reps[0]); - doEnd(apos[0], v, 0); - } - EndPrimitive(); - } + doSeg(dist[0], apos[0], bpos[0], 0.f, reps[0], rot[0], rot[0]); } -- cgit v1.2.3