mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 23:00:04 +00:00
Add threshold geometry shader, refactor vertex and fragment shaders
This commit is contained in:
parent
5e1b1a5ba6
commit
69f93d6faf
9 changed files with 83 additions and 14 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#version 330 core
|
||||
in vec4 color;
|
||||
smooth in vec4 color;
|
||||
|
||||
layout (location = 0) out vec4 fragColor;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ layout (location = 1) in vec4 aColor;
|
|||
|
||||
uniform mat4 uMVPMatrix;
|
||||
|
||||
out vec4 color;
|
||||
smooth out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
41
scwx-qt/gl/threshold.geom
Normal file
41
scwx-qt/gl/threshold.geom
Normal file
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
<file>gl/texture1d.frag</file>
|
||||
<file>gl/texture1d.vert</file>
|
||||
<file>gl/texture2d.frag</file>
|
||||
<file>gl/threshold.geom</file>
|
||||
<file>res/config/radar_sites.json</file>
|
||||
<file>res/fonts/din1451alt.ttf</file>
|
||||
<file>res/fonts/din1451alt_g.ttf</file>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue