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/sceneShader.cpp | 17 ++++++++++++----- gfx/gl/sceneShader.h | 1 + gfx/gl/shaders/network.fs | 6 ++++++ gfx/gl/shaders/networkCurve.gs | 9 +++++++++ gfx/gl/shaders/networkCurve.vs | 20 ++++++++++++++++++++ gfx/gl/shaders/networkStraight.gs | 15 +++++++++++++++ gfx/gl/shaders/networkStraight.vs | 20 ++++++++++++++++++++ 7 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 gfx/gl/shaders/network.fs create mode 100644 gfx/gl/shaders/networkCurve.gs create mode 100644 gfx/gl/shaders/networkCurve.vs create mode 100644 gfx/gl/shaders/networkStraight.gs create mode 100644 gfx/gl/shaders/networkStraight.vs (limited to 'gfx') diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index 1b3b27c..146e642 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -1,14 +1,19 @@ #include "sceneShader.h" #include #include +#include #include #include #include +#include +#include #include #include #include #include #include +#include +#include #include #include #include @@ -21,15 +26,17 @@ SceneShader::SceneShader() : basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, absolute {fixedPoint_vs, material_fs}, spotLightInst {spotLight_vs, spotLight_gs, spotLight_fs}, - pointLightInst {pointLight_vs, pointLight_gs, pointLight_fs} + pointLightInst {pointLight_vs, pointLight_gs, pointLight_fs}, + networkStraight {networkStraight_vs, networkStraight_gs, network_fs}, + networkCurve {networkCurve_vs, networkCurve_gs, network_fs} { } void SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const { - for (const auto & prog : std::initializer_list { - &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { + for (const auto & prog : std::initializer_list {&basic, &basicInst, &water, &landmass, + &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { prog->setViewProjection(viewPoint, viewProjection); } } @@ -37,8 +44,8 @@ SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::ma void SceneShader::setViewPort(const ViewPort & viewPort) const { - for (const auto & prog : std::initializer_list { - &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { + for (const auto & prog : std::initializer_list {&basic, &basicInst, &water, &landmass, + &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { prog->setViewPort(viewPort); } } diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h index 813c1bf..c86d157 100644 --- a/gfx/gl/sceneShader.h +++ b/gfx/gl/sceneShader.h @@ -57,6 +57,7 @@ public: BasicProgram basic; WaterProgram water; AbsolutePosProgram basicInst, landmass, absolute, spotLightInst, pointLightInst; + AbsolutePosProgram networkStraight, networkCurve; void setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const; void setViewPort(const ViewPort & viewPort) const; diff --git a/gfx/gl/shaders/network.fs b/gfx/gl/shaders/network.fs new file mode 100644 index 0000000..d427da2 --- /dev/null +++ b/gfx/gl/shaders/network.fs @@ -0,0 +1,6 @@ +#version 330 core + +void +main() +{ +} diff --git a/gfx/gl/shaders/networkCurve.gs b/gfx/gl/shaders/networkCurve.gs new file mode 100644 index 0000000..cf70b6e --- /dev/null +++ b/gfx/gl/shaders/networkCurve.gs @@ -0,0 +1,9 @@ +#version 330 core + +layout(points) in; +layout(triangle_strip, max_vertices = 255) out; + +void +main() +{ +} diff --git a/gfx/gl/shaders/networkCurve.vs b/gfx/gl/shaders/networkCurve.vs new file mode 100644 index 0000000..b4324d6 --- /dev/null +++ b/gfx/gl/shaders/networkCurve.vs @@ -0,0 +1,20 @@ +#version 330 core + +layout(location = 0) in ivec3 v_apos; +layout(location = 1) in ivec3 v_bpos; +layout(location = 2) in ivec3 v_centre; +layout(location = 3) in float v_reps; + +uniform mat4 viewProjection; + +flat out ivec3 apos; +flat out ivec3 bpos; +flat out mat2 rot; +flat out float reps; +flat out float dist; + +void +main() +{ + dist = viewProjection[0][0]; +} 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() +{ +} diff --git a/gfx/gl/shaders/networkStraight.vs b/gfx/gl/shaders/networkStraight.vs new file mode 100644 index 0000000..025ae8f --- /dev/null +++ b/gfx/gl/shaders/networkStraight.vs @@ -0,0 +1,20 @@ +#version 330 core + +layout(location = 0) in ivec3 v_apos; +layout(location = 1) in ivec3 v_bpos; +layout(location = 2) in mat2 v_rot; +layout(location = 4) in float v_reps; + +uniform mat4 viewProjection; + +flat out ivec3 apos; +flat out ivec3 bpos; +flat out mat2 rot; +flat out float reps; +flat out float dist; + +void +main() +{ + dist = viewProjection[0][0]; +} -- cgit v1.2.3