From a8a91c146641615a3a65892beb41efcd5e44b7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Guionni=C3=A8re?= Date: Sat, 16 Dec 2023 07:27:17 +0100 Subject: [PATCH 1/3] Clean --- lib/renderer/include/renderer/passes.hpp | 6 +++--- lib/renderer/include/renderer/renderer.hpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/renderer/include/renderer/passes.hpp b/lib/renderer/include/renderer/passes.hpp index f888f87fe..de002b580 100644 --- a/lib/renderer/include/renderer/passes.hpp +++ b/lib/renderer/include/renderer/passes.hpp @@ -161,7 +161,7 @@ namespace VTX::Renderer Uniforms { { "Color", E_TYPE::COLOR4, StructUniformValue { COLOR_WHITE } }, { "Sensitivity", E_TYPE::FLOAT, - StructUniformValue { 0.f, StructUniformValue::MinMax { 0.01f, 1.f } } }, + StructUniformValue { 0.f, StructUniformValue::MinMax { 0.f, 1.f } } }, { "Thickness", E_TYPE::UINT, StructUniformValue { 1, StructUniformValue::MinMax { 1, 5 } } } } } } @@ -218,11 +218,11 @@ namespace VTX::Renderer // Chromatic aberration. static const Pass descPassChromaticAberration { - "Chromatic Aberration", + "Chromatic aberration", Inputs { { E_CHANNEL_INPUT::_0, { "", imageRGBA16F } } }, Outputs { { E_CHANNEL_OUTPUT::COLOR_0, { "", imageRGBA16F } } }, Programs { - { "Chromatic Aberration", + { "Chromatic aberration", std::vector { "default.vert", "chromatic_aberration.frag" }, Uniforms { { "Red", diff --git a/lib/renderer/include/renderer/renderer.hpp b/lib/renderer/include/renderer/renderer.hpp index 54935e8a2..489cb7a24 100644 --- a/lib/renderer/include/renderer/renderer.hpp +++ b/lib/renderer/include/renderer/renderer.hpp @@ -231,8 +231,6 @@ namespace VTX::Renderer size_t _sizeAtoms = 0; size_t _sizeBonds = 0; - std::vector _noise; - void _setData( const StructProxyMolecule & p_proxy ) { _renderGraph->setData( *p_proxy.atomPositions, "MoleculesPositions" ); From e25a3eb79d36d65e90929b10dd6a120c13258276 Mon Sep 17 00:00:00 2001 From: sguionni Date: Mon, 18 Dec 2023 23:17:56 +0100 Subject: [PATCH 2/3] colorize.frag --- lib/renderer/bench/src/input_manager.hpp | 34 +++++++++++++------ lib/renderer/bench/src/main.cpp | 2 ++ lib/renderer/include/renderer/passes.hpp | 13 ++++++- lib/renderer/include/renderer/renderer.hpp | 7 +++- .../shaders/chromatic_aberration.frag | 6 ++-- lib/renderer/shaders/colorize.frag | 24 +++++++++++++ .../shaders/layout_uniforms_camera.glsl | 1 + 7 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 lib/renderer/shaders/colorize.frag diff --git a/lib/renderer/bench/src/input_manager.hpp b/lib/renderer/bench/src/input_manager.hpp index fb230c2fe..b3d374838 100644 --- a/lib/renderer/bench/src/input_manager.hpp +++ b/lib/renderer/bench/src/input_manager.hpp @@ -11,17 +11,19 @@ namespace VTX::Bench class InputManager { public: - using CallbackClose = std::function; - using CallbackResize = std::function; - using CallbackTranslate = std::function; - using CallbackRotate = std::function; - using CallbackZoom = std::function; + using CallbackClose = std::function; + using CallbackResize = std::function; + using CallbackTranslate = std::function; + using CallbackRotate = std::function; + using CallbackZoom = std::function; + using CallbackMouseMotion = std::function; inline void setCallbackClose( const CallbackClose & p_cb ) { _callbackClose = p_cb; } inline void setCallbackResize( const CallbackResize & p_cb ) { _callbackResize = p_cb; } inline void setCallbackTranslate( const CallbackTranslate & p_cb ) { _callbackTranslate = p_cb; } inline void setCallbackRotate( const CallbackRotate & p_cb ) { _callbackRotate = p_cb; } inline void setCallbackZoom( const CallbackZoom & p_cb ) { _callbackZoom = p_cb; } + inline void setCallbackMouseMotion( const CallbackMouseMotion & p_cb ) { _callbackMouseMotion = p_cb; } inline bool isKeyPressed( const SDL_Scancode p_key ) const { return _keys[ p_key ]; } inline bool isMouseButtonPressed( const size_t p_button ) const { return _mouseButtons[ p_button ]; } @@ -41,6 +43,9 @@ namespace VTX::Bench _deltaMouse.x += p_event.motion.xrel; _deltaMouse.y += p_event.motion.yrel; } + int x, y; + SDL_GetMouseState( &x, &y ); + _onMouseMotion( x, y ); break; case SDL_MOUSEWHEEL: _deltaWheel += p_event.wheel.y; break; case SDL_WINDOWEVENT: @@ -116,11 +121,12 @@ namespace VTX::Bench Vec2i _deltaMouse = { 0, 0 }; int _deltaWheel = 0; - CallbackClose _callbackClose; - CallbackResize _callbackResize; - CallbackTranslate _callbackTranslate; - CallbackRotate _callbackRotate; - CallbackZoom _callbackZoom; + CallbackClose _callbackClose; + CallbackResize _callbackResize; + CallbackTranslate _callbackTranslate; + CallbackRotate _callbackRotate; + CallbackZoom _callbackZoom; + CallbackMouseMotion _callbackMouseMotion; inline void _onClose() { @@ -137,6 +143,14 @@ namespace VTX::Bench _callbackResize( p_w, p_h ); } } + + inline void _onMouseMotion( const size_t p_x, const size_t p_y ) + { + if ( _callbackMouseMotion ) + { + _callbackMouseMotion( { p_x, p_y } ); + } + } }; } // namespace VTX::Bench diff --git a/lib/renderer/bench/src/main.cpp b/lib/renderer/bench/src/main.cpp index 1e0c103d2..5007d43e9 100644 --- a/lib/renderer/bench/src/main.cpp +++ b/lib/renderer/bench/src/main.cpp @@ -65,6 +65,8 @@ int main( int, char ** ) camera.resize( p_width, p_height ); } ); + inputManager.setCallbackMouseMotion( [ &renderer ]( const Vec2i & p_position ) + { renderer.setMousePosition( p_position ); } ); renderer.setCallbackClean( [ &camera, &inputManager ]() { diff --git a/lib/renderer/include/renderer/passes.hpp b/lib/renderer/include/renderer/passes.hpp index de002b580..1ffc31522 100644 --- a/lib/renderer/include/renderer/passes.hpp +++ b/lib/renderer/include/renderer/passes.hpp @@ -236,6 +236,17 @@ namespace VTX::Renderer StructUniformValue { -0.006f, StructUniformValue::MinMax { -0.05f, 0.05f } } } } } } }; + // Colorize. + static const Pass descPassColorize { + "Colorize", + Inputs { { E_CHANNEL_INPUT::_0, { "", imageRGBA16F } } }, + Outputs { { E_CHANNEL_OUTPUT::COLOR_0, { "", imageRGBA16F } } }, + Programs { + { "Colorize", + std::vector { "default.vert", "colorize.frag" }, + Uniforms { { "Color", E_TYPE::COLOR4, StructUniformValue { COLOR_YELLOW } } } } } + }; + // Debug. static const Pass descPassDebug { "Debug", @@ -255,7 +266,7 @@ namespace VTX::Renderer static const std::vector availablePasses { descPassGeometric, descPassDepth, descPassSSAO, descPassBlur, descPassShading, descPassOutline, desPassFXAA, descPassPixelize, descPassCRT, descPassChromaticAberration, - descPassDebug + descPassColorize, descPassDebug }; } // namespace VTX::Renderer diff --git a/lib/renderer/include/renderer/renderer.hpp b/lib/renderer/include/renderer/renderer.hpp index 489cb7a24..0eee91582 100644 --- a/lib/renderer/include/renderer/renderer.hpp +++ b/lib/renderer/include/renderer/renderer.hpp @@ -74,7 +74,7 @@ namespace VTX::Renderer { "Matrix projection", E_TYPE::MAT4F, StructUniformValue { MAT4F_ID } }, // { _near * _far, _far, _far - _near, _near } { "Camera clip infos", E_TYPE::VEC4F, StructUniformValue { VEC4F_ZERO } }, - // TODO: check why not compiling with bool. + { "Mouse position", E_TYPE::VEC2I, StructUniformValue { { 0, 0 } } }, { "Is perspective", E_TYPE::BOOL, StructUniformValue { true } } } ); } @@ -185,6 +185,11 @@ namespace VTX::Renderer setUniform( Vec4f( p_near * p_far, p_far, p_far - p_near, p_near ), "Camera clip infos" ); } + inline void setMousePosition( const Vec2i & p_position ) + { + setUniform( Vec2i { p_position.x, _height - p_position.y }, "Mouse position" ); + } + inline void addMolecule( const StructProxyMolecule & p_proxy ) { _molecules.push_back( p_proxy ); diff --git a/lib/renderer/shaders/chromatic_aberration.frag b/lib/renderer/shaders/chromatic_aberration.frag index 88d3f2fed..2530d2c23 100644 --- a/lib/renderer/shaders/chromatic_aberration.frag +++ b/lib/renderer/shaders/chromatic_aberration.frag @@ -1,6 +1,6 @@ #version 450 core -#include "struct_data_packed.glsl" +#include "layout_uniforms_camera.glsl"; // In. layout( binding = 0 ) uniform sampler2D inTextureColor; @@ -20,9 +20,7 @@ void main() const ivec2 texCoord = ivec2( gl_FragCoord.xy ); const vec2 texSize = textureSize( inTextureColor, 0 ); const vec2 uv = texCoord / texSize; - - const ivec2 focusPoint = ivec2( 0, 0 ); - const vec2 direction = uv - focusPoint; + const vec2 direction = uv - uniformsCamera.mousePosition / texSize; outFragColor.r = texture( inTextureColor, uv + ( direction * vec2( uniforms.offsetRed ) ) ).r; outFragColor.g = texture( inTextureColor, uv + ( direction * vec2( uniforms.offsetGreen ) ) ).g; diff --git a/lib/renderer/shaders/colorize.frag b/lib/renderer/shaders/colorize.frag new file mode 100644 index 000000000..b5f3b2882 --- /dev/null +++ b/lib/renderer/shaders/colorize.frag @@ -0,0 +1,24 @@ +#version 450 core + +// In. +layout( binding = 0 ) uniform sampler2D inTextureColor; + +layout ( std140, binding = 1 ) uniform Uniforms +{ + vec4 color; +} uniforms; + +// Out. +layout( location = 0 ) out vec4 outFragColor; + +void main() +{ + const ivec2 texCoord = ivec2( gl_FragCoord.xy ); + const vec2 texSize = textureSize( inTextureColor, 0 ); + const vec2 uv = texCoord / texSize; + + vec4 fragColor = texture( inTextureColor, texCoord / texSize ); + float greyscale = max( fragColor.r, max( fragColor.g, fragColor.b ) ); + + outFragColor = vec4( greyscale, greyscale, greyscale, 1.f ) * uniforms.color; +} \ No newline at end of file diff --git a/lib/renderer/shaders/layout_uniforms_camera.glsl b/lib/renderer/shaders/layout_uniforms_camera.glsl index 3ef60619a..1f87fa8a2 100644 --- a/lib/renderer/shaders/layout_uniforms_camera.glsl +++ b/lib/renderer/shaders/layout_uniforms_camera.glsl @@ -5,5 +5,6 @@ layout ( std140, binding = 15 ) uniform UniformsCamera mat4 matrixView; mat4 matrixProjection; vec4 cameraClipInfos; // _near * _far, _far, _far - _near, _near + ivec2 mousePosition; bool isCameraPerspective; } uniformsCamera; \ No newline at end of file From 41dca19c226fb8afcb7b4912a047b3fa4e9bad48 Mon Sep 17 00:00:00 2001 From: sguionni Date: Tue, 19 Dec 2023 16:55:03 +0100 Subject: [PATCH 3/3] Remove Gitter badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 6d730d779..6b415df28 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ # VTX - High performance molecular visualization software -[![Gitter](https://badges.gitter.im/VTX_mol/VTX.svg)](https://gitter.im/VTX_mol/VTX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - ![VTX Image](https://vtx.drugdesign.fr/assets/snapshots/2.png) ## USER GUIDE