diff --git a/scwx-qt/gl/color.frag b/scwx-qt/gl/color.frag index 003c6c8d..1266306b 100644 --- a/scwx-qt/gl/color.frag +++ b/scwx-qt/gl/color.frag @@ -1,5 +1,5 @@ #version 330 core -in vec4 color; +smooth in vec4 color; layout (location = 0) out vec4 fragColor; diff --git a/scwx-qt/gl/color.vert b/scwx-qt/gl/color.vert index 5c8d1ff7..f849710c 100644 --- a/scwx-qt/gl/color.vert +++ b/scwx-qt/gl/color.vert @@ -4,7 +4,7 @@ layout (location = 1) in vec4 aColor; uniform mat4 uMVPMatrix; -out vec4 color; +smooth out vec4 color; void main() { diff --git a/scwx-qt/gl/geo_line.vert b/scwx-qt/gl/geo_line.vert index ea7d6351..490fc3eb 100644 --- a/scwx-qt/gl/geo_line.vert +++ b/scwx-qt/gl/geo_line.vert @@ -16,7 +16,7 @@ uniform mat4 uMapMatrix; uniform vec2 uMapScreenCoord; smooth out vec2 texCoord; -flat out vec4 modulate; +smooth out vec4 color; vec2 latLngToScreenCoordinate(in vec2 latLng) { @@ -31,7 +31,7 @@ void main() { // Pass the texture coordinate and color modulate to the fragment shader texCoord = aTexCoord; - modulate = aModulate; + color = aModulate; vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord; diff --git a/scwx-qt/gl/geo_texture2d.vert b/scwx-qt/gl/geo_texture2d.vert index 467aa72f..05a8c5d0 100644 --- a/scwx-qt/gl/geo_texture2d.vert +++ b/scwx-qt/gl/geo_texture2d.vert @@ -12,13 +12,21 @@ layout (location = 1) in vec2 aXYOffset; layout (location = 2) in vec2 aTexCoord; layout (location = 3) in vec4 aModulate; layout (location = 4) in float aAngleDeg; +layout (location = 5) in int aThreshold; uniform mat4 uMVPMatrix; uniform mat4 uMapMatrix; uniform vec2 uMapScreenCoord; +out VertexData +{ + int threshold; + vec2 texCoord; + vec4 color; +} vsOut; + smooth out vec2 texCoord; -flat out vec4 modulate; +smooth out vec4 color; vec2 latLngToScreenCoordinate(in vec2 latLng) { @@ -31,9 +39,15 @@ vec2 latLngToScreenCoordinate(in vec2 latLng) void main() { - // Pass the texture coordinate and color modulate to the fragment shader - texCoord = aTexCoord; - modulate = aModulate; + // Pass the threshold to the geometry shader + vsOut.threshold = aThreshold; + + // Pass the texture coordinate and color modulate to the geometry and + // fragment shaders + vsOut.texCoord = aTexCoord; + vsOut.color = aModulate; + texCoord = aTexCoord; + color = aModulate; vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord; diff --git a/scwx-qt/gl/map_color.vert b/scwx-qt/gl/map_color.vert index e2f96d5a..cc19f8a4 100644 --- a/scwx-qt/gl/map_color.vert +++ b/scwx-qt/gl/map_color.vert @@ -3,17 +3,29 @@ layout (location = 0) in vec2 aScreenCoord; layout (location = 1) in vec2 aXYOffset; layout (location = 2) in vec4 aColor; +layout (location = 3) in int aThreshold; uniform mat4 uMVPMatrix; uniform mat4 uMapMatrix; uniform vec2 uMapScreenCoord; -out vec4 color; +out VertexData +{ + int threshold; + vec2 texCoord; + vec4 color; +} vsOut; + +smooth out vec4 color; void main() { - // Pass the color to the fragment shader - color = aColor; + // Pass the threshold and color to the geometry shader + vsOut.threshold = aThreshold; + + // Pass the color to the geometry and fragment shaders + vsOut.color = aColor; + color = aColor; vec2 p = aScreenCoord - uMapScreenCoord; diff --git a/scwx-qt/gl/texture2d.frag b/scwx-qt/gl/texture2d.frag index 16ab8960..725d66ad 100644 --- a/scwx-qt/gl/texture2d.frag +++ b/scwx-qt/gl/texture2d.frag @@ -6,11 +6,11 @@ precision mediump float; uniform sampler2D uTexture; smooth in vec2 texCoord; -flat in vec4 modulate; +smooth in vec4 color; layout (location = 0) out vec4 fragColor; void main() { - fragColor = texture(uTexture, texCoord) * modulate; + fragColor = texture(uTexture, texCoord) * color; } diff --git a/scwx-qt/gl/threshold.geom b/scwx-qt/gl/threshold.geom new file mode 100644 index 00000000..4d9d3b53 --- /dev/null +++ b/scwx-qt/gl/threshold.geom @@ -0,0 +1,41 @@ +#version 330 core + +layout (triangles) in; +layout (triangle_strip, max_vertices = 3) out; + +uniform float uMapDistance; + +in VertexData +{ + int threshold; + vec2 texCoord; + vec4 color; +} gsIn[]; + +smooth out vec2 texCoord; +smooth out vec4 color; + +void main() +{ + if (gsIn[0].threshold <= 0 || // If Threshold: 0 was specified, no threshold + gsIn[0].threshold >= uMapDistance || // If Threshold is above current map distance + gsIn[0].threshold >= 999) // If Threshold: 999 was specified (or greater), no threshold + { + gl_Position = gl_in[0].gl_Position; + texCoord = gsIn[0].texCoord; + color = gsIn[0].color; + EmitVertex(); + + gl_Position = gl_in[1].gl_Position; + texCoord = gsIn[1].texCoord; + color = gsIn[1].color; + + EmitVertex(); + gl_Position = gl_in[2].gl_Position; + texCoord = gsIn[2].texCoord; + color = gsIn[2].color; + + EmitVertex(); + EndPrimitive(); + } +} diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 7af57f18..f5d6a489 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -252,7 +252,8 @@ set(SHADER_FILES gl/color.frag gl/text.vert gl/texture1d.frag gl/texture1d.vert - gl/texture2d.frag) + gl/texture2d.frag + gl/threshold.geom) set(CMAKE_FILES scwx-qt.cmake) diff --git a/scwx-qt/scwx-qt.qrc b/scwx-qt/scwx-qt.qrc index 1f9e1123..05a94725 100644 --- a/scwx-qt/scwx-qt.qrc +++ b/scwx-qt/scwx-qt.qrc @@ -12,6 +12,7 @@ gl/texture1d.frag gl/texture1d.vert gl/texture2d.frag + gl/threshold.geom res/config/radar_sites.json res/fonts/din1451alt.ttf res/fonts/din1451alt_g.ttf