Skip to content
Snippets Groups Projects
Commit c97870ac authored by Ali Can Demiralp's avatar Ali Can Demiralp
Browse files

Scatter plot fragment shader now creates smoother points.

parent 4315ff96
No related branches found
No related tags found
No related merge requests found
...@@ -957,6 +957,8 @@ void main() ...@@ -957,6 +957,8 @@ void main()
std::string scatter_plot_vert = R"(\ std::string scatter_plot_vert = R"(\
#version 400 #version 400
uniform mat4 view;
uniform mat4 projection;
uniform float scale; uniform float scale;
in vec3 vertex ; in vec3 vertex ;
...@@ -966,7 +968,7 @@ flat out int vert_selected; ...@@ -966,7 +968,7 @@ flat out int vert_selected;
void main() void main()
{ {
gl_Position = vec4(vertex, 1.0); gl_Position = projection * view * vec4(vertex, 1.0);
gl_PointSize = scale; gl_PointSize = scale;
vert_selected = selected; vert_selected = selected;
} }
...@@ -974,6 +976,7 @@ void main() ...@@ -974,6 +976,7 @@ void main()
std::string scatter_plot_frag = R"(\ std::string scatter_plot_frag = R"(\
#version 400 #version 400
uniform vec4 background_color;
uniform vec4 normal_color ; uniform vec4 normal_color ;
uniform vec4 selected_color ; uniform vec4 selected_color ;
...@@ -983,15 +986,24 @@ out vec4 frag_color; ...@@ -983,15 +986,24 @@ out vec4 frag_color;
void main() void main()
{ {
float radius = length(gl_PointCoord - vec2(0.5));
if(radius > 0.5)
discard;
vec4 color;
if(vert_selected == 0) if(vert_selected == 0)
frag_color = normal_color; color = normal_color;
else else
frag_color = selected_color; color = selected_color;
frag_color = mix(color, background_color, smoothstep(0.0, 0.6, radius));
} }
)"; )";
std::string scatter_plot_click_vert = R"(\ std::string scatter_plot_click_vert = R"(\
#version 400 #version 400
uniform mat4 view;
uniform mat4 projection;
uniform float scale; uniform float scale;
in vec3 vertex; in vec3 vertex;
...@@ -1001,7 +1013,7 @@ flat out int vert_id; ...@@ -1001,7 +1013,7 @@ flat out int vert_id;
void main() void main()
{ {
gl_Position = vec4(vertex, 1.0); gl_Position = projection * view * vec4(vertex, 1.0);
gl_PointSize = scale; gl_PointSize = scale;
vert_id = id; vert_id = id;
} }
...@@ -1015,6 +1027,9 @@ out int frag_id; ...@@ -1015,6 +1027,9 @@ out int frag_id;
void main() void main()
{ {
if(length(gl_PointCoord - vec2(0.5)) > 0.5)
discard;
frag_id = vert_id; frag_id = vert_id;
} }
)"; )";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment