From c967ddb544dddccffd7ddc9cbc11e30971ec0eaa Mon Sep 17 00:00:00 2001 From: Jonathan Fransson Date: Tue, 30 Apr 2019 14:33:17 -0600 Subject: [PATCH] merge --- .../space/rendering/renderablesatellites.cpp | 2 +- modules/space/shaders/debrisViz_fs.glsl | 28 +++++++++++++++++++ modules/space/shaders/debrisViz_vs.glsl | 13 ++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 49376bc76b..3767d62aed 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -780,7 +780,7 @@ int getNearestVertexNeighbour(int whatOrbit) { void RenderableSatellites::render(const RenderData& data, RendererTasks&) { //if (_TLEData.empty()) // return; - _inGameTime = static_cast(data.time.j2000Seconds()); + _inGameTime = data.time.j2000Seconds(); // ----------------- // double nrOfPeriods = (_inGameTime - _vertexBufferData[4].epoch) / _vertexBufferData[4].period; // double periodFraction = std::fmod(nrOfPeriods, 1); diff --git a/modules/space/shaders/debrisViz_fs.glsl b/modules/space/shaders/debrisViz_fs.glsl index c9a7bd1424..3a4a5b36f0 100644 --- a/modules/space/shaders/debrisViz_fs.glsl +++ b/modules/space/shaders/debrisViz_fs.glsl @@ -25,17 +25,45 @@ #include "fragment.glsl" #include "floatoperations.glsl" +//layout(location = 0) in vec4 vertex; // 1: x, 2: y, 3: z, 4: time +// This doesn't work, plz help +//layout(location = 1) in vec2 orbit; // 1: epoch, 2: period + uniform vec3 color; uniform float opacity = 1.0; +uniform float lineFade; +uniform float inGameTime; + in vec4 viewSpacePosition; in vec4 vs_position; +//in float nrOfPeriods; +//in float offsetPeriods; in float fade; //in vec3 vs_color; //in vec2 vs_texcoord; Fragment getFragment() { + + float nrOfPeriods = (inGameTime - orbit.x) / orbit.y; + float periodFraction = fract(nrOfPeriods); + + float offsetPeriods = vertex.w / orbit.y; + float offsetFraction = offsetPeriods; + + // check difference of these two locations + float vertexDistance = periodFraction - offsetFraction; + + if (vertexDistance < 0.0) { + vertexDistance += 1.0; + } + + float invert = 1.0 - vertexDistance; + + float fade = clamp(invert * lineFade, 0.0, 1.0); + + Fragment frag; frag.color = vec4(color, fade * opacity); frag.depth = vs_position.w; diff --git a/modules/space/shaders/debrisViz_vs.glsl b/modules/space/shaders/debrisViz_vs.glsl index 23f9cff97f..2b1f1a63fe 100644 --- a/modules/space/shaders/debrisViz_vs.glsl +++ b/modules/space/shaders/debrisViz_vs.glsl @@ -34,6 +34,11 @@ layout (location = 0) in vec4 vertex_data; // 1: x, 2: y, 3: z, 4: time layout (location = 1) in vec2 orbit_data; // 1: epoch, 2: period +//layout(location = 0) out vec4 vertex_data; // 1: x, 2: y, 3: z, 4: time +// This doesn't work, plz help +//layout(location = 1) out vec2 orbit_data; // 1: epoch, 2: period + + uniform dmat4 modelViewTransform; uniform mat4 projectionTransform; @@ -42,16 +47,16 @@ uniform float lineFade; //uniform vec3 debrisPosition; //uniform int* VertexIDs; //uniform int numberOfOrbits; -uniform /*double*/float inGameTime; +uniform float inGameTime; out vec4 viewSpacePosition; out vec4 vs_position; +//out float nrOfPeriods; +//out float offsetPeriods; out float fade; void main() { - // The error is in line 33 at "location 1"!! - // calculate nr of periods, get fractional part to know where // the vertex closest to the debris part is right now float nrOfPeriods = (inGameTime - orbit_data.x) / orbit_data.y; @@ -65,7 +70,7 @@ void main() { float vertexDistance = periodFraction - offsetFraction; if(vertexDistance < 0.0) { - vertexDistance += 1.0; + vertexDistance += 1.0; } // int vertexID = gl_VertexID;