summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/network/rail.cpp4
-rw-r--r--game/network/rail.h2
-rw-r--r--gfx/gl/shaders/networkCurve.gs4
-rw-r--r--gfx/gl/shaders/networkCurve.vs3
4 files changed, 8 insertions, 5 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 46c129b..b500006 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -156,7 +156,7 @@ RailLinkCurve::RailLinkCurve(NetworkLinkHolder<RailLinkCurve> & instances, const
glm::length(RelativePosition3D(a->pos - c)) * arc_length(arc)),
LinkCurve {c, glm::length(RelativePosition3D(ends[0].node->pos - c)), arc},
instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2000.F),
- half_pi - arc.first, half_pi - arc.second)}
+ half_pi - arc.first, half_pi - arc.second, radius)}
{
if (glGenVertexArrays) {
const auto & e0p {ends[0].node->pos};
@@ -199,7 +199,7 @@ template<> NetworkLinkHolder<RailLinkCurve>::NetworkLinkHolder()
VertexArrayObject {vao}
.addAttribs<RailLinkCurve::Vertex, &RailLinkCurve::Vertex::a, &RailLinkCurve::Vertex::b,
&RailLinkCurve::Vertex::c, &RailLinkCurve::Vertex::textureRepeats, &RailLinkCurve::Vertex::aangle,
- &RailLinkCurve::Vertex::bangle>(vertices.bufferName());
+ &RailLinkCurve::Vertex::bangle, &RailLinkCurve::Vertex::radius>(vertices.bufferName());
}
namespace {
diff --git a/game/network/rail.h b/game/network/rail.h
index 39dfdc9..a95ba04 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -64,7 +64,7 @@ public:
struct Vertex {
GlobalPosition3D a, b, c;
float textureRepeats;
- float aangle, bangle;
+ float aangle, bangle, radius;
};
private:
diff --git a/gfx/gl/shaders/networkCurve.gs b/gfx/gl/shaders/networkCurve.gs
index 82d8c59..d373c0c 100644
--- a/gfx/gl/shaders/networkCurve.gs
+++ b/gfx/gl/shaders/networkCurve.gs
@@ -6,6 +6,7 @@ flat in ivec3 cpos[];
flat in float reps[];
flat in float aangle[];
flat in float bangle[];
+flat in float radius[];
layout(points) in;
layout(triangle_strip, max_vertices = 255) out;
@@ -24,7 +25,6 @@ void
main()
{
float segs = floor(255 / (profile.length() * 2));
- float radius = distance(cpos[0], apos[0]);
vec3 arcstep = vec3((bangle[0] - aangle[0]), // angle
reps[0], // texture
(bpos[0].z - apos[0].z)) // height
@@ -35,7 +35,7 @@ main()
float prevTex = 0;
for (vec3 arc = arcstep; arc.y < reps[0] - 0.01; arc += arcstep) {
mat2 rot = getRot(arc.x + aangle[0]);
- ivec3 pos = cpos[0] + ivec3(rot * vec2(radius, 0), arc.z);
+ ivec3 pos = cpos[0] + ivec3(rot * vec2(radius[0], 0), arc.z);
float tex = arc.y;
doSeg(segDist(prevPos, pos), pos, prevPos, tex, prevTex, rot, prevRot);
prevPos = pos;
diff --git a/gfx/gl/shaders/networkCurve.vs b/gfx/gl/shaders/networkCurve.vs
index 6c56e93..f51bb87 100644
--- a/gfx/gl/shaders/networkCurve.vs
+++ b/gfx/gl/shaders/networkCurve.vs
@@ -6,6 +6,7 @@ layout(location = 2) in ivec3 v_centre;
layout(location = 3) in float v_reps;
layout(location = 4) in float v_aangle;
layout(location = 5) in float v_bangle;
+layout(location = 6) in float v_radius;
flat out ivec3 apos;
flat out ivec3 bpos;
@@ -13,6 +14,7 @@ flat out ivec3 cpos;
flat out float reps;
flat out float aangle;
flat out float bangle;
+flat out float radius;
void
main()
@@ -23,4 +25,5 @@ main()
reps = v_reps;
aangle = v_aangle;
bangle = v_bangle;
+ radius = v_radius;
}