From 7c82253251e937b2caa9a0717b1008282d2200ce Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sun, 12 May 2024 21:48:43 -0400 Subject: [PATCH] highlighting is hard --- CMakeLists.txt | 2 +- include/blt/gfx/renderer/batch_2d_renderer.h | 9 ++++----- .../blt/gfx/renderer/shaders/pp_highlight.frag | 15 +++++++++------ libraries/imgui | 2 +- libraries/openal-soft | 2 +- src/blt/gfx/renderer/postprocess.cpp | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a7094..5cb3c3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.13.12) +set(BLT_GRAPHICS_VERSION 0.13.13) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) diff --git a/include/blt/gfx/renderer/batch_2d_renderer.h b/include/blt/gfx/renderer/batch_2d_renderer.h index dd2990b..473b1f2 100644 --- a/include/blt/gfx/renderer/batch_2d_renderer.h +++ b/include/blt/gfx/renderer/batch_2d_renderer.h @@ -213,11 +213,10 @@ namespace blt::gfx explicit batch_renderer_2d(resource_manager& resources, matrix_state_manager& state): resources(resources), state(state) { engine = pp_engine_t::make_multi_pp(std::make_unique(), - std::make_unique(frame_buffer_t::attachment_t::COLOR1), - //std::make_unique(state, frame_buffer_t::attachment_t::COLOR1), - //std::make_unique(frame_buffer_t::attachment_t::COLOR1, - // vec4{4, 4, 4, 1}), - //std::make_unique(frame_buffer_t::attachment_t::COLOR1, 2, 2), + std::make_unique(state, frame_buffer_t::attachment_t::COLOR1), + std::make_unique(frame_buffer_t::attachment_t::COLOR1, + vec4{4, 4, 4, 1}), + std::make_unique(frame_buffer_t::attachment_t::COLOR1, 2, 2), std::make_unique(state) ); } diff --git a/include/blt/gfx/renderer/shaders/pp_highlight.frag b/include/blt/gfx/renderer/shaders/pp_highlight.frag index ca3977f..2b3f31b 100644 --- a/include/blt/gfx/renderer/shaders/pp_highlight.frag +++ b/include/blt/gfx/renderer/shaders/pp_highlight.frag @@ -22,19 +22,22 @@ void main() { } } - float px = mousePos.x / float(size.x); - float py = mousePos.y / float(size.y); - float dx = (gl_FragCoord.x - mousePos.x) / float(size.x); float dy = (gl_FragCoord.y - mousePos.y) / float(size.y); - float distx = sqrt(dx * dx); - float disty = sqrt(dy * dy); + float distx = 1.0 - sqrt(dx * dx); + float disty = 1.0 - sqrt(dy * dy); + + float dist = (distx + disty) / 2.0; vec4 n_color = result / vec4((float(size.z) * 2.0 + 1.0) * (float(size.w) * 2.0 + 1.0)); - FragColor = vec4(distx, disty, 0.0, 1.0); + n_color = n_color * vec4(16.0); + if (dist >= 0.5) + FragColor = normalize(n_color); + else + FragColor = texture(tex, uv); //FragColor = ; } diff --git a/libraries/imgui b/libraries/imgui index a1b0682..231cbee 160000 --- a/libraries/imgui +++ b/libraries/imgui @@ -1 +1 @@ -Subproject commit a1b06823fe2d964a62fda99385499b218cf5cea5 +Subproject commit 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65 diff --git a/libraries/openal-soft b/libraries/openal-soft index 6675317..111397c 160000 --- a/libraries/openal-soft +++ b/libraries/openal-soft @@ -1 +1 @@ -Subproject commit 6675317107257c2cc16c947b359d557821d85bf2 +Subproject commit 111397c71a5f1c2c88e05da9c84edfdba2e472a4 diff --git a/src/blt/gfx/renderer/postprocess.cpp b/src/blt/gfx/renderer/postprocess.cpp index 7253f47..568b61e 100644 --- a/src/blt/gfx/renderer/postprocess.cpp +++ b/src/blt/gfx/renderer/postprocess.cpp @@ -315,6 +315,6 @@ namespace blt::gfx shader->bind(); auto v = vec2(getWindowWidth(), getWindowHeight()); shader->setVec4("mousePos", blt::make_vec4(blt::vec2{getMouseX(), v.y() - getMouseY()})); - shader->setVec4i("size", {static_cast(v.x()), static_cast(v.y()), 2, 2}); + shader->setVec4i("size", {static_cast(v.x()), static_cast(v.y()), 4, 4}); } } \ No newline at end of file