From ab30228b1a57053323363674fa7f137c0329a180 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 7 Jul 2020 23:12:04 -0300 Subject: Voltage heat map implemented Voltage heat map implemented using modern OpenGL =) New external library required: -GLEW -GLFW -GLM (incorporeted at the source) Old memory leaks fixed =) --- Project/HMLabel.shader | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Project/HMLabel.shader (limited to 'Project/HMLabel.shader') diff --git a/Project/HMLabel.shader b/Project/HMLabel.shader new file mode 100644 index 0000000..adf9989 --- /dev/null +++ b/Project/HMLabel.shader @@ -0,0 +1,35 @@ +#shader vertex +#version 330 core + +layout(location = 0) in vec4 position; + +uniform mat4 u_mvpMatrix; + +void main() +{ + gl_Position = u_mvpMatrix * position; +}; + +#shader fragment +#version 330 core + +layout(location = 0) out vec4 color; + +uniform vec4 u_offset; + +vec3 hsl2rgb(in vec3 c) +{ + vec3 rgb = clamp(abs(mod(c.x * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0); + + return c.z + c.y * (rgb - 0.5) * (1.0 - abs(2.0 * c.z - 1.0)); +} + +void main() +{ + vec3 colorRGB = hsl2rgb(vec3(gl_FragCoord.z * 0.8, 1.0, 0.5)); + color = vec4(colorRGB, 1.0); + if(gl_FragCoord.x - u_offset.x <= 2.0) color = vec4(0.0, 0.0, 0.0, 1.0); + if(gl_FragCoord.x - u_offset.x >= 28.0) color = vec4(0.0, 0.0, 0.0, 1.0); + if(gl_FragCoord.y + u_offset.y >= u_offset.w - 2.0) color = vec4(0.0, 0.0, 0.0, 1.0); + if(gl_FragCoord.y + u_offset.y <= u_offset.w - 298.0) color = vec4(0.0, 0.0, 0.0, 1.0); +}; \ No newline at end of file -- cgit