From 5ea2f6ee06a6f2244f35dd0ed2a64cbe9754ef3f Mon Sep 17 00:00:00 2001 From: David Allemang Date: Wed, 11 Mar 2020 01:06:13 -0400 Subject: [PATCH] translucent wireframe --- vis/shaders/solid.fs.glsl | 4 ++-- vis/src/main.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vis/shaders/solid.fs.glsl b/vis/shaders/solid.fs.glsl index 11f3ec0..0f81323 100644 --- a/vis/shaders/solid.fs.glsl +++ b/vis/shaders/solid.fs.glsl @@ -1,6 +1,6 @@ #version 430 -layout(location=2) uniform vec3 c; +layout(location=2) uniform vec4 c; in vec4 pos; @@ -8,5 +8,5 @@ out vec4 color; void main() { float d = smoothstep(-2, 2, pos.z); - color = vec4(c * d, 1); + color = vec4(c.xyz * d, c.w); } diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 90b5dd3..99827f4 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -141,6 +141,8 @@ void run(GLFWwindow *window) { glEnable(GL_DEPTH_TEST); // glEnable(GL_CULL_FACE); glCullFace(GL_BACK); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Shaders sh; @@ -204,15 +206,15 @@ void run(GLFWwindow *window) { glLineWidth(1.5); - glProgramUniform3f(sh.solid, 2, 0.3, 0.3, 0.3); - proj_pipe.bound([&]() { - wires.draw_direct(); - }); - slice_pipe.bound([&]() { slices.draw_deferred(); }); + glProgramUniform4f(sh.solid, 2, 0.3, 0.3, 0.3, 0.4); + proj_pipe.bound([&]() { + wires.draw_direct(); + }); + glfwSwapInterval(2); glfwSwapBuffers(window);