diff --git a/src/Mara/CMakeLists.txt b/src/Mara/CMakeLists.txt index 0f8cdef7d42fc80066a062cddd30d7e89a81bc0d..99e079be5497367da14c2c8ab8dcd949b19378ca 100644 --- a/src/Mara/CMakeLists.txt +++ b/src/Mara/CMakeLists.txt @@ -55,7 +55,7 @@ set(app_headers ) get_target_property(RADIUM_IO_HAS_VOLUMES Radium::IO RADIUM_IO_HAS_VOLUMES) -if( NOT RADIUM_IO_HAS_VOLUMES) +if (NOT RADIUM_IO_HAS_VOLUMES) message(STATUS " *** ${PROJECT_NAME} *** Using internal volume loaders") list(APPEND app_sources VolumeLoader/VolumeLoader.cpp @@ -65,7 +65,7 @@ if( NOT RADIUM_IO_HAS_VOLUMES) VolumeLoader/VolumeLoader.hpp VolumeLoader/pvmutils.hpp ) -else() +else () message(STATUS " *** ${PROJECT_NAME} *** Using Radium::IO volume loaders") endif (NOT RADIUM_IO_HAS_VOLUMES) @@ -93,7 +93,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -if( RADIUM_IO_HAS_VOLUMES) +if (RADIUM_IO_HAS_VOLUMES) target_compile_definitions(${PROJECT_NAME} PRIVATE RADIUM_IO_HAS_VOLUMES) endif (RADIUM_IO_HAS_VOLUMES) @@ -134,7 +134,7 @@ endif (WITH_H3D_SUPPORT) if (RADIUM_EXPERIMENTAL) message(STATUS " *** ${PROJECT_NAME} *** Compiling with Radium experimental features activated.") target_compile_definitions(${PROJECT_NAME} PRIVATE RADIUM_EXPERIMENTAL) -endif() +endif () configure_radium_app( NAME ${PROJECT_NAME} diff --git a/src/Mara/Gui/MainWindow.cpp b/src/Mara/Gui/MainWindow.cpp index 3f77cedee6a1ca0f1bfb2d55abbed8d47876fbd4..da09c1fc4e3c77e116c84ca92231993912c59efd 100644 --- a/src/Mara/Gui/MainWindow.cpp +++ b/src/Mara/Gui/MainWindow.cpp @@ -263,20 +263,21 @@ void MainWindow::createConnections() { // Connect engine signals to the appropriate callbacks auto signalManager = Ra::Engine::RadiumEngine::getInstance()->getSignalManager(); - auto& entityAddedObs = signalManager->getEntityCreatedNotifier(); - m_entityAddObserverId = entityAddedObs.attachMember( this, &MainWindow::ItemAdded); - auto& entityRemovedObs = signalManager->getEntityDestroyedNotifier(); - m_entityRemoveObserverId = entityRemovedObs.attachMember( this, &MainWindow::ItemRemoved); + auto& entityAddedObs = signalManager->getEntityCreatedNotifier(); + m_entityAddObserverId = entityAddedObs.attachMember( this, &MainWindow::ItemAdded ); + auto& entityRemovedObs = signalManager->getEntityDestroyedNotifier(); + m_entityRemoveObserverId = entityRemovedObs.attachMember( this, &MainWindow::ItemRemoved ); - auto& componentAddedObs = signalManager->getComponentCreatedNotifier(); - m_componentAddObserverId = componentAddedObs.attachMember( this, &MainWindow::ItemAdded); + auto& componentAddedObs = signalManager->getComponentCreatedNotifier(); + m_componentAddObserverId = componentAddedObs.attachMember( this, &MainWindow::ItemAdded ); auto& componentRemovedObs = signalManager->getComponentDestroyedNotifier(); - m_componentRemoveObserverId = componentRemovedObs.attachMember( this, &MainWindow::ItemRemoved); + m_componentRemoveObserverId = + componentRemovedObs.attachMember( this, &MainWindow::ItemRemoved ); - auto& roAddedObs = signalManager->getRenderObjectCreatedNotifier(); - m_roAddObserverId = roAddedObs.attachMember( this, &MainWindow::ItemAdded); - auto& roRemovedObs = signalManager->getRenderObjectDestroyedNotifier(); - m_roRemoveObserverId = roRemovedObs.attachMember( this, &MainWindow::ItemRemoved); + auto& roAddedObs = signalManager->getRenderObjectCreatedNotifier(); + m_roAddObserverId = roAddedObs.attachMember( this, &MainWindow::ItemAdded ); + auto& roRemovedObs = signalManager->getRenderObjectDestroyedNotifier(); + m_roRemoveObserverId = roRemovedObs.attachMember( this, &MainWindow::ItemRemoved ); // Qt Gui callbacks connect( action_Load, &QAction::triggered, this, &MainWindow::loadFile ); @@ -373,7 +374,7 @@ void MainWindow::updateUi( Ra::Plugins::RadiumPluginInterface* plugin ) { QString tabName; if ( plugin->doAddWidget( tabName ) ) { - QString shortcut = QString("Ctrl+") + tabName[0]; + QString shortcut = QString( "Ctrl+" ) + tabName[0]; addControl( tabName, tr( shortcut.toStdString().c_str() ) ); m_controlWindow->addTab( plugin->getWidget(), tabName.toStdString() ); } @@ -386,9 +387,7 @@ void MainWindow::loadFile() { { QString exts; for ( const auto& e : loader->getFileExtensions() ) - { - exts.append( QString::fromStdString( e ) + tr( " " ) ); - } + { exts.append( QString::fromStdString( e ) + tr( " " ) ); } allexts.append( exts + tr( " " ) ); filter.append( QString::fromStdString( loader->name() ) + tr( " (" ) + exts + tr( ");;" ) ); } @@ -405,17 +404,15 @@ void MainWindow::loadFile() { if ( !pathList.empty() ) { /* Remove existing scene before loading the new one */ -// m_viewer->getCameraManipulator()->resetToDefaultCamera(); + // m_viewer->getCameraManipulator()->resetToDefaultCamera(); m_selectionManager->clear(); Ra::Engine::RadiumEngine::getInstance()->getEntityManager()->deleteEntities(); -// fitCamera(); + // fitCamera(); // load the new scene settings.setValue( "files/load", pathList.front() ); for ( const auto& file : pathList ) - { - emit fileLoading( file ); - } + { emit fileLoading( file ); } auto sceneName = pathList.first().toStdString(); activateCamera( sceneName ); @@ -550,10 +547,7 @@ void MainWindow::onSelectionChanged( const QItemSelection& /*selected*/, void MainWindow::timelinePlay( bool play ) { actionPlay->setChecked( play ); - if ( !m_lockTimeSystem ) - { - on_actionPlay_triggered( play ); - } + if ( !m_lockTimeSystem ) { on_actionPlay_triggered( play ); } } void MainWindow::timelineGoTo( double t ) { diff --git a/src/Mara/Gui/MainWindow.hpp b/src/Mara/Gui/MainWindow.hpp index bcaef09295a6d0839f90932104b8ba54684dd223..b9c8e8eda50b286b8ac308f57bcaa10f77f13ecb 100644 --- a/src/Mara/Gui/MainWindow.hpp +++ b/src/Mara/Gui/MainWindow.hpp @@ -182,7 +182,7 @@ class MainWindow : public Ra::Gui::MainWindowInterface, private Ui::MainWindow /// add the Radium Engine default systems UI void addRadiumSystemsUI(); - bool m_lockTimeSystem{false}; + bool m_lockTimeSystem{ false }; /// create the UI connections void createConnections(); @@ -208,24 +208,23 @@ class MainWindow : public Ra::Gui::MainWindowInterface, private Ui::MainWindow Ra::Gui::ItemModel* m_sceneModel; /// Timeline gui - Ra::Gui::Timeline* m_timeline{nullptr}; + Ra::Gui::Timeline* m_timeline{ nullptr }; #ifdef SHOWTREEVIEW /// QTreeview of the scene QTreeView* m_sceneTreeView; #endif // no more needed ? - //Ra::Engine::Scene::Camera* m_initialCamera{nullptr}; - + // Ra::Engine::Scene::Camera* m_initialCamera{nullptr}; /// Observers id for engine event ///@{ - int m_entityAddObserverId {-1}; - int m_entityRemoveObserverId {-1}; - int m_componentAddObserverId {-1}; - int m_componentRemoveObserverId {-1}; - int m_roAddObserverId {-1}; - int m_roRemoveObserverId {-1}; + int m_entityAddObserverId{ -1 }; + int m_entityRemoveObserverId{ -1 }; + int m_componentAddObserverId{ -1 }; + int m_componentRemoveObserverId{ -1 }; + int m_roAddObserverId{ -1 }; + int m_roRemoveObserverId{ -1 }; ///@} }; } // namespace Mara diff --git a/src/Mara/Gui/MaraResources.qrc b/src/Mara/Gui/MaraResources.qrc index bd8f863fef5b03d37777a5785a071ebd06ff36b1..61cdd465e6eb056657f8581d7d4a67caf3cf6649 100644 --- a/src/Mara/Gui/MaraResources.qrc +++ b/src/Mara/Gui/MaraResources.qrc @@ -1,17 +1,17 @@ <RCC> - <qresource prefix="Resources"> - <file>Icons/pause_on.png</file> - <file>Icons/pause_off.png</file> - <file>Icons/play_off.png</file> - <file>Icons/play_on.png</file> - <file>Icons/step_off.png</file> - <file>Icons/step_on.png</file> - <file>Icons/stop_off.png</file> - <file>Icons/stop_on.png</file> - <file>Icons/gizmo.png</file> - <file>Icons/rotate.png</file> - <file>Icons/scale.png</file> - <file>Icons/select.png</file> - <file>Icons/translate.png</file> - </qresource> + <qresource prefix="Resources"> + <file>Icons/pause_on.png</file> + <file>Icons/pause_off.png</file> + <file>Icons/play_off.png</file> + <file>Icons/play_on.png</file> + <file>Icons/step_off.png</file> + <file>Icons/step_on.png</file> + <file>Icons/stop_off.png</file> + <file>Icons/stop_on.png</file> + <file>Icons/gizmo.png</file> + <file>Icons/rotate.png</file> + <file>Icons/scale.png</file> + <file>Icons/select.png</file> + <file>Icons/translate.png</file> + </qresource> </RCC> diff --git a/src/Mara/Gui/RendererControl.cpp b/src/Mara/Gui/RendererControl.cpp index ca140c73f1718fc4543993365dcf20c2d744b804..4d0a3362165289fcdc3ffba6bb3ef96d6650caa5 100644 --- a/src/Mara/Gui/RendererControl.cpp +++ b/src/Mara/Gui/RendererControl.cpp @@ -52,9 +52,7 @@ void RendererControl::changeRenderer( const std::string& renderer ) { { auto texs = m_renderersCallbacks[m_currentRenderer].first->getAvailableTextures(); for ( const auto& tex : texs ) - { - m_textureList->addItem( tex.c_str() ); - } + { m_textureList->addItem( tex.c_str() ); } m_textureList->setCurrentIndex( 0 ); } diff --git a/src/Mara/Gui/RendererControl.hpp b/src/Mara/Gui/RendererControl.hpp index d358e0444ec1650722f8d4bed8d462a33f16b9df..7981480799734527c05384208b7db564df23ab34 100644 --- a/src/Mara/Gui/RendererControl.hpp +++ b/src/Mara/Gui/RendererControl.hpp @@ -76,7 +76,7 @@ class RendererControl : public QFrame, private Ui::RendererControler /// The association between a renderer and its activation function using RendererInfo = std::pair<Ra::Engine::Rendering::Renderer* const, std::function<bool()>>; /// The active renderer - int m_currentRenderer{-1}; + int m_currentRenderer{ -1 }; /// The Renderers/callbacks managed by the gui std::vector<RendererInfo> m_renderersCallbacks; @@ -84,6 +84,6 @@ class RendererControl : public QFrame, private Ui::RendererControler std::vector<RadiumNBR::Gui::RendererPanel*> m_renderersPanels; /// combo bos to select one renderer output for display - QComboBox* m_textureList{nullptr}; + QComboBox* m_textureList{ nullptr }; }; } // namespace Mara diff --git a/src/Mara/Gui/ui/MainWindow.ui b/src/Mara/Gui/ui/MainWindow.ui index 003ad7431dae27d92a4baff6003f28cba5b655d4..516d43a9f6d99172f99d15b4063b639b939317fe 100644 --- a/src/Mara/Gui/ui/MainWindow.ui +++ b/src/Mara/Gui/ui/MainWindow.ui @@ -1,263 +1,266 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>640</height> - </rect> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget"/> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>22</height> - </rect> - </property> - <widget class="QMenu" name="menu_File"> - <property name="title"> - <string>&File</string> - </property> - <addaction name="action_Load"/> - <addaction name="separator"/> - </widget> - <widget class="QMenu" name="menuRadium"> - <property name="title"> - <string>Radium</string> - </property> - <widget class="QMenu" name="menuPlugins"> - <property name="title"> - <string>Plugins</string> - </property> - <addaction name="actionAdd_PluginsDir"/> - <addaction name="actionClear_PluginsDir"/> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>640</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"/> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menu_File"> + <property name="title"> + <string>&File</string> + </property> + <addaction name="action_Load"/> + <addaction name="separator"/> + </widget> + <widget class="QMenu" name="menuRadium"> + <property name="title"> + <string>Radium</string> + </property> + <widget class="QMenu" name="menuPlugins"> + <property name="title"> + <string>Plugins</string> + </property> + <addaction name="actionAdd_PluginsDir"/> + <addaction name="actionClear_PluginsDir"/> + </widget> + <addaction name="action_Config"/> + <addaction name="action_Reload_shaders"/> + <addaction name="separator"/> + <addaction name="menuPlugins"/> + </widget> + <widget class="QMenu" name="menuControl"> + <property name="title"> + <string>Control</string> + </property> + <addaction name="separator"/> + <addaction name="actionInfo"/> + <addaction name="separator"/> + </widget> + <widget class="QMenu" name="menuToolbars"> + <property name="title"> + <string>Toolbars</string> + </property> + <addaction name="showAnimationToolbar"/> + </widget> + <addaction name="menuRadium"/> + <addaction name="menu_File"/> + <addaction name="menuControl"/> + <addaction name="menuToolbars"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <widget class="QToolBar" name="AnimationToolbar"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="windowTitle"> + <string>Animation toolbar</string> + </property> + <property name="movable"> + <bool>true</bool> + </property> + <property name="iconSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonIconOnly</enum> + </property> + <property name="floatable"> + <bool>false</bool> + </property> + <attribute name="toolBarArea"> + <enum>TopToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionPlay"/> + <addaction name="actionStop"/> + <addaction name="actionStep"/> + <addaction name="separator"/> + </widget> + <action name="action_Load"> + <property name="text"> + <string>Open ...</string> + </property> + <property name="shortcut"> + <string>Ctrl+O</string> + </property> + </action> + <action name="action_Config"> + <property name="text"> + <string>&Config</string> + </property> + </action> + <action name="action_Reload_shaders"> + <property name="text"> + <string>&Reload shaders</string> + </property> + <property name="shortcut"> + <string>Ctrl+Alt+R</string> + </property> + </action> + <action name="actionTree_view"> + <property name="text"> + <string>&Tree view</string> + </property> + <property name="shortcut"> + <string>Ctrl+T</string> + </property> + </action> + <action name="actionInfo"> + <property name="text"> + <string>Info</string> + </property> + <property name="shortcut"> + <string>Ctrl+I</string> + </property> + </action> + <action name="actionAdd_PluginsDir"> + <property name="text"> + <string>&Add directory</string> + </property> + </action> + <action name="actionClear_PluginsDir"> + <property name="text"> + <string>Clear plugins dir</string> + </property> + </action> + <action name="actionPlay"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="../MaraResources.qrc"> + <normaloff>:/Resources/Icons/play_on.png</normaloff> + <normalon>:/Resources/Icons/pause_on.png</normalon> + <activeoff>:/Resources/Icons/play_on.png</activeoff> + <activeon>:/Resources/Icons/pause_on.png</activeon>:/Resources/Icons/play_on.png + </iconset> + </property> + <property name="text"> + <string>play</string> + </property> + <property name="toolTip"> + <string>Play/Pause time flow</string> + </property> + <property name="shortcut"> + <string>Space</string> + </property> + </action> + <action name="actionStop"> + <property name="icon"> + <iconset resource="../MaraResources.qrc"> + <normaloff>:/Resources/Icons/stop_on.png</normaloff> + <normalon>:/Resources/Icons/stop_on.png</normalon> + <activeoff>:/Resources/Icons/stop_on.png</activeoff> + <activeon>:/Resources/Icons/stop_on.png</activeon>:/Resources/Icons/stop_on.png + </iconset> + </property> + <property name="text"> + <string>stop</string> + </property> + <property name="toolTip"> + <string>Reset time</string> + </property> + <property name="shortcut"> + <string>Backspace</string> + </property> + </action> + <action name="actionStep"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="../MaraResources.qrc"> + <normaloff>:/Resources/Icons/step_on.png</normaloff> + <normalon>:/Resources/Icons/step_on.png</normalon> + <activeoff>:/Resources/Icons/step_on.png</activeoff>:/Resources/Icons/step_on.png + </iconset> + </property> + <property name="text"> + <string>step</string> + </property> + <property name="toolTip"> + <string>Step time</string> + </property> + <property name="shortcut"> + <string>Meta+Space</string> + </property> + </action> + <action name="showAnimationToolbar"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Animation toolbar</string> + </property> + <property name="toolTip"> + <string>Show/hide the animation toolbar</string> + </property> + </action> </widget> - <addaction name="action_Config"/> - <addaction name="action_Reload_shaders"/> - <addaction name="separator"/> - <addaction name="menuPlugins"/> - </widget> - <widget class="QMenu" name="menuControl"> - <property name="title"> - <string>Control</string> - </property> - <addaction name="separator"/> - <addaction name="actionInfo"/> - <addaction name="separator"/> - </widget> - <widget class="QMenu" name="menuToolbars"> - <property name="title"> - <string>Toolbars</string> - </property> - <addaction name="showAnimationToolbar"/> - </widget> - <addaction name="menuRadium"/> - <addaction name="menu_File"/> - <addaction name="menuControl"/> - <addaction name="menuToolbars"/> - </widget> - <widget class="QStatusBar" name="statusbar"/> - <widget class="QToolBar" name="AnimationToolbar"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="windowTitle"> - <string>Animation toolbar</string> - </property> - <property name="movable"> - <bool>true</bool> - </property> - <property name="iconSize"> - <size> - <width>24</width> - <height>24</height> - </size> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonIconOnly</enum> - </property> - <property name="floatable"> - <bool>false</bool> - </property> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - <addaction name="actionPlay"/> - <addaction name="actionStop"/> - <addaction name="actionStep"/> - <addaction name="separator"/> - </widget> - <action name="action_Load"> - <property name="text"> - <string>Open ...</string> - </property> - <property name="shortcut"> - <string>Ctrl+O</string> - </property> - </action> - <action name="action_Config"> - <property name="text"> - <string>&Config</string> - </property> - </action> - <action name="action_Reload_shaders"> - <property name="text"> - <string>&Reload shaders</string> - </property> - <property name="shortcut"> - <string>Ctrl+Alt+R</string> - </property> - </action> - <action name="actionTree_view"> - <property name="text"> - <string>&Tree view</string> - </property> - <property name="shortcut"> - <string>Ctrl+T</string> - </property> - </action> - <action name="actionInfo"> - <property name="text"> - <string>Info</string> - </property> - <property name="shortcut"> - <string>Ctrl+I</string> - </property> - </action> - <action name="actionAdd_PluginsDir"> - <property name="text"> - <string>&Add directory</string> - </property> - </action> - <action name="actionClear_PluginsDir"> - <property name="text"> - <string>Clear plugins dir</string> - </property> - </action> - <action name="actionPlay"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="icon"> - <iconset resource="../MaraResources.qrc"> - <normaloff>:/Resources/Icons/play_on.png</normaloff> - <normalon>:/Resources/Icons/pause_on.png</normalon> - <activeoff>:/Resources/Icons/play_on.png</activeoff> - <activeon>:/Resources/Icons/pause_on.png</activeon>:/Resources/Icons/play_on.png</iconset> - </property> - <property name="text"> - <string>play</string> - </property> - <property name="toolTip"> - <string>Play/Pause time flow</string> - </property> - <property name="shortcut"> - <string>Space</string> - </property> - </action> - <action name="actionStop"> - <property name="icon"> - <iconset resource="../MaraResources.qrc"> - <normaloff>:/Resources/Icons/stop_on.png</normaloff> - <normalon>:/Resources/Icons/stop_on.png</normalon> - <activeoff>:/Resources/Icons/stop_on.png</activeoff> - <activeon>:/Resources/Icons/stop_on.png</activeon>:/Resources/Icons/stop_on.png</iconset> - </property> - <property name="text"> - <string>stop</string> - </property> - <property name="toolTip"> - <string>Reset time</string> - </property> - <property name="shortcut"> - <string>Backspace</string> - </property> - </action> - <action name="actionStep"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="icon"> - <iconset resource="../MaraResources.qrc"> - <normaloff>:/Resources/Icons/step_on.png</normaloff> - <normalon>:/Resources/Icons/step_on.png</normalon> - <activeoff>:/Resources/Icons/step_on.png</activeoff>:/Resources/Icons/step_on.png</iconset> - </property> - <property name="text"> - <string>step</string> - </property> - <property name="toolTip"> - <string>Step time</string> - </property> - <property name="shortcut"> - <string>Meta+Space</string> - </property> - </action> - <action name="showAnimationToolbar"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>true</bool> - </property> - <property name="text"> - <string>Animation toolbar</string> - </property> - <property name="toolTip"> - <string>Show/hide the animation toolbar</string> - </property> - </action> - </widget> - <resources> - <include location="../MaraResources.qrc"/> - </resources> - <connections> - <connection> - <sender>showAnimationToolbar</sender> - <signal>triggered(bool)</signal> - <receiver>AnimationToolbar</receiver> - <slot>setVisible(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>399</x> - <y>39</y> - </hint> - </hints> - </connection> - <connection> - <sender>AnimationToolbar</sender> - <signal>visibilityChanged(bool)</signal> - <receiver>showAnimationToolbar</receiver> - <slot>setChecked(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>399</x> - <y>39</y> - </hint> - <hint type="destinationlabel"> - <x>-1</x> - <y>-1</y> - </hint> - </hints> - </connection> - </connections> + <resources> + <include location="../MaraResources.qrc"/> + </resources> + <connections> + <connection> + <sender>showAnimationToolbar</sender> + <signal>triggered(bool)</signal> + <receiver>AnimationToolbar</receiver> + <slot>setVisible(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>399</x> + <y>39</y> + </hint> + </hints> + </connection> + <connection> + <sender>AnimationToolbar</sender> + <signal>visibilityChanged(bool)</signal> + <receiver>showAnimationToolbar</receiver> + <slot>setChecked(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>399</x> + <y>39</y> + </hint> + <hint type="destinationlabel"> + <x>-1</x> + <y>-1</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/src/Mara/Gui/ui/RendererControl.ui b/src/Mara/Gui/ui/RendererControl.ui index 636a76c48cbc4b08d61141beec501d787080d351..4533e63e9c83727ecb11e65373585133ae4953a9 100644 --- a/src/Mara/Gui/ui/RendererControl.ui +++ b/src/Mara/Gui/ui/RendererControl.ui @@ -1,121 +1,121 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>RendererControler</class> - <widget class="QFrame" name="RendererControler"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>608</width> - <height>467</height> - </rect> - </property> - <property name="windowTitle"> - <string>Frame</string> - </property> - <layout class="QVBoxLayout" name="controlerLayout"> - <item> - <widget class="QFrame" name="rendererSelector"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>52</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>52</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QHBoxLayout" name="rendererSelectorLayout"> - <item> - <widget class="QLabel" name="rendererLabel"> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> + <class>RendererControler</class> + <widget class="QFrame" name="RendererControler"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>608</width> + <height>467</height> + </rect> </property> - <property name="text"> - <string>Active Renderer</string> + <property name="windowTitle"> + <string>Frame</string> </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="rendererList"> - <property name="minimumSize"> - <size> - <width>459</width> - <height>0</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QFrame" name="cameraPanel"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>52</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>52</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="b_fitCamera"> - <property name="text"> - <string>Fit camera to scene</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="b_resetCamera"> - <property name="text"> - <string>Reset camera</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QFrame" name="confPanel"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QVBoxLayout" name="panelLayout"> - <property name="leftMargin"> - <number>13</number> - </property> - </layout> + <layout class="QVBoxLayout" name="controlerLayout"> + <item> + <widget class="QFrame" name="rendererSelector"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>52</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>52</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QHBoxLayout" name="rendererSelectorLayout"> + <item> + <widget class="QLabel" name="rendererLabel"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Active Renderer</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="rendererList"> + <property name="minimumSize"> + <size> + <width>459</width> + <height>0</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QFrame" name="cameraPanel"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>52</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>52</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="b_fitCamera"> + <property name="text"> + <string>Fit camera to scene</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="b_resetCamera"> + <property name="text"> + <string>Reset camera</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QFrame" name="confPanel"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="panelLayout"> + <property name="leftMargin"> + <number>13</number> + </property> + </layout> + </widget> + </item> + </layout> </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> + <resources/> + <connections/> </ui> diff --git a/src/Mara/RadiumPlayer.cpp b/src/Mara/RadiumPlayer.cpp index 0525110bf91e5afc3572892fc47a151f23aa8467..61bcadae9e366a06c661b1095bd4df5e45f8eeb4 100644 --- a/src/Mara/RadiumPlayer.cpp +++ b/src/Mara/RadiumPlayer.cpp @@ -8,7 +8,7 @@ #include <Gui/Viewer/Viewer.hpp> #ifndef RADIUM_IO_HAS_VOLUMES -#include <VolumeLoader/VolumeLoader.hpp> +# include <VolumeLoader/VolumeLoader.hpp> #endif #include <Core/Utils/Log.hpp> @@ -26,9 +26,9 @@ using namespace Ra::Core::Utils; // for LOG( logLEVEL ) #include <RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.hpp> #include <RadiumNBR/VolumeVisualization/VolumeVisualization.hpp> -#include <RadiumNBR/Renderer/NodeGraphController.hpp> #include <RadiumNBR/Gui/NodeGraphControllerGui.hpp> #include <RadiumNBR/NodeGraph/NodeFactory.hpp> +#include <RadiumNBR/Renderer/NodeGraphController.hpp> #ifdef WITH_H3D_SUPPORT # include <RadiumH3D/h3DLoader.hpp> @@ -38,12 +38,12 @@ using namespace Ra::Core::Utils; // for LOG( logLEVEL ) #define SEMINARDEMO #ifdef SEMINARDEMO -#include <Engine/Data/RenderParameters.hpp> -#include <Engine/Data/Material.hpp> -#include <Engine/Data/ShaderConfigFactory.hpp> -#include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp> +# include <Engine/Data/Material.hpp> +# include <Engine/Data/RenderParameters.hpp> +# include <Engine/Data/ShaderConfigFactory.hpp> +# include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> +# include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp> +# include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> template <typename T> class NodeCreator @@ -180,8 +180,6 @@ void RadiumPlayer::engineOpenGLInitialize() { addRenderers(); } - - void RadiumPlayer::addRenderers() { auto mainWindow = dynamic_cast<MainWindow*>( m_mainWindow.get() ); // add MultipassRenderer with controler renderer @@ -195,13 +193,12 @@ void RadiumPlayer::addRenderers() { mainWindow->addRenderer( rendererName, myRenderer, controlPanel ); } - // add NodeGraph renderer as controller { // 1 - Initialize the base node graph system NodeFactory::initializeNodeFactory(); - #ifdef SEMINARDEMO +#ifdef SEMINARDEMO // Demo NodeFactory::registerNode<SimpleNode>( []( const nlohmann::json& data ) { auto simpleNode = @@ -214,19 +211,18 @@ void RadiumPlayer::addRenderers() { new DifferenceNode( "DifferenceNode" + std::to_string( NodeFactory::newNodeId() ) ); return differenceNode; } ); - #endif +#endif // 2 - Initialize the renderer using default or customized NodeGraphController - auto renderControl = new RadiumNBR::NodeGraphController; - auto myRenderer = std::make_shared<RadiumNBR::NodeBasedRenderer>( *renderControl ); + auto renderControl = new RadiumNBR::NodeGraphController; + auto myRenderer = std::make_shared<RadiumNBR::NodeBasedRenderer>( *renderControl ); std::string rendererName = myRenderer->getRendererName(); // The panel returned by buildNodeGraphControllerGui will manage the Qt NodeEditor window - // This function must initialize the default nodeEditor functionality for the edited renderGraph - // (i.e. DataModelRegistry) - auto controlPanel = RadiumNBR::buildNodeGraphControllerGui( + // This function must initialize the default nodeEditor functionality for the edited + // renderGraph (i.e. DataModelRegistry) + auto controlPanel = RadiumNBR::buildNodeGraphControllerGui( myRenderer.get(), [this]() { this->askForUpdate(); } ); - mainWindow->addRenderer( rendererName, myRenderer, controlPanel ); #if 1 @@ -247,7 +243,6 @@ void RadiumPlayer::addRenderers() { } myRenderer->signalReloadJson(); #endif - } // add the default forward renderer diff --git a/src/Mara/RadiumPlayer.hpp b/src/Mara/RadiumPlayer.hpp index db6cc1852aacb4b0e3fb1f920dcead7f5be7668c..92625d59541fcea9aab80c4f36b02a23506b9ed1 100644 --- a/src/Mara/RadiumPlayer.hpp +++ b/src/Mara/RadiumPlayer.hpp @@ -2,7 +2,7 @@ #include <Gui/BaseApplication.hpp> -#include<optional> +#include <optional> namespace Mara { class RadiumPlayer : public Ra::Gui::BaseApplication @@ -44,7 +44,7 @@ class RadiumPlayer : public Ra::Gui::BaseApplication void addConnections(); /// Current nodeGraph. First indicate that the file (second) must be loaded at startup - std::optional<std::string> m_graphOption{std::nullopt}; + std::optional<std::string> m_graphOption{ std::nullopt }; private slots: /// Allow to pick using a circle diff --git a/src/Mara/VolumeLoader/VolumeLoader.cpp b/src/Mara/VolumeLoader/VolumeLoader.cpp index 8fe38d49fa78ba66cae65bc9125eb830a8b5a1ab..54f815ee55d4616bf2680e1e5bd1013c6aeeb44e 100644 --- a/src/Mara/VolumeLoader/VolumeLoader.cpp +++ b/src/Mara/VolumeLoader/VolumeLoader.cpp @@ -14,14 +14,14 @@ using namespace Ra::Core; using namespace Ra::Core::Utils; namespace Mara { -const std::string volFileExtension{"vol"}; -const std::string pvmFileExtension{"pvm"}; +const std::string volFileExtension{ "vol" }; +const std::string pvmFileExtension{ "pvm" }; VolumeLoader::VolumeLoader() {} VolumeLoader::~VolumeLoader() {} std::vector<std::string> VolumeLoader::getFileExtensions() const { - return {{"*." + volFileExtension}, {"*." + pvmFileExtension}}; + return { { "*." + volFileExtension }, { "*." + pvmFileExtension } }; } bool VolumeLoader::handleFileExtension( const std::string& extension ) const { @@ -76,7 +76,7 @@ Ra::Core::Asset::FileData* VolumeLoader::loadVolFile( const std::string& filenam LOG( logINFO ) << "\tVolumeLoader : reading a volume of size " << sx << "x" << sy << "x" << sz; - Ra::Core::Vector3 voxelSize{1_ra, 1_ra, 1_ra}; + Ra::Core::Vector3 voxelSize{ 1_ra, 1_ra, 1_ra }; auto density = new Geometry::VolumeGrid(); density->setSize( Vector3i( sx, sy, sz ) ); density->setBinSize( voxelSize ); @@ -134,7 +134,7 @@ Ra::Core::Asset::FileData* VolumeLoader::loadPvmFile( const std::string& filenam if ( volumeData ) { { - unsigned char empty[1] {'\0'}; + unsigned char empty[1]{ '\0' }; LOG( logINFO ) << "VolumeLoader : \n\tpvm (The Volume Library) file " << filename << " \n\twidth = " << width << " \n\theight = " << height << " \n\tdepth = " << depth << " \n\tbyte per voxel = " << bytePerVoxel @@ -155,7 +155,7 @@ Ra::Core::Asset::FileData* VolumeLoader::loadPvmFile( const std::string& filenam auto density = new Geometry::VolumeGrid(); density->setSize( Vector3i( width, height, depth ) ); density->setBinSize( - Ra::Core::Vector3{Scalar( scalex ), Scalar( scaley ), Scalar( scalez )} ); + Ra::Core::Vector3{ Scalar( scalex ), Scalar( scaley ), Scalar( scalez ) } ); switch ( bytePerVoxel ) { diff --git a/src/Mara/main.cpp b/src/Mara/main.cpp index e7d2e4ad2da8553b467358a1b7409f4eee7576a6..8acdc21bd0742c009365b175ccae6df371154f8a 100644 --- a/src/Mara/main.cpp +++ b/src/Mara/main.cpp @@ -25,21 +25,21 @@ int main( int argc, char** argv ) { int main( int argc, char** argv ) { RadiumNBR::testConnections(); } -#if 0 +# if 0 // Access to the Base Radium application interface -# include <GuiBase/BaseApplication.hpp> +# include <GuiBase/BaseApplication.hpp> // Allow to build a Simple Radium window -# include <GuiBase/RadiumWindow/SimpleWindowFactory.hpp> +# include <GuiBase/RadiumWindow/SimpleWindowFactory.hpp> /* Includes from the core to define meshes and appearance */ -# include <Core/Asset/BlinnPhongMaterialData.hpp> -# include <Core/Geometry/MeshPrimitives.hpp> +# include <Core/Asset/BlinnPhongMaterialData.hpp> +# include <Core/Geometry/MeshPrimitives.hpp> /* Includes from the Engine to manipulate entities and components*/ -# include <Engine/Component/GeometryComponent.hpp> -# include <Engine/Managers/EntityManager/EntityManager.hpp> -# include <Engine/RadiumEngine.hpp> -# include <Engine/System/GeometrySystem.hpp> +# include <Engine/Component/GeometryComponent.hpp> +# include <Engine/Managers/EntityManager/EntityManager.hpp> +# include <Engine/RadiumEngine.hpp> +# include <Engine/System/GeometrySystem.hpp> int main( int argc, char** argv ) { Ra::GuiBase::BaseApplication app( argc, argv, Ra::GuiBase::SimpleWindowFactory{} ); @@ -87,6 +87,6 @@ int main( int argc, char** argv ) { return Ra::GuiBase::BaseApplication::exec(); } -#endif +# endif #endif diff --git a/src/libRender/CMakeLists.txt b/src/libRender/CMakeLists.txt index b680987d8c1644ec83d37e32b73250050ac15c37..f828b9fad442ce915d9028b386efc678e73fe1df 100644 --- a/src/libRender/CMakeLists.txt +++ b/src/libRender/CMakeLists.txt @@ -61,6 +61,7 @@ set(sources RadiumNBR/NodeGraph/RenderGraph.cpp RadiumNBR/NodeGraph/NodeFactory.cpp + RadiumNBR/NodeGraph/Node.cpp # MULTI PASS RadiumNBR/MultiPassRenderer.cpp diff --git a/src/libRender/RadiumNBR/EnvMap.cpp b/src/libRender/RadiumNBR/EnvMap.cpp index e94616526e141556310657b254f148aa3f5a7990..4587c2a14b339a98051d9cfabedfea209f3cdf83 100644 --- a/src/libRender/RadiumNBR/EnvMap.cpp +++ b/src/libRender/RadiumNBR/EnvMap.cpp @@ -45,9 +45,7 @@ void flip_horizontally( T* img, size_t w, size_t h, size_t c ) { T* from = img + ( l * c ); T* to = img + ( w - ( l + 1 ) ) * c; for ( size_t e = 0; e < c; ++e ) - { - std::swap( *( from + e ), *( to + e ) ); - } + { std::swap( *( from + e ), *( to + e ) ); } } img += w * c; } @@ -158,70 +156,70 @@ using namespace Ra::Core; static Geometry::TriangleMesh makeSkyBox( const Aabb& aabb ) { Geometry::TriangleMesh result; - result.setVertices( {// Z- face - aabb.corner( Aabb::BottomLeftFloor ), - aabb.corner( Aabb::TopLeftFloor ), - aabb.corner( Aabb::TopRightFloor ), - aabb.corner( Aabb::BottomRightFloor ), - // Z+ face - aabb.corner( Aabb::BottomLeftCeil ), - aabb.corner( Aabb::BottomRightCeil ), - aabb.corner( Aabb::TopRightCeil ), - aabb.corner( Aabb::TopLeftCeil ), - // X- Face - aabb.corner( Aabb::TopLeftFloor ), - aabb.corner( Aabb::BottomLeftFloor ), - aabb.corner( Aabb::BottomLeftCeil ), - aabb.corner( Aabb::TopLeftCeil ), - - // X+ Face - aabb.corner( Aabb::BottomRightFloor ), - aabb.corner( Aabb::TopRightFloor ), - aabb.corner( Aabb::TopRightCeil ), - aabb.corner( Aabb::BottomRightCeil ), - - // Y- Face - aabb.corner( Aabb::BottomLeftFloor ), - aabb.corner( Aabb::BottomRightFloor ), - aabb.corner( Aabb::BottomRightCeil ), - aabb.corner( Aabb::BottomLeftCeil ), - - // Y+ face - aabb.corner( Aabb::TopLeftFloor ), - aabb.corner( Aabb::TopLeftCeil ), - aabb.corner( Aabb::TopRightCeil ), - aabb.corner( Aabb::TopRightFloor )} ); - - result.setNormals( {// Floor face - Vector3( 0, 0, -1 ), - Vector3( 0, 0, -1 ), - Vector3( 0, 0, -1 ), - Vector3( 0, 0, -1 ), - // Ceil Face - Vector3( 0, 0, +1 ), - Vector3( 0, 0, +1 ), - Vector3( 0, 0, +1 ), - Vector3( 0, 0, +1 ), - // Left Face - Vector3( -1, 0, 0 ), - Vector3( -1, 0, 0 ), - Vector3( -1, 0, 0 ), - Vector3( -1, 0, 0 ), - // Right Face - Vector3( +1, 0, 0 ), - Vector3( +1, 0, 0 ), - Vector3( +1, 0, 0 ), - Vector3( +1, 0, 0 ), - // Bottom Face - Vector3( 0, -1, 0 ), - Vector3( 0, -1, 0 ), - Vector3( 0, -1, 0 ), - Vector3( 0, -1, 0 ), - // Top Face - Vector3( 0, +1, 0 ), - Vector3( 0, +1, 0 ), - Vector3( 0, +1, 0 ), - Vector3( 0, +1, 0 )} ); + result.setVertices( { // Z- face + aabb.corner( Aabb::BottomLeftFloor ), + aabb.corner( Aabb::TopLeftFloor ), + aabb.corner( Aabb::TopRightFloor ), + aabb.corner( Aabb::BottomRightFloor ), + // Z+ face + aabb.corner( Aabb::BottomLeftCeil ), + aabb.corner( Aabb::BottomRightCeil ), + aabb.corner( Aabb::TopRightCeil ), + aabb.corner( Aabb::TopLeftCeil ), + // X- Face + aabb.corner( Aabb::TopLeftFloor ), + aabb.corner( Aabb::BottomLeftFloor ), + aabb.corner( Aabb::BottomLeftCeil ), + aabb.corner( Aabb::TopLeftCeil ), + + // X+ Face + aabb.corner( Aabb::BottomRightFloor ), + aabb.corner( Aabb::TopRightFloor ), + aabb.corner( Aabb::TopRightCeil ), + aabb.corner( Aabb::BottomRightCeil ), + + // Y- Face + aabb.corner( Aabb::BottomLeftFloor ), + aabb.corner( Aabb::BottomRightFloor ), + aabb.corner( Aabb::BottomRightCeil ), + aabb.corner( Aabb::BottomLeftCeil ), + + // Y+ face + aabb.corner( Aabb::TopLeftFloor ), + aabb.corner( Aabb::TopLeftCeil ), + aabb.corner( Aabb::TopRightCeil ), + aabb.corner( Aabb::TopRightFloor ) } ); + + result.setNormals( { // Floor face + Vector3( 0, 0, -1 ), + Vector3( 0, 0, -1 ), + Vector3( 0, 0, -1 ), + Vector3( 0, 0, -1 ), + // Ceil Face + Vector3( 0, 0, +1 ), + Vector3( 0, 0, +1 ), + Vector3( 0, 0, +1 ), + Vector3( 0, 0, +1 ), + // Left Face + Vector3( -1, 0, 0 ), + Vector3( -1, 0, 0 ), + Vector3( -1, 0, 0 ), + Vector3( -1, 0, 0 ), + // Right Face + Vector3( +1, 0, 0 ), + Vector3( +1, 0, 0 ), + Vector3( +1, 0, 0 ), + Vector3( +1, 0, 0 ), + // Bottom Face + Vector3( 0, -1, 0 ), + Vector3( 0, -1, 0 ), + Vector3( 0, -1, 0 ), + Vector3( 0, -1, 0 ), + // Top Face + Vector3( 0, +1, 0 ), + Vector3( 0, +1, 0 ), + Vector3( 0, +1, 0 ), + Vector3( 0, +1, 0 ) } ); result.setIndices( { Vector3ui( 0, 1, 2 ), @@ -238,36 +236,36 @@ static Geometry::TriangleMesh makeSkyBox( const Aabb& aabb ) { Vector3ui( 20, 22, 23 ) // Top } ); - Vector3Array texcoord = {// Floor Face (Z-) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra ), - // Ceil Face (Z+) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra ), - // Left Face (Y-) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra ), - // Right Face (Y+) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra ), - // Bottom Face (X-) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra ), - // Top Face (X+) - Vector3( 0_ra, 0_ra, 0_ra ), - Vector3( 0_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 1_ra, 0_ra ), - Vector3( 1_ra, 0_ra, 0_ra )}; + Vector3Array texcoord = { // Floor Face (Z-) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ), + // Ceil Face (Z+) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ), + // Left Face (Y-) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ), + // Right Face (Y+) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ), + // Bottom Face (X-) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ), + // Top Face (X+) + Vector3( 0_ra, 0_ra, 0_ra ), + Vector3( 0_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 1_ra, 0_ra ), + Vector3( 1_ra, 0_ra, 0_ra ) }; result.addAttrib( "in_texcoord", texcoord ); @@ -280,8 +278,8 @@ static Geometry::TriangleMesh makeSkyBox( const Aabb& aabb ) { EnvMap::EnvMap( const std::string& mapName, EnvMap::EnvMapType type, bool isSkybox ) : m_name( mapName ), m_type( type ), - m_skyData{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, - m_isSkyBox{isSkybox} { + m_skyData{ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }, + m_isSkyBox{ isSkybox } { switch ( m_type ) { case EnvMapType::ENVMAP_PFM: @@ -296,27 +294,27 @@ EnvMap::EnvMap( const std::string& mapName, EnvMap::EnvMapType type, bool isSkyb } computeSHMatrices(); // make the envmap cube texture - Ra::Engine::Data::TextureParameters params{"envmap", - GL_TEXTURE_CUBE_MAP, - m_width, - m_height, - 1, - GL_RGBA, - GL_RGBA, - GL_FLOAT, - GL_CLAMP_TO_EDGE, - GL_CLAMP_TO_EDGE, - GL_CLAMP_TO_EDGE, - GL_LINEAR_MIPMAP_LINEAR, - GL_LINEAR, - (void**)( m_skyData )}; + Ra::Engine::Data::TextureParameters params{ "envmap", + GL_TEXTURE_CUBE_MAP, + m_width, + m_height, + 1, + GL_RGBA, + GL_RGBA, + GL_FLOAT, + GL_CLAMP_TO_EDGE, + GL_CLAMP_TO_EDGE, + GL_CLAMP_TO_EDGE, + GL_LINEAR_MIPMAP_LINEAR, + GL_LINEAR, + (void**)( m_skyData ) }; m_skyTexture = std::make_unique<Ra::Engine::Data::Texture>( params ); if ( m_isSkyBox ) { // make the skybox geometry /// Todo, port this to new attrib management - Aabb aabb( Vector3{-1_ra, -1_ra, -1_ra}, Vector3{1_ra, 1_ra, 1_ra} ); + Aabb aabb( Vector3{ -1_ra, -1_ra, -1_ra }, Vector3{ 1_ra, 1_ra, 1_ra } ); Geometry::TriangleMesh skyMesh = makeSkyBox( aabb ); m_displayMesh = std::make_unique<Ra::Engine::Data::Mesh>( "skyBox" ); m_displayMesh->loadGeometry( std::move( skyMesh ) ); @@ -431,9 +429,9 @@ void EnvMap::setupTexturesFromCube() { std::string imgname; while ( getline( imgs, imgname, ';' ) ) { - int imgIdx{-1}; - bool flipV{false}; - bool flipH{false}; + int imgIdx{ -1 }; + bool flipV{ false }; + bool flipH{ false }; // is it a +X face ? if ( ( imgname.find( "posx" ) != imgname.npos ) || ( imgname.find( "-X-plux" ) != imgname.npos ) ) @@ -491,11 +489,11 @@ void EnvMap::setupTexturesFromCube() { void EnvMap::setupTexturesFromSphericalEquiRectangular() { auto ext = m_name.substr( m_name.size() - 3 ); - float* latlonPix{nullptr}; + float* latlonPix{ nullptr }; int n, w, h; if ( ext == "exr" ) { - const char* err{nullptr}; + const char* err{ nullptr }; int ret = LoadEXR( &latlonPix, &w, &h, m_name.c_str(), &err ); n = 4; if ( ret != TINYEXR_SUCCESS ) @@ -514,19 +512,17 @@ void EnvMap::setupTexturesFromSphericalEquiRectangular() { } int textureSize = 1; while ( textureSize < h ) - { - textureSize <<= 1; - } + { textureSize <<= 1; } textureSize >>= 1; // Bases to use to convert sphericalequirectangular images to cube faces // These bases allow to convert (u, v) cordinates of each faces to (x, y, z) in the frame of the // equirectangular map. : (x, y, z) = u*A[0] + v*A[1] + A[2] - Vector3 bases[6][3] = {{{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}, - {{1, 0, 0}, {0, -1, 0}, {0, 0, -1}}, - {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, - {{0, 0, -1}, {1, 0, 0}, {0, -1, 0}}, - {{0, 1, 0}, {1, 0, 0}, {0, 0, -1}}, - {{0, -1, 0}, {-1, 0, 0}, {0, 0, -1}}}; + Vector3 bases[6][3] = { { { -1, 0, 0 }, { 0, 1, 0 }, { 0, 0, -1 } }, + { { 1, 0, 0 }, { 0, -1, 0 }, { 0, 0, -1 } }, + { { 0, 0, 1 }, { 1, 0, 0 }, { 0, 1, 0 } }, + { { 0, 0, -1 }, { 1, 0, 0 }, { 0, -1, 0 } }, + { { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, -1 } }, + { { 0, -1, 0 }, { -1, 0, 0 }, { 0, 0, -1 } } }; auto sphericalPhi = []( const Vector3& d ) { Scalar p = std::atan2( d.x(), d.y() ); return ( p < 0 ) ? ( p + 2 * M_PI ) : p; @@ -544,7 +540,7 @@ void EnvMap::setupTexturesFromSphericalEquiRectangular() { { Vector3 d = bases[imgIdx][0] + u * bases[imgIdx][1] + v * bases[imgIdx][2]; d = d.normalized(); - Vector2 st{w * sphericalPhi( d ) / ( 2 * M_PI ), h * sphericalTheta( d ) / M_PI}; + Vector2 st{ w * sphericalPhi( d ) / ( 2 * M_PI ), h * sphericalTheta( d ) / M_PI }; // TODO : use st to access and filter the original envmap // for now, no filtering is done. (eq to GL_NEAREST) int s = int( st.x() ); @@ -571,9 +567,7 @@ void EnvMap::computeSHMatrices() { for ( int i = 0; i < 9; i++ ) { for ( int j = 0; j < 3; j++ ) - { - m_shcoefs[i][j] = 0.f; - } + { m_shcoefs[i][j] = 0.f; } } /// @todo replace this integration to use a sphere sampler ... /// Must evaluate the elementary solid angle for each sample @@ -767,20 +761,20 @@ Ra::Engine::Data::Texture* EnvMap::getSHImage() { thepixels[4 * ( j * ambientWidth + i ) + 3] = 255; } } - Ra::Engine::Data::TextureParameters params{"shImage", - GL_TEXTURE_2D, - ambientWidth, - ambientWidth, - 1, - GL_RGBA, - GL_RGBA, - GL_UNSIGNED_BYTE, - GL_CLAMP_TO_EDGE, - GL_CLAMP_TO_EDGE, - GL_CLAMP_TO_EDGE, - GL_LINEAR, - GL_LINEAR, - thepixels}; + Ra::Engine::Data::TextureParameters params{ "shImage", + GL_TEXTURE_2D, + ambientWidth, + ambientWidth, + 1, + GL_RGBA, + GL_RGBA, + GL_UNSIGNED_BYTE, + GL_CLAMP_TO_EDGE, + GL_CLAMP_TO_EDGE, + GL_CLAMP_TO_EDGE, + GL_LINEAR, + GL_LINEAR, + thepixels }; m_shtexture = std::make_unique<Ra::Engine::Data::Texture>( params ); return m_shtexture.get(); } @@ -811,7 +805,7 @@ void EnvMap::updateGL() { " mat4 mvp = transform.proj * transform.view;\n" " gl_Position = mvp*vec4(in_position.xyz, 1.0);\n" " var_texcoord = vec3(in_position.x, in_position.y, in_position.z);\n" - "}\n"}; + "}\n" }; const std::string fragmentShadersource{ "layout (location = 0) out vec4 out_color;\n" "in vec3 var_texcoord;\n" @@ -821,8 +815,8 @@ void EnvMap::updateGL() { "{\n" " vec3 envColor = texture(skytexture, normalize(var_texcoord)).rgb;\n" " out_color =vec4(strength*envColor, 1);\n" - "}\n"}; - Ra::Engine::Data::ShaderConfiguration config{"Built In SkyBox"}; + "}\n" }; + Ra::Engine::Data::ShaderConfiguration config{ "Built In SkyBox" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vertexShaderSource ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, @@ -848,7 +842,7 @@ void EnvMap::render( const Ra::Engine::Data::ViewingParameters& viewParams ) { // put this in a initializeGL method ? if ( !m_glReady ) { updateGL(); } auto skyparams = viewParams; - Ra::Core::Matrix3 t = Ra::Core::Transform{skyparams.viewMatrix}.linear(); + Ra::Core::Matrix3 t = Ra::Core::Transform{ skyparams.viewMatrix }.linear(); skyparams.viewMatrix.setIdentity(); skyparams.viewMatrix.topLeftCorner<3, 3>() = t; //\todo send camera to retrieve fov and aspect. diff --git a/src/libRender/RadiumNBR/EnvMap.hpp b/src/libRender/RadiumNBR/EnvMap.hpp index c68a05487e1aad7b0916b6cac2a90cc06c02f2c5..d15fdb683733f616afd5baa142a2445f6ad65458 100644 --- a/src/libRender/RadiumNBR/EnvMap.hpp +++ b/src/libRender/RadiumNBR/EnvMap.hpp @@ -122,21 +122,21 @@ class NodeBasedRenderer_LIBRARY_API EnvMap // The raw pixel values of the envmap float* m_skyData[6]; - size_t m_width{0}; - size_t m_height{0}; + size_t m_width{ 0 }; + size_t m_height{ 0 }; float m_shcoefs[9][3]; Ra::Core::Matrix4 m_shMatrices[3]; - std::unique_ptr<Ra::Engine::Data::Texture> m_shtexture{nullptr}; + std::unique_ptr<Ra::Engine::Data::Texture> m_shtexture{ nullptr }; /// Is the envmap a Skybox ? - bool m_isSkyBox{false}; + bool m_isSkyBox{ false }; /// The mesh of the skybox - std::unique_ptr<Ra::Engine::Data::Mesh> m_displayMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Mesh> m_displayMesh{ nullptr }; /// The texture of the skybox - std::unique_ptr<Ra::Engine::Data::Texture> m_skyTexture{nullptr}; + std::unique_ptr<Ra::Engine::Data::Texture> m_skyTexture{ nullptr }; /// The Lod to use for the skybox - float m_envStrength{1}; + float m_envStrength{ 1 }; /// The shader for the skybox - const Ra::Engine::Data::ShaderProgram* m_skyShader{nullptr}; - bool m_glReady{false}; + const Ra::Engine::Data::ShaderProgram* m_skyShader{ nullptr }; + bool m_glReady{ false }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Gui/GlslEditor.cpp b/src/libRender/RadiumNBR/Gui/GlslEditor.cpp index e98b6c6c87caa4abb06c364450dfe0f60842ff10..dc705f91901cea78b5ff9fce4a859ba84721317a 100644 --- a/src/libRender/RadiumNBR/Gui/GlslEditor.cpp +++ b/src/libRender/RadiumNBR/Gui/GlslEditor.cpp @@ -12,7 +12,7 @@ GlslEditor::GlslEditor( QWidget* parent ) : QCodeEditor( parent ) { // Creates a new code editor, sets the rules and design, adds it to the form setDesign( design ); setRules( rules ); - setKeywords( {"printf", "scanf", "atoi", "mbtoa", "strlen", "memcpy", "memset"} ); + setKeywords( { "printf", "scanf", "atoi", "mbtoa", "strlen", "memcpy", "memset" } ); // Connects the highlighter's onMatch signal to our printMatch slot connect( highlighter(), diff --git a/src/libRender/RadiumNBR/Gui/HoverPoints.cpp b/src/libRender/RadiumNBR/Gui/HoverPoints.cpp index 6232e66c9f4162024d022d44a0e8a690e1ad5f79..837926bf42b1431f5ae67a59bf51f6853e3ba758 100644 --- a/src/libRender/RadiumNBR/Gui/HoverPoints.cpp +++ b/src/libRender/RadiumNBR/Gui/HoverPoints.cpp @@ -48,112 +48,103 @@ #define printf -HoverPoints::HoverPoints(QWidget *widget, PointShape shape) - : QObject(widget) -{ +HoverPoints::HoverPoints( QWidget* widget, PointShape shape ) : QObject( widget ) { m_widget = widget; - widget->installEventFilter(this); - widget->setAttribute(Qt::WA_AcceptTouchEvents); + widget->installEventFilter( this ); + widget->setAttribute( Qt::WA_AcceptTouchEvents ); m_connectionType = CurveConnection; - m_sortType = NoSort; - m_shape = shape; - m_pointPen = QPen(QColor(255, 255, 255, 191), 1); - m_connectionPen = QPen(QColor(255, 255, 255, 127), 2); - m_pointBrush = QBrush(QColor(191, 191, 191, 127)); - m_pointSize = QSize(11, 11); - m_currentIndex = -1; - m_editable = true; - m_enabled = true; - - connect(this, SIGNAL(pointsChanged(QPolygonF)), - m_widget, SLOT(update())); + m_sortType = NoSort; + m_shape = shape; + m_pointPen = QPen( QColor( 255, 255, 255, 191 ), 1 ); + m_connectionPen = QPen( QColor( 255, 255, 255, 127 ), 2 ); + m_pointBrush = QBrush( QColor( 191, 191, 191, 127 ) ); + m_pointSize = QSize( 11, 11 ); + m_currentIndex = -1; + m_editable = true; + m_enabled = true; + + connect( this, SIGNAL( pointsChanged( QPolygonF ) ), m_widget, SLOT( update() ) ); } -void HoverPoints::setEnabled(bool enabled) -{ - if (m_enabled != enabled) +void HoverPoints::setEnabled( bool enabled ) { + if ( m_enabled != enabled ) { m_enabled = enabled; m_widget->update(); } } -bool HoverPoints::eventFilter(QObject *object, QEvent *event) -{ - if (object == m_widget && m_enabled) +bool HoverPoints::eventFilter( QObject* object, QEvent* event ) { + if ( object == m_widget && m_enabled ) { - switch (event->type()) + switch ( event->type() ) { case QEvent::MouseButtonPress: { - if (!m_fingerPointMapping.isEmpty()) - return true; - QMouseEvent *me = (QMouseEvent *) event; + if ( !m_fingerPointMapping.isEmpty() ) return true; + QMouseEvent* me = (QMouseEvent*)event; QPointF clickPos = me->pos(); - int index = -1; - for (int i = 0; i < m_points.size(); ++i) + int index = -1; + for ( int i = 0; i < m_points.size(); ++i ) { QPainterPath path; - if (m_shape == CircleShape) - path.addEllipse(pointBoundingRect(i)); + if ( m_shape == CircleShape ) + path.addEllipse( pointBoundingRect( i ) ); else - path.addRect(pointBoundingRect(i)); + path.addRect( pointBoundingRect( i ) ); - if (path.contains(clickPos)) + if ( path.contains( clickPos ) ) { index = i; break; } } - if (me->button() == Qt::LeftButton) + if ( me->button() == Qt::LeftButton ) { - if (index == -1) + if ( index == -1 ) { - if (!m_editable) - return false; + if ( !m_editable ) return false; int pos = 0; // Insert sort for x or y - if (m_sortType == XSort) + if ( m_sortType == XSort ) { - for (int i = 0; i < m_points.size(); ++i) - if (m_points.at(i).x() > clickPos.x()) + for ( int i = 0; i < m_points.size(); ++i ) + if ( m_points.at( i ).x() > clickPos.x() ) { pos = i; break; } } - else if (m_sortType == YSort) + else if ( m_sortType == YSort ) { - for (int i = 0; i < m_points.size(); ++i) - if (m_points.at(i).y() > clickPos.y()) + for ( int i = 0; i < m_points.size(); ++i ) + if ( m_points.at( i ).y() > clickPos.y() ) { pos = i; break; } } - m_points.insert(pos, clickPos); - m_locks.insert(pos, 0); + m_points.insert( pos, clickPos ); + m_locks.insert( pos, 0 ); m_currentIndex = pos; firePointChange(); } else - { - m_currentIndex = index; - } + { m_currentIndex = index; } return true; } - else if (me->button() == Qt::RightButton) + else if ( me->button() == Qt::RightButton ) { - if (index >= 0 && m_editable) + if ( index >= 0 && m_editable ) { - if (m_locks[index] == 0) + if ( m_locks[index] == 0 ) { - m_locks.remove(index); - m_points.remove(index); + m_locks.remove( index ); + m_points.remove( index ); } firePointChange(); return true; @@ -163,103 +154,100 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) break; case QEvent::MouseButtonRelease: - if (!m_fingerPointMapping.isEmpty()) - return true; + if ( !m_fingerPointMapping.isEmpty() ) return true; m_currentIndex = -1; break; case QEvent::MouseMove: - if (!m_fingerPointMapping.isEmpty()) - return true; - if (m_currentIndex >= 0) - movePoint(m_currentIndex, ((QMouseEvent *) event)->pos()); + if ( !m_fingerPointMapping.isEmpty() ) return true; + if ( m_currentIndex >= 0 ) movePoint( m_currentIndex, ( (QMouseEvent*)event )->pos() ); break; case QEvent::TouchBegin: case QEvent::TouchUpdate: { - const QTouchEvent *const touchEvent = static_cast<const QTouchEvent *>(event); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + const QTouchEvent* const touchEvent = static_cast<const QTouchEvent*>( event ); +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints(); #else const QList<QTouchEvent::TouchPoint> points = touchEvent->points(); #endif - const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); - foreach (const QTouchEvent::TouchPoint &touchPoint, points) + const qreal pointSize = qMax( m_pointSize.width(), m_pointSize.height() ); + foreach ( const QTouchEvent::TouchPoint& touchPoint, points ) { const int id = touchPoint.id(); - switch (touchPoint.state()) + switch ( touchPoint.state() ) { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) case Qt::TouchPointPressed: { #else case QEventPoint::Pressed: { #endif // find the point, move it - QSet<int> activePoints = QSet<int>(m_fingerPointMapping.begin(), m_fingerPointMapping.end()); + QSet<int> activePoints = + QSet<int>( m_fingerPointMapping.begin(), m_fingerPointMapping.end() ); int activePoint = -1; - const int pointsCount = m_points.size(); + const int pointsCount = m_points.size(); const int activePointCount = activePoints.size(); - if (pointsCount == 2 && activePointCount == 1) - {// only two points - activePoint = activePoints.contains(0) ? 1 : 0; + if ( pointsCount == 2 && activePointCount == 1 ) + { // only two points + activePoint = activePoints.contains( 0 ) ? 1 : 0; } else { qreal distance = -1; - for (int i = 0; i < pointsCount; ++i) + for ( int i = 0; i < pointsCount; ++i ) { - if (activePoints.contains(i)) - continue; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); + if ( activePoints.contains( i ) ) continue; +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + qreal d = QLineF( touchPoint.pos(), m_points.at( i ) ).length(); #else - qreal d = QLineF(touchPoint.position(), m_points.at(i)).length(); + qreal d = QLineF( touchPoint.position(), m_points.at( i ) ).length(); #endif - if ((distance < 0 && d < 12 * pointSize) || d < distance) + if ( ( distance < 0 && d < 12 * pointSize ) || d < distance ) { - distance = d; + distance = d; activePoint = i; } } } - if (activePoint != -1) + if ( activePoint != -1 ) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - movePoint(activePoint, touchPoint.pos()); + m_fingerPointMapping.insert( touchPoint.id(), activePoint ); +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + movePoint( activePoint, touchPoint.pos() ); #else - movePoint(activePoint, touchPoint.position()); + movePoint( activePoint, touchPoint.position() ); #endif } } break; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) case Qt::TouchPointReleased: { #else case QEventPoint::Released: { #endif // move the point and release - QHash<int, int>::iterator it = m_fingerPointMapping.find(id); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - movePoint(it.value(), touchPoint.pos()); + QHash<int, int>::iterator it = m_fingerPointMapping.find( id ); +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + movePoint( it.value(), touchPoint.pos() ); #else - movePoint(it.value(), touchPoint.position()); + movePoint( it.value(), touchPoint.position() ); #endif - m_fingerPointMapping.erase(it); + m_fingerPointMapping.erase( it ); } break; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) case Qt::TouchPointMoved: { #else case QEventPoint::Updated: { #endif // move the point - const int pointIdx = m_fingerPointMapping.value(id, -1); - if (pointIdx >= 0)// do we track this point? -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - movePoint(pointIdx, touchPoint.pos()); + const int pointIdx = m_fingerPointMapping.value( id, -1 ); + if ( pointIdx >= 0 ) // do we track this point? +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + movePoint( pointIdx, touchPoint.pos() ); #else - movePoint(pointIdx, touchPoint.position()); + movePoint( pointIdx, touchPoint.position() ); #endif } break; @@ -267,19 +255,17 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) break; } } - if (m_fingerPointMapping.isEmpty()) + if ( m_fingerPointMapping.isEmpty() ) { event->ignore(); return false; } else - { - return true; - } + { return true; } } break; case QEvent::TouchEnd: - if (m_fingerPointMapping.isEmpty()) + if ( m_fingerPointMapping.isEmpty() ) { event->ignore(); return false; @@ -288,15 +274,14 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) break; case QEvent::Resize: { - QResizeEvent *e = (QResizeEvent *) event; - if (e->oldSize().width() == 0 || e->oldSize().height() == 0) - break; - qreal stretch_x = e->size().width() / qreal(e->oldSize().width()); - qreal stretch_y = e->size().height() / qreal(e->oldSize().height()); - for (int i = 0; i < m_points.size(); ++i) + QResizeEvent* e = (QResizeEvent*)event; + if ( e->oldSize().width() == 0 || e->oldSize().height() == 0 ) break; + qreal stretch_x = e->size().width() / qreal( e->oldSize().width() ); + qreal stretch_y = e->size().height() / qreal( e->oldSize().height() ); + for ( int i = 0; i < m_points.size(); ++i ) { QPointF p = m_points[i]; - movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false); + movePoint( i, QPointF( p.x() * stretch_x, p.y() * stretch_y ), false ); } firePointChange(); @@ -304,9 +289,9 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) } case QEvent::Paint: { - QWidget *that_widget = m_widget; - m_widget = 0; - QApplication::sendEvent(object, event); + QWidget* that_widget = m_widget; + m_widget = 0; + QApplication::sendEvent( object, event ); m_widget = that_widget; paintPoints(); return true; @@ -319,132 +304,117 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) return false; } -void HoverPoints::paintPoints() -{ +void HoverPoints::paintPoints() { QPainter p; - p.begin(m_widget); + p.begin( m_widget ); - p.setRenderHint(QPainter::Antialiasing); + p.setRenderHint( QPainter::Antialiasing ); - if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) + if ( m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection ) { - p.setPen(m_connectionPen); + p.setPen( m_connectionPen ); - if (m_connectionType == CurveConnection) + if ( m_connectionType == CurveConnection ) { QPainterPath path; - path.moveTo(m_points.at(0)); - for (int i = 1; i < m_points.size(); ++i) + path.moveTo( m_points.at( 0 ) ); + for ( int i = 1; i < m_points.size(); ++i ) { - QPointF p1 = m_points.at(i - 1); - QPointF p2 = m_points.at(i); + QPointF p1 = m_points.at( i - 1 ); + QPointF p2 = m_points.at( i ); qreal distance = p2.x() - p1.x(); - path.cubicTo(p1.x() + distance / 2, p1.y(), - p1.x() + distance / 2, p2.y(), - p2.x(), p2.y()); + path.cubicTo( + p1.x() + distance / 2, p1.y(), p1.x() + distance / 2, p2.y(), p2.x(), p2.y() ); } - p.drawPath(path); + p.drawPath( path ); } else - { - p.drawPolyline(m_points); - } + { p.drawPolyline( m_points ); } } - p.setPen(m_pointPen); - p.setBrush(m_pointBrush); + p.setPen( m_pointPen ); + p.setBrush( m_pointBrush ); - for (int i = 0; i < m_points.size(); ++i) + for ( int i = 0; i < m_points.size(); ++i ) { - QRectF bounds = pointBoundingRect(i); - if (m_shape == CircleShape) - p.drawEllipse(bounds); + QRectF bounds = pointBoundingRect( i ); + if ( m_shape == CircleShape ) + p.drawEllipse( bounds ); else - p.drawRect(bounds); + p.drawRect( bounds ); } } -static QPointF bound_point(const QPointF &point, const QRectF &bounds, int lock) -{ +static QPointF bound_point( const QPointF& point, const QRectF& bounds, int lock ) { QPointF p = point; - qreal left = bounds.left(); - qreal right = bounds.right(); - qreal top = bounds.top(); + qreal left = bounds.left(); + qreal right = bounds.right(); + qreal top = bounds.top(); qreal bottom = bounds.bottom(); - if (p.x() < left || (lock & HoverPoints::LockToLeft)) - p.setX(left); - else if (p.x() > right || (lock & HoverPoints::LockToRight)) - p.setX(right); + if ( p.x() < left || ( lock & HoverPoints::LockToLeft ) ) + p.setX( left ); + else if ( p.x() > right || ( lock & HoverPoints::LockToRight ) ) + p.setX( right ); - if (p.y() < top || (lock & HoverPoints::LockToTop)) - p.setY(top); - else if (p.y() > bottom || (lock & HoverPoints::LockToBottom)) - p.setY(bottom); + if ( p.y() < top || ( lock & HoverPoints::LockToTop ) ) + p.setY( top ); + else if ( p.y() > bottom || ( lock & HoverPoints::LockToBottom ) ) + p.setY( bottom ); return p; } -void HoverPoints::setPoints(const QPolygonF &points) -{ - if (points.size() != m_points.size()) - m_fingerPointMapping.clear(); +void HoverPoints::setPoints( const QPolygonF& points ) { + if ( points.size() != m_points.size() ) m_fingerPointMapping.clear(); m_points.clear(); - for (int i = 0; i < points.size(); ++i) - m_points << bound_point(points.at(i), boundingRect(), 0); + for ( int i = 0; i < points.size(); ++i ) + m_points << bound_point( points.at( i ), boundingRect(), 0 ); m_locks.clear(); - if (m_points.size() > 0) + if ( m_points.size() > 0 ) { - m_locks.resize(m_points.size()); + m_locks.resize( m_points.size() ); - m_locks.fill(0); + m_locks.fill( 0 ); } } -void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate) -{ - m_points[index] = bound_point(point, boundingRect(), m_locks.at(index)); - if (emitUpdate) - firePointChange(); +void HoverPoints::movePoint( int index, const QPointF& point, bool emitUpdate ) { + m_points[index] = bound_point( point, boundingRect(), m_locks.at( index ) ); + if ( emitUpdate ) firePointChange(); } -inline static bool x_less_than(const QPointF &p1, const QPointF &p2) -{ +inline static bool x_less_than( const QPointF& p1, const QPointF& p2 ) { return p1.x() < p2.x(); } -inline static bool y_less_than(const QPointF &p1, const QPointF &p2) -{ +inline static bool y_less_than( const QPointF& p1, const QPointF& p2 ) { return p1.y() < p2.y(); } -void HoverPoints::firePointChange() -{ +void HoverPoints::firePointChange() { // printf("HoverPoints::firePointChange(), current=%d\n", m_currentIndex); - if (m_sortType != NoSort) + if ( m_sortType != NoSort ) { QPointF oldCurrent; - if (m_currentIndex != -1) - { - oldCurrent = m_points[m_currentIndex]; - } + if ( m_currentIndex != -1 ) { oldCurrent = m_points[m_currentIndex]; } - if (m_sortType == XSort) - std::sort(m_points.begin(), m_points.end(), x_less_than); - else if (m_sortType == YSort) - std::sort(m_points.begin(), m_points.end(), y_less_than); + if ( m_sortType == XSort ) + std::sort( m_points.begin(), m_points.end(), x_less_than ); + else if ( m_sortType == YSort ) + std::sort( m_points.begin(), m_points.end(), y_less_than ); // Compensate for changed order... - if (m_currentIndex != -1) + if ( m_currentIndex != -1 ) { - for (int i = 0; i < m_points.size(); ++i) + for ( int i = 0; i < m_points.size(); ++i ) { - if (m_points[i] == oldCurrent) + if ( m_points[i] == oldCurrent ) { m_currentIndex = i; break; @@ -460,5 +430,5 @@ void HoverPoints::firePointChange() // i, m_points.at(i).x(), m_points.at(i).y(), m_locks.at(i)); // } - emit pointsChanged(m_points); + emit pointsChanged( m_points ); } diff --git a/src/libRender/RadiumNBR/Gui/HoverPoints.hpp b/src/libRender/RadiumNBR/Gui/HoverPoints.hpp index 9c25f56b64470a2a206ed28641a8fd6eedc9645b..470b54a9adde6ced36782ab282750af3cad1edcc 100644 --- a/src/libRender/RadiumNBR/Gui/HoverPoints.hpp +++ b/src/libRender/RadiumNBR/Gui/HoverPoints.hpp @@ -42,89 +42,69 @@ #ifndef HOVERPOINTS_H #define HOVERPOINTS_H +#include <QHash> #include <QPen> #include <QWidget> -#include <QHash> -QT_FORWARD_DECLARE_CLASS(QBypassWidget) +QT_FORWARD_DECLARE_CLASS( QBypassWidget ) class HoverPoints : public QObject { Q_OBJECT -public: - enum PointShape - { - CircleShape, - RectangleShape - }; - - enum LockType - { - LockToLeft = 0x01, - LockToRight = 0x02, - LockToTop = 0x04, - LockToBottom = 0x08 - }; - - enum SortType - { - NoSort, - XSort, - YSort - }; - - enum ConnectionType - { - NoConnection, - LineConnection, - CurveConnection - }; - - HoverPoints(QWidget *widget, PointShape shape); - - bool eventFilter(QObject *object, QEvent *event); + public: + enum PointShape { CircleShape, RectangleShape }; + + enum LockType { LockToLeft = 0x01, LockToRight = 0x02, LockToTop = 0x04, LockToBottom = 0x08 }; + + enum SortType { NoSort, XSort, YSort }; + + enum ConnectionType { NoConnection, LineConnection, CurveConnection }; + + HoverPoints( QWidget* widget, PointShape shape ); + + bool eventFilter( QObject* object, QEvent* event ); void paintPoints(); inline QRectF boundingRect() const; - void setBoundingRect(const QRectF &boundingRect) { m_bounds = boundingRect; } + void setBoundingRect( const QRectF& boundingRect ) { m_bounds = boundingRect; } QPolygonF points() const { return m_points; } - void setPoints(const QPolygonF &points); + void setPoints( const QPolygonF& points ); QSizeF pointSize() const { return m_pointSize; } - void setPointSize(const QSizeF &size) { m_pointSize = size; } + void setPointSize( const QSizeF& size ) { m_pointSize = size; } SortType sortType() const { return m_sortType; } - void setSortType(SortType sortType) { m_sortType = sortType; } + void setSortType( SortType sortType ) { m_sortType = sortType; } ConnectionType connectionType() const { return m_connectionType; } - void setConnectionType(ConnectionType connectionType) { m_connectionType = connectionType; } + void setConnectionType( ConnectionType connectionType ) { m_connectionType = connectionType; } - void setConnectionPen(const QPen &pen) { m_connectionPen = pen; } - void setShapePen(const QPen &pen) { m_pointPen = pen; } - void setShapeBrush(const QBrush &brush) { m_pointBrush = brush; } + void setConnectionPen( const QPen& pen ) { m_connectionPen = pen; } + void setShapePen( const QPen& pen ) { m_pointPen = pen; } + void setShapeBrush( const QBrush& brush ) { m_pointBrush = brush; } - void setPointLock(int pos, LockType lock) { m_locks[pos] = lock; } + void setPointLock( int pos, LockType lock ) { m_locks[pos] = lock; } - void setEditable(bool editable) { m_editable = editable; } + void setEditable( bool editable ) { m_editable = editable; } bool editable() const { return m_editable; } -public slots: - void setEnabled(bool enabled); - void setDisabled(bool disabled) { setEnabled(!disabled); } + public slots: + void setEnabled( bool enabled ); + void setDisabled( bool disabled ) { setEnabled( !disabled ); } -signals: - void pointsChanged(const QPolygonF &points); + signals: + void pointsChanged( const QPolygonF& points ); -public: + public: void firePointChange(); -private: - inline QRectF pointBoundingRect(int i) const; - void movePoint(int i, const QPointF &newPos, bool emitChange = true); + private: + inline QRectF pointBoundingRect( int i ) const; + void movePoint( int i, const QPointF& newPos, bool emitChange = true ); - QWidget *m_widget; + QWidget* m_widget; QPolygonF m_points; QRectF m_bounds; @@ -146,22 +126,20 @@ private: QPen m_connectionPen; }; -inline QRectF HoverPoints::pointBoundingRect(int i) const -{ - QPointF p = m_points.at(i); - qreal w = m_pointSize.width(); - qreal h = m_pointSize.height(); - qreal x = p.x() - w / 2; - qreal y = p.y() - h / 2; - return QRectF(x, y, w, h); +inline QRectF HoverPoints::pointBoundingRect( int i ) const { + QPointF p = m_points.at( i ); + qreal w = m_pointSize.width(); + qreal h = m_pointSize.height(); + qreal x = p.x() - w / 2; + qreal y = p.y() - h / 2; + return QRectF( x, y, w, h ); } -inline QRectF HoverPoints::boundingRect() const -{ - if (m_bounds.isEmpty()) +inline QRectF HoverPoints::boundingRect() const { + if ( m_bounds.isEmpty() ) return m_widget->rect(); else return m_bounds; } -#endif// HOVERPOINTS_H +#endif // HOVERPOINTS_H diff --git a/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.cpp b/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.cpp index 46414a16a5f461f1a8d3794c6599f4cd3f5f4985..ca4dd2e7e17270487b8ffdbe724ba7e8cf029ae5 100644 --- a/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.cpp +++ b/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.cpp @@ -4,8 +4,9 @@ namespace RadiumNBR { using namespace Gui; -RadiumNBR::Gui::RendererPanel* buildMultiPassControllerGui( MultiPassRenderer* renderer, - const std::function<void()>& appUpdateCallback ) { +RadiumNBR::Gui::RendererPanel* +buildMultiPassControllerGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ) { auto& controller = dynamic_cast<MultiPassController&>( renderer->getController() ); auto controlPanel = new RendererPanel( renderer->getRendererName() ); diff --git a/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.hpp b/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.hpp index f45fba8dea75ce9ac4023c59c53d6d88be7de2a9..666d8028c37554a2ecd553c42694be5e7651ba7b 100644 --- a/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.hpp +++ b/src/libRender/RadiumNBR/Gui/MultiPassControllerGui.hpp @@ -6,6 +6,7 @@ namespace RadiumNBR { class MultiPassRenderer; NodeBasedRenderer_LIBRARY_API RadiumNBR::Gui::RendererPanel* -buildMultiPassControllerGui( MultiPassRenderer* renderer, const std::function<void()>& appUpdateCallback ); +buildMultiPassControllerGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ); } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp index 7d1248ec7b3bc128f5c72789594e1ea0ebd251a1..68df1e4b617a2961ecfd023f8b0986c39a01b4d9 100644 --- a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp +++ b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp @@ -4,23 +4,23 @@ #include <RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp> #include <nodes/FlowScene> -#include<optional> +#include <optional> #include <QFileDialog> - namespace RadiumNBR { using namespace Gui; using QtNodes::FlowScene; -RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* renderer, - const std::function<void()>& appUpdateCallback ) { +RadiumNBR::Gui::RendererPanel* +buildNodeGraphControllerGui( NodeBasedRenderer* renderer, + const std::function<void()>& appUpdateCallback ) { auto& controller = dynamic_cast<NodeGraphController&>( renderer->getController() ); auto controlPanel = new RendererPanel( renderer->getRendererName() ); - auto nodeEditor = new RenderGraphEditorView( nullptr ); + auto nodeEditor = new RenderGraphEditorView( nullptr ); nodeEditor->current = renderer; auto editorRegistry = NodeGraphQtEditor::initializeNodeRegistry( renderer->getRenderGraph() ); nodeEditor->scene->setRegistry( editorRegistry ); @@ -28,21 +28,23 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r // TODO: find a way to refresh the main window when a widget gets updated instead of // when the mouse moves nodeEditor->connections.push_back( - QObject::connect( nodeEditor, &RenderGraphEditorView::mouseMoved, appUpdateCallback) ); + QObject::connect( nodeEditor, &RenderGraphEditorView::mouseMoved, appUpdateCallback ) ); - auto loadGraph = [nodeEditor, renderer, appUpdateCallback](){ + auto loadGraph = [nodeEditor, renderer, appUpdateCallback]() { QString fileName = QFileDialog::getOpenFileName( nullptr, "Open Flow Scene", QDir::homePath(), "Flow Scene Files (*.flow)" ); - if ( QFileInfo::exists( fileName ) ) { + if ( QFileInfo::exists( fileName ) ) + { QFile file( fileName ); - if ( file.open( QIODevice::ReadOnly ) ) { + if ( file.open( QIODevice::ReadOnly ) ) + { nodeEditor->scene->clearScene(); renderer->getRenderGraph()->clearNodes(); QByteArray wholeFile = file.readAll(); nodeEditor->scene->loadFromMemory( wholeFile ); nodeEditor->setWindowTitle( std::string( "RenderGraph Node Editor - " + - renderer->getRendererName() + - " - " + fileName.toStdString() ) + renderer->getRendererName() + " - " + + fileName.toStdString() ) .c_str() ); renderer->setJsonFilePath( fileName.toStdString() ); nodeEditor->scene->setSceneName( fileName ); @@ -51,7 +53,7 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r } }; - auto saveGraphToFile = [](const std::string& filename, FlowScene* scene){ + auto saveGraphToFile = []( const std::string& filename, FlowScene* scene ) { if ( !filename.empty() && QFileInfo::exists( filename.c_str() ) ) { QFile file( filename.c_str() ); @@ -60,10 +62,8 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r } else { - QString newFileName = QFileDialog::getSaveFileName( nullptr, - "Save Flow Scene", - filename.c_str(), - "Flow Scene Files (*.flow)" ); + QString newFileName = QFileDialog::getSaveFileName( + nullptr, "Save Flow Scene", filename.c_str(), "Flow Scene Files (*.flow)" ); if ( !newFileName.isEmpty() ) { if ( !newFileName.endsWith( "flow", Qt::CaseInsensitive ) ) newFileName += ".flow"; @@ -75,23 +75,21 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r } }; - auto saveGraph = [nodeEditor, renderer, saveGraphToFile](){ - saveGraphToFile( renderer->getJsonFilePath() , nodeEditor->scene); + auto saveGraph = [nodeEditor, renderer, saveGraphToFile]() { + saveGraphToFile( renderer->getJsonFilePath(), nodeEditor->scene ); }; - auto saveGraphAs = [nodeEditor, renderer, saveGraphToFile](){ - auto filename = saveGraphToFile( "" , nodeEditor->scene); + auto saveGraphAs = [nodeEditor, renderer, saveGraphToFile]() { + auto filename = saveGraphToFile( "", nodeEditor->scene ); renderer->setJsonFilePath( filename ); nodeEditor->setWindowTitle( std::string( "RenderGraph Node Editor - " + - renderer->getRendererName() + " - " + - filename ) + renderer->getRendererName() + " - " + filename ) .c_str() ); }; - auto newGraph = [nodeEditor, renderer, appUpdateCallback](){ + auto newGraph = [nodeEditor, renderer, appUpdateCallback]() { nodeEditor->setWindowTitle( std::string( "RenderGraph Node Editor - " + - renderer->getRendererName() + - " - New graph" ) + renderer->getRendererName() + " - New graph" ) .c_str() ); nodeEditor->scene->clearScene(); @@ -99,40 +97,45 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r appUpdateCallback(); }; - nodeEditor->connections.push_back( QObject::connect( - nodeEditor->openAction, &QAction::triggered, loadGraph) ); - - nodeEditor->connections.push_back( QObject::connect( - nodeEditor->saveAsAction, &QAction::triggered, saveGraphAs) ); + nodeEditor->connections.push_back( + QObject::connect( nodeEditor->openAction, &QAction::triggered, loadGraph ) ); - nodeEditor->connections.push_back( QObject::connect( - nodeEditor->saveAction, &QAction::triggered, saveGraph) ); + nodeEditor->connections.push_back( + QObject::connect( nodeEditor->saveAsAction, &QAction::triggered, saveGraphAs ) ); nodeEditor->connections.push_back( - QObject::connect( nodeEditor->newAction, &QAction::triggered, newGraph) ); + QObject::connect( nodeEditor->saveAction, &QAction::triggered, saveGraph ) ); + nodeEditor->connections.push_back( + QObject::connect( nodeEditor->newAction, &QAction::triggered, newGraph ) ); - auto show_hideNodeEditor = [renderer, nodeEditor]() { + auto show_hideNodeEditor = [renderer, nodeEditor]() { if ( !nodeEditor->isVisible() ) { // Fill the flowscene in the editor with the current graph if any - if ( renderer->getJsonFilePath() != "" ) { + if ( renderer->getJsonFilePath() != "" ) + { // Fill the editor with the current graph ... - // TODO modify the editor to reflect exactly the same graph than in the renderer (e.g. if adding a node programatically, update the flowscene - if ( nodeEditor->scene->getSceneName().compare( renderer->getJsonFilePath().c_str() ) != 0) { + // TODO modify the editor to reflect exactly the same graph than in the renderer + // (e.g. if adding a node programatically, update the flowscene + if ( nodeEditor->scene->getSceneName().compare( + renderer->getJsonFilePath().c_str() ) != 0 ) + { if ( QFileInfo::exists( renderer->getJsonFilePath().c_str() ) ) { QFile file( renderer->getJsonFilePath().c_str() ); if ( file.open( QIODevice::ReadOnly ) ) { - std::cerr << "Loading nodegraph " << renderer->getJsonFilePath() << " in the editor." << std::endl; + std::cerr << "Loading nodegraph " << renderer->getJsonFilePath() + << " in the editor." << std::endl; nodeEditor->scene->clearScene(); renderer->getRenderGraph()->clearNodes(); QByteArray wholeFile = file.readAll(); nodeEditor->scene->loadFromMemory( wholeFile ); nodeEditor->scene->setSceneName( renderer->getJsonFilePath().c_str() ); nodeEditor->setWindowTitle( std::string( "RenderGraph Node Editor - " + - renderer->getRendererName() + " - " + + renderer->getRendererName() + + " - " + renderer->getJsonFilePath() ) .c_str() ); } @@ -140,11 +143,11 @@ RadiumNBR::Gui::RendererPanel* buildNodeGraphControllerGui( NodeBasedRenderer* r } } - nodeEditor->resize(800, 600); + nodeEditor->resize( 800, 600 ); nodeEditor->show(); - } else { - nodeEditor->hide(); } + else + { nodeEditor->hide(); } }; controlPanel->addButton( "Node Editor", show_hideNodeEditor ); diff --git a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.hpp b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.hpp index c85733f47b93cc93c9320179ea8b2e7836dea7be..47ba6da1d9d7842d50965996cbbc41774c441158 100644 --- a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.hpp +++ b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.hpp @@ -6,6 +6,7 @@ namespace RadiumNBR { class NodeBasedRenderer; NodeBasedRenderer_LIBRARY_API RadiumNBR::Gui::RendererPanel* -buildNodeGraphControllerGui( NodeBasedRenderer* renderer, const std::function<void()>& appUpdateCallback ); +buildNodeGraphControllerGui( NodeBasedRenderer* renderer, + const std::function<void()>& appUpdateCallback ); } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Gui/PowerSlider.hpp b/src/libRender/RadiumNBR/Gui/PowerSlider.hpp index 2025a178b91466be40859812f211176e6de69047..c55967eebd355df39f6e3470b9c029354993fb7e 100644 --- a/src/libRender/RadiumNBR/Gui/PowerSlider.hpp +++ b/src/libRender/RadiumNBR/Gui/PowerSlider.hpp @@ -4,8 +4,8 @@ #ifdef ENABLE_QDOM # include <QDomElement> #endif -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <QWidget> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #ifdef POWERSLIDER_DESIGNER_PLUGIN # include <QtUiPlugin/QDesignerExportWidget> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectNameModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectNameModel.hpp index b97626e72c2e7ae3426d420096e448342c75166f..557970783a9d83054897f70268edde1e3cb5755d 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectNameModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectNameModel.hpp @@ -1,7 +1,7 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <QtCore/QObject> #include <QtWidgets/QLineEdit> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <nodes/NodeDataModel> @@ -59,7 +59,7 @@ class NodeBasedRenderer_LIBRARY_API FilterRenderObjectNameModel : public QtNodes m_node, m_node->getInputs()[port]->getName() ); - m_validationError = ""; + m_validationError = ""; m_validationState = QtNodes::NodeValidationState::Valid; } else diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.cpp index c570d239e822d56f4e95ef27f528abe4eb98f45f..413029ef3887f76ec54ebbdac730cf62618702b2 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.cpp @@ -1,4 +1,4 @@ -#include <RadiumNBR/Gui/RenderGraphEditor//FilterRenderObjectTypeModel.hpp> +#include <RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp> #include <Engine/Data/Material.hpp> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp index c74ca912a919e0aa5af6882aabcc37441ecdde3d..1b838eb87be91cf3ae8e780432ce4ea9b28cb8b1 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp @@ -1,7 +1,7 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <QtCore/QObject> #include <QtWidgets/QComboBox> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <nodes/NodeDataModel> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp index 22550e49315936c404f21201c0f55f94ff876cdb..b1424377b02f8a34715d1cfe326521db3b8c3000 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp @@ -1,27 +1,26 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp> #include <QtCore/QObject> #include <QtWidgets/QLabel> +#include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp> #include <nodes/NodeDataModel> #include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp> #include <RadiumNBR/NodeGraph/Node.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> #include <RadiumNBR/Gui/RendererPanel.hpp> #include <iostream> -QWidget* getWidget(Node* node) { +QWidget* getWidget( Node* node ) { if ( node->getEditableParameters().size() == 0 ) { return nullptr; } - auto controlPanel = - new RadiumNBR::Gui::RendererPanel( "Editable parameters", false, nullptr ); + auto controlPanel = new RadiumNBR::Gui::RendererPanel( "Editable parameters", false, nullptr ); controlPanel->beginLayout( QBoxLayout::TopToBottom ); for ( size_t i = 0; i < node->getEditableParameters().size(); i++ ) { @@ -50,7 +49,7 @@ class NodeAdapterModel : public QtNodes::NodeDataModel m_renderGraph->addNode( m_node ); m_inputsConnected.resize( m_node->getInputs().size() ); - m_widget = getWidget(m_node); + m_widget = getWidget( m_node ); checkConnections(); } @@ -59,14 +58,11 @@ class NodeAdapterModel : public QtNodes::NodeDataModel m_renderGraph->removeNode( m_node ); m_renderGraph->m_recompile = true; } + public: - NodeAdapterModel( RenderGraph* renderGraph ) : m_renderGraph( renderGraph ) { - init(); - } + NodeAdapterModel( RenderGraph* renderGraph ) : m_renderGraph( renderGraph ) { init(); } - ~NodeAdapterModel() override { - destroy(); - } + ~NodeAdapterModel() override { destroy(); } public: QString caption() const override { return NodeAdapterModel::Name(); } @@ -203,7 +199,7 @@ class NodeAdapterModel : public QtNodes::NodeDataModel public: QJsonObject save() const override { return QtNodes::NodeDataModel::save(); } - void restore(QJsonObject const & p) override { QtNodes::NodeDataModel::restore(p); } + void restore( QJsonObject const& p ) override { QtNodes::NodeDataModel::restore( p ); } }; #include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.inl> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.inl b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.inl index 328bd2b4e6d4e0a34fc36200e3a274349e68b3cc..4b092891dfa7bd842374bfe24024ef6ff7e0b512 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.inl +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.inl @@ -22,35 +22,27 @@ void NodeAdapterModel<DataNode<NodeTypeCamera>>::init() { template <> void NodeAdapterModel<DisplaySinkNode>::init() { - m_node = m_renderGraph->getDisplayNode(); + m_node = m_renderGraph->getDisplayNode(); m_inputsConnected.resize( m_node->getInputs().size() ); checkConnections(); } template <> -void NodeAdapterModel<DataNode<NodeTypeRenderObject>>::destroy() { - -} +void NodeAdapterModel<DataNode<NodeTypeRenderObject>>::destroy() {} template <> -void NodeAdapterModel<DataNode<NodeTypeLight>>::destroy() { - -} +void NodeAdapterModel<DataNode<NodeTypeLight>>::destroy() {} template <> -void NodeAdapterModel<DataNode<NodeTypeCamera>>::destroy() { - -} +void NodeAdapterModel<DataNode<NodeTypeCamera>>::destroy() {} template <> -void NodeAdapterModel<DisplaySinkNode>::destroy() { - -} +void NodeAdapterModel<DisplaySinkNode>::destroy() {} // --------- // method specialization for models with internal parameters -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> #include <RadiumNBR/Gui/PowerSlider.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> #include <filesystem> template <> QJsonObject NodeAdapterModel<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>::save() const { @@ -62,7 +54,8 @@ QJsonObject NodeAdapterModel<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>::sa } template <> -void NodeAdapterModel<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>::restore( QJsonObject const& p ) { +void NodeAdapterModel<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>::restore( + QJsonObject const& p ) { auto controlPanel = dynamic_cast<RadiumNBR::Gui::RendererPanel*>( m_widget ); QJsonValue n = p["files"]; diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp index 415c2535958442d66a9a94186e0f8c5dda955fb8..f0ec68bfc2a4139a9d5c046e824a6d49ba3f4948 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp @@ -1,10 +1,10 @@ #include <RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp> -#include <QVBoxLayout> #include <QCheckBox> -#include <QPushButton> #include <QColorDialog> #include <QCoreApplication> +#include <QPushButton> +#include <QVBoxLayout> #include <RadiumNBR/EnvMap.hpp> @@ -16,9 +16,9 @@ #include <nodes/NodeData> -#include <RadiumNBR/NodeBasedRenderer.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp> #include <RadiumNBR/Gui/RendererPanel.hpp> +#include <RadiumNBR/NodeBasedRenderer.hpp> RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( parent, Qt::Window ) { QtNodes::ConnectionStyle::setConnectionStyle( @@ -70,159 +70,148 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren // Create widgets WidgetFactory::registerWidget<std::shared_ptr<RadiumNBR::EnvMap>>( - [] (EditableParameterBase* editableParameter) { - auto editableEnvMap = - dynamic_cast<EditableParameter<std::shared_ptr<RadiumNBR::EnvMap>>*>( editableParameter ); - - auto controlPanel = new RadiumNBR::Gui::RendererPanel( "EnvMap", false ); - auto envmpClbck = [editableEnvMap, controlPanel]( const std::string& files ) { - if ( files.empty() ) { editableEnvMap->m_data = nullptr; } - else - { - auto t = ( files.find( ';' ) != files.npos ) - ? RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE - : RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM; - if ( t == RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM ) + []( EditableParameterBase* editableParameter ) { + auto editableEnvMap = + dynamic_cast<EditableParameter<std::shared_ptr<RadiumNBR::EnvMap>>*>( + editableParameter ); + + auto controlPanel = new RadiumNBR::Gui::RendererPanel( "EnvMap", false ); + auto envmpClbck = [editableEnvMap, controlPanel]( const std::string& files ) { + if ( files.empty() ) { editableEnvMap->m_data = nullptr; } + else { - auto ext = files.substr( files.size() - 3 ); - if ( ext != "pfm" ) { t = RadiumNBR::EnvMap::EnvMapType::ENVMAP_LATLON; } + auto t = ( files.find( ';' ) != files.npos ) + ? RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE + : RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM; + if ( t == RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM ) + { + auto ext = files.substr( files.size() - 3 ); + if ( ext != "pfm" ) { t = RadiumNBR::EnvMap::EnvMapType::ENVMAP_LATLON; } + } + // for now, only skyboxes are managed + editableEnvMap->m_data = std::make_shared<RadiumNBR::EnvMap>( files, t, true ); + auto slider = controlPanel->findChild<PowerSlider*>( "Strength" ); + if ( slider ) + { editableEnvMap->m_data->setEnvStrength( slider->value() / 100. ); } } - // for now, only skyboxes are managed - editableEnvMap->m_data = std::make_shared<RadiumNBR::EnvMap>( files, t, true ); - auto slider = controlPanel->findChild<PowerSlider*>( "Strength" ); - if ( slider ) { editableEnvMap->m_data->setEnvStrength( slider->value() / 100. ); } - } - }; - controlPanel->addFileInput( - "Image(s)", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" ); - - auto strengthClbk = [editableEnvMap]( double v ) { + }; + controlPanel->addFileInput( + "Image(s)", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" ); + + auto strengthClbk = [editableEnvMap]( double v ) { + if ( editableEnvMap->m_data ) + { + auto* env = editableEnvMap->m_data.get(); + if ( env ) { env->setEnvStrength( v / 100. ); } + } + }; + float s_init = 100.; if ( editableEnvMap->m_data ) - { - auto* env = editableEnvMap->m_data.get(); - if ( env ) { env->setEnvStrength( v / 100. ); } - } - }; - float s_init = 100.; - if ( editableEnvMap->m_data ) { s_init = editableEnvMap->m_data->getEnvStrength() * 100.; } - controlPanel->addPowerSliderInput( "Strength", strengthClbk, s_init, 0., 100 ); - controlPanel->setVisible( true ); - return controlPanel; - } - ); - - WidgetFactory::registerWidget<Scalar>( - [] (EditableParameterBase* editableParameter) { - auto editableScalar = - dynamic_cast<EditableParameter<Scalar>*>( editableParameter ); - - auto powerSlider = new PowerSlider(); - powerSlider->setValue( editableScalar->m_data ); - if ( editableScalar->additionalData.size() >= 2 ) - { - powerSlider->setRange( editableScalar->additionalData[0], - editableScalar->additionalData[1] ); - } - else - { powerSlider->setRange( 0.0, 9999.0 ); - } - PowerSlider::connect( powerSlider, - &PowerSlider::valueChanged, - [editableScalar]( double value ) { - editableScalar->m_data = value; - } ); - return powerSlider; + { s_init = editableEnvMap->m_data->getEnvStrength() * 100.; } + controlPanel->addPowerSliderInput( "Strength", strengthClbk, s_init, 0., 100 ); + controlPanel->setVisible( true ); + return controlPanel; + } ); + + WidgetFactory::registerWidget<Scalar>( []( EditableParameterBase* editableParameter ) { + auto editableScalar = dynamic_cast<EditableParameter<Scalar>*>( editableParameter ); + + auto powerSlider = new PowerSlider(); + powerSlider->setValue( editableScalar->m_data ); + if ( editableScalar->additionalData.size() >= 2 ) + { + powerSlider->setRange( editableScalar->additionalData[0], + editableScalar->additionalData[1] ); } - ); - - WidgetFactory::registerWidget<bool>( - [] (EditableParameterBase* editableParameter) { - auto editableBoolean = - dynamic_cast<EditableParameter<bool>*>( editableParameter ); - - auto checkBox = new QCheckBox(); - checkBox->setCheckState(editableBoolean->m_data ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); - QCheckBox::connect( checkBox, &QCheckBox::stateChanged, [editableBoolean]( int state ) { - if ( state == Qt::Unchecked ) { editableBoolean->m_data = false; } - else if ( state == Qt::Checked ) - { editableBoolean->m_data = true; } + else + { powerSlider->setRange( 0.0, 9999.0 ); } + PowerSlider::connect( + powerSlider, &PowerSlider::valueChanged, [editableScalar]( double value ) { + editableScalar->m_data = value; } ); - return checkBox; - } - ); - - WidgetFactory::registerWidget<NodeTypeColor>( - [] (EditableParameterBase* editableParameter) { - auto editableColor = - dynamic_cast<EditableParameter<NodeTypeColor>*>( editableParameter ); - - auto button = new QPushButton( "Open widget" ); - auto colorDialog = new QColorDialog(); -#if !defined(__APPLE__) - colorDialog->setOption(QColorDialog::DontUseNativeDialog); + return powerSlider; + } ); + + WidgetFactory::registerWidget<bool>( []( EditableParameterBase* editableParameter ) { + auto editableBoolean = dynamic_cast<EditableParameter<bool>*>( editableParameter ); + + auto checkBox = new QCheckBox(); + checkBox->setCheckState( editableBoolean->m_data ? Qt::CheckState::Checked + : Qt::CheckState::Unchecked ); + QCheckBox::connect( checkBox, &QCheckBox::stateChanged, [editableBoolean]( int state ) { + if ( state == Qt::Unchecked ) { editableBoolean->m_data = false; } + else if ( state == Qt::Checked ) + { editableBoolean->m_data = true; } + } ); + return checkBox; + } ); + + WidgetFactory::registerWidget<NodeTypeColor>( []( EditableParameterBase* editableParameter ) { + auto editableColor = dynamic_cast<EditableParameter<NodeTypeColor>*>( editableParameter ); + + auto button = new QPushButton( "Open widget" ); + auto colorDialog = new QColorDialog(); +#if !defined( __APPLE__ ) + colorDialog->setOption( QColorDialog::DontUseNativeDialog ); #endif - QColor tmpColor; - tmpColor.setRed( editableColor->m_data.x() * 255); - tmpColor.setRed( editableColor->m_data.y() * 255); - tmpColor.setRed( editableColor->m_data.z() * 255); - colorDialog->setCurrentColor( tmpColor ); - ColorSlider::connect( colorDialog, &QColorDialog::currentColorChanged, [editableColor]( QColor value ) { + QColor tmpColor; + tmpColor.setRed( editableColor->m_data.x() * 255 ); + tmpColor.setRed( editableColor->m_data.y() * 255 ); + tmpColor.setRed( editableColor->m_data.z() * 255 ); + colorDialog->setCurrentColor( tmpColor ); + ColorSlider::connect( + colorDialog, &QColorDialog::currentColorChanged, [editableColor]( QColor value ) { int newR, newG, newB; value.getRgb( &newR, &newG, &newB ); - editableColor->m_data = ( NodeTypeColor::sRGBToLinearRGB(NodeTypeColor::fromRGB( + editableColor->m_data = ( NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB( Ra::Core::Utils::ColorBase<float>( newR / 255.0f, newG / 255.0f, newB / 255.0f ) .rgb() ) ) ); } ); - connect(button, &QPushButton::clicked, [colorDialog] () { - colorDialog->show(); - }); + connect( button, &QPushButton::clicked, [colorDialog]() { colorDialog->show(); } ); - return button; - } - ); + return button; + } ); WidgetFactory::registerWidget<std::array<float, 256 * 4>>( []( EditableParameterBase* editableParameter ) { auto editableTransferFunction = - dynamic_cast<EditableParameter<std::array<float, 256 * 4>>*>( - editableParameter ); + dynamic_cast<EditableParameter<std::array<float, 256 * 4>>*>( editableParameter ); - auto button = new QPushButton( "Open widget" ); + auto button = new QPushButton( "Open widget" ); auto transferEditor = new TransferEditor(); - TransferEditor::connect( transferEditor, - &TransferEditor::propertiesChanged, - [editableTransferFunction, transferEditor]() { - int pos = 0; - for (int i = 0; i < 256; i++) { - unsigned int color = transferEditor->colorAt( i ); - editableTransferFunction->m_data.at(pos) = - (unsigned char)( ( 0x00ff0000 & color ) >> 16 ) / 255.f; - editableTransferFunction->m_data.at( pos + 1 ) = - (unsigned char)( ( 0x0000ff00 & color ) >> 8 ) / 255.f; - editableTransferFunction->m_data.at( pos + 2 ) = - (unsigned char)( ( 0x000000ff & color ) ) / 255.f; - editableTransferFunction->m_data.at( pos + 3 ) = - (unsigned char)( ( 0xff000000 & color ) >> 24 ) / 255.f; - pos = pos + 4; - } - } ); - connect( button, &QPushButton::clicked, [transferEditor]() { - transferEditor->show(); - } ); + TransferEditor::connect( + transferEditor, + &TransferEditor::propertiesChanged, + [editableTransferFunction, transferEditor]() { + int pos = 0; + for ( int i = 0; i < 256; i++ ) + { + unsigned int color = transferEditor->colorAt( i ); + editableTransferFunction->m_data.at( pos ) = + (unsigned char)( ( 0x00ff0000 & color ) >> 16 ) / 255.f; + editableTransferFunction->m_data.at( pos + 1 ) = + (unsigned char)( ( 0x0000ff00 & color ) >> 8 ) / 255.f; + editableTransferFunction->m_data.at( pos + 2 ) = + (unsigned char)( ( 0x000000ff & color ) ) / 255.f; + editableTransferFunction->m_data.at( pos + 3 ) = + (unsigned char)( ( 0xff000000 & color ) >> 24 ) / 255.f; + pos = pos + 4; + } + } ); + connect( + button, &QPushButton::clicked, [transferEditor]() { transferEditor->show(); } ); return button; - } - ); + } ); } - -#include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectNameModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/FilterRenderObjectTypeModel.hpp> +#include <RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.hpp> @@ -245,20 +234,14 @@ class NodeCreator }; using namespace QtNodes; -std::shared_ptr<DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGraph) { +std::shared_ptr<DataModelRegistry> initializeNodeRegistry( RenderGraph* renderGraph ) { auto ret = std::make_shared<DataModelRegistry>(); ret->registerModel<NodeAdapterModel<DataNode<NodeTypeRenderObject>>>( - NodeCreator<NodeAdapterModel<DataNode<NodeTypeRenderObject>>>( - renderGraph ), - "Data" ); + NodeCreator<NodeAdapterModel<DataNode<NodeTypeRenderObject>>>( renderGraph ), "Data" ); ret->registerModel<NodeAdapterModel<DataNode<NodeTypeLight>>>( - NodeCreator<NodeAdapterModel<DataNode<NodeTypeLight>>>( - renderGraph ), - "Data" ); + NodeCreator<NodeAdapterModel<DataNode<NodeTypeLight>>>( renderGraph ), "Data" ); ret->registerModel<NodeAdapterModel<DataNode<NodeTypeCamera>>>( - NodeCreator<NodeAdapterModel<DataNode<NodeTypeCamera>>>( - renderGraph ), - "Data" ); + NodeCreator<NodeAdapterModel<DataNode<NodeTypeCamera>>>( renderGraph ), "Data" ); ret->registerModel<FilterRenderObjectNameModel>( NodeCreator<FilterRenderObjectNameModel>( renderGraph ), "Filters" ); @@ -266,43 +249,30 @@ std::shared_ptr<DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGra NodeCreator<FilterRenderObjectTypeModel>( renderGraph ), "Filters" ); ret->registerModel<NodeAdapterModel<ClearColorNode>>( - NodeCreator<NodeAdapterModel<ClearColorNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<ClearColorNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<ZGeomPrepassNode>>( - NodeCreator<NodeAdapterModel<ZGeomPrepassNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<ZGeomPrepassNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<AccessibilityBufferNode>>( - NodeCreator<NodeAdapterModel<AccessibilityBufferNode>>( - renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<AccessibilityBufferNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<EnvLightNode>>( - NodeCreator<NodeAdapterModel<EnvLightNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<EnvLightNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<LocalLightNode>>( - NodeCreator<NodeAdapterModel<LocalLightNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<LocalLightNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<EmissivityNode>>( - NodeCreator<NodeAdapterModel<EmissivityNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<EmissivityNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<TransparencyNode>>( - NodeCreator<NodeAdapterModel<TransparencyNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<TransparencyNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<VolumeNode>>( - NodeCreator<NodeAdapterModel<VolumeNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<VolumeNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<VolumeVizualisationNode>>( - NodeCreator<NodeAdapterModel<VolumeVizualisationNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<VolumeVizualisationNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<UINode>>( - NodeCreator<NodeAdapterModel<UINode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<UINode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<WireframeNode>>( - NodeCreator<NodeAdapterModel<WireframeNode>>( renderGraph ), - "Premade Nodes" ); + NodeCreator<NodeAdapterModel<WireframeNode>>( renderGraph ), "Premade Nodes" ); ret->registerModel<NodeAdapterModel<SourceNode<NodeTypeColor>>>( - NodeCreator<NodeAdapterModel<SourceNode<NodeTypeColor>>>( renderGraph ), - "Sources" ); + NodeCreator<NodeAdapterModel<SourceNode<NodeTypeColor>>>( renderGraph ), "Sources" ); ret->registerModel<NodeAdapterModel<SourceNode<bool>>>( NodeCreator<NodeAdapterModel<SourceNode<bool>>>( renderGraph ), "Sources" ); ret->registerModel<NodeAdapterModel<SourceNode<float>>>( @@ -315,19 +285,15 @@ std::shared_ptr<DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGra ret->registerModel<SourceDepthTextureModel>( NodeCreator<SourceDepthTextureModel>( renderGraph ), "Sources" ); - ret->registerModel<NodeAdapterModel<DisplaySinkNode>>( - NodeCreator<NodeAdapterModel<DisplaySinkNode>>( renderGraph ), - "Sinks" ); + NodeCreator<NodeAdapterModel<DisplaySinkNode>>( renderGraph ), "Sinks" ); #define SEMINARDEMO #ifdef SEMINARDEMO ret->registerModel<NodeAdapterModel<SimpleNode>>( - NodeCreator<NodeAdapterModel<SimpleNode>>( renderGraph ), - "Custom Nodes" ); + NodeCreator<NodeAdapterModel<SimpleNode>>( renderGraph ), "Custom Nodes" ); ret->registerModel<NodeAdapterModel<DifferenceNode>>( - NodeCreator<NodeAdapterModel<DifferenceNode>>( renderGraph ), - "Custom Nodes" ); + NodeCreator<NodeAdapterModel<DifferenceNode>>( renderGraph ), "Custom Nodes" ); #endif return ret; } -} +} // namespace NodeGraphQtEditor diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp index 375eb95316be56c0c8db3b941ff0df45fa6348a3..ebdb44729dd8e43dc4997e9ea234af4449c095e8 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.hpp @@ -1,9 +1,9 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <QWidget> #include <QEvent> #include <QMenuBar> +#include <QWidget> #include <nodes/FlowScene> #include <nodes/FlowView> @@ -16,7 +16,7 @@ class NodeBasedRenderer; class RenderGraph; namespace NodeGraphQtEditor { -std::shared_ptr<QtNodes::DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGraph); +std::shared_ptr<QtNodes::DataModelRegistry> initializeNodeRegistry( RenderGraph* renderGraph ); } class NodeBasedRenderer_LIBRARY_API RenderGraphEditorView : public QWidget diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.cpp index 242ab8cb8051baa71ee4d947caf014f9640af6af..c586a57ad56a98ff6e79fd6ccdecb7acd4aacc54 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.cpp @@ -12,8 +12,8 @@ using QtNodes::PortType; SourceColorTextureModel::SourceColorTextureModel( RenderGraph* renderGraph ) : m_renderGraph( renderGraph ) { - m_node = new ColorTextureNode( - "Source node color texture" + std::to_string( m_renderGraph->getNodesCount() ) ); + m_node = new ColorTextureNode( "Source node color texture" + + std::to_string( m_renderGraph->getNodesCount() ) ); m_renderGraph->addNode( m_node ); } diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.hpp index 8cffa69cfab2c708fb36d02b5c8d13b850b6bf1c..78d4a70710db65db2e5c57aa16bf33395a54dbf4 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceColorTextureModel.hpp @@ -1,6 +1,6 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <QtCore/QObject> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <nodes/NodeDataModel> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.cpp index f00f84311514a7d59d7bc47e73547e5ec05491b8..eb81fba19a649e96eb5d038d37d061c0ef7a86ae 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.cpp @@ -11,8 +11,8 @@ using QtNodes::PortType; SourceDepthTextureModel::SourceDepthTextureModel( RenderGraph* renderGraph ) : m_renderGraph( renderGraph ) { - m_node = new DepthTextureNode( - "Source node depth texture" + std::to_string( m_renderGraph->getNodesCount() ) ); + m_node = new DepthTextureNode( "Source node depth texture" + + std::to_string( m_renderGraph->getNodesCount() ) ); m_renderGraph->addNode( m_node ); } @@ -42,4 +42,4 @@ unsigned int SourceDepthTextureModel::nPorts( PortType portType ) const { NodeDataType SourceDepthTextureModel::dataType( PortType, PortIndex ) const { return QtNodes::NodeDataType{ std::to_string( typeid( NodeTypeTexture ).hash_code() ).c_str(), "outDepthTexture" }; -} \ No newline at end of file +} diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.hpp index 868de2207f6ecff60fd246c437862cfea99aea99..d698907cae685370dcc6ea8bebe1d2262d6e43a4 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceDepthTextureModel.hpp @@ -1,6 +1,6 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <QtCore/QObject> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <nodes/NodeDataModel> diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.cpp index aac9dfd92f7335947b0b9fa967b1b10022a4314d..b08578e3a8296f387b4e15280bd60162217acf94 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.cpp @@ -1,9 +1,9 @@ #include <QtCore/QObject> #include <QtWidgets/QCheckBox> -#include <RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp> #include <RadiumNBR/Gui/PowerSlider.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/ColorSlider.hpp> +#include <RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp> #include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp> @@ -80,8 +80,8 @@ NodeBasedRenderer_LIBRARY_API QJsonObject SourceNodeModel<bool>::save() const { template <> NodeBasedRenderer_LIBRARY_API void SourceNodeModel<bool>::restore( QJsonObject const& p ) { - //auto checkBox = dynamic_cast<QCheckBox*>( m_widget ); - // strange bug on MacOs : dynamic_cast segfault here + // auto checkBox = dynamic_cast<QCheckBox*>( m_widget ); + // strange bug on MacOs : dynamic_cast segfault here auto checkBox = qobject_cast<QCheckBox*>( m_widget ); QJsonValue b = p["boolean"]; @@ -113,7 +113,7 @@ NodeBasedRenderer_LIBRARY_API QWidget* SourceNodeModel<NodeTypeColor>::getWidget int newR, newG, newB; value.getRgb( &newR, &newG, &newB ); - m_node->setData( NodeTypeColor::sRGBToLinearRGB(NodeTypeColor::fromRGB( + m_node->setData( NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB( Ra::Core::Utils::ColorBase<float>( newR / 255.0f, newG / 255.0f, newB / 255.0f ) .rgb() ) ) ); } ); @@ -176,8 +176,7 @@ NodeBasedRenderer_LIBRARY_API void SourceNodeModel<NodeTypeColor>::restore( QJso colorSlider->setBlueSliderValue( newB ); colorSlider->setColor( color ); - m_node->setData( NodeTypeColor::sRGBToLinearRGB(NodeTypeColor::fromRGB( + m_node->setData( NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB( Ra::Core::Utils::ColorBase<float>( newR / 255.0f, newG / 255.0f, newB / 255.0f ) .rgb() ) ) ); - } diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp index b056e99b7bbfb21413f1bd6c3a6de7c28150c878..63f3314adc8e0e4d5a41611ff42d66c316306764 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/SourceNodeModel.hpp @@ -1,6 +1,6 @@ #pragma once -#include <nodes/NodeDataModel> #include <RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp> +#include <nodes/NodeDataModel> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> #include <RadiumNBR/NodeGraph/RenderGraph.hpp> @@ -78,7 +78,7 @@ class SourceNodeModel : public QtNodes::NodeDataModel return IOToDataType( m_node->getOutputs()[portIndex]->getType(), m_node->getOutputs()[portIndex]->getName() ); } - default : + default: break; } diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.cpp index ff8dc13a0a410bed20a919248ad403549f16c6bd..efd1e10df870b0a5d1620b8f21e3fa441bf07e46 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.cpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.cpp @@ -1,8 +1,7 @@ #include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp> namespace WidgetFactory { -std::unordered_map<size_t, std::function<QWidget*( EditableParameterBase* )>> - widgetsCreators; +std::unordered_map<size_t, std::function<QWidget*( EditableParameterBase* )>> widgetsCreators; void registerWidgetInternal( size_t hashedType, std::function<QWidget*( EditableParameterBase* )> widgetCreator ) { @@ -26,4 +25,4 @@ QWidget* createWidget( EditableParameterBase* editableParameter ) { } return nullptr; } -} \ No newline at end of file +} // namespace WidgetFactory diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp index a7952029fff2f06c0ce70563d55931e3ec98dfa8..bcc11528649a7b71f48fc256e69f3169e778ccd2 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp @@ -1,17 +1,19 @@ #pragma once +#include <QWidget> #include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/NodeGraph/EditableParameter.hpp> -#include <QWidget> -#include <unordered_map> #include <iostream> +#include <unordered_map> namespace WidgetFactory { - NodeBasedRenderer_LIBRARY_API void registerWidgetInternal( size_t hashedType, std::function<QWidget*( EditableParameterBase* )> widgetCreator ); +NodeBasedRenderer_LIBRARY_API void +registerWidgetInternal( size_t hashedType, + std::function<QWidget*( EditableParameterBase* )> widgetCreator ); - NodeBasedRenderer_LIBRARY_API QWidget* createWidget( EditableParameterBase* editableParameter ); +NodeBasedRenderer_LIBRARY_API QWidget* createWidget( EditableParameterBase* editableParameter ); - template <typename T> - void registerWidget( std::function<QWidget*( EditableParameterBase* )> widgetCreator ) { - registerWidgetInternal( typeid(T).hash_code(), std::move(widgetCreator) ); - } -}; \ No newline at end of file +template <typename T> +void registerWidget( std::function<QWidget*( EditableParameterBase* )> widgetCreator ) { + registerWidgetInternal( typeid( T ).hash_code(), std::move( widgetCreator ) ); +} +}; // namespace WidgetFactory diff --git a/src/libRender/RadiumNBR/Gui/RendererPanel.cpp b/src/libRender/RadiumNBR/Gui/RendererPanel.cpp index 2618c44f79f3f5836968cd2169b28dd430d060d8..205d84736ec17c4436564b03e399419ccb2ecabd 100644 --- a/src/libRender/RadiumNBR/Gui/RendererPanel.cpp +++ b/src/libRender/RadiumNBR/Gui/RendererPanel.cpp @@ -158,9 +158,7 @@ void RendererPanel::addFileInput( const std::string& name, { std::string fileList; for ( const auto& file : pathList ) - { - fileList += file.toStdString() + ";"; - } + { fileList += file.toStdString() + ";"; } fileList.erase( fileList.size() - 1 ); callback( fileList ); } @@ -269,7 +267,7 @@ void RendererPanel::addCodeEditor( const std::string& name, m_currentLayout->addWidget( button ); } -void RendererPanel::addWidget(QWidget* newWidget) { +void RendererPanel::addWidget( QWidget* newWidget ) { m_currentLayout->addWidget( newWidget ); } diff --git a/src/libRender/RadiumNBR/Gui/RendererPanel.hpp b/src/libRender/RadiumNBR/Gui/RendererPanel.hpp index e6413eebef70397db749df4e0eb1f2e5765121bc..0c381bbec9e158fe7c2321b9f79ee03d5520c97a 100644 --- a/src/libRender/RadiumNBR/Gui/RendererPanel.hpp +++ b/src/libRender/RadiumNBR/Gui/RendererPanel.hpp @@ -74,14 +74,14 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame * Shows text. * @param text The text to show */ - void addLabel( const std::string& text ); + void addLabel( const std::string& text ); /** Add a button. * This button, when pressed, will call the associated callback. * @param name The name of the button * @param callback The function to call when the state changed */ - void addButton( const std::string& name, std::function<void( )> callback); + void addButton( const std::string& name, std::function<void()> callback ); /** Add a color input button. * This button, when pressed, will open a color chooser and call the associated callback. @@ -174,8 +174,8 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame std::function<std::string()> initialText ); /** Add an arbitrary widget to the ui. - * @param newWidget The widget to add to the ui. - */ + * @param newWidget The widget to add to the ui. + */ void addWidget( QWidget* newWidget ); /**@}*/ diff --git a/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.cpp b/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.cpp index 8c77207490757f8a2e54ef6d1e29081d60ccf2c3..10757a808f2ddf0a9a79902be97fc18ddca60b92 100644 --- a/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.cpp +++ b/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.cpp @@ -8,8 +8,10 @@ namespace RadiumNBR { using namespace Gui; RadiumNBR::Gui::RendererPanel* -buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, const std::function<void()>& appUpdateCallback ) { - auto& controller = dynamic_cast<SurfaceAttributeVisualizerController&>( renderer->getController() ); +buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ) { + auto& controller = + dynamic_cast<SurfaceAttributeVisualizerController&>( renderer->getController() ); auto controlPanel = new RendererPanel( renderer->getRendererName() ); @@ -52,8 +54,8 @@ buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, const std::func controlPanel->beginLayout( QBoxLayout::LeftToRight ); auto envmpClbck = [&controller, appUpdateCallback]( const std::string& files ) { - controller.setEnvMap( files ); - appUpdateCallback(); + controller.setEnvMap( files ); + appUpdateCallback(); }; controlPanel->addFileInput( "Environment map", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" ); @@ -62,16 +64,16 @@ buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, const std::func controlPanel->addOption( " Show envMap ", [&controller, appUpdateCallback]( bool b ) { - controller.showEnvMap( b ); - appUpdateCallback(); + controller.showEnvMap( b ); + appUpdateCallback(); }, true ); controlPanel->addSliderInput( " Environment strength ", [&controller, appUpdateCallback]( int v ) { - controller.setEnvStrength( v ); - appUpdateCallback(); + controller.setEnvStrength( v ); + appUpdateCallback(); }, 100 ); controlPanel->endLayout(); @@ -81,8 +83,8 @@ buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, const std::func controlPanel->addOption( " Exports vector field ", [&controller, appUpdateCallback]( bool b ) { - controller.exportVectorField( b ); - appUpdateCallback(); + controller.exportVectorField( b ); + appUpdateCallback(); }, // TODO : find a way to initialise this according to futre controller configuration true /*controller.exportsVectorField()*/ ); diff --git a/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.hpp b/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.hpp index 4ef3d4f791d0d5bfb3f2009756941834edc7a649..3532ed13062e1725a5ca1d64ba367e6260e936b7 100644 --- a/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.hpp +++ b/src/libRender/RadiumNBR/Gui/SurfaceAttributeVisualizerGui.hpp @@ -6,6 +6,7 @@ namespace RadiumNBR { class MultiPassRenderer; NodeBasedRenderer_LIBRARY_API RadiumNBR::Gui::RendererPanel* -buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, const std::function<void()>& appUpdateCallback ); +buildSurfaceAttribVisualizationGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ); } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Gui/TransferEditor.cpp b/src/libRender/RadiumNBR/Gui/TransferEditor.cpp index c5d382a7d45ea900459b94db92512a7c79ad7eab..67c8ff93ae39766b517e0905f1702f1d798ccd81 100644 --- a/src/libRender/RadiumNBR/Gui/TransferEditor.cpp +++ b/src/libRender/RadiumNBR/Gui/TransferEditor.cpp @@ -10,80 +10,74 @@ #include "HoverPoints.hpp" -ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) - : QWidget(parent), m_shade_type(type), m_alpha_gradient(QLinearGradient(0, 0, 0, 0)) -{ +ShadeWidget::ShadeWidget( ShadeType type, QWidget* parent ) : + QWidget( parent ), m_shade_type( type ), m_alpha_gradient( QLinearGradient( 0, 0, 0, 0 ) ) { // Checkers background - if (m_shade_type == ARGBShade) + if ( m_shade_type == ARGBShade ) { - QPixmap pm(20, 20); - QPainter pmp(&pm); - pmp.fillRect(0, 0, 10, 10, Qt::lightGray); - pmp.fillRect(10, 10, 10, 10, Qt::lightGray); - pmp.fillRect(0, 10, 10, 10, Qt::darkGray); - pmp.fillRect(10, 0, 10, 10, Qt::darkGray); + QPixmap pm( 20, 20 ); + QPainter pmp( &pm ); + pmp.fillRect( 0, 0, 10, 10, Qt::lightGray ); + pmp.fillRect( 10, 10, 10, 10, Qt::lightGray ); + pmp.fillRect( 0, 10, 10, 10, Qt::darkGray ); + pmp.fillRect( 10, 0, 10, 10, Qt::darkGray ); pmp.end(); QPalette pal = palette(); - pal.setBrush(backgroundRole(), QBrush(pm)); - setAutoFillBackground(true); - setPalette(pal); + pal.setBrush( backgroundRole(), QBrush( pm ) ); + setAutoFillBackground( true ); + setPalette( pal ); } else - { - setAttribute(Qt::WA_OpaquePaintEvent); - } + { setAttribute( Qt::WA_OpaquePaintEvent ); } QPolygonF points; - points << QPointF(0, sizeHint().height()) - << QPointF(sizeHint().width(), 0); + points << QPointF( 0, sizeHint().height() ) << QPointF( sizeHint().width(), 0 ); - m_hoverPoints = new HoverPoints(this, HoverPoints::CircleShape); + m_hoverPoints = new HoverPoints( this, HoverPoints::CircleShape ); // m_hoverPoints->setConnectionType(HoverPoints::LineConnection); - m_hoverPoints->setPoints(points); - m_hoverPoints->setPointLock(0, HoverPoints::LockToLeft); - m_hoverPoints->setPointLock(1, HoverPoints::LockToRight); - m_hoverPoints->setSortType(HoverPoints::XSort); + m_hoverPoints->setPoints( points ); + m_hoverPoints->setPointLock( 0, HoverPoints::LockToLeft ); + m_hoverPoints->setPointLock( 1, HoverPoints::LockToRight ); + m_hoverPoints->setSortType( HoverPoints::XSort ); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - setFixedHeight(200); + setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); + setFixedHeight( 200 ); - connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged())); + connect( m_hoverPoints, SIGNAL( pointsChanged( QPolygonF ) ), this, SIGNAL( colorsChanged() ) ); } -QPolygonF ShadeWidget::points() const -{ +QPolygonF ShadeWidget::points() const { return m_hoverPoints->points(); } -uint ShadeWidget::colorAt(int x) -{ +uint ShadeWidget::colorAt( int x ) { generateShade(); QPolygonF pts = m_hoverPoints->points(); - for (int i = 1; i < pts.size(); ++i) + for ( int i = 1; i < pts.size(); ++i ) { - if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) + if ( pts.at( i - 1 ).x() <= x && pts.at( i ).x() >= x ) { - QLineF l(pts.at(i - 1), pts.at(i)); - l.setLength(l.length() * ((x - l.x1()) / l.dx())); - return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))), - qRound(qMin(l.y2(), qreal(m_shade.height() - 1)))); + QLineF l( pts.at( i - 1 ), pts.at( i ) ); + l.setLength( l.length() * ( ( x - l.x1() ) / l.dx() ) ); + return m_shade.pixel( qRound( qMin( l.x2(), ( qreal( m_shade.width() - 1 ) ) ) ), + qRound( qMin( l.y2(), qreal( m_shade.height() - 1 ) ) ) ); } } return 0; } -void ShadeWidget::setGradientStops(const QGradientStops &stops) -{ - if (m_shade_type == ARGBShade) +void ShadeWidget::setGradientStops( const QGradientStops& stops ) { + if ( m_shade_type == ARGBShade ) { - m_alpha_gradient = QLinearGradient(0, 0, width(), 0); + m_alpha_gradient = QLinearGradient( 0, 0, width(), 0 ); - for (int i = 0; i < stops.size(); ++i) + for ( int i = 0; i < stops.size(); ++i ) { - QColor c = stops.at(i).second; - m_alpha_gradient.setColorAt(stops.at(i).first, QColor(c.red(), c.green(), c.blue())); + QColor c = stops.at( i ).second; + m_alpha_gradient.setColorAt( stops.at( i ).first, + QColor( c.red(), c.green(), c.blue() ) ); } m_shade = QImage(); @@ -92,85 +86,79 @@ void ShadeWidget::setGradientStops(const QGradientStops &stops) } } -void ShadeWidget::paintEvent(QPaintEvent *) -{ +void ShadeWidget::paintEvent( QPaintEvent* ) { generateShade(); - QPainter p(this); - p.drawImage(0, 0, m_shade); + QPainter p( this ); + p.drawImage( 0, 0, m_shade ); - p.setPen(QColor(146, 146, 146)); - p.drawRect(0, 0, width() - 1, height() - 1); + p.setPen( QColor( 146, 146, 146 ) ); + p.drawRect( 0, 0, width() - 1, height() - 1 ); } -void ShadeWidget::generateShade() -{ - if (m_shade.isNull() || m_shade.size() != size()) +void ShadeWidget::generateShade() { + if ( m_shade.isNull() || m_shade.size() != size() ) { - if (m_shade_type == ARGBShade) + if ( m_shade_type == ARGBShade ) { - m_shade = QImage(size(), QImage::Format_ARGB32_Premultiplied); - m_shade.fill(0); + m_shade = QImage( size(), QImage::Format_ARGB32_Premultiplied ); + m_shade.fill( 0 ); - QPainter p(&m_shade); - p.fillRect(rect(), m_alpha_gradient); + QPainter p( &m_shade ); + p.fillRect( rect(), m_alpha_gradient ); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - QLinearGradient fade(0, 0, 0, height()); - fade.setColorAt(0, QColor(0, 0, 0, 255)); - fade.setColorAt(1, QColor(0, 0, 0, 0)); - p.fillRect(rect(), fade); + p.setCompositionMode( QPainter::CompositionMode_DestinationIn ); + QLinearGradient fade( 0, 0, 0, height() ); + fade.setColorAt( 0, QColor( 0, 0, 0, 255 ) ); + fade.setColorAt( 1, QColor( 0, 0, 0, 0 ) ); + p.fillRect( rect(), fade ); } else { - m_shade = QImage(size(), QImage::Format_RGB32); - QLinearGradient shade(0, 0, 0, height()); - shade.setColorAt(1, Qt::black); - - if (m_shade_type == RedShade) - shade.setColorAt(0, Qt::red); - else if (m_shade_type == GreenShade) - shade.setColorAt(0, Qt::green); + m_shade = QImage( size(), QImage::Format_RGB32 ); + QLinearGradient shade( 0, 0, 0, height() ); + shade.setColorAt( 1, Qt::black ); + + if ( m_shade_type == RedShade ) + shade.setColorAt( 0, Qt::red ); + else if ( m_shade_type == GreenShade ) + shade.setColorAt( 0, Qt::green ); else - shade.setColorAt(0, Qt::blue); + shade.setColorAt( 0, Qt::blue ); - QPainter p(&m_shade); - p.fillRect(rect(), shade); + QPainter p( &m_shade ); + p.fillRect( rect(), shade ); } } } -GradientEditor::GradientEditor(QWidget *parent) - : QWidget(parent) -{ - QVBoxLayout *vbox = new QVBoxLayout(this); - vbox->setSpacing(1); - vbox->setContentsMargins(1, 1, 1, 1); - - m_red_shade = new ShadeWidget(ShadeWidget::RedShade, this); - m_green_shade = new ShadeWidget(ShadeWidget::GreenShade, this); - m_blue_shade = new ShadeWidget(ShadeWidget::BlueShade, this); - m_alpha_shade = new ShadeWidget(ShadeWidget::ARGBShade, this); - - vbox->addWidget(m_red_shade); - vbox->addWidget(m_green_shade); - vbox->addWidget(m_blue_shade); - vbox->addWidget(m_alpha_shade); - - connect(m_red_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_green_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_blue_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); +GradientEditor::GradientEditor( QWidget* parent ) : QWidget( parent ) { + QVBoxLayout* vbox = new QVBoxLayout( this ); + vbox->setSpacing( 1 ); + vbox->setContentsMargins( 1, 1, 1, 1 ); + + m_red_shade = new ShadeWidget( ShadeWidget::RedShade, this ); + m_green_shade = new ShadeWidget( ShadeWidget::GreenShade, this ); + m_blue_shade = new ShadeWidget( ShadeWidget::BlueShade, this ); + m_alpha_shade = new ShadeWidget( ShadeWidget::ARGBShade, this ); + + vbox->addWidget( m_red_shade ); + vbox->addWidget( m_green_shade ); + vbox->addWidget( m_blue_shade ); + vbox->addWidget( m_alpha_shade ); + + connect( m_red_shade, SIGNAL( colorsChanged() ), this, SLOT( pointsUpdated() ) ); + connect( m_green_shade, SIGNAL( colorsChanged() ), this, SLOT( pointsUpdated() ) ); + connect( m_blue_shade, SIGNAL( colorsChanged() ), this, SLOT( pointsUpdated() ) ); + connect( m_alpha_shade, SIGNAL( colorsChanged() ), this, SLOT( pointsUpdated() ) ); } -inline static bool x_less_than(const QPointF &p1, const QPointF &p2) -{ +inline static bool x_less_than( const QPointF& p1, const QPointF& p2 ) { return p1.x() < p2.x(); } -void GradientEditor::pointsUpdated() -{ +void GradientEditor::pointsUpdated() { qreal w = m_alpha_shade->width(); QGradientStops stops; @@ -182,184 +170,179 @@ void GradientEditor::pointsUpdated() points += m_blue_shade->points(); points += m_alpha_shade->points(); - std::sort(points.begin(), points.end(), x_less_than); + std::sort( points.begin(), points.end(), x_less_than ); - for (int i = 0; i < points.size(); ++i) + for ( int i = 0; i < points.size(); ++i ) { - qreal x = int(points.at(i).x()); - if (i < points.size() - 1 && x == points.at(i + 1).x()) - continue; - QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16, - (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, - (0x000000ff & m_blue_shade->colorAt(int(x))), - (0xff000000 & m_alpha_shade->colorAt(int(x))) >> 24); - - if (x / w > 1) - return; - - stops << QGradientStop(x / w, color); + qreal x = int( points.at( i ).x() ); + if ( i < points.size() - 1 && x == points.at( i + 1 ).x() ) continue; + QColor color( ( 0x00ff0000 & m_red_shade->colorAt( int( x ) ) ) >> 16, + ( 0x0000ff00 & m_green_shade->colorAt( int( x ) ) ) >> 8, + ( 0x000000ff & m_blue_shade->colorAt( int( x ) ) ), + ( 0xff000000 & m_alpha_shade->colorAt( int( x ) ) ) >> 24 ); + + if ( x / w > 1 ) return; + + stops << QGradientStop( x / w, color ); } - m_alpha_shade->setGradientStops(stops); + m_alpha_shade->setGradientStops( stops ); - emit gradientStopsChanged(stops); + emit gradientStopsChanged( stops ); } -static void set_shade_points(const QPolygonF &points, ShadeWidget *shade) -{ - shade->hoverPoints()->setPoints(points); - shade->hoverPoints()->setPointLock(0, HoverPoints::LockToLeft); - shade->hoverPoints()->setPointLock(points.size() - 1, HoverPoints::LockToRight); +static void set_shade_points( const QPolygonF& points, ShadeWidget* shade ) { + shade->hoverPoints()->setPoints( points ); + shade->hoverPoints()->setPointLock( 0, HoverPoints::LockToLeft ); + shade->hoverPoints()->setPointLock( points.size() - 1, HoverPoints::LockToRight ); shade->update(); } -void GradientEditor::setGradientStops(const QGradientStops &stops) -{ +void GradientEditor::setGradientStops( const QGradientStops& stops ) { QPolygonF pts_red, pts_green, pts_blue, pts_alpha; - qreal h_red = m_red_shade->height(); + qreal h_red = m_red_shade->height(); qreal h_green = m_green_shade->height(); - qreal h_blue = m_blue_shade->height(); + qreal h_blue = m_blue_shade->height(); qreal h_alpha = m_alpha_shade->height(); - for (int i = 0; i < stops.size(); ++i) + for ( int i = 0; i < stops.size(); ++i ) { - qreal pos = stops.at(i).first; - QRgb color = stops.at(i).second.rgba(); - pts_red << QPointF(pos * m_red_shade->width(), h_red - qRed(color) * h_red / 255); - pts_green << QPointF(pos * m_green_shade->width(), h_green - qGreen(color) * h_green / 255); - pts_blue << QPointF(pos * m_blue_shade->width(), h_blue - qBlue(color) * h_blue / 255); - pts_alpha << QPointF(pos * m_alpha_shade->width(), h_alpha - qAlpha(color) * h_alpha / 255); + qreal pos = stops.at( i ).first; + QRgb color = stops.at( i ).second.rgba(); + pts_red << QPointF( pos * m_red_shade->width(), h_red - qRed( color ) * h_red / 255 ); + pts_green << QPointF( pos * m_green_shade->width(), + h_green - qGreen( color ) * h_green / 255 ); + pts_blue << QPointF( pos * m_blue_shade->width(), h_blue - qBlue( color ) * h_blue / 255 ); + pts_alpha << QPointF( pos * m_alpha_shade->width(), + h_alpha - qAlpha( color ) * h_alpha / 255 ); } - set_shade_points(pts_red, m_red_shade); - set_shade_points(pts_green, m_green_shade); - set_shade_points(pts_blue, m_blue_shade); - set_shade_points(pts_alpha, m_alpha_shade); - m_alpha_shade->setGradientStops(stops); + set_shade_points( pts_red, m_red_shade ); + set_shade_points( pts_green, m_green_shade ); + set_shade_points( pts_blue, m_blue_shade ); + set_shade_points( pts_alpha, m_alpha_shade ); + m_alpha_shade->setGradientStops( stops ); - emit gradientStopsChanged(stops); + emit gradientStopsChanged( stops ); } -uint GradientEditor::colorAt(int x) -{ - return m_alpha_shade->colorAt(x); +uint GradientEditor::colorAt( int x ) { + return m_alpha_shade->colorAt( x ); } //------------------------------------------------------- -TransferEditor::TransferEditor(QWidget *parent) : QDialog(parent) -{ - QGroupBox *mainGroup = new QGroupBox(this); - mainGroup->setTitle(tr("Gradients")); - - QGroupBox *editorGroup = new QGroupBox(mainGroup); - editorGroup->setTitle(tr("Color Editor")); - m_gradientEditor = new GradientEditor(editorGroup); - - QGroupBox *defaultsGroup = new QGroupBox(mainGroup); - defaultsGroup->setTitle(tr("Defaults")); - QPushButton *default1Button = new QPushButton(tr("1"), defaultsGroup); - QPushButton *default2Button = new QPushButton(tr("2"), defaultsGroup); - QPushButton *default3Button = new QPushButton(tr("3"), defaultsGroup); - QPushButton *default4Button = new QPushButton(tr("Reset"), editorGroup); - - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->addWidget(mainGroup); - - mainGroup->setFixedWidth(440); - QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); - mainGroupLayout->addWidget(editorGroup); - mainGroupLayout->addWidget(defaultsGroup); - - QVBoxLayout *editorGroupLayout = new QVBoxLayout(editorGroup); - editorGroupLayout->addWidget(m_gradientEditor); - - QHBoxLayout *defaultsGroupLayout = new QHBoxLayout(defaultsGroup); - defaultsGroupLayout->addWidget(default1Button); - defaultsGroupLayout->addWidget(default2Button); - defaultsGroupLayout->addWidget(default3Button); - editorGroupLayout->addWidget(default4Button); - - connect(m_gradientEditor, SIGNAL(gradientStopsChanged(QGradientStops)), - this, SLOT(setTransferFonction())); - - connect(default1Button, SIGNAL(clicked()), this, SLOT(setDefault1())); - connect(default2Button, SIGNAL(clicked()), this, SLOT(setDefault2())); - connect(default3Button, SIGNAL(clicked()), this, SLOT(setDefault3())); - connect(default4Button, SIGNAL(clicked()), this, SLOT(setDefault4())); +TransferEditor::TransferEditor( QWidget* parent ) : QDialog( parent ) { + QGroupBox* mainGroup = new QGroupBox( this ); + mainGroup->setTitle( tr( "Gradients" ) ); + + QGroupBox* editorGroup = new QGroupBox( mainGroup ); + editorGroup->setTitle( tr( "Color Editor" ) ); + m_gradientEditor = new GradientEditor( editorGroup ); + + QGroupBox* defaultsGroup = new QGroupBox( mainGroup ); + defaultsGroup->setTitle( tr( "Defaults" ) ); + QPushButton* default1Button = new QPushButton( tr( "1" ), defaultsGroup ); + QPushButton* default2Button = new QPushButton( tr( "2" ), defaultsGroup ); + QPushButton* default3Button = new QPushButton( tr( "3" ), defaultsGroup ); + QPushButton* default4Button = new QPushButton( tr( "Reset" ), editorGroup ); + + QHBoxLayout* mainLayout = new QHBoxLayout( this ); + mainLayout->addWidget( mainGroup ); + + mainGroup->setFixedWidth( 440 ); + QVBoxLayout* mainGroupLayout = new QVBoxLayout( mainGroup ); + mainGroupLayout->addWidget( editorGroup ); + mainGroupLayout->addWidget( defaultsGroup ); + + QVBoxLayout* editorGroupLayout = new QVBoxLayout( editorGroup ); + editorGroupLayout->addWidget( m_gradientEditor ); + + QHBoxLayout* defaultsGroupLayout = new QHBoxLayout( defaultsGroup ); + defaultsGroupLayout->addWidget( default1Button ); + defaultsGroupLayout->addWidget( default2Button ); + defaultsGroupLayout->addWidget( default3Button ); + editorGroupLayout->addWidget( default4Button ); + + connect( m_gradientEditor, + SIGNAL( gradientStopsChanged( QGradientStops ) ), + this, + SLOT( setTransferFonction() ) ); + + connect( default1Button, SIGNAL( clicked() ), this, SLOT( setDefault1() ) ); + connect( default2Button, SIGNAL( clicked() ), this, SLOT( setDefault2() ) ); + connect( default3Button, SIGNAL( clicked() ), this, SLOT( setDefault3() ) ); + connect( default4Button, SIGNAL( clicked() ), this, SLOT( setDefault4() ) ); } -void TransferEditor::setDefault(int config) -{ +void TransferEditor::setDefault( int config ) { QGradientStops stops; QPolygonF points; - switch (config) + switch ( config ) { case 1: - stops << QGradientStop(0.00, QColor::fromRgba(0x11000000)); - stops << QGradientStop(0.04, QColor::fromRgba(0x11131360)); - stops << QGradientStop(0.08, QColor::fromRgba(0x11202ccc)); - stops << QGradientStop(0.42, QColor::fromRgba(0x1193d3f9)); - stops << QGradientStop(0.51, QColor::fromRgba(0x11b3e6ff)); - stops << QGradientStop(0.73, QColor::fromRgba(0x11ffffec)); - stops << QGradientStop(0.92, QColor::fromRgba(0x115353d9)); - stops << QGradientStop(0.96, QColor::fromRgba(0x11262666)); - stops << QGradientStop(1.00, QColor::fromRgba(0x11000000)); + stops << QGradientStop( 0.00, QColor::fromRgba( 0x11000000 ) ); + stops << QGradientStop( 0.04, QColor::fromRgba( 0x11131360 ) ); + stops << QGradientStop( 0.08, QColor::fromRgba( 0x11202ccc ) ); + stops << QGradientStop( 0.42, QColor::fromRgba( 0x1193d3f9 ) ); + stops << QGradientStop( 0.51, QColor::fromRgba( 0x11b3e6ff ) ); + stops << QGradientStop( 0.73, QColor::fromRgba( 0x11ffffec ) ); + stops << QGradientStop( 0.92, QColor::fromRgba( 0x115353d9 ) ); + stops << QGradientStop( 0.96, QColor::fromRgba( 0x11262666 ) ); + stops << QGradientStop( 1.00, QColor::fromRgba( 0x11000000 ) ); break; case 2: - stops << QGradientStop(0.00, QColor::fromRgba(0x11ffffff)); - stops << QGradientStop(0.11, QColor::fromRgba(0x11f9ffa0)); - stops << QGradientStop(0.13, QColor::fromRgba(0x11f9ff99)); - stops << QGradientStop(0.14, QColor::fromRgba(0x11f3ff86)); - stops << QGradientStop(0.49, QColor::fromRgba(0x1193b353)); - stops << QGradientStop(0.87, QColor::fromRgba(0x11264619)); - stops << QGradientStop(0.96, QColor::fromRgba(0x110c1306)); - stops << QGradientStop(1.00, QColor::fromRgba(0x11000000)); + stops << QGradientStop( 0.00, QColor::fromRgba( 0x11ffffff ) ); + stops << QGradientStop( 0.11, QColor::fromRgba( 0x11f9ffa0 ) ); + stops << QGradientStop( 0.13, QColor::fromRgba( 0x11f9ff99 ) ); + stops << QGradientStop( 0.14, QColor::fromRgba( 0x11f3ff86 ) ); + stops << QGradientStop( 0.49, QColor::fromRgba( 0x1193b353 ) ); + stops << QGradientStop( 0.87, QColor::fromRgba( 0x11264619 ) ); + stops << QGradientStop( 0.96, QColor::fromRgba( 0x110c1306 ) ); + stops << QGradientStop( 1.00, QColor::fromRgba( 0x11000000 ) ); break; case 3: - stops << QGradientStop(0.00, QColor::fromRgba(0x11000000)); - stops << QGradientStop(0.10, QColor::fromRgba(0x11e0cc73)); - stops << QGradientStop(0.17, QColor::fromRgba(0x11c6a006)); - stops << QGradientStop(0.46, QColor::fromRgba(0x11600659)); - stops << QGradientStop(0.72, QColor::fromRgba(0x110680ac)); - stops << QGradientStop(0.92, QColor::fromRgba(0x11b9d9e6)); - stops << QGradientStop(1.00, QColor::fromRgba(0x11000000)); + stops << QGradientStop( 0.00, QColor::fromRgba( 0x11000000 ) ); + stops << QGradientStop( 0.10, QColor::fromRgba( 0x11e0cc73 ) ); + stops << QGradientStop( 0.17, QColor::fromRgba( 0x11c6a006 ) ); + stops << QGradientStop( 0.46, QColor::fromRgba( 0x11600659 ) ); + stops << QGradientStop( 0.72, QColor::fromRgba( 0x110680ac ) ); + stops << QGradientStop( 0.92, QColor::fromRgba( 0x11b9d9e6 ) ); + stops << QGradientStop( 1.00, QColor::fromRgba( 0x11000000 ) ); break; case 4: - stops << QGradientStop(0.00, QColor::fromRgba(0x11ffffff)); - stops << QGradientStop(1.00, QColor::fromRgba(0x11ffffff)); + stops << QGradientStop( 0.00, QColor::fromRgba( 0x11ffffff ) ); + stops << QGradientStop( 1.00, QColor::fromRgba( 0x11ffffff ) ); break; default: - qWarning("bad default: %d\n", config); + qWarning( "bad default: %d\n", config ); break; } - m_gradientEditor->setGradientStops(stops); + m_gradientEditor->setGradientStops( stops ); } -uint TransferEditor::colorAt(int x) -{ - return m_gradientEditor->colorAt(x); +uint TransferEditor::colorAt( int x ) { + return m_gradientEditor->colorAt( x ); } -void TransferEditor::setTransferFonction() -{ +void TransferEditor::setTransferFonction() { unsigned char pixels[256 * 4]; int pos = 0; - for (int x = 0; x < 256; x++) + for ( int x = 0; x < 256; x++ ) { - unsigned int color = colorAt(x); - pixels[pos] = (unsigned char) ((0x00ff0000 & color) >> 16); - pixels[pos + 1] = (unsigned char) ((0x0000ff00 & color) >> 8); - pixels[pos + 2] = (unsigned char) ((0x000000ff & color)); - pixels[pos + 3] = (unsigned char) ((0xff000000 & color) >> 24); - pos = pos + 4; + unsigned int color = colorAt( x ); + pixels[pos] = (unsigned char)( ( 0x00ff0000 & color ) >> 16 ); + pixels[pos + 1] = (unsigned char)( ( 0x0000ff00 & color ) >> 8 ); + pixels[pos + 2] = (unsigned char)( ( 0x000000ff & color ) ); + pixels[pos + 3] = (unsigned char)( ( 0xff000000 & color ) >> 24 ); + pos = pos + 4; } emit propertiesChanged(); diff --git a/src/libRender/RadiumNBR/Gui/TransferEditor.hpp b/src/libRender/RadiumNBR/Gui/TransferEditor.hpp index 8152ac8d5dfc9ff6d8692602593b2370cd7c24ac..9e56da29f06e7062c5f8493e386f34e662ab7781 100644 --- a/src/libRender/RadiumNBR/Gui/TransferEditor.hpp +++ b/src/libRender/RadiumNBR/Gui/TransferEditor.hpp @@ -7,61 +7,55 @@ class HoverPoints; class ShadeWidget : public QWidget { Q_OBJECT -public: - enum ShadeType - { - RedShade, - GreenShade, - BlueShade, - ARGBShade - }; + public: + enum ShadeType { RedShade, GreenShade, BlueShade, ARGBShade }; - ShadeWidget(ShadeType type, QWidget *parent); + ShadeWidget( ShadeType type, QWidget* parent ); - void setGradientStops(const QGradientStops &stops); + void setGradientStops( const QGradientStops& stops ); - void paintEvent(QPaintEvent *e); + void paintEvent( QPaintEvent* e ); - QSize sizeHint() const { return QSize(256, 96); } + QSize sizeHint() const { return QSize( 256, 96 ); } QPolygonF points() const; - HoverPoints *hoverPoints() const { return m_hoverPoints; } + HoverPoints* hoverPoints() const { return m_hoverPoints; } - uint colorAt(int x); + uint colorAt( int x ); -signals: + signals: void colorsChanged(); -private: + private: void generateShade(); ShadeType m_shade_type; QImage m_shade; - HoverPoints *m_hoverPoints; + HoverPoints* m_hoverPoints; QLinearGradient m_alpha_gradient; }; class GradientEditor : public QWidget { Q_OBJECT -public: - GradientEditor(QWidget *parent); + public: + GradientEditor( QWidget* parent ); - void setGradientStops(const QGradientStops &stops); + void setGradientStops( const QGradientStops& stops ); - uint colorAt(int x); + uint colorAt( int x ); -public slots: + public slots: void pointsUpdated(); -signals: - void gradientStopsChanged(const QGradientStops &stops); + signals: + void gradientStopsChanged( const QGradientStops& stops ); -private: - ShadeWidget *m_red_shade; - ShadeWidget *m_green_shade; - ShadeWidget *m_blue_shade; - ShadeWidget *m_alpha_shade; + private: + ShadeWidget* m_red_shade; + ShadeWidget* m_green_shade; + ShadeWidget* m_blue_shade; + ShadeWidget* m_alpha_shade; }; //--------------------------------- @@ -69,22 +63,22 @@ private: class TransferEditor : public QDialog { Q_OBJECT -public: - TransferEditor(QWidget *parent = 0); + public: + TransferEditor( QWidget* parent = 0 ); uint colorAt( int x ); -public slots: - void setDefault1() { setDefault(1); } - void setDefault2() { setDefault(2); } - void setDefault3() { setDefault(3); } - void setDefault4() { setDefault(4); } + public slots: + void setDefault1() { setDefault( 1 ); } + void setDefault2() { setDefault( 2 ); } + void setDefault3() { setDefault( 3 ); } + void setDefault4() { setDefault( 4 ); } void setTransferFonction(); -signals: + signals: void propertiesChanged(); -private: - void setDefault(int i); + private: + void setDefault( int i ); - GradientEditor *m_gradientEditor; + GradientEditor* m_gradientEditor; }; diff --git a/src/libRender/RadiumNBR/MultiPassRenderer.cpp b/src/libRender/RadiumNBR/MultiPassRenderer.cpp index c2ee2618ba372158a4874fed7b44b1825556b7d1..d2d4b0da7405a24169ec2f7a9ec9f28f89534374 100644 --- a/src/libRender/RadiumNBR/MultiPassRenderer.cpp +++ b/src/libRender/RadiumNBR/MultiPassRenderer.cpp @@ -27,23 +27,21 @@ using namespace gl; int MultiPassRendererMagic = 0xFF0F00F0; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; static MultiPassRenderer::RenderControlFunctor noOpController; -MultiPassRenderer::MultiPassRenderer() : Renderer(), m_controller{noOpController} {} +MultiPassRenderer::MultiPassRenderer() : Renderer(), m_controller{ noOpController } {} MultiPassRenderer::MultiPassRenderer( MultiPassRenderer::RenderControlFunctor& controller ) : - Renderer(), m_controller{controller}, m_name{m_controller.getRendererName()} {} + Renderer(), m_controller{ controller }, m_name{ m_controller.getRendererName() } {} MultiPassRenderer::~MultiPassRenderer() = default; bool MultiPassRenderer::buildRenderTechnique( RenderObject* ro ) const { auto rt = Ra::Core::make_shared<RenderTechnique>(); for ( auto& rp : renderPasses() ) - { - rp.second->buildRenderTechnique( ro, *rt ); - } + { rp.second->buildRenderTechnique( ro, *rt ); } rt->updateGL(); ro->setRenderTechnique( rt ); return true; @@ -51,11 +49,12 @@ bool MultiPassRenderer::buildRenderTechnique( RenderObject* ro ) const { void MultiPassRenderer::initResources() { // uses several resources from the Radium engine - auto resourcesRootDir{RadiumEngine::getInstance()->getResourcesDir() + "Shaders/"}; + auto resourcesRootDir{ RadiumEngine::getInstance()->getResourcesDir() + "Shaders/" }; - m_shaderProgramManager->addShaderProgram( {{"Hdr2Ldr"}, - resourcesRootDir + "2DShaders/Basic2D.vert.glsl", - resourcesRootDir + "2DShaders/Hdr2Ldr.frag.glsl"} ); + m_shaderProgramManager->addShaderProgram( + { { "Hdr2Ldr" }, + resourcesRootDir + "2DShaders/Basic2D.vert.glsl", + resourcesRootDir + "2DShaders/Hdr2Ldr.frag.glsl" } ); m_postprocessFbo = std::make_unique<globjects::Framebuffer>(); @@ -74,7 +73,7 @@ void MultiPassRenderer::initResources() { texparams.format = GL_DEPTH_COMPONENT; texparams.type = GL_UNSIGNED_INT; texparams.name = "Depth (RadiumNBR)"; - m_sharedTextures.insert( {texparams.name, std::make_shared<Texture>( texparams )} ); + m_sharedTextures.insert( { texparams.name, std::make_shared<Texture>( texparams ) } ); // Linear (and HDR) RGBA Color texture texparams.internalFormat = GL_RGBA32F; @@ -83,7 +82,7 @@ void MultiPassRenderer::initResources() { texparams.minFilter = GL_LINEAR; texparams.magFilter = GL_LINEAR; texparams.name = "Linear RGB (RadiumNBR)"; - m_sharedTextures.insert( {texparams.name, std::make_shared<Texture>( texparams )} ); + m_sharedTextures.insert( { texparams.name, std::make_shared<Texture>( texparams ) } ); } void MultiPassRenderer::initializeInternal() { @@ -109,19 +108,17 @@ void MultiPassRenderer::initializeInternal() { m_controller.configure( this, m_width, m_height ); for ( const auto& t : m_sharedTextures ) - { - m_secondaryTextures.insert( {t.first, t.second.get()} ); - } + { m_secondaryTextures.insert( { t.first, t.second.get() } ); } // Todo cache this in an attribute ? auto resourcesCheck = Ra::Core::Resources::getResourcesPath( - reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), {"Resources/RadiumNBR"} ); + reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), { "Resources/RadiumNBR" } ); if ( !resourcesCheck ) { LOG( Ra::Core::Utils::logERROR ) << "Unable to find resources for MultiPassRenderer!"; return; } - auto resourcesPath{*resourcesCheck}; + auto resourcesPath{ *resourcesCheck }; // TODO, do we really need to setup an index for the two following passes // build the Ui pass @@ -152,9 +149,7 @@ void MultiPassRenderer::resizeInternal() { m_sharedTextures["Linear RGB (RadiumNBR)"]->resize( m_width, m_height ); for ( auto& rp : m_renderPasses ) - { - rp.second->resize( m_width, m_height ); - } + { rp.second->resize( m_width, m_height ); } m_postprocessFbo->bind(); m_postprocessFbo->attachTexture( GL_COLOR_ATTACHMENT0, m_fancyTexture->texture() ); @@ -320,7 +315,7 @@ void MultiPassRenderer::updateStepInternal( const ViewingParameters& renderData bool MultiPassRenderer::addPass( std::shared_ptr<RadiumNBR::RenderPass> pass, int rank, bool defaultPass ) { - const auto [itPass, success] = m_renderPasses.insert( {rank, pass} ); + const auto [itPass, success] = m_renderPasses.insert( { rank, pass } ); if ( defaultPass && success ) { m_defaultPass = rank; } return success; } diff --git a/src/libRender/RadiumNBR/MultiPassRenderer.hpp b/src/libRender/RadiumNBR/MultiPassRenderer.hpp index 0697efec377e63da2c91f8df484b5d74cd5b4370..3f09b6112e7448b2f1bbbfbf687cc8edef9d1fe4 100644 --- a/src/libRender/RadiumNBR/MultiPassRenderer.hpp +++ b/src/libRender/RadiumNBR/MultiPassRenderer.hpp @@ -72,7 +72,9 @@ class NodeBasedRenderer_LIBRARY_API MultiPassRenderer : public Ra::Engine::Rende /// Called once before each frame to update the internal state of the renderer virtual void update( const Ra::Engine::Data::ViewingParameters& renderData ){}; - [[nodiscard]] virtual std::string getRendererName() const { return "Configurable Renderer"; } + [[nodiscard]] virtual std::string getRendererName() const { + return "Configurable Renderer"; + } }; /// Construct a renderer that has to be configured explicitly @@ -158,21 +160,21 @@ class NodeBasedRenderer_LIBRARY_API MultiPassRenderer : public Ra::Engine::Rende std::map<int, std::shared_ptr<RenderPass>> m_renderPasses; /// The default pass - int m_defaultPass{-1}; + int m_defaultPass{ -1 }; /// The configurator functor to use RenderControlFunctor& m_controller; /// The pass to draw UI object std::unique_ptr<UIPass> m_uiPass; - bool m_showUi{false}; + bool m_showUi{ false }; /// The pass to draw Debug object std::unique_ptr<DebugPass> m_debugPass; - bool m_showDebug{false}; + bool m_showDebug{ false }; /// The name of the renderer - std::string m_name{"Configurable Renderer"}; + std::string m_name{ "Configurable Renderer" }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/NodeBasedRenderer.cpp b/src/libRender/RadiumNBR/NodeBasedRenderer.cpp index 1bf63e4eb98b735a7e4edc7da8f4ae65303f4aef..2f4914cc7bc82aa62dd94f5b83227bede80c46a3 100644 --- a/src/libRender/RadiumNBR/NodeBasedRenderer.cpp +++ b/src/libRender/RadiumNBR/NodeBasedRenderer.cpp @@ -20,9 +20,6 @@ using namespace Ra::Core::Utils; // log #include <RadiumNBR/Passes/DebugPass.hpp> #include <RadiumNBR/Passes/UiPass.hpp> - - - using namespace Ra::Engine; using namespace Ra::Engine::Scene; using namespace Ra::Engine::Data; @@ -192,7 +189,7 @@ void NodeBasedRenderer::renderInternal( const ViewingParameters& renderData ) { bool colorTextureSet = false; if ( m_displaySinkNode ) { - auto textures = m_displaySinkNode->getTextures(); + auto textures = m_displaySinkNode->getTextures(); for ( const auto t : textures ) { #ifdef GRAPH_CALL_TRACE @@ -348,9 +345,10 @@ void NodeBasedRenderer::updateStepInternal( const ViewingParameters& renderData if ( m_reloadJson ) { reloadRenderGraphFromJson(); - if (m_resetPath) { - m_jsonFilePath = m_jsonFilePath.substr(0, m_jsonFilePath.rfind('/') + 1); - m_resetPath = false; + if ( m_resetPath ) + { + m_jsonFilePath = m_jsonFilePath.substr( 0, m_jsonFilePath.rfind( '/' ) + 1 ); + m_resetPath = false; } m_reloadJson = false; } @@ -362,19 +360,16 @@ void NodeBasedRenderer::updateStepInternal( const ViewingParameters& renderData } // Render objects - m_originalRenderGraph.getDataNode<NodeTypeRenderObject>() - ->setElements( *allRenderObjects() ); + m_originalRenderGraph.getDataNode<NodeTypeRenderObject>()->setElements( *allRenderObjects() ); // Lights std::vector<const Ra::Engine::Scene::Light*> lights; for ( size_t i = 0; i < getLightManager()->count(); i++ ) { lights.push_back( getLightManager()->getLight( i ) ); } - m_originalRenderGraph.getDataNode<NodeTypeLight>() - ->setElements( lights ); + m_originalRenderGraph.getDataNode<NodeTypeLight>()->setElements( lights ); // Cameras std::vector<NodeTypeCamera> cameras; cameras.push_back( renderData ); - m_originalRenderGraph.getDataNode<NodeTypeCamera>() - ->setElements( cameras ); + m_originalRenderGraph.getDataNode<NodeTypeCamera>()->setElements( cameras ); // Update the render graph m_originalRenderGraph.update(); diff --git a/src/libRender/RadiumNBR/NodeBasedRenderer.hpp b/src/libRender/RadiumNBR/NodeBasedRenderer.hpp index af9b439eb689de4ca1c7545503961b1eb50fd998..aac89df76089eea0ea9758ce78f2c807b132cf55 100644 --- a/src/libRender/RadiumNBR/NodeBasedRenderer.hpp +++ b/src/libRender/RadiumNBR/NodeBasedRenderer.hpp @@ -1,8 +1,8 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> +#include <RadiumNBR/NodeGraph/RenderGraph.hpp> #include <Core/Resources/Resources.hpp> #include <Engine/Rendering/Renderer.hpp> @@ -70,7 +70,9 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende /// Called once before each frame to update the internal state of the renderer virtual void update( const Ra::Engine::Data::ViewingParameters& renderData ){}; - [[nodiscard]] virtual std::string getRendererName() const { return "Configurable Renderer"; } + [[nodiscard]] virtual std::string getRendererName() const { + return "Configurable Renderer"; + } }; /// Construct a renderer that has to be configured explicitly @@ -96,16 +98,16 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende RenderGraph* getRenderGraph() { return &m_originalRenderGraph; } /// Sets the display sink node - void setDisplayNode(DisplaySinkNode* displayNode) { m_displaySinkNode = displayNode; } + void setDisplayNode( DisplaySinkNode* displayNode ) { m_displaySinkNode = displayNode; } /// Loads the render graph from a Json file. - void loadFromJson(const std::string& jsonFilePath); + void loadFromJson( const std::string& jsonFilePath ); /// Gets the Json file path const std::string& getJsonFilePath() { return m_jsonFilePath; } /// Sets the Json file path - void setJsonFilePath(const std::string& jsonFilePath) { m_jsonFilePath = jsonFilePath; } + void setJsonFilePath( const std::string& jsonFilePath ) { m_jsonFilePath = jsonFilePath; } /// Reloads the render graph void reloadRenderGraph(); @@ -114,13 +116,12 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende void reloadRenderGraphFromJson(); /// Raises the flag to reload the Json - void signalReloadJson(bool resetPath = false) { + void signalReloadJson( bool resetPath = false ) { m_reloadJson = true; - m_resetPath = resetPath; + m_resetPath = resetPath; } protected: - void initializeInternal() override; void resizeInternal() override; void updateStepInternal( const Ra::Engine::Data::ViewingParameters& renderData ) override; @@ -136,13 +137,13 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende virtual void initResources(); /// The render graph used to start the rendering - RenderGraph m_originalRenderGraph {"Original Render Graph"}; + RenderGraph m_originalRenderGraph{ "Original Render Graph" }; /// The JSON file to read to create the render graph - std::string m_jsonFilePath {""}; + std::string m_jsonFilePath{ "" }; /// The display sink node used to get the secondary textures - DisplaySinkNode* m_displaySinkNode {nullptr}; + DisplaySinkNode* m_displaySinkNode{ nullptr }; public: inline std::map<std::string, std::shared_ptr<Ra::Engine::Data::Texture>>& sharedTextures() { @@ -164,16 +165,16 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende RenderControlFunctor& m_controller; /// The name of the renderer - std::string m_name{"Configurable Renderer"}; + std::string m_name{ "Configurable Renderer" }; /// Texture to be read for postprocess according to the display node - Ra::Engine::Data::Texture* m_colorTexture {nullptr}; + Ra::Engine::Data::Texture* m_colorTexture{ nullptr }; /// Signal the renderer to reload the json - bool m_reloadJson {false}; + bool m_reloadJson{ false }; /// Signal the renderer to reset its json path - bool m_resetPath {false}; + bool m_resetPath{ false }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp b/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp index 73f5a1e2f5042b02b9acfd49157fc6dc89f207ae..2265c3a4345dd7018333377c626df306b7c79b41 100644 --- a/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp @@ -18,8 +18,7 @@ struct EditableParameter : public EditableParameterBase { EditableParameter( std::string name, T& data ) : EditableParameterBase( name, typeid( T ).hash_code() ), m_data( data ){}; - void addAdditionalData( T newData ) { additionalData.push_back( newData ); - } + void addAdditionalData( T newData ) { additionalData.push_back( newData ); } T& m_data; std::vector<T> additionalData; diff --git a/src/libRender/RadiumNBR/NodeGraph/ExternalData.hpp b/src/libRender/RadiumNBR/NodeGraph/ExternalData.hpp index a32e923a5ba63a85012ac808fcb15c8fe9659fc5..144544af4e3c1a7992db7cd0e122538783dce465 100644 --- a/src/libRender/RadiumNBR/NodeGraph/ExternalData.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/ExternalData.hpp @@ -2,23 +2,15 @@ #pragma once #include <string> -enum struct RenderObjectVisibility { - OPAQUE, - MASK, - BLEND -}; +enum struct RenderObjectVisibility { OPAQUE, MASK, BLEND }; struct TmpRenderObject { - std::string name = ""; + std::string name = ""; RenderObjectVisibility visibility = RenderObjectVisibility::OPAQUE; }; -enum struct LightType { - DIRECTIONAL, - SPOT, - POINT -}; +enum struct LightType { DIRECTIONAL, SPOT, POINT }; struct TmpLight { LightType type = LightType::DIRECTIONAL; -}; \ No newline at end of file +}; diff --git a/src/libRender/RadiumNBR/NodeGraph/Node.cpp b/src/libRender/RadiumNBR/NodeGraph/Node.cpp new file mode 100644 index 0000000000000000000000000000000000000000..39bcfcb497f8aed57988a1fb2d8fea64d615ebd6 --- /dev/null +++ b/src/libRender/RadiumNBR/NodeGraph/Node.cpp @@ -0,0 +1,16 @@ +#include <RadiumNBR/NodeGraph/Node.hpp> + +void Node::fromJson( const nlohmann::json& data ) { + // TODO get the common content of the Node from the json data + m_uuid = data["id"]; + + // get the specific concrete node informations + fromJsonInternal( data ); +} + +void Node::toJson( nlohmann::json& data ) const { + // TODO write the common content of the Node to the json data + + // Fill the specific concrete node informations + toJsonInternal( data ); +} diff --git a/src/libRender/RadiumNBR/NodeGraph/Node.hpp b/src/libRender/RadiumNBR/NodeGraph/Node.hpp index eb0ae0d46da6d4a16fd35c6ff17f701f58fc2f3e..c85968db5baf40e7cb20bec8f5d0cfd0b9d7253a 100644 --- a/src/libRender/RadiumNBR/NodeGraph/Node.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/Node.hpp @@ -1,7 +1,9 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <RadiumNBR/NodeGraph/Port.hpp> #include <RadiumNBR/NodeGraph/EditableParameter.hpp> +#include <RadiumNBR/NodeGraph/Port.hpp> + +#include <RadiumNBR/externals/json.hpp> #include <cstdint> #include <iostream> @@ -28,24 +30,22 @@ constexpr std::string_view type_name() { std::string_view p = __FUNCSIG__; return std::string_view( p.data() + 84, p.size() - 84 - 7 ); #else - return type_id(T).type_name(); + return type_id( T ).type_name(); #endif } - -inline std::size_t replace_all_in_string(std::string& inout, std::string_view what, std::string_view with) -{ +inline std::size_t +replace_all_in_string( std::string& inout, std::string_view what, std::string_view with ) { std::size_t count{}; - for (std::string::size_type pos{}; - inout.npos != (pos = inout.find(what.data(), pos, what.length())); - pos += with.length(), ++count) { - inout.replace(pos, what.length(), with.data(), with.length()); - } + for ( std::string::size_type pos{}; + inout.npos != ( pos = inout.find( what.data(), pos, what.length() ) ); + pos += with.length(), ++count ) + { inout.replace( pos, what.length(), with.data(), with.length() ); } return count; } -inline std::size_t remove_all_in_string(std::string& inout, std::string_view what) { - return replace_all_in_string(inout, what, ""); +inline std::size_t remove_all_in_string( std::string& inout, std::string_view what ) { + return replace_all_in_string( inout, what, "" ); } #include <Core/Utils/Color.hpp> @@ -65,11 +65,10 @@ class NodeBasedRenderer_LIBRARY_API Node { public: /// Constructor. - /// @param name The name of the node - Node( const std::string& name ) : m_name( name ) {} + Node() = delete; Node( const Node& ) = delete; - Node &operator=(const Node &) = delete; - virtual ~Node() = default; + Node& operator=( const Node& ) = delete; + virtual ~Node() = default; /// The init() function is called once at the start of the application. /// Its goal is to initialize the node's internal data. @@ -89,6 +88,15 @@ class NodeBasedRenderer_LIBRARY_API Node /// @param height The new height of the surface. virtual void resize( uint32_t width, uint32_t height ) = 0; + /// TODO : specify the json format for nodes and what is expected from the following ethods + + /// return the json representation of the concrete node + void toJson( nlohmann::json& data ) const; + virtual void toJsonInternal( nlohmann::json& data ) const {} //= 0; + /// Fill the node from its json description + void fromJson( const nlohmann::json& data ); + virtual void fromJsonInternal( const nlohmann::json& data ) {} //= 0; + /// Build a render technic per material. /// @param ro The render object to get the material from /// @param rt The render technic to build @@ -96,7 +104,7 @@ class NodeBasedRenderer_LIBRARY_API Node Ra::Engine::Rendering::RenderTechnique& rt ) const {} /// Gets the name of the node. - const std::string& getName() const { return m_name; } + const std::string& getName() const { return m_typeName; } /// Gets the in ports of the node. std::vector<std::unique_ptr<PortBase>>& getInputs() { return m_inputs; } /// Gets the out ports of the node. @@ -104,7 +112,7 @@ class NodeBasedRenderer_LIBRARY_API Node /// Gets the editable parameters of the node. std::vector<std::unique_ptr<EditableParameterBase>>& getEditableParameters() { return m_editableParameters; - } + } /// Sets the filesystem (real or virtual) location for the pass resources inline void setResourcesDir( std::string resourcesRootDir ) { @@ -120,12 +128,17 @@ class NodeBasedRenderer_LIBRARY_API Node } /// Flag that checks if the node is already initialized - bool m_initialized{false}; + bool m_initialized{ false }; /// Two nodes are considered equal if there names are the same. - bool operator==( const Node& o_node ) { return m_name == o_node.getName(); } + bool operator==( const Node& o_node ) { return m_typeName == o_node.getName(); } protected: + /// @param instanceName The name of the node + /// @param typeName The type name of the node + Node( const std::string instanceName, const std::string& typeName ) : + m_typeName{ typeName }, m_instanceName{ instanceName } {} + /// Adds an in port to the node. /// This function checks if there is no in port with the same name already associated with this /// node. @@ -162,12 +175,17 @@ class NodeBasedRenderer_LIBRARY_API Node /// Adds an editable parameter to the node. /// @param editableParameter The editable parameter to add. template <typename T> - void addEditableParameter(EditableParameter<T>* editableParameter) { + void addEditableParameter( EditableParameter<T>* editableParameter ) { m_editableParameters.emplace_back( editableParameter ); } - /// The name of the node - std::string m_name; + /// The uuid of the node (TODO, use https://github.com/mariusbancila/stduuid instead of a + /// string) + std::string m_uuid; + /// The type name of the node + std::string m_typeName; + /// The instance name of the node + std::string m_instanceName; /// The in ports of the node std::vector<std::unique_ptr<PortBase>> m_inputs; /// The out ports of the node @@ -177,7 +195,7 @@ class NodeBasedRenderer_LIBRARY_API Node /// The index of the node in the render technique description Ra::Core::Utils::Index m_idx; /// The base resources directory - std::string m_resourceDir{"./"}; + std::string m_resourceDir{ "./" }; /// The renderer's shader program manager Ra::Engine::Data::ShaderProgramManager* m_shaderMngr; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp index a8aabc718dfe7fdabc5804a7598877021287f313..391fd5408918f3f3795d0513aba7c4e404fbef21 100644 --- a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp @@ -1,12 +1,10 @@ #include <RadiumNBR/NodeGraph/NodeFactory.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp> #include <RadiumNBR/EnvMap.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp> namespace NodeFactory { -std::unordered_map<std::string, - std::function<Node*( const nlohmann::json& data )>> - nodesCreators; +std::unordered_map<std::string, std::function<Node*( const nlohmann::json& data )>> nodesCreators; int nodesCreated = 0; @@ -17,16 +15,14 @@ Node* createNode( std::string& nodeType, const nlohmann::json& data ) { { std::cerr << "NodeFactory: no defined node for type " << nodeType << "." << std::endl; std::cerr << "Available nodes are : " << std::endl; - for(const auto&e : nodesCreators ) { - std::cerr << "\t" << e.first << std::endl; - } - + for ( const auto& e : nodesCreators ) + { std::cerr << "\t" << e.first << std::endl; } } return nullptr; } void registerNodeInternal( std::string nodeType, - std::function<Node*( const nlohmann::json& data )> nodeCreator ) { + std::function<Node*( const nlohmann::json& data )> nodeCreator ) { if ( nodesCreators.find( nodeType ) == nodesCreators.end() ) { nodesCreators[nodeType] = std::move( nodeCreator ); } else @@ -41,15 +37,16 @@ int newNodeId() { } void initializeNodeFactory() { - static bool needsInitialization {true}; - if ( needsInitialization ) { + static bool needsInitialization{ true }; + if ( needsInitialization ) + { needsInitialization = false; // Fill the factory with premades nodes NodeFactory::registerNode<SourceNode<bool>>( []( const nlohmann::json& data ) { std::string value = data["model"]["boolean"]; auto sourceBoolean = new SourceNode<bool>( "boolean" + std::to_string( NodeFactory::newNodeId() ) ); - sourceBoolean->setData(value == "1"); + sourceBoolean->setData( value == "1" ); return sourceBoolean; } ); @@ -70,23 +67,23 @@ void initializeNodeFactory() { float green = std::stof( valueGreen ) / 255.0f; float blue = std::stof( valueBlue ) / 255.0f; - auto sourceColor = new SourceNode<NodeTypeColor>( + auto sourceColor = new SourceNode<NodeTypeColor>( "color" + std::to_string( NodeFactory::newNodeId() ) ); - sourceColor->setData(NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB( - Ra::Core::Utils::ColorBase<float>( red, green, blue ).rgb() ) )); + sourceColor->setData( NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB( + Ra::Core::Utils::ColorBase<float>( red, green, blue ).rgb() ) ) ); return sourceColor; } ); NodeFactory::registerNode<ColorTextureNode>( []( const nlohmann::json& data ) { - auto sourceColorTexture = new ColorTextureNode( - "colorTexture" + std::to_string( NodeFactory::newNodeId() ) ); + auto sourceColorTexture = + new ColorTextureNode( "colorTexture" + std::to_string( NodeFactory::newNodeId() ) ); return sourceColorTexture; } ); NodeFactory::registerNode<DepthTextureNode>( []( const nlohmann::json& data ) { - auto sourceDepthTexture = new DepthTextureNode( - "depthTexture" + std::to_string( NodeFactory::newNodeId() ) ); + auto sourceDepthTexture = + new DepthTextureNode( "depthTexture" + std::to_string( NodeFactory::newNodeId() ) ); return sourceDepthTexture; } ); @@ -100,8 +97,8 @@ void initializeNodeFactory() { NodeFactory::registerNode<FilterROByNameNode>( []( const nlohmann::json& data ) { std::string filteredName = data["model"]["filteredName"]; - auto filterROByName = new FilterROByNameNode( - "filterROByName" + std::to_string( NodeFactory::newNodeId() )); + auto filterROByName = new FilterROByNameNode( + "filterROByName" + std::to_string( NodeFactory::newNodeId() ) ); filterROByName->setNameToFilter( filteredName ); return filterROByName; } ); @@ -125,8 +122,8 @@ void initializeNodeFactory() { } ); NodeFactory::registerNode<EnvLightNode>( []( const nlohmann::json& data ) { - auto environmentLight = - new EnvLightNode( "environmentLightPass" + std::to_string( NodeFactory::newNodeId() ) ); + auto environmentLight = new EnvLightNode( "environmentLightPass" + + std::to_string( NodeFactory::newNodeId() ) ); return environmentLight; } ); @@ -143,19 +140,20 @@ void initializeNodeFactory() { } ); NodeFactory::registerNode<TransparencyNode>( []( const nlohmann::json& data ) { - auto transparency = - new TransparencyNode( "transparencyPass" + std::to_string( NodeFactory::newNodeId() ) ); + auto transparency = new TransparencyNode( "transparencyPass" + + std::to_string( NodeFactory::newNodeId() ) ); return transparency; } ); NodeFactory::registerNode<VolumeNode>( []( const nlohmann::json& data ) { - auto volume = new VolumeNode( "volumePass" + std::to_string( NodeFactory::newNodeId() ) ); + auto volume = + new VolumeNode( "volumePass" + std::to_string( NodeFactory::newNodeId() ) ); return volume; } ); NodeFactory::registerNode<VolumeVizualisationNode>( []( const nlohmann::json& data ) { - auto volumeViz = new VolumeVizualisationNode( "volumeVizualisationPass" + - std::to_string( NodeFactory::newNodeId() ) ); + auto volumeViz = new VolumeVizualisationNode( + "volumeVizualisationPass" + std::to_string( NodeFactory::newNodeId() ) ); return volumeViz; } ); @@ -170,57 +168,57 @@ void initializeNodeFactory() { return wireframe; } ); - NodeFactory::registerNode<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>( []( const nlohmann::json& data ) -> Node* { - std::string name = data["model"]["name"]; - std::string files = data["model"]["files"]; - std::string envt = data["model"]["type"]; - std::string strength = data["model"]["strength"]; - float s = std::atof( strength.c_str() ) / 100.; - int t = std::stoi( envt.c_str() ); - RadiumNBR::EnvMap::EnvMapType envType; - switch ( t ) - { - case 0: - envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM; - break; - case 1: - envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE; - break; - case 2: - envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_LATLON; - break; - default: - return nullptr; - } - // check if the file exists - bool envmap_exist; - if ( envType == RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE ) - { - std::string f1 = files.substr( 0, files.find( ';' ) - 1 ); - envmap_exist = std::filesystem::exists( f1 ); - } - else - { envmap_exist = std::filesystem::exists( files ); } - if ( !envmap_exist ) - { - auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>( - name + "_" + std::to_string( NodeFactory::newNodeId() ) ); - return node; - } - else - { - auto envmp = std::make_shared<RadiumNBR::EnvMap>( files, envType, true ); - envmp->setEnvStrength( s ); - auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>( - name + "_" + std::to_string( NodeFactory::newNodeId() ) ); - node->setData( envmp ); - return node; - } - } ); + NodeFactory::registerNode<SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>>( + []( const nlohmann::json& data ) -> Node* { + std::string name = data["model"]["name"]; + std::string files = data["model"]["files"]; + std::string envt = data["model"]["type"]; + std::string strength = data["model"]["strength"]; + float s = std::atof( strength.c_str() ) / 100.; + int t = std::stoi( envt.c_str() ); + RadiumNBR::EnvMap::EnvMapType envType; + switch ( t ) + { + case 0: + envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM; + break; + case 1: + envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE; + break; + case 2: + envType = RadiumNBR::EnvMap::EnvMapType::ENVMAP_LATLON; + break; + default: + return nullptr; + } + // check if the file exists + bool envmap_exist; + if ( envType == RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE ) + { + std::string f1 = files.substr( 0, files.find( ';' ) - 1 ); + envmap_exist = std::filesystem::exists( f1 ); + } + else + { envmap_exist = std::filesystem::exists( files ); } + if ( !envmap_exist ) + { + auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>( + name + "_" + std::to_string( NodeFactory::newNodeId() ) ); + return node; + } + else + { + auto envmp = std::make_shared<RadiumNBR::EnvMap>( files, envType, true ); + envmp->setEnvStrength( s ); + auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>( + name + "_" + std::to_string( NodeFactory::newNodeId() ) ); + node->setData( envmp ); + return node; + } + } ); NodeFactory::registerNode<SumNode>( []( const nlohmann::json& data ) { - auto sum = - new SumNode( "sum" + std::to_string( NodeFactory::newNodeId() ) ); + auto sum = new SumNode( "sum" + std::to_string( NodeFactory::newNodeId() ) ); return sum; } ); @@ -243,34 +241,31 @@ void initializeNodeFactory() { } ); NodeFactory::registerNode<MaxNode>( []( const nlohmann::json& data ) { - auto max = - new MaxNode( "max" + std::to_string( NodeFactory::newNodeId() ) ); + auto max = new MaxNode( "max" + std::to_string( NodeFactory::newNodeId() ) ); return max; } ); NodeFactory::registerNode<MinNode>( []( const nlohmann::json& data ) { - auto min = - new MinNode( "min" + std::to_string( NodeFactory::newNodeId() ) ); + auto min = new MinNode( "min" + std::to_string( NodeFactory::newNodeId() ) ); return min; } ); NodeFactory::registerNode<MoreThanThresholdNode>( []( const nlohmann::json& data ) { - auto moreThanThreshold = - new MoreThanThresholdNode( "more than threshold" + std::to_string( NodeFactory::newNodeId() ) ); + auto moreThanThreshold = new MoreThanThresholdNode( + "more than threshold" + std::to_string( NodeFactory::newNodeId() ) ); return moreThanThreshold; } ); NodeFactory::registerNode<LessThanThresholdNode>( []( const nlohmann::json& data ) { - auto lessThanThreshold = - new LessThanThresholdNode( "less than threshold" + std::to_string( NodeFactory::newNodeId() ) ); + auto lessThanThreshold = new LessThanThresholdNode( + "less than threshold" + std::to_string( NodeFactory::newNodeId() ) ); return lessThanThreshold; } ); NodeFactory::registerNode<FXAANode>( []( const nlohmann::json& data ) { - auto fxaa = - new FXAANode( "fxaa" + std::to_string( NodeFactory::newNodeId() ) ); + auto fxaa = new FXAANode( "fxaa" + std::to_string( NodeFactory::newNodeId() ) ); return fxaa; } ); } } -}; +}; // namespace NodeFactory diff --git a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.hpp b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.hpp index a7f17a592805aad7d46ffd2bdc9c842519e95ae5..53583f1abb691d2e89f220db5e7a29ddd01f0246 100644 --- a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.hpp @@ -2,23 +2,24 @@ #include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/NodeGraph/Node.hpp> #include <RadiumNBR/externals/json.hpp> -#include <unordered_map> -#include <iostream> #include <functional> +#include <iostream> +#include <unordered_map> namespace NodeFactory { NodeBasedRenderer_LIBRARY_API Node* createNode( std::string& nodeType, const nlohmann::json& data ); -NodeBasedRenderer_LIBRARY_API void registerNodeInternal( std::string nodeType, std::function<Node*( const nlohmann::json& data )> nodeCreator ); +NodeBasedRenderer_LIBRARY_API void +registerNodeInternal( std::string nodeType, + std::function<Node*( const nlohmann::json& data )> nodeCreator ); template <typename T> -void -registerNode( std::function<Node*( const nlohmann::json& data )> nodeCreator ) { - registerNodeInternal(T::getTypename(), std::move(nodeCreator)); +void registerNode( std::function<Node*( const nlohmann::json& data )> nodeCreator ) { + registerNodeInternal( T::getTypename(), std::move( nodeCreator ) ); } NodeBasedRenderer_LIBRARY_API int newNodeId(); NodeBasedRenderer_LIBRARY_API void initializeNodeFactory(); -}; +}; // namespace NodeFactory diff --git a/src/libRender/RadiumNBR/NodeGraph/Port.hpp b/src/libRender/RadiumNBR/NodeGraph/Port.hpp index 77ef3f40a7e25c1dba86c12c9b0521b9b0463373..9925e9b7905b52f5123b9e7590f6e2e0d36c559e 100644 --- a/src/libRender/RadiumNBR/NodeGraph/Port.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/Port.hpp @@ -116,8 +116,8 @@ class PortIn : public PortBase bool connect( PortBase* other ) override { if ( accept( other ) ) { - m_from = dynamic_cast<PortOut<T>*>( other ); - m_isLinked = true; + m_from = dynamic_cast<PortOut<T>*>( other ); + m_isLinked = true; } return m_isLinked; } diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.cpp index 0308d8b93e2133e3b834d94ad0c7ea589c97d4a4..20350ced1bb6891baecbe493ff05a8c5a25a85b0 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.hpp> -FXAANode::FXAANode( const std::string& name ) : Node( name ) { +FXAANode::FXAANode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -62,8 +62,10 @@ void FXAANode::init() { "float brightnessE = dot(e, brightnessCoefficients);\n" "float brightnessW = dot(w, brightnessCoefficients);\n" "float brightnessM = dot(m, brightnessCoefficients);\n" - "float brightnessMin = min(brightnessM, min(min(brightnessN, brightnessS), min(brightnessE, brightnessW)));\n" - "float brightnessMax = max(brightnessM, max(max(brightnessN, brightnessS), max(brightnessE, brightnessW)));\n" + "float brightnessMin = min(brightnessM, min(min(brightnessN, brightnessS), " + "min(brightnessE, brightnessW)));\n" + "float brightnessMax = max(brightnessM, max(max(brightnessN, brightnessS), " + "max(brightnessE, brightnessW)));\n" "float contrast = brightnessMax - brightnessMin;\n" "float threshold = max(THRESHOLD, RELATIVE_THRESHOLD * brightnessMax);\n" "if (contrast < threshold) {\n" @@ -159,5 +161,4 @@ void FXAANode::resize( uint32_t width, uint32_t height ) { } void FXAANode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.cpp index fd2dc6d29d873520ebca84436365302eb803a17a..1dac170d5ccad3c35a72479e27a2ca8a658f8903 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp> -DifferenceNode::DifferenceNode( const std::string& name ) : Node( name ) { +DifferenceNode::DifferenceNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -109,4 +109,4 @@ void DifferenceNode::resize( uint32_t width, uint32_t height ) { } void DifferenceNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} \ No newline at end of file + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp index 66ad96ee2b2c74b7834ef3f463719616b293a19e..eb3ce33da2fd67c6413dc81c053bc6d7df4d9203 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp @@ -1,6 +1,7 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp> -LessThanThresholdNode::LessThanThresholdNode( const std::string& name ) : Node( name ) { +LessThanThresholdNode::LessThanThresholdNode( const std::string& name ) : + Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -25,8 +26,8 @@ LessThanThresholdNode::LessThanThresholdNode( const std::string& name ) : Node( addOutput( portOutColorTex, m_colorTexture ); auto editableThreshold = new EditableParameter<float>( "threshold", m_editableThreshold ); - editableThreshold->addAdditionalData(0.0f); - editableThreshold->addAdditionalData(1.0f); + editableThreshold->addAdditionalData( 0.0f ); + editableThreshold->addAdditionalData( 1.0f ); addEditableParameter( editableThreshold ); } @@ -53,7 +54,8 @@ void LessThanThresholdNode::init() { "uniform float threshold;\n" "in vec2 varTexcoord;\n" "void main() {\n" - " out_tex = dot(texture(tex1_sampler, varTexcoord).rgb, vec3(0.2126, 0.7152, 0.0722)) <= threshold ? texture(tex1_sampler, varTexcoord) : vec4(0.0, 0.0, 0.0, 1.0);\n" + " out_tex = dot(texture(tex1_sampler, varTexcoord).rgb, vec3(0.2126, 0.7152, 0.0722)) <= " + "threshold ? texture(tex1_sampler, varTexcoord) : vec4(0.0, 0.0, 0.0, 1.0);\n" "}" }; Ra::Engine::Data::ShaderConfiguration config{ "ComposeMax" }; @@ -106,6 +108,6 @@ void LessThanThresholdNode::resize( uint32_t width, uint32_t height ) { m_colorTexture->resize( width, height ); } -void LessThanThresholdNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - +void LessThanThresholdNode::buildRenderTechnique( + const Ra::Engine::Rendering::RenderObject* ro, + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp index 482df29384d83ce85bc2b8d944d84ef42783f7d3..6d5596a8c7d208fa476f84256c46a99f31ca563a 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp @@ -32,5 +32,5 @@ class NodeBasedRenderer_LIBRARY_API LessThanThresholdNode : public Node globjects::Framebuffer* m_framebuffer{ nullptr }; - float m_editableThreshold{0.0}; + float m_editableThreshold{ 0.0 }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.cpp index e82f87db9ab9d2ba58ebd9a12d46f93c4cc537cf..4b0e6cbe165f5f60b411843dd8bffb5976721c0d 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.hpp> -MaxNode::MaxNode( const std::string& name ) : Node( name ) { +MaxNode::MaxNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -45,14 +45,14 @@ void MaxNode::init() { " gl_Position = vec4(in_position, 1.0);\n" " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" "}\n" }; - const std::string composeFragmentShader{ - "layout (location = 0) out vec4 out_tex;\n" - "uniform sampler2D tex1_sampler;\n" - "uniform sampler2D tex2_sampler;\n" - "in vec2 varTexcoord;\n" - "void main() {\n" - " out_tex = max(texture(tex1_sampler, varTexcoord), texture(tex2_sampler, varTexcoord));\n" - "}" }; + const std::string composeFragmentShader{ "layout (location = 0) out vec4 out_tex;\n" + "uniform sampler2D tex1_sampler;\n" + "uniform sampler2D tex2_sampler;\n" + "in vec2 varTexcoord;\n" + "void main() {\n" + " out_tex = max(texture(tex1_sampler, varTexcoord), " + "texture(tex2_sampler, varTexcoord));\n" + "}" }; Ra::Engine::Data::ShaderConfiguration config{ "ComposeMax" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader ); @@ -109,5 +109,4 @@ void MaxNode::resize( uint32_t width, uint32_t height ) { } void MaxNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.cpp index 2785e4d8647109b34d016095f1028b884046828c..22e4565a6e8459083e53c96830be43bd27510396 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.hpp> -MinNode::MinNode( const std::string& name ) : Node( name ) { +MinNode::MinNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -45,14 +45,14 @@ void MinNode::init() { " gl_Position = vec4(in_position, 1.0);\n" " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" "}\n" }; - const std::string composeFragmentShader{ - "layout (location = 0) out vec4 out_tex;\n" - "uniform sampler2D tex1_sampler;\n" - "uniform sampler2D tex2_sampler;\n" - "in vec2 varTexcoord;\n" - "void main() {\n" - " out_tex = min(texture(tex1_sampler, varTexcoord), texture(tex2_sampler, varTexcoord));\n" - "}" }; + const std::string composeFragmentShader{ "layout (location = 0) out vec4 out_tex;\n" + "uniform sampler2D tex1_sampler;\n" + "uniform sampler2D tex2_sampler;\n" + "in vec2 varTexcoord;\n" + "void main() {\n" + " out_tex = min(texture(tex1_sampler, varTexcoord), " + "texture(tex2_sampler, varTexcoord));\n" + "}" }; Ra::Engine::Data::ShaderConfiguration config{ "ComposeMin" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader ); @@ -109,5 +109,4 @@ void MinNode::resize( uint32_t width, uint32_t height ) { } void MinNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp index 010c61e24739451a2160914c7116c77a9df27360..1fc30cdda98771de553a3e26f19a0d2911068ef2 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp @@ -1,6 +1,7 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp> -MoreThanThresholdNode::MoreThanThresholdNode( const std::string& name ) : Node( name ) { +MoreThanThresholdNode::MoreThanThresholdNode( const std::string& name ) : + Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -25,8 +26,8 @@ MoreThanThresholdNode::MoreThanThresholdNode( const std::string& name ) : Node( addOutput( portOutColorTex, m_colorTexture ); auto editableThreshold = new EditableParameter<float>( "threshold", m_editableThreshold ); - editableThreshold->addAdditionalData(0.0f); - editableThreshold->addAdditionalData(1.0f); + editableThreshold->addAdditionalData( 0.0f ); + editableThreshold->addAdditionalData( 1.0f ); addEditableParameter( editableThreshold ); } @@ -53,7 +54,8 @@ void MoreThanThresholdNode::init() { "uniform float threshold;\n" "in vec2 varTexcoord;\n" "void main() {\n" - " out_tex = dot(texture(tex1_sampler, varTexcoord).rgb, vec3(0.2126, 0.7152, 0.0722)) >= threshold ? texture(tex1_sampler, varTexcoord) : vec4(0.0, 0.0, 0.0, 1.0);\n" + " out_tex = dot(texture(tex1_sampler, varTexcoord).rgb, vec3(0.2126, 0.7152, 0.0722)) >= " + "threshold ? texture(tex1_sampler, varTexcoord) : vec4(0.0, 0.0, 0.0, 1.0);\n" "}" }; Ra::Engine::Data::ShaderConfiguration config{ "ComposeMax" }; @@ -106,6 +108,6 @@ void MoreThanThresholdNode::resize( uint32_t width, uint32_t height ) { m_colorTexture->resize( width, height ); } -void MoreThanThresholdNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - +void MoreThanThresholdNode::buildRenderTechnique( + const Ra::Engine::Rendering::RenderObject* ro, + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp index 5abe80571b1fd57498928cdf684659644049637f..b803d78dad3e2110be6fe9f7c9a1419e7a2d8643 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp @@ -32,5 +32,5 @@ class NodeBasedRenderer_LIBRARY_API MoreThanThresholdNode : public Node globjects::Framebuffer* m_framebuffer{ nullptr }; - float m_editableThreshold{0.0}; + float m_editableThreshold{ 0.0 }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.cpp index aec4da6baeaff40cebab6912f0c05faffcd11311..1cd9640a33af1b083b37e058721c00c3f0f8fa7c 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.hpp> -MultiplyNode::MultiplyNode( const std::string& name ) : Node( name ) { +MultiplyNode::MultiplyNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -109,5 +109,4 @@ void MultiplyNode::resize( uint32_t width, uint32_t height ) { } void MultiplyNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.cpp index d1e60dd16818fa6a13f5a074e6b3dce3bdb94007..77a7d22ead822f337154a7741ca325813f15e068 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.hpp> -OneMinusNode::OneMinusNode( const std::string& name ) : Node( name ) { +OneMinusNode::OneMinusNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -100,5 +100,4 @@ void OneMinusNode::resize( uint32_t width, uint32_t height ) { } void OneMinusNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.cpp index 6cdf64037cf8868a0d056b49bb358c64a93f9d91..b49ba8040c0e65c006552bc9c9d72d782438768e 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.cpp @@ -1,6 +1,6 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp> -SumNode::SumNode( const std::string& name ) : Node( name ) { +SumNode::SumNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor1 = new PortIn<NodeTypeTexture>( "inColorTexture1", this ); addInput( portInColor1 ); portInColor1->mustBeLinked(); @@ -109,5 +109,4 @@ void SumNode::resize( uint32_t width, uint32_t height ) { } void SumNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const {} - + Ra::Engine::Rendering::RenderTechnique& rt ) const {} diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp index 263198a3e66100cb1c70ca732eadcb66055ef097..a477aaf0a3e8d69b6e38db54a0fe75197f4f6c9b 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp @@ -6,7 +6,7 @@ class NodeBasedRenderer_LIBRARY_API SimpleNode : public Node { public: - explicit SimpleNode(const std::string& name) : Node( name ) { + explicit SimpleNode( const std::string& name ) : Node( name, getTypename() ) { auto portInRO = new PortIn<std::vector<NodeTypeRenderObject>>( "inRenderObjects", this ); addInput( portInRO ); auto portInC = new PortIn<std::vector<NodeTypeCamera>>( "inCameras", this ); @@ -36,7 +36,7 @@ class NodeBasedRenderer_LIBRARY_API SimpleNode : public Node } void init() override { - m_framebuffer = new globjects::Framebuffer(); + m_framebuffer = new globjects::Framebuffer(); Ra::Engine::Data::TextureParameters depthTexParams = { "Depth Texture", gl::GL_TEXTURE_2D, @@ -70,14 +70,12 @@ class NodeBasedRenderer_LIBRARY_API SimpleNode : public Node m_blankAO->initializeGL(); } - void update() override { + void update() override {} - } - - void execute() override { + void execute() override { Ra::Engine::Data::RenderParameters inPassParams; - // Render objects + // Render objects auto inputRO = dynamic_cast<PortIn<std::vector<NodeTypeRenderObject>>*>( m_inputs[0].get() ); std::vector<NodeTypeRenderObject> renderObjects; @@ -155,19 +153,19 @@ class NodeBasedRenderer_LIBRARY_API SimpleNode : public Node m_framebuffer->unbind(); } - void destroy() override { + void destroy() override { delete m_framebuffer; delete m_colorTexture; delete m_depthTexture; } - void resize(uint32_t width, uint32_t height) override { + void resize( uint32_t width, uint32_t height ) override { m_colorTexture->resize( width, height ); m_depthTexture->resize( width, height ); } - void buildRenderTechnique(const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt) const override { + void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, + Ra::Engine::Rendering::RenderTechnique& rt ) const override { auto mat = const_cast<Ra::Engine::Rendering::RenderObject*>( ro )->getMaterial(); // Volumes are not used in EnvLightPass if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp index 64b3a92758c208c9640324cd6e390d713e1581f4..5b1eba1e6be34049bb274b11d978b0be7b8037de 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp @@ -6,14 +6,8 @@ template <typename T> class FilterNode : public Node { public: - FilterNode( const std::string& name, std::function<bool( T )> filterFunction ) : - Node( name ), m_filterFunction( filterFunction ) { - auto portIn = new PortIn<std::vector<T>>( "in", this ); - addInput( portIn ); - portIn->mustBeLinked(); - auto portOut = new PortOut<std::vector<T>>( "out", this ); - addOutput( portOut, &m_elements ); - } + FilterNode( const std::string& instanceName, std::function<bool( T )> filterFunction ) : + FilterNode( instanceName, getTypename(), filterFunction ) {} void init() override { #ifdef GRAPH_CALL_TRACE @@ -57,6 +51,18 @@ class FilterNode : public Node } static const std::string getTypename() { return "Filter"; } + protected: + FilterNode( const std::string& instanceName, + const std::string& typeName, + std::function<bool( T )> filterFunction ) : + Node( instanceName, typeName ), m_filterFunction( filterFunction ) { + auto portIn = new PortIn<std::vector<T>>( "in", this ); + addInput( portIn ); + portIn->mustBeLinked(); + auto portOut = new PortOut<std::vector<T>>( "out", this ); + addOutput( portOut, &m_elements ); + } + private: std::function<bool( T )> m_filterFunction; std::vector<T> m_elements; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp index 4084edf3abca3ec14841daf19fcd4d7886cb1674..b7696c22d00415d44c8c17a5d118dee2e3dc68c4 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByNameNode.hpp @@ -2,19 +2,22 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp> #include <regex> -class FilterROByNameNode : public FilterNode<NodeTypeRenderObject> { +class FilterROByNameNode : public FilterNode<NodeTypeRenderObject> +{ public: FilterROByNameNode( const std::string& name ) : - FilterNode<NodeTypeRenderObject>( name, [this]( const NodeTypeRenderObject& ro ) { - try - { - std::regex regularExpression{ m_filteredName, - std::regex::egrep }; - return std::regex_search( ro->getName().c_str(), regularExpression ); - } - catch ( ... ) - { return false; } - } ) {} + FilterNode<NodeTypeRenderObject>( + name, + getTypename(), + [this]( const NodeTypeRenderObject& ro ) { + try + { + std::regex regularExpression{ m_filteredName, std::regex::egrep }; + return std::regex_search( ro->getName().c_str(), regularExpression ); + } + catch ( ... ) + { return false; } + } ) {} void setNameToFilter( const std::string& newNameToFilter ) { m_filteredName = newNameToFilter; } @@ -22,4 +25,4 @@ class FilterROByNameNode : public FilterNode<NodeTypeRenderObject> { private: std::string m_filteredName{ "" }; -}; \ No newline at end of file +}; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp index 4aa92d7e09f26694dedf9ca1c714702f0529f2dd..df569972f230069d9333d05ea6f6664d09d58626 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp @@ -1,24 +1,27 @@ #pragma once -#include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp> #include <Engine/Data/Material.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp> class FilterROByTypeNode : public FilterNode<NodeTypeRenderObject> { public: FilterROByTypeNode( const std::string& name ) : - FilterNode<NodeTypeRenderObject>( name, [this]( const NodeTypeRenderObject& ro ) { - if ( m_filteredType == "Opaque" ) { return !ro->isTransparent(); } - else if ( m_filteredType == "Transparent" ) - { return ro->isTransparent(); } - else if ( m_filteredType == "Volume" ) - { - auto material = ro->getMaterial(); - return material && material->getMaterialAspect() == - Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY; - } - else - { return false; } - } ) {} + FilterNode<NodeTypeRenderObject>( + name, + getTypename(), + [this]( const NodeTypeRenderObject& ro ) { + if ( m_filteredType == "Opaque" ) { return !ro->isTransparent(); } + else if ( m_filteredType == "Transparent" ) + { return ro->isTransparent(); } + else if ( m_filteredType == "Volume" ) + { + auto material = ro->getMaterial(); + return material && material->getMaterialAspect() == + Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY; + } + else + { return false; } + } ) {} void setTypeToFilter( const std::string& newTypeToFilter ) { m_filteredType = newTypeToFilter; } @@ -26,4 +29,4 @@ class FilterROByTypeNode : public FilterNode<NodeTypeRenderObject> private: std::string m_filteredType{ "Opaque" }; -}; \ No newline at end of file +}; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp index 126b9d5609b97555e7d630dafa737aa4736319c6..80bf3630473165bf1306b667c6e10a843e918bae 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/PremadeNodesIncludes.hpp @@ -1,9 +1,9 @@ #pragma once #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp> @@ -11,10 +11,10 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> @@ -25,14 +25,14 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterROByTypeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/DifferenceNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MaxNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MinNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/MultiplyNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/OneMinusNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Compositing/SumNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/AntiAliasing/FXAANode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> \ No newline at end of file +#include <RadiumNBR/NodeGraph/PremadeNodes/Demo/SimpleNode.hpp> diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp index ae2811cbd9bb895738314821d5c1451663550a6b..f893396cc7e7df59d933f258420498e9d18c5559 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp @@ -5,7 +5,8 @@ #include <Engine/Data/RenderParameters.hpp> #include <Engine/RadiumEngine.hpp> -AccessibilityBufferNode::AccessibilityBufferNode( const std::string& name ) : Node( name ) { +AccessibilityBufferNode::AccessibilityBufferNode( const std::string& name ) : + Node( name, getTypename() ) { auto portInPosition = new PortIn<NodeTypeTexture>( "inPositionToWorldTexture", this ); addInput( portInPosition ); portInPosition->mustBeLinked(); @@ -69,9 +70,9 @@ void AccessibilityBufferNode::init() { std::string resourcesRootDir = m_resourceDir; auto added = m_shaderMngr->addShaderProgram( - {{"SSDO"}, - resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", - resourcesRootDir + "Shaders/AccessibilityPass/ssao.frag.glsl"} ); + { { "SSDO" }, + resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", + resourcesRootDir + "Shaders/AccessibilityPass/ssao.frag.glsl" } ); if ( added ) { m_shader = added.value(); } else { @@ -80,9 +81,9 @@ void AccessibilityBufferNode::init() { } added = m_shaderMngr->addShaderProgram( - {{"blurSSDO"}, - resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", - resourcesRootDir + "Shaders/AccessibilityPass/blurao.frag.glsl"} ); + { { "blurSSDO" }, + resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", + resourcesRootDir + "Shaders/AccessibilityPass/blurao.frag.glsl" } ); if ( added ) { m_blurShader = added.value(); } else { @@ -109,11 +110,11 @@ void AccessibilityBufferNode::update() { void AccessibilityBufferNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Positions - auto inputPosition = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputPosition = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); NodeTypeTexture* posTexture = &inputPosition->getData(); // Normals - auto inputNormal = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputNormal = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* normalTexture = &inputNormal->getData(); // AO Radius @@ -123,19 +124,19 @@ void AccessibilityBufferNode::execute() { #ifdef GRAPH_CALL_TRACE else { - std::cout << "AO Radius port is not linked, using default value " << m_aoRadius - << "." << std::endl; } + std::cout << "AO Radius port is not linked, using default value " << m_aoRadius << "." + << std::endl; + } #endif // AO Samples int samples = m_editableSamples; if ( m_inputs[3]->isLinked() ) + { samples = static_cast<int>( dynamic_cast<PortIn<Scalar>*>( m_inputs[3].get() )->getData() ); } + if ( m_currentSamples != samples ) { - samples = static_cast<int>(dynamic_cast<PortIn<Scalar>*>(m_inputs[3].get())->getData()); - } - if (m_currentSamples != samples) { m_currentSamples = samples; - m_sphereSampler = std::make_unique<RadiumNBR::SphereSampler>( + m_sphereSampler = std::make_unique<RadiumNBR::SphereSampler>( RadiumNBR::SphereSampler::SamplingMethod::HAMMERSLEY, m_currentSamples ); } @@ -147,9 +148,9 @@ void AccessibilityBufferNode::execute() { #endif m_framebuffer->bind(); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); - float clearWhite[4] = {1.0f, 1.0f, 1.0f, 0.0f}; + float clearWhite[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; gl::glClearBufferfv( gl::GL_COLOR, 0, clearWhite ); gl::glDisable( gl::GL_DEPTH_TEST ); gl::glDepthMask( gl::GL_FALSE ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp index 6d62ee8cbfceb7e9748eb0f44e29d0ebc3c3f1fd..85a7f7af3bcf92347da4f1782e5b9066c2ee364e 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp @@ -21,8 +21,8 @@ class NodeBasedRenderer_LIBRARY_API AccessibilityBufferNode : public Node static const std::string getTypename() { return "Accessibility Buffer Pass"; } private: - NodeTypeTexture* m_rawAO{nullptr}; - NodeTypeTexture* m_AO{nullptr}; + NodeTypeTexture* m_rawAO{ nullptr }; + NodeTypeTexture* m_AO{ nullptr }; Scalar m_editableAORadius{ 5 }; Scalar m_editableSamples{ 64 }; @@ -30,12 +30,12 @@ class NodeBasedRenderer_LIBRARY_API AccessibilityBufferNode : public Node int m_currentSamples{ 64 }; Scalar m_sceneDiag{ 1.0 }; - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; - std::unique_ptr<RadiumNBR::SphereSampler> m_sphereSampler{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; + std::unique_ptr<RadiumNBR::SphereSampler> m_sphereSampler{ nullptr }; - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; - const Ra::Engine::Data::ShaderProgram* m_blurShader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; + const Ra::Engine::Data::ShaderProgram* m_blurShader{ nullptr }; - globjects::Framebuffer* m_blurFramebuffer{nullptr}; - globjects::Framebuffer* m_framebuffer{nullptr}; + globjects::Framebuffer* m_blurFramebuffer{ nullptr }; + globjects::Framebuffer* m_framebuffer{ nullptr }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp index a809d7b7f9104c00f0e2e29b87cd14e454b65137..a6cb0928f9806d0698d3bd472b1e17ba28a3b0f8 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp @@ -4,7 +4,7 @@ using EnvMapData = std::shared_ptr<RadiumNBR::EnvMap>; -ClearColorNode::ClearColorNode( const std::string& name ) : Node( name ) { +ClearColorNode::ClearColorNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTextureToClear", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -18,8 +18,8 @@ ClearColorNode::ClearColorNode( const std::string& name ) : Node( name ) { auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColor", this ); addOutput( portOutColorTex, m_colorTexture ); - auto editableColor = new EditableParameter("clear color", m_editableClearColor); - addEditableParameter(editableColor); + auto editableColor = new EditableParameter( "clear color", m_editableClearColor ); + addEditableParameter( editableColor ); } void ClearColorNode::init() { @@ -38,7 +38,7 @@ void ClearColorNode::update() { void ClearColorNode::execute() { // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); @@ -53,10 +53,10 @@ void ClearColorNode::execute() { if ( inputClearColor->isLinked() ) { NodeTypeColor tmpColor = inputClearColor->getData(); - clearColor[0] = tmpColor.x(); - clearColor[1] = tmpColor.y(); - clearColor[2] = tmpColor.z(); - clearColor[3] = tmpColor.w(); + clearColor[0] = tmpColor.x(); + clearColor[1] = tmpColor.y(); + clearColor[2] = tmpColor.z(); + clearColor[3] = tmpColor.w(); #ifdef GRAPH_CALL_TRACE std::cout << "Clear color: " << clearColor[0] << " " << clearColor[1] << " " << clearColor[2] << " " << clearColor[3] << std::endl; @@ -69,7 +69,7 @@ void ClearColorNode::execute() { // Envmap auto inputEnvmap = dynamic_cast<PortIn<EnvMapData>*>( m_inputs[2].get() ); - RadiumNBR::EnvMap* envmap{nullptr}; + RadiumNBR::EnvMap* envmap{ nullptr }; std::vector<NodeTypeCamera> cameras; if ( inputEnvmap->isLinked() ) { @@ -93,15 +93,14 @@ void ClearColorNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glDisable( gl::GL_BLEND ); if ( envmap ) { gl::glDepthMask( gl::GL_FALSE ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); gl::glDisable( gl::GL_DEPTH_TEST ); envmap->render( cameras[0] ); gl::glDepthMask( gl::GL_TRUE ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp index daf75ae4cc807a975c72d04ffa4a0b92dc221678..34faff80428bf0d35ea8d804a073bbc625f9605c 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp @@ -22,8 +22,8 @@ class NodeBasedRenderer_LIBRARY_API ClearColorNode : public Node static const std::string getTypename() { return "Clear Color Pass"; } private: - Ra::Engine::Data::Texture* m_colorTexture{nullptr}; - globjects::Framebuffer* m_framebuffer{nullptr}; + Ra::Engine::Data::Texture* m_colorTexture{ nullptr }; + globjects::Framebuffer* m_framebuffer{ nullptr }; - NodeTypeColor m_editableClearColor{NodeTypeColor::Black()}; + NodeTypeColor m_editableClearColor{ NodeTypeColor::Black() }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.cpp index 5e540d5c904dc401e40fb2ffa662843fb1241eac..7476b2e0f4adc54ae34ff945d77260d39c87abac 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.cpp @@ -3,7 +3,7 @@ #include <Engine/Data/Material.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> -EmissivityNode::EmissivityNode( const std::string& name ) : Node( name ) { +EmissivityNode::EmissivityNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -54,13 +54,13 @@ void EmissivityNode::update() { void EmissivityNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // AO Radius @@ -93,19 +93,16 @@ void EmissivityNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glDepthMask( gl::GL_FALSE ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); gl::glEnable( gl::GL_DEPTH_TEST ); gl::glDepthFunc( gl::GL_EQUAL ); gl::glDisable( gl::GL_BLEND ); for ( auto const& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } #ifdef GRAPH_CALL_TRACE std::cout << "\e[31m\e[1mEmissivityNode\e[0m \"" << m_name << "\": execute." << std::endl; #endif @@ -133,15 +130,15 @@ void EmissivityNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderOb if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"EmissivityPass::" + mat->getMaterialName()} ) ) + { "EmissivityPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"EmissivityPass::" + mat->getMaterialName()}, + { "EmissivityPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.vert.glsl", - resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.frag.glsl"}; + resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.cpp index ccb4c4994c97f0320e8597b3deb16e72d7d81c74..19fb1b0335182cc5959f08fe2131e2db3ce06705 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.cpp @@ -7,7 +7,7 @@ using EnvMapData = std::shared_ptr<RadiumNBR::EnvMap>; -EnvLightNode::EnvLightNode( const std::string& name ) : Node( name ) { +EnvLightNode::EnvLightNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -60,13 +60,13 @@ void EnvLightNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // AO @@ -76,8 +76,9 @@ void EnvLightNode::execute() { // Envmap auto inputEnvmap = dynamic_cast<PortIn<EnvMapData>*>( m_inputs[3].get() ); - RadiumNBR::EnvMap* envmap{nullptr}; - if ( inputEnvmap->isLinked() ) { + RadiumNBR::EnvMap* envmap{ nullptr }; + if ( inputEnvmap->isLinked() ) + { envmap = inputEnvmap->getData().get(); if ( envmap ) { @@ -105,7 +106,8 @@ void EnvLightNode::execute() { // Render objects auto inputRO = dynamic_cast<PortIn<std::vector<NodeTypeRenderObject>>*>( m_inputs[4].get() ); std::vector<NodeTypeRenderObject> renderObjects; - if ( inputRO->isLinked() ) { + if ( inputRO->isLinked() ) + { renderObjects = inputRO->getData(); #ifdef GRAPH_CALL_TRACE std::cout << renderObjects.size() << " render objects" << std::endl; @@ -122,11 +124,10 @@ void EnvLightNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glDepthMask( gl::GL_FALSE ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); gl::glEnable( gl::GL_DEPTH_TEST ); gl::glDepthFunc( gl::GL_EQUAL ); @@ -134,9 +135,7 @@ void EnvLightNode::execute() { gl::glBlendFunc( gl::GL_ONE, gl::GL_ONE ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } // Reset gl::glDisable( gl::GL_BLEND ); @@ -168,15 +167,15 @@ void EnvLightNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObje if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"EnvLightPass::" + mat->getMaterialName()} ) ) + { "EnvLightPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"EnvLightPass::" + mat->getMaterialName()}, + { "EnvLightPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/EnvLightPass/envlightpass.vert.glsl", - resourcesRootDir + "Shaders/EnvLightPass/envlightpass.frag.glsl"}; + resourcesRootDir + "Shaders/EnvLightPass/envlightpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp index ead5270763a10f3d7c5fca04e52709b726d7e0f3..9dbd96fa4b59ad8b73712aab464b3c1537c872b4 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp @@ -17,9 +17,9 @@ class NodeBasedRenderer_LIBRARY_API EnvLightNode : public Node static const std::string getTypename() { return "Environment Light Pass"; } private: - Ra::Engine::Data::Texture* m_colorTexture{nullptr}; + Ra::Engine::Data::Texture* m_colorTexture{ nullptr }; Ra::Engine::Data::Texture* m_blankAO{ nullptr }; - globjects::Framebuffer* m_framebuffer{nullptr}; + globjects::Framebuffer* m_framebuffer{ nullptr }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.cpp index 7aef7961aba58f2b783180e43d0c54c88c15b8f7..09215716a209dbf991eb0fd052c169cedfc6d052 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.cpp @@ -3,7 +3,7 @@ #include <Engine/Data/Material.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> -LocalLightNode::LocalLightNode( const std::string& name ) : Node( name ) { +LocalLightNode::LocalLightNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -29,7 +29,7 @@ void LocalLightNode::init() { float blankAO[4] = { 1.f, 1.f, 1.f, 1.f }; Ra::Engine::Data::TextureParameters texParams; - texParams.target = gl::GL_TEXTURE_2D; + texParams.target = gl::GL_TEXTURE_2D; texParams.width = 1; texParams.height = 1; texParams.internalFormat = gl::GL_RGBA32F; @@ -39,7 +39,7 @@ void LocalLightNode::init() { texParams.magFilter = gl::GL_NEAREST; texParams.name = "Blank AO"; texParams.texels = &blankAO; - m_blankAO = new Ra::Engine::Data::Texture( texParams ); + m_blankAO = new Ra::Engine::Data::Texture( texParams ); m_blankAO->initializeGL(); #ifdef GRAPH_CALL_TRACE std::cout << "\e[32m\e[1mLocalLightNode\e[0m \"" << m_name << "\": initialization." @@ -56,17 +56,17 @@ void LocalLightNode::update() { void LocalLightNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // AO - auto inputAO = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[2].get() ); + auto inputAO = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[2].get() ); NodeTypeTexture* AOTexture = inputAO->isLinked() ? &inputAO->getData() : m_blankAO; inPassParams.addParameter( "amb_occ_sampler", AOTexture ); @@ -114,13 +114,12 @@ void LocalLightNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glEnable( gl::GL_DEPTH_TEST ); gl::glDepthMask( gl::GL_FALSE ); gl::glDepthFunc( gl::GL_EQUAL ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); gl::glEnable( gl::GL_BLEND ); gl::glBlendFunc( gl::GL_ONE, gl::GL_ONE ); @@ -132,9 +131,7 @@ void LocalLightNode::execute() { l->getRenderParameters( inPassParams ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } } } @@ -170,16 +167,16 @@ void LocalLightNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderOb { return; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"LocalLightPass::" + mat->getMaterialName()} ) ) + { "LocalLightPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { std::string resourcesRootDir = m_resourceDir; // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"LocalLightPass::" + mat->getMaterialName()}, + { "LocalLightPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/LocalLightPass/lightpass.vert.glsl", - resourcesRootDir + "Shaders/LocalLightPass/lightpass.frag.glsl"}; + resourcesRootDir + "Shaders/LocalLightPass/lightpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.cpp index 5c869f44fbca0f67d0620fb44dc600614bb07f42..071efdad10bbf8afcfd14200a1e83de3e54974ad 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.cpp @@ -6,7 +6,7 @@ #include <Engine/Data/Mesh.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> -TransparencyNode::TransparencyNode( const std::string& name ) : Node( name ) { +TransparencyNode::TransparencyNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -29,7 +29,6 @@ TransparencyNode::TransparencyNode( const std::string& name ) : Node( name ) { auto accumulationOutTex = new PortOut<NodeTypeTexture>( "accumulation", this ); addOutput( accumulationOutTex, m_accumulationTexture ); - } void TransparencyNode::init() { @@ -55,13 +54,13 @@ void TransparencyNode::init() { m_quadMesh = std::move( qm ); m_quadMesh->updateGL(); - const std::string composeVertexShader{"layout (location = 0) in vec3 in_position;\n" - "out vec2 varTexcoord;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(in_position, 1.0);\n" - " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" - "}\n"}; + const std::string composeVertexShader{ "layout (location = 0) in vec3 in_position;\n" + "out vec2 varTexcoord;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_position, 1.0);\n" + " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" + "}\n" }; const std::string composeFragmentShader{ "in vec2 varTexcoord;\n" "out vec4 f_Color;\n" @@ -73,8 +72,8 @@ void TransparencyNode::init() { " vec4 accum = texture( u_OITSumColor, varTexcoord );\n" " vec3 avg_color = accum.rgb / max( accum.a, 0.00001 );\n" " f_Color = vec4( avg_color, r );\n" - "}"}; - Ra::Engine::Data::ShaderConfiguration config{"ComposeTransparency"}; + "}" }; + Ra::Engine::Data::ShaderConfiguration config{ "ComposeTransparency" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, composeFragmentShader ); @@ -95,13 +94,13 @@ void TransparencyNode::update() { void TransparencyNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); - + // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // Render objects @@ -145,10 +144,9 @@ void TransparencyNode::execute() { #endif } - static const float clearZeros[4] = {0.0, 0.0, 0.0, 1.0}; - static const float clearOnes[4] = {1.0, 1.0, 1.0, 1.0}; - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0, - gl::GL_COLOR_ATTACHMENT1}; + static const float clearZeros[4] = { 0.0, 0.0, 0.0, 1.0 }; + static const float clearOnes[4] = { 1.0, 1.0, 1.0, 1.0 }; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0, gl::GL_COLOR_ATTACHMENT1 }; m_oitFramebuffer->bind(); m_oitFramebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); @@ -171,9 +169,7 @@ void TransparencyNode::execute() { l->getRenderParameters( inPassParams ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } } } m_oitFramebuffer->detach( gl::GL_DEPTH_ATTACHMENT ); @@ -211,25 +207,21 @@ void TransparencyNode::destroy() { void TransparencyNode::resize( uint32_t width, uint32_t height ) { - m_accumulationTexture->resize( width, height ); m_revealageTexture->resize( width, height ); // output { - auto revealageOut = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[1].get() ); + auto revealageOut = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[1].get() ); revealageOut->setData( m_revealageTexture ); auto accumulationOut = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[2].get() ); accumulationOut->setData( m_accumulationTexture ); - } m_oitFramebuffer->bind(); - m_oitFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, - m_accumulationTexture->texture() ); - m_oitFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT1, - m_revealageTexture->texture() ); + m_oitFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_accumulationTexture->texture() ); + m_oitFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT1, m_revealageTexture->texture() ); globjects::Framebuffer::unbind(); #ifdef GRAPH_CALL_TRACE @@ -246,16 +238,16 @@ void TransparencyNode::buildRenderTechnique( const Ra::Engine::Rendering::Render auto mat = const_cast<Ra::Engine::Rendering::RenderObject*>( ro )->getMaterial(); if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"TransparencyPass::" + mat->getMaterialName()} ) ) + { "TransparencyPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { std::string resourcesRootDir = m_resourceDir; // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"TransparencyPass::" + mat->getMaterialName()}, + { "TransparencyPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/TransparencyPass/oitpass.vert.glsl", - resourcesRootDir + "Shaders/TransparencyPass/oitpass.frag.glsl"}; + resourcesRootDir + "Shaders/TransparencyPass/oitpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp index 77ced67edeea358b93d664378f8f2783eee822b5..c7d1d3fd0962fad9de4f57b81ab682f4d7001402 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp @@ -9,7 +9,7 @@ class NodeBasedRenderer_LIBRARY_API TransparencyNode : public Node explicit TransparencyNode( const std::string& name ); void init() override; void update() override; - void execute() override ; + void execute() override; void destroy() override; void resize( uint32_t width, uint32_t height ) override; void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.cpp index 9842d8ecb786e29c67e06680025fed2730b8eb81..c72a3b4db442d17fa074b16c4cc50e9e2245f3bb 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.cpp @@ -3,7 +3,7 @@ #include <Engine/Data/Material.hpp> #include <Engine/Data/Mesh.hpp> -UINode::UINode( const std::string& name ) : Node( name ) { +UINode::UINode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -38,13 +38,13 @@ void UINode::update() { void UINode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); - + // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // Activate @@ -80,7 +80,7 @@ void UINode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glDepthMask( gl::GL_TRUE ); gl::glEnable( gl::GL_DEPTH_TEST ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.cpp index 432e44976bdb59251e00242353798b26a907c0ab..01ebb1ae1548e3570e80e500117a905174dbe27b 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.cpp @@ -6,7 +6,7 @@ #include <Engine/Data/Mesh.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> -VolumeNode::VolumeNode( const std::string& name ) : Node( name ) { +VolumeNode::VolumeNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -46,13 +46,13 @@ void VolumeNode::init() { m_quadMesh = std::move( qm ); m_quadMesh->updateGL(); - const std::string vrtxSrc{"layout (location = 0) in vec3 in_position;\n" - "out vec2 varTexcoord;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(in_position, 1.0);\n" - " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" - "}\n"}; + const std::string vrtxSrc{ "layout (location = 0) in vec3 in_position;\n" + "out vec2 varTexcoord;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_position, 1.0);\n" + " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" + "}\n" }; const std::string frgSrc{ "out vec4 fragColor;\n" "in vec2 varTexcoord;\n" @@ -64,8 +64,8 @@ void VolumeNode::init() { " if (volColor.a < 1)\n" " discard;\n" " fragColor = vec4(volColor.rgb, 0);\n" - "}\n"}; - Ra::Engine::Data::ShaderConfiguration config{"ComposeVolume"}; + "}\n" }; + Ra::Engine::Data::ShaderConfiguration config{ "ComposeVolume" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vrtxSrc ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, frgSrc ); auto added = m_shaderMngr->addShaderProgram( config ); @@ -84,13 +84,13 @@ void VolumeNode::update() { void VolumeNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); - + // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // Render objects @@ -131,8 +131,8 @@ void VolumeNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - static const float clearZeros[4] = {0.0, 0.0, 0.0, 0.0}; - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + static const float clearZeros[4] = { 0.0, 0.0, 0.0, 0.0 }; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; m_volumeFramebuffer->bind(); gl::glDrawBuffers( 1, buffers ); gl::glClearBufferfv( gl::GL_COLOR, 0, clearZeros ); @@ -149,9 +149,7 @@ void VolumeNode::execute() { l->getRenderParameters( inPassParams ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } } m_framebuffer->bind(); @@ -187,8 +185,7 @@ void VolumeNode::resize( uint32_t width, uint32_t height ) { m_volumeTexture->resize( width, height ); m_volumeFramebuffer->bind(); - m_volumeFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, - m_volumeTexture->texture() ); + m_volumeFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_volumeTexture->texture() ); globjects::Framebuffer::unbind(); #ifdef GRAPH_CALL_TRACE @@ -211,15 +208,15 @@ void VolumeNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject rt.setConfiguration( *passconfig, m_idx ); #else if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"VolumeLightingPass::" + mat->getMaterialName()} ) ) + { "VolumeLightingPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"VolumeLightingPass::" + mat->getMaterialName()}, + { "VolumeLightingPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/VolumeLightingPass/volume.vert.glsl", - resourcesRootDir + "Shaders/VolumeLightingPass/volume.frag.glsl"}; + resourcesRootDir + "Shaders/VolumeLightingPass/volume.frag.glsl" }; /* // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp index efda11f9fde4bf01ef9a0577044aedd998fc6261..98700800c601527c5b6faf6c19eadbb225eacf74 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp @@ -21,20 +21,20 @@ class NodeBasedRenderer_LIBRARY_API VolumeNode : public Node private: /// The pointer to the color texture used by a previous pass (blending) /// It is used to compose this pass' final image - Ra::Engine::Data::Texture* m_colorTexture{nullptr}; + Ra::Engine::Data::Texture* m_colorTexture{ nullptr }; /// The texture to draw the volume on - Ra::Engine::Data::Texture* m_volumeTexture{nullptr}; + Ra::Engine::Data::Texture* m_volumeTexture{ nullptr }; /// The framebuffer used to draw in this pass - globjects::Framebuffer* m_framebuffer{nullptr}; + globjects::Framebuffer* m_framebuffer{ nullptr }; /// The framebuffer used to draw the volume - globjects::Framebuffer* m_volumeFramebuffer{nullptr}; + globjects::Framebuffer* m_volumeFramebuffer{ nullptr }; /// The composite shader, owned by the shader manager - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The fullscreen quad to draw - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp index 6a7cc3390af6d36d959302372f630f8d67b7de33..21a98f3110f9e5c81a0ba962913e68719ecba22d 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp @@ -1,6 +1,7 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp> -VolumeVizualisationNode::VolumeVizualisationNode( const std::string& name ) : Node( name ) { +VolumeVizualisationNode::VolumeVizualisationNode( const std::string& name ) : + Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -18,7 +19,8 @@ VolumeVizualisationNode::VolumeVizualisationNode( const std::string& name ) : No auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this ); addOutput( portOutColorTex, m_colorTexture ); - auto editableTransferFunction = new EditableParameter<std::array<float, 256 * 4>>( "transfer function", m_editableTransferFunction); + auto editableTransferFunction = new EditableParameter<std::array<float, 256 * 4>>( + "transfer function", m_editableTransferFunction ); addEditableParameter( editableTransferFunction ); } @@ -43,13 +45,13 @@ void VolumeVizualisationNode::init() { m_quadMesh = std::move( qm ); m_quadMesh->updateGL(); - const std::string vrtxSrc{"layout (location = 0) in vec3 in_position;\n" + const std::string vrtxSrc{ "layout (location = 0) in vec3 in_position;\n" "out vec2 varTexcoord;\n" "void main()\n" "{\n" " gl_Position = vec4(in_position, 1.0);\n" " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" - "}\n"}; + "}\n" }; const std::string frgSrc{ "out vec4 fragColor;\n" "in vec2 varTexcoord;\n" @@ -61,8 +63,8 @@ void VolumeVizualisationNode::init() { " if (volColor.a < 1)\n" " discard;\n" " fragColor = vec4(volColor.rgb, 0);\n" - "}\n"}; - Ra::Engine::Data::ShaderConfiguration config{"ComposeVolumeVizualisation"}; + "}\n" }; + Ra::Engine::Data::ShaderConfiguration config{ "ComposeVolumeVizualisation" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vrtxSrc ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, frgSrc ); auto added = m_shaderMngr->addShaderProgram( config ); @@ -88,13 +90,15 @@ void VolumeVizualisationNode::init() { m_transferFunctionTexture = new Ra::Engine::Data::Texture( transferTexParams ); m_transferFunctionTexture->initializeGL(); #ifdef GRAPH_CALL_TRACE - std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": initialization." << std::endl; + std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": initialization." + << std::endl; #endif } void VolumeVizualisationNode::update() { #ifdef GRAPH_CALL_TRACE - std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": update." << std::endl; + std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": update." + << std::endl; #endif } @@ -145,8 +149,8 @@ void VolumeVizualisationNode::execute() { m_transferFunctionTexture->updateData( m_editableTransferFunction.data() ); - static const float clearZeros[4] = {0.0, 0.0, 0.0, 0.0}; - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + static const float clearZeros[4] = { 0.0, 0.0, 0.0, 0.0 }; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; m_volumeFramebuffer->bind(); m_volumeFramebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); @@ -166,9 +170,7 @@ void VolumeVizualisationNode::execute() { l->getRenderParameters( inPassParams ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } } m_framebuffer->bind(); @@ -189,7 +191,8 @@ void VolumeVizualisationNode::execute() { m_framebuffer->detach( gl::GL_COLOR_ATTACHMENT0 ); m_framebuffer->unbind(); #ifdef GRAPH_CALL_TRACE - std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": execute." << std::endl; + std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": execute." + << std::endl; #endif } @@ -198,7 +201,8 @@ void VolumeVizualisationNode::destroy() { delete m_transferFunctionTexture; #ifdef GRAPH_CALL_TRACE - std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": destroy." << std::endl; + std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": destroy." + << std::endl; #endif } @@ -206,18 +210,18 @@ void VolumeVizualisationNode::resize( uint32_t width, uint32_t height ) { m_volumeTexture->resize( width, height ); m_volumeFramebuffer->bind(); - m_volumeFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, - m_volumeTexture->texture() ); + m_volumeFramebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_volumeTexture->texture() ); globjects::Framebuffer::unbind(); #ifdef GRAPH_CALL_TRACE - std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": resize: " << width << "x" - << height << "." << std::endl; + std::cout << "\e[33m\e[1mVolumeVizualisationNode\e[0m \"" << m_name << "\": resize: " << width + << "x" << height << "." << std::endl; #endif } -void VolumeVizualisationNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const { +void VolumeVizualisationNode::buildRenderTechnique( + const Ra::Engine::Rendering::RenderObject* ro, + Ra::Engine::Rendering::RenderTechnique& rt ) const { std::string resourcesRootDir = m_resourceDir; auto mat = const_cast<Ra::Engine::Rendering::RenderObject*>( ro )->getMaterial(); // Only volumes are used by this pass @@ -227,19 +231,18 @@ void VolumeVizualisationNode::buildRenderTechnique( const Ra::Engine::Rendering: auto mro = const_cast<Ra::Engine::Rendering::RenderObject*>( ro ); auto volume = dynamic_cast<Ra::Core::Geometry::VolumeGrid&>( mro->getMesh()->getAbstractGeometry() ); - auto paramProvider = - std::make_shared<VolumeWithGradientParameterProvider>( mat, volume ); + auto paramProvider = std::make_shared<VolumeWithGradientParameterProvider>( mat, volume ); if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"VolumeLightingPass::" + mat->getMaterialName()} ) ) + { "VolumeLightingPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"VolumeLightingPass::" + mat->getMaterialName()}, + { "VolumeLightingPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/VolumeVisualization/volviz.vert.glsl", - resourcesRootDir + "Shaders/VolumeVisualization/volviz.frag.glsl"}; + resourcesRootDir + "Shaders/VolumeVisualization/volviz.frag.glsl" }; /* // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp index 2a7ae5b061ad1f909caa9c9ac7db1acf4bde7e49..c07526fce128f29ddc0bece8f67f6d1dc2f8497a 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.hpp @@ -5,48 +5,47 @@ #include <Core/Geometry/Volume.hpp> #include <Engine/Data/Material.hpp> -#include <Engine/Data/Texture.hpp> #include <Engine/Data/Mesh.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> +#include <Engine/Data/Texture.hpp> #include <RadiumNBR/NodeGraph/Node.hpp> #include <numeric> -class VolumeWithGradientParameterProvider : public Ra::Engine::Data::ShaderParameterProvider { +class VolumeWithGradientParameterProvider : public Ra::Engine::Data::ShaderParameterProvider +{ public: VolumeWithGradientParameterProvider( std::shared_ptr<Ra::Engine::Data::Material> mat, Ra::Core::Geometry::VolumeGrid& volume ) : - Ra::Engine::Data::ShaderParameterProvider(), m_displayMaterial( mat ), m_volumeGrid( volume ) { - if (!m_volumeGrid.hasGradients()) { - m_volumeGrid.computeGradients(); - } + Ra::Engine::Data::ShaderParameterProvider(), + m_displayMaterial( mat ), + m_volumeGrid( volume ) { + if ( !m_volumeGrid.hasGradients() ) { m_volumeGrid.computeGradients(); } Ra::Engine::Data::TextureParameters texParams{ "Volume gradient", - gl::GL_TEXTURE_3D, - size_t( m_volumeGrid.size().x() ), - size_t( m_volumeGrid.size().y() ), - size_t( m_volumeGrid.size().z() ), - gl::GL_RGBA, - gl::GL_RGBA32F, - gl::GL_FLOAT, - gl::GL_CLAMP_TO_BORDER, - gl::GL_CLAMP_TO_BORDER, - gl::GL_CLAMP_TO_BORDER, - gl::GL_LINEAR, - gl::GL_LINEAR, - m_volumeGrid.gradient().data() }; - m_gradientTexture = new Ra::Engine::Data::Texture(texParams); + gl::GL_TEXTURE_3D, + size_t( m_volumeGrid.size().x() ), + size_t( m_volumeGrid.size().y() ), + size_t( m_volumeGrid.size().z() ), + gl::GL_RGBA, + gl::GL_RGBA32F, + gl::GL_FLOAT, + gl::GL_CLAMP_TO_BORDER, + gl::GL_CLAMP_TO_BORDER, + gl::GL_CLAMP_TO_BORDER, + gl::GL_LINEAR, + gl::GL_LINEAR, + m_volumeGrid.gradient().data() }; + m_gradientTexture = new Ra::Engine::Data::Texture( texParams ); m_gradientTexture->initializeGL(); } - ~VolumeWithGradientParameterProvider() { - delete m_gradientTexture; - } + ~VolumeWithGradientParameterProvider() { delete m_gradientTexture; } void updateGL() override { m_displayMaterial->updateGL(); m_renderParameters = m_displayMaterial->getParameters(); - m_renderParameters.addParameter("material.density", m_gradientTexture ); + m_renderParameters.addParameter( "material.density", m_gradientTexture ); } private: @@ -80,19 +79,19 @@ class NodeBasedRenderer_LIBRARY_API VolumeVizualisationNode : public Node Ra::Engine::Data::Texture* m_transferFunctionTexture{ nullptr }; /// The texture to draw the volume on - Ra::Engine::Data::Texture* m_volumeTexture{nullptr}; + Ra::Engine::Data::Texture* m_volumeTexture{ nullptr }; /// The framebuffer used to draw in this pass - globjects::Framebuffer* m_framebuffer{nullptr}; + globjects::Framebuffer* m_framebuffer{ nullptr }; /// The framebuffer used to draw the volume - globjects::Framebuffer* m_volumeFramebuffer{nullptr}; + globjects::Framebuffer* m_volumeFramebuffer{ nullptr }; /// The composite shader, owned by the shader manager - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The fullscreen quad to draw - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The editable transfer function result std::array<float, 256 * 4> m_editableTransferFunction; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp index 07357fa3dfd237801b3094328953e7fa7101fbd4..20e6242e22f5e1d5cc568baac89ad13d3097fce9 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp @@ -36,7 +36,7 @@ class VerticesUpdater { public: VerticesUpdater( std::shared_ptr<Ra::Engine::Data::LineMesh> disp, CoreGeometry& core ) : - m_disp{disp}, m_core{core} {}; + m_disp{ disp }, m_core{ core } {}; void operator()() { m_disp->getCoreGeometry().setVertices( m_core.vertices() ); } std::shared_ptr<Ra::Engine::Data::LineMesh> m_disp; @@ -48,7 +48,7 @@ class IndicesUpdater { public: IndicesUpdater( std::shared_ptr<Ra::Engine::Data::LineMesh> disp, CoreGeometry& core ) : - m_disp{disp}, m_core{core} {}; + m_disp{ disp }, m_core{ core } {}; void operator()() { auto lineIndices = m_disp->getCoreGeometry().getIndicesWithLock(); @@ -90,7 +90,7 @@ void processLineMesh( const std::shared_ptr<CoreGeometry>& m, { setupLineMesh( r, m->getCoreGeometry() ); } } -WireframeNode::WireframeNode( const std::string& name ) : Node( name ) { +WireframeNode::WireframeNode( const std::string& name ) : Node( name, getTypename() ) { auto portInColor = new PortIn<NodeTypeTexture>( "inColorTexture", this ); addInput( portInColor ); portInColor->mustBeLinked(); @@ -108,8 +108,8 @@ WireframeNode::WireframeNode( const std::string& name ) : Node( name ) { auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this ); addOutput( portOutColorTex, m_colorTexture ); - auto editableActivate = new EditableParameter("activate", m_editableActivate); - addEditableParameter(editableActivate); + auto editableActivate = new EditableParameter( "activate", m_editableActivate ); + addEditableParameter( editableActivate ); } void WireframeNode::init() { @@ -128,22 +128,22 @@ void WireframeNode::update() { void WireframeNode::execute() { Ra::Engine::Data::RenderParameters inPassParams; // Color - auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); + auto inputColor = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[0].get() ); m_colorTexture = &inputColor->getData(); auto outputColor = dynamic_cast<PortOut<NodeTypeTexture>*>( m_outputs[0].get() ); outputColor->setData( m_colorTexture ); // Depth - auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); + auto inputDepth = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[1].get() ); NodeTypeTexture* depthTexture = &inputDepth->getData(); // Activate auto inputActivate = dynamic_cast<PortIn<bool>*>( m_inputs[2].get() ); - bool activate = m_editableActivate; - if ( inputActivate->isLinked() ) - { activate = inputActivate->getData(); } + bool activate = m_editableActivate; + if ( inputActivate->isLinked() ) { activate = inputActivate->getData(); } #ifdef GRAPH_CALL_TRACE - else { std::cout << "Activation port is not linked, default to false" << std::endl; } + else + { std::cout << "Activation port is not linked, default to false" << std::endl; } #endif // Render objects @@ -172,20 +172,17 @@ void WireframeNode::execute() { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, depthTexture->texture() ); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_colorTexture->texture() ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0}; + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0 }; gl::glDrawBuffers( 1, buffers ); gl::glDepthMask( gl::GL_FALSE ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); gl::glEnable( gl::GL_DEPTH_TEST ); gl::glDepthFunc( gl::GL_LESS ); gl::glEnable( gl::GL_BLEND ); gl::glBlendEquationSeparate( gl::GL_FUNC_ADD, gl::GL_FUNC_ADD ); - gl::glBlendFuncSeparate( gl::GL_SRC_ALPHA, - gl::GL_ONE_MINUS_SRC_ALPHA, - gl::GL_ONE, - gl::GL_ZERO ); + gl::glBlendFuncSeparate( + gl::GL_SRC_ALPHA, gl::GL_ONE_MINUS_SRC_ALPHA, gl::GL_ONE, gl::GL_ZERO ); gl::glDisable( gl::GL_POLYGON_OFFSET_FILL ); for ( const auto& ro : renderObjects ) @@ -223,7 +220,7 @@ void WireframeNode::execute() { shader->setUniform( "transform.view", cameras[0].viewMatrix ); shader->setUniform( "transform.model", modelMatrix ); shader->setUniform( "viewport", - Ra::Core::Vector2{m_wireframeWidth, m_wireframeHeight} ); + Ra::Core::Vector2{ m_wireframeWidth, m_wireframeHeight } ); wro->render( shader ); } } @@ -265,15 +262,15 @@ void WireframeNode::buildRenderTechnique( const Ra::Engine::Rendering::RenderObj if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"WireframePass::WireframeProgram"} ) ) + { "WireframePass::WireframeProgram" } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { Ra::Engine::Data::ShaderConfiguration theConfig{ - {"WireframePass::WireframeProgram"}, + { "WireframePass::WireframeProgram" }, resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.vert.glsl", - resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.frag.glsl"}; + resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.frag.glsl" }; theConfig.addShader( Ra::Engine::Data::ShaderType_GEOMETRY, resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.geom.glsl" ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.cpp index a14515ff8afc370919173cc572163d6934139321..cb7174481dbd5723aee389d825599a31f76dd54a 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.cpp @@ -3,7 +3,7 @@ #include <Engine/Data/Material.hpp> #include <Engine/Data/ShaderConfigFactory.hpp> -ZGeomPrepassNode::ZGeomPrepassNode( const std::string& name ) : Node( name ) { +ZGeomPrepassNode::ZGeomPrepassNode( const std::string& name ) : Node( name, getTypename() ) { auto portInRO = new PortIn<std::vector<NodeTypeRenderObject>>( "inRenderObjects", this ); addInput( portInRO ); auto portInC = new PortIn<std::vector<NodeTypeCamera>>( "inCameras", this ); @@ -70,7 +70,8 @@ void ZGeomPrepassNode::execute() { #endif } #ifdef GRAPH_CALL_TRACE - else { std::cout << "RenderObjects port is not linked, no render object" << std::endl; } + else + { std::cout << "RenderObjects port is not linked, no render object" << std::endl; } #endif // Cameras @@ -83,12 +84,10 @@ void ZGeomPrepassNode::execute() { m_framebuffer->bind(); gl::glEnable( gl::GL_DEPTH_TEST ); gl::glDepthMask( gl::GL_TRUE ); - gl::glColorMask( - gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); - const gl::GLenum buffers[] = {gl::GL_COLOR_ATTACHMENT0, - gl::GL_COLOR_ATTACHMENT1}; + gl::glColorMask( gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE, gl::GL_TRUE ); + const gl::GLenum buffers[] = { gl::GL_COLOR_ATTACHMENT0, gl::GL_COLOR_ATTACHMENT1 }; gl::glDrawBuffers( 2, buffers ); - float clearBlack[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float clearBlack[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; float clearDepth = 1.0f; gl::glClearBufferfv( gl::GL_COLOR, 0, clearBlack ); gl::glClearBufferfv( gl::GL_COLOR, 1, clearBlack ); @@ -100,9 +99,7 @@ void ZGeomPrepassNode::execute() { gl::glEnable( gl::GL_POLYGON_OFFSET_FILL ); for ( const auto& ro : renderObjects ) - { - ro->render( inPassParams, cameras[0], m_idx ); - } + { ro->render( inPassParams, cameras[0], m_idx ); } #ifdef GRAPH_CALL_TRACE std::cout << "\e[33m\e[1mZGeomPrepass\e[0m \"" << m_name << "\": execute with " << renderObjects.size() << " render objects and " << cameras.size() << " cameras." @@ -128,8 +125,7 @@ void ZGeomPrepassNode::resize( uint32_t width, uint32_t height ) { m_framebuffer->bind(); m_framebuffer->attachTexture( gl::GL_DEPTH_ATTACHMENT, m_depthTexture->texture() ); m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT0, m_posInWorldTexture->texture() ); - m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT1, - m_normalInWorldTexture->texture() ); + m_framebuffer->attachTexture( gl::GL_COLOR_ATTACHMENT1, m_normalInWorldTexture->texture() ); globjects::Framebuffer::unbind(); #ifdef GRAPH_CALL_TRACE @@ -146,15 +142,15 @@ void ZGeomPrepassNode::buildRenderTechnique( const Ra::Engine::Rendering::Render if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"ZGeomPrePass::" + mat->getMaterialName()} ) ) + { "ZGeomPrePass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, m_idx ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"ZGeomPrePass::" + mat->getMaterialName()}, + { "ZGeomPrePass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/ZPrepass/zprepass.vert.glsl", - resourcesRootDir + "Shaders/ZPrepass/zprepass.frag.glsl"}; + resourcesRootDir + "Shaders/ZPrepass/zprepass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp index af418d464fbd98caf6ad98a7e35eba84e5ae0e46..5058ef959990f5a1632e3ddb36b084d16ac4852f 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp @@ -13,7 +13,7 @@ class NodeBasedRenderer_LIBRARY_API ZGeomPrepassNode : public Node void destroy() override; void resize( uint32_t width, uint32_t height ) override; void buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, - Ra::Engine::Rendering::RenderTechnique& rt ) const override ; + Ra::Engine::Rendering::RenderTechnique& rt ) const override; static const std::string getTypename() { return "Z Geometry Prepass"; } diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.cpp index ead6bf583e4be461f676f78cc256399e38b88ee1..95d8feec6c66910a57be3e7d0e05fb207a0814df 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.cpp @@ -2,7 +2,7 @@ #define MAX_DISPLAY_INPUTS 16 -DisplaySinkNode::DisplaySinkNode( const std::string& name ) : Node( name ) { +DisplaySinkNode::DisplaySinkNode( const std::string& name ) : Node( name, getTypename() ) { for ( size_t i = 0; i < MAX_DISPLAY_INPUTS; i++ ) { auto portIn = new PortIn<NodeTypeTexture>( "inTexture" + std::to_string( i ), this ); @@ -27,7 +27,7 @@ void DisplaySinkNode::execute() { { if ( m_inputs[i]->isLinked() ) { - auto input = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[i].get() ); + auto input = dynamic_cast<PortIn<NodeTypeTexture>*>( m_inputs[i].get() ); NodeTypeTexture* texture = &input->getData(); if ( texture ) { m_textures.push_back( texture ); } } diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp index c173537c4bec778f4d0c636252279d7a2a64dc0c..44550239947b62c352763b2a47a480e37d1c4b0e 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp @@ -1,7 +1,8 @@ #pragma once #include <RadiumNBR/NodeGraph/Node.hpp> -class NodeBasedRenderer_LIBRARY_API DisplaySinkNode : public Node { +class NodeBasedRenderer_LIBRARY_API DisplaySinkNode : public Node +{ public: explicit DisplaySinkNode( const std::string& name ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp index 86aa98fa29d5f9ea82b4f18efde356bf8975d607..f808844b1e119341f2f451dc423dff1bcb816114 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp @@ -5,7 +5,7 @@ template <typename T> class NodeBasedRenderer_LIBRARY_API SinkNode : public Node { public: - SinkNode( const std::string& name ) : Node( name ) { + SinkNode( const std::string& name ) : Node( name, getTypename() ) { auto portIn = new PortIn<T>( "from", this ); addInput( portIn ); } diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp index 8974fcbf72a2c6a320f46edf8239258935681c63..4b46f08b577a739e6b810851ded07643e5efa2d0 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/ColorTextureNode.hpp @@ -5,14 +5,22 @@ class NodeBasedRenderer_LIBRARY_API ColorTextureNode : public TextureNode { public: explicit ColorTextureNode( const std::string& name ) : - TextureNode( - name, - Ra::Engine::Data::TextureParameters { - "Color Texture", gl::GL_TEXTURE_2D, 1, 1, 1, gl::GL_RGBA, - gl::GL_RGBA32F, gl::GL_FLOAT, gl::GL_CLAMP_TO_EDGE, - gl::GL_CLAMP_TO_EDGE, gl::GL_CLAMP_TO_EDGE, gl::GL_LINEAR, - gl::GL_LINEAR, nullptr - } ) {} + TextureNode( name, + getTypename(), + Ra::Engine::Data::TextureParameters{ "Color Texture", + gl::GL_TEXTURE_2D, + 1, + 1, + 1, + gl::GL_RGBA, + gl::GL_RGBA32F, + gl::GL_FLOAT, + gl::GL_CLAMP_TO_EDGE, + gl::GL_CLAMP_TO_EDGE, + gl::GL_CLAMP_TO_EDGE, + gl::GL_LINEAR, + gl::GL_LINEAR, + nullptr } ) {} static const std::string getTypename() { return "Color Texture"; } }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp index a9304049f707b1de39b7e54b1e0096ae0b51093d..3af6c50175a566eafaca0afcbf9899ec29d27d0d 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp @@ -5,7 +5,7 @@ template <typename T> class DataNode : public Node { public: - DataNode( const std::string& name ) : Node( name ) { + explicit DataNode( const std::string& name ) : Node( name, getTypename() ) { auto portOut = new PortOut<std::vector<T>>( "outData", this ); addOutput( portOut, &m_elements ); } @@ -40,8 +40,7 @@ class DataNode : public Node static const std::string getTypename() { auto typeId = typeid( T ).hash_code(); - if ( typeId == typeid( NodeTypeRenderObject ).hash_code() ) - { return "RenderObjects"; } + if ( typeId == typeid( NodeTypeRenderObject ).hash_code() ) { return "RenderObjects"; } else if ( typeId == typeid( NodeTypeLight ).hash_code() ) { return "Lights"; } else if ( typeId == typeid( NodeTypeCamera ).hash_code() ) diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp index 7cb55f7d5c8325efe5b7ed68aca45251b0060a7e..dc8f3ba907ae51bfe587e5712d55d9f9c32eaee4 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/DepthTextureNode.hpp @@ -5,14 +5,22 @@ class NodeBasedRenderer_LIBRARY_API DepthTextureNode : public TextureNode { public: explicit DepthTextureNode( const std::string& name ) : - TextureNode( - name, - Ra::Engine::Data::TextureParameters { - "Depth Texture", gl::GL_TEXTURE_2D, 1, 1, 1, gl::GL_DEPTH_COMPONENT, - gl::GL_DEPTH_COMPONENT24, gl::GL_UNSIGNED_INT, gl::GL_CLAMP_TO_EDGE, - gl::GL_CLAMP_TO_EDGE, gl::GL_CLAMP_TO_EDGE, gl::GL_NEAREST, - gl::GL_NEAREST, nullptr - } ) {} + TextureNode( name, + getTypename(), + Ra::Engine::Data::TextureParameters{ "Depth Texture", + gl::GL_TEXTURE_2D, + 1, + 1, + 1, + gl::GL_DEPTH_COMPONENT, + gl::GL_DEPTH_COMPONENT24, + gl::GL_UNSIGNED_INT, + gl::GL_CLAMP_TO_EDGE, + gl::GL_CLAMP_TO_EDGE, + gl::GL_CLAMP_TO_EDGE, + gl::GL_NEAREST, + gl::GL_NEAREST, + nullptr } ) {} static const std::string getTypename() { return "Depth Texture"; } }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp index 52797cb8647661b6db749392844093004aef3492..95aa24f9b2e7ec14835ff7a7897453cff91317e8 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp @@ -8,7 +8,7 @@ template <typename T> class SourceNode : public Node { public: - SourceNode( const std::string& name ) : Node( name ) { + SourceNode( const std::string& name ) : Node( name, getTypename() ) { auto portOut = new PortOut<T>( "to", this ); addOutput( portOut, &m_data ); @@ -16,6 +16,8 @@ class SourceNode : public Node addEditableParameter( editableData ); } + public: + SourceNode() : SourceNode( getTypename ) {} void init() override { #ifdef GRAPH_CALL_TRACE std::cout << "\e[34m\e[1mSourceNode\e[0m \"" << m_name << "\": initialization." @@ -59,10 +61,10 @@ class SourceNode : public Node templatedTypeName = templatedTypeName.substr( pos + 1, templatedTypeName.size() ); } pos = templatedTypeName.find_first_of('>'); if (pos != std::string::npos) { templatedTypeName = templatedTypeName.substr( 0, pos ); }*/ - remove_all_in_string(templatedTypeName, "::__1"); // --> HACK to put in type_name<T> + remove_all_in_string( templatedTypeName, "::__1" ); // --> HACK to put in type_name<T> return "Source " + templatedTypeName; } private: - T m_data {}; + T m_data{}; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.cpp index ac752da486a415cd6cface89c5efa8560f8a0551..d958f6540256f264647f43109d02eb2be8d8233e 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.cpp @@ -1,8 +1,13 @@ #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp> -TextureNode::TextureNode( const std::string& name, +TextureNode::TextureNode( const std::string& instanceName, const Ra::Engine::Data::TextureParameters& texParams ) : - Node( name ) { + TextureNode( instanceName, getTypename(), texParams ) {} + +TextureNode::TextureNode( const std::string& instanceName, + const std::string& typeName, + const Ra::Engine::Data::TextureParameters& texParams ) : + Node( instanceName, typeName ) { if ( !m_texture ) { m_texture = new Ra::Engine::Data::Texture( texParams ); } auto portOut = new PortOut<NodeTypeTexture>( "to", this ); diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp index add05594b8589960e11d87e603baf92104285a41..0d3faa18fbd01e06032f95643c8764e9c97512be 100644 --- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp @@ -4,7 +4,8 @@ class NodeBasedRenderer_LIBRARY_API TextureNode : public Node { public: - explicit TextureNode( const std::string& name, const Ra::Engine::Data::TextureParameters& texParams ); + TextureNode( const std::string& instanceName, + const Ra::Engine::Data::TextureParameters& texParams ); void init() override; void update() override; void execute() override; @@ -13,6 +14,11 @@ class NodeBasedRenderer_LIBRARY_API TextureNode : public Node static const std::string getTypename() { return "Texture"; } + protected: + TextureNode( const std::string& instanceName, + const std::string& typeName, + const Ra::Engine::Data::TextureParameters& texParams ); + private: - Ra::Engine::Data::Texture* m_texture{nullptr}; + Ra::Engine::Data::Texture* m_texture{ nullptr }; }; diff --git a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp index 0b44a8a058aec7b6563fbc1505da6b3b5956b75d..e581b06c7bc91653b33fea1237758bfaea127200 100644 --- a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp @@ -101,7 +101,7 @@ void RenderGraph::resize( uint32_t width, uint32_t height ) { void RenderGraph::loadFromJson( const std::string& jsonFilePath ) { - std::cout << "\e[32m\e[1mRenderGraph\e[0m \"" << m_name << "\": loadFromJson: " << jsonFilePath + std::cout << "\e[32m\e[1mRenderGraph\e[0m \"" << m_instanceName << "\": loadFromJson: " << jsonFilePath << std::endl; std::ifstream file( jsonFilePath ); nlohmann::json j; @@ -123,10 +123,10 @@ void RenderGraph::loadFromJson( const std::string& jsonFilePath ) { else if ( name == "Display Sink" ) { nodeById.emplace( id, getDisplayNode() ); } else - { - auto newNode = NodeFactory::createNode( name, n ); + { + std::cerr << "Loading a node = " << name << " --- " << std::endl; - std::cerr << "TYPE = " << typeid(*newNode).name() << " --- " << std::endl; + auto newNode = NodeFactory::createNode( name, n ); nodeById.emplace( id, newNode ); addNode( newNode ); } @@ -478,10 +478,13 @@ bool RenderGraph::compile() { { if ( infoNodes.find( n.get() ) != infoNodes.end() ) { - for ( size_t i = 0; i < n->getInputs().size(); i++ ) { + for ( size_t i = 0; i < n->getInputs().size(); i++ ) + { // If the node accepts render objects as input // then it needs an index for the render techniques - if (n->getInputs()[i]->getType() == typeid(std::vector<NodeTypeRenderObject>).hash_code()) { + if ( n->getInputs()[i]->getType() == + typeid( std::vector<NodeTypeRenderObject> ).hash_code() ) + { n->setIndex( idx++ ); break; } diff --git a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp index d397bfc3c94fb77d880f76dafc3d419d56cd13b3..8a2e6c3854198658394348eb56c337b537150e89 100644 --- a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp @@ -1,16 +1,17 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/NodeGraph/Node.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> // TODO : Find a new name, it is not a RENDER graph only anymore -class NodeBasedRenderer_LIBRARY_API RenderGraph : public Node { +class NodeBasedRenderer_LIBRARY_API RenderGraph : public Node +{ public: /// Constructor. /// The nodes pointing to external data are created here. /// @param name The name of the render graph. - RenderGraph( const std::string& name ) : Node( name ) { + RenderGraph( const std::string& name ) : Node( name, getTypename() ) { auto renderObjects = new DataNode<NodeTypeRenderObject>( "renderObjects" ); addNode( renderObjects ); auto lights = new DataNode<NodeTypeLight>( "lights" ); @@ -60,10 +61,10 @@ class NodeBasedRenderer_LIBRARY_API RenderGraph : public Node { template <typename T> DataNode<T>* getDataNode() { int index = getDataNodeIndex<DataNode<T>>(); - return static_cast<DataNode<T>*>(m_nodes[index].get()); + return static_cast<DataNode<T>*>( m_nodes[index].get() ); } /// Gets the display sink node. - DisplaySinkNode* getDisplayNode() { return static_cast<DisplaySinkNode*>(m_nodes[3].get()); } + DisplaySinkNode* getDisplayNode() { return static_cast<DisplaySinkNode*>( m_nodes[3].get() ); } /// Gets the data node index template <typename T> int getDataNodeIndex(); diff --git a/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.cpp b/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.cpp index c197aeda126bea25d2746423986e60d21a148ba6..3438f256ed583c867c3376d0b3642eb2efdbb3a6 100644 --- a/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.cpp +++ b/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.cpp @@ -18,7 +18,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffer = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffer = { GL_COLOR_ATTACHMENT0 }; AccessibilityBufferPass::AccessibilityBufferPass( const std::vector<RenderObjectPtr>* objectsToRender, @@ -46,7 +46,8 @@ bool AccessibilityBufferPass::initializePass( size_t width, texparams.type = GL_FLOAT; texparams.name = "SSDO::AOBuffer"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); texparams.minFilter = GL_LINEAR; texparams.magFilter = GL_LINEAR; @@ -64,17 +65,17 @@ bool AccessibilityBufferPass::initializePass( size_t width, // The shader std::string resourcesRootDir = getResourcesDir(); auto added = shaderMngr->addShaderProgram( - {{"SSDO"}, - resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", - resourcesRootDir + "Shaders/AccessibilityPass/ssao.frag.glsl"} ); + { { "SSDO" }, + resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", + resourcesRootDir + "Shaders/AccessibilityPass/ssao.frag.glsl" } ); if ( added ) { m_shader = added.value(); } else { return false; } added = shaderMngr->addShaderProgram( - {{"blurSSDO"}, - resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", - resourcesRootDir + "Shaders/AccessibilityPass/blurao.frag.glsl"} ); + { { "blurSSDO" }, + resourcesRootDir + "Shaders/AccessibilityPass/ssao.vert.glsl", + resourcesRootDir + "Shaders/AccessibilityPass/blurao.frag.glsl" } ); if ( added ) { m_blurShader = added.value(); @@ -164,8 +165,8 @@ void AccessibilityBufferPass::execute( /// positions and normals must be computed in world space void AccessibilityBufferPass::setInputs( const SharedTextures& positions, const SharedTextures& normals ) { - addImportedTexture( {"SSDO::PositionSampler", positions.second} ); - addImportedTexture( {"SSDO::NormalSampler", normals.second} ); + addImportedTexture( { "SSDO::PositionSampler", positions.second } ); + addImportedTexture( { "SSDO::NormalSampler", normals.second } ); } /// Set the sampler to use to compute SSDO diff --git a/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.hpp b/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.hpp index 84591884b87241c8f041580c6d7bd3434ca998b7..7bfce37c308c377e1c10639997b2ac39f140804d 100644 --- a/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.hpp +++ b/src/libRender/RadiumNBR/Passes/AccessibilityBufferPass.hpp @@ -47,28 +47,28 @@ class AccessibilityBufferPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The quad to be drawn for shader invocation - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The shader that computes ssdo (the Radium shader manager has ownership) - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The shader that blurs ssdo (the Radium shader manager has ownership) - const Ra::Engine::Data::ShaderProgram* m_blurShader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_blurShader{ nullptr }; std::unique_ptr<SphereSampler> m_sphereSampler; /// Ambiant occlusion Radius, in % of the scene bbox - Scalar m_aoRadius{5}; + Scalar m_aoRadius{ 5 }; /// Dimension of the scene. Used to adapt the aoRadius to the scene dimensions. - Scalar m_sceneDiag{1}; + Scalar m_sceneDiag{ 1 }; /// Temporary texture for raw AO computation std::unique_ptr<Ra::Engine::Data::Texture> m_rawAO; /// The framebuffer used to blur the AO - std::unique_ptr<globjects::Framebuffer> m_blurfbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_blurfbo{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/ClearPass.cpp b/src/libRender/RadiumNBR/Passes/ClearPass.cpp index a4ce40c4ffa4a9f05cbb1fcae0ada5de7582fd64..afb0c6785b3f2ec048699cb39d1fdd6a508ab54e 100644 --- a/src/libRender/RadiumNBR/Passes/ClearPass.cpp +++ b/src/libRender/RadiumNBR/Passes/ClearPass.cpp @@ -9,7 +9,7 @@ namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; ClearPass::ClearPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : diff --git a/src/libRender/RadiumNBR/Passes/ClearPass.hpp b/src/libRender/RadiumNBR/Passes/ClearPass.hpp index 4c27a0175c8d335b9132fb10fc40322f54e88d29..93e1b5e42cde4c4b4309684869a429da4d2d16eb 100644 --- a/src/libRender/RadiumNBR/Passes/ClearPass.hpp +++ b/src/libRender/RadiumNBR/Passes/ClearPass.hpp @@ -41,10 +41,10 @@ class ClearPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; @@ -53,11 +53,11 @@ class ClearPass : public RenderPass Ra::Core::Utils::Color m_bgkColor; /// The Environment to used for skybox display - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; /// Is the environment drawn ? - bool m_showEnvMap{true}; + bool m_showEnvMap{ true }; - int m_skyLod{0}; + int m_skyLod{ 0 }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp b/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp index 7b735da48db94a711463a009cd9e71184381d711..2cdb92d34e55ba36190a617afac6287cd40e19b7 100644 --- a/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp +++ b/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.cpp @@ -20,10 +20,10 @@ namespace RadiumNBR { using namespace gl; // Envmap shader source -static const std::string noopEnvMapFunction{"\nint getEnvMapColors(float roughness, vec3 " - "normalWorld, out vec3 diffuse, out vec3 specular) {\n" - " diffuse = vec3(1); specular = vec3(1); return 0;\n" - "}\n\n"}; +static const std::string noopEnvMapFunction{ "\nint getEnvMapColors(float roughness, vec3 " + "normalWorld, out vec3 diffuse, out vec3 specular) {\n" + " diffuse = vec3(1); specular = vec3(1); return 0;\n" + "}\n\n" }; static const std::string envMapFunction{ "\nuniform samplerCube envTexture;\n" @@ -46,7 +46,7 @@ static const std::string envMapFunction{ " float r = roughness * numLod;\n" " specular = textureLod(envTexture, rfl, r).rgb * cosTi * envStrength;\n" " return 1;\n" - "}\n\n"}; + "}\n\n" }; /* Test Point cloud parameter provider */ /* @@ -73,7 +73,7 @@ class PointCloudParameterProvider : public Ra::Engine::Data::ShaderParameterProv Ra::Engine::Scene::PointCloudComponent* m_component; }; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; CustomAttribToColorPass::CustomAttribToColorPass( const std::vector<RenderObjectPtr>* objectsToRender, @@ -98,13 +98,14 @@ bool CustomAttribToColorPass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "CustomAtt2Clr::VectorField"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); return true; } void CustomAttribToColorPass::setInputs( const SharedTextures& depthBuffer ) { - addImportedTexture( {"CustomAtt2Clr::Depth", depthBuffer.second} ); + addImportedTexture( { "CustomAtt2Clr::Depth", depthBuffer.second } ); } void CustomAttribToColorPass::setOutput( const SharedTextures& colorBuffer ) { @@ -136,8 +137,8 @@ void CustomAttribToColorPass::resize( size_t width, size_t height ) { void CustomAttribToColorPass::execute( const Ra::Engine::Data::ViewingParameters& viewParams ) const { - static constexpr const float clearDepth{1.0f}; - static const float clearColor[4]{0.f, 0.f, 0.f, 0.f}; + static constexpr const float clearDepth{ 1.0f }; + static const float clearColor[4]{ 0.f, 0.f, 0.f, 0.f }; m_fbo->bind(); // only draw into 1 or 2 buffers depending on the export of a vector field if ( m_exportVectorField ) @@ -160,9 +161,7 @@ void CustomAttribToColorPass::execute( { m_passParams.addParameter( "envStrength", m_envmap->getEnvStrength() ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( m_passParams, viewParams, passIndex() ); - } + { ro->render( m_passParams, viewParams, passIndex() ); } } else { @@ -174,9 +173,7 @@ void CustomAttribToColorPass::execute( const auto l = m_lightmanager->getLight( i ); l->getRenderParameters( passParams ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( passParams, viewParams, passIndex() ); - } + { ro->render( passParams, viewParams, passIndex() ); } } } } @@ -194,10 +191,10 @@ bool CustomAttribToColorPass::buildRenderTechnique( if ( m_needConfigRebuild ) { Ra::Engine::Data::ShaderConfigurationFactory::removeConfiguration( - {"CustomAtt2ClrPass::CustomColorProgram" + ro->getName()} ); + { "CustomAtt2ClrPass::CustomColorProgram" + ro->getName() } ); } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"CustomAtt2ClrPass::CustomColorProgram" + ro->getName()} ) ) + { "CustomAtt2ClrPass::CustomColorProgram" + ro->getName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); std::shared_ptr<Ra::Engine::Data::ShaderParameterProvider> paramProvider = mat; @@ -258,7 +255,7 @@ bool CustomAttribToColorPass::buildRenderTechnique( "out_viewVector = vec3(eye - out_position);\n" "out_lightVector = getLightDirection(light, out_position);\n" "outputCustomAttribs();" - "}\n"}; + "}\n" }; // the function computeCustomColor, alongside the declaration of frag_attrib is appended to // the source const std::string fragmentShadersource{ @@ -290,10 +287,10 @@ bool CustomAttribToColorPass::buildRenderTechnique( "vec3 lightDir = normalize(world2local * in_lightVector);\n" "vec3 viewDir = normalize(world2local * in_viewVector);\n" "out_color = computeCustomColor(material, lightDir, viewDir, normalWorld);\n" - "}\n"}; + "}\n" }; - Ra::Engine::Data::ShaderConfiguration theConfig{"CustomAtt2ClrPass::CustomColorProgram" + - ro->getName()}; + Ra::Engine::Data::ShaderConfiguration theConfig{ "CustomAtt2ClrPass::CustomColorProgram" + + ro->getName() }; theConfig.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vertexShaderSource + m_customVertexAttrib ); if ( m_envmap ) @@ -391,7 +388,7 @@ bool CustomAttribToColorPass::buildRenderTechnique( " EmitVertex();\n" "}\n" "EndPrimitive();\n" - "}\n"}; + "}\n" }; auto pointCloudConst = dynamic_cast<const Ra::Engine::Scene::PointCloudComponent*>( ro->getComponent() ); diff --git a/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.hpp b/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.hpp index c44c0c518c66e2f0520ad964879f0175bc9ae56a..0ea9ced092e1b41e32a4d537aaa743b89789f51f 100644 --- a/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.hpp +++ b/src/libRender/RadiumNBR/Passes/CustomAttribToColorPass.hpp @@ -1,6 +1,6 @@ #pragma once -#include <RadiumNBR/RenderPass.hpp> #include <RadiumNBR/EnvMap.hpp> +#include <RadiumNBR/RenderPass.hpp> #include <Core/Utils/Color.hpp> @@ -55,7 +55,7 @@ class CustomAttribToColorPass : public RenderPass inline float getSplatSize() { return m_splatsSize; } /// return the splatSize used for point clouds - void setSplatSize(float s); + void setSplatSize( float s ); /// set the env map to use void setEnvMap( std::shared_ptr<EnvMap> envmp ); @@ -77,29 +77,30 @@ class CustomAttribToColorPass : public RenderPass m_exportVectorField = state; rebuildShaders(); }; - bool exportsVectorField() const { return m_exportVectorField;} + bool exportsVectorField() const { return m_exportVectorField; } private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; /// The custom Attrib Vertex shader function - std::string m_customVertexAttrib{"void outputCustomAttribs(){}\n"}; + std::string m_customVertexAttrib{ "void outputCustomAttribs(){}\n" }; /// The custom Attrib Geometry shader function /// Todo : find what is the gooe profile ... - std::string m_customGeometryAttrib{"void propagateAttributes(){}\n"}; + std::string m_customGeometryAttrib{ "void propagateAttributes(){}\n" }; /// the custom FragmentColor shader function /// If not changed, compute the same expression (without ao) than the envlight stage std::string m_customFragmentColor{ - "\nvec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir, vec3 normal_world) { \n" + "\nvec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir, vec3 normal_world) { " + "\n" "vec3 diffColor; \n" "vec3 specColor; \n" "getSeparateBSDFComponent( mat, getPerVertexTexCoord(), lightDir, viewDir,\n" @@ -116,24 +117,24 @@ class CustomAttribToColorPass : public RenderPass "out_vector_field = vec4(getWorldSpaceTangent(), 1);\n" "#endif\n" "return vec4( finalColor, 1); \n" - "}\n"}; + "}\n" }; /// State indicator - mutable bool m_needConfigRebuild{true}; + mutable bool m_needConfigRebuild{ true }; /// The light manager to use const Ra::Engine::Scene::LightManager* m_lightmanager; /// The splats size - float m_splatsSize{0.025}; + float m_splatsSize{ 0.025 }; /// The Environment to used for envmap lighting - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; /// The strength of the envmap float m_envStrength; /// Export a vector texture - bool m_exportVectorField{true}; + bool m_exportVectorField{ true }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/DebugPass.cpp b/src/libRender/RadiumNBR/Passes/DebugPass.cpp index d8fbcd07fc4628b22fb3b38faa56a97046fd5dee..be0278a5426ee056b54140a0fe69e2dcf67d04ed 100644 --- a/src/libRender/RadiumNBR/Passes/DebugPass.cpp +++ b/src/libRender/RadiumNBR/Passes/DebugPass.cpp @@ -15,7 +15,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; #define DEBUG_PASS_ID 30 DebugPass::DebugPass( const std::vector<RenderObjectPtr>* objectsToRender ) : RenderPass( "User Interface pass", DEBUG_PASS_ID, objectsToRender ) {} @@ -69,9 +69,7 @@ void DebugPass::execute( const Ra::Engine::Data::ViewingParameters& viewParams ) GL_ASSERT( glDepthFunc( GL_LESS ) ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( {}, viewParams ); - } + { ro->render( {}, viewParams ); } // DebugRender::getInstance()->render( renderData.viewMatrix, renderData.projMatrix ); @@ -86,7 +84,7 @@ void DebugPass::setOutput( const Ra::Engine::Data::Texture* colorBuffer ) { /// These inputs must be computed before executing this pass /// depth buffer ? // TODO verify we need this void DebugPass::setInputs( const SharedTextures& depthBuffer ) { - addImportedTexture( {"Debug::Depth", depthBuffer.second} ); + addImportedTexture( { "Debug::Depth", depthBuffer.second } ); } } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/DebugPass.hpp b/src/libRender/RadiumNBR/Passes/DebugPass.hpp index bbed642cdc08fd40d5cb2dee7312dbdc92ea1116..6276c2e8e1729e71f06fd1d9e7656f3357d0d458 100644 --- a/src/libRender/RadiumNBR/Passes/DebugPass.hpp +++ b/src/libRender/RadiumNBR/Passes/DebugPass.hpp @@ -39,10 +39,10 @@ class DebugPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. const Ra::Engine::Data::Texture* m_outputTexture; diff --git a/src/libRender/RadiumNBR/Passes/EmissivityPass.cpp b/src/libRender/RadiumNBR/Passes/EmissivityPass.cpp index d2feed7aa06f8b48cccecbc5ebb844b7eaf83b6a..9b5aa14ced107467bf5e7d2d06945277d186f89b 100644 --- a/src/libRender/RadiumNBR/Passes/EmissivityPass.cpp +++ b/src/libRender/RadiumNBR/Passes/EmissivityPass.cpp @@ -16,7 +16,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; EmissivityPass::EmissivityPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -35,8 +35,8 @@ bool EmissivityPass::initializePass( size_t /* width */, void EmissivityPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& ambientOcclusion ) { - addImportedTexture( {"Emissivity::Depth", depthBuffer.second} ); - addImportedTexture( {"Emissivity::AmbOcc", ambientOcclusion.second} ); + addImportedTexture( { "Emissivity::Depth", depthBuffer.second } ); + addImportedTexture( { "Emissivity::AmbOcc", ambientOcclusion.second } ); m_passParams.addParameter( "amb_occ_sampler", ambientOcclusion.second.get() ); } @@ -78,9 +78,7 @@ void EmissivityPass::execute( const Ra::Engine::Data::ViewingParameters& viewPar GL_ASSERT( glDisable( GL_BLEND ) ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( m_passParams, viewParams, passIndex() ); - } + { ro->render( m_passParams, viewParams, passIndex() ); } } bool EmissivityPass::buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, @@ -91,15 +89,15 @@ bool EmissivityPass::buildRenderTechnique( const Ra::Engine::Rendering::RenderOb if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"EmissivityPass::" + mat->getMaterialName()} ) ) + { "EmissivityPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"EmissivityPass::" + mat->getMaterialName()}, + { "EmissivityPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.vert.glsl", - resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.frag.glsl"}; + resourcesRootDir + "Shaders/EmissivityPass/emissivitypass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/Passes/EmissivityPass.hpp b/src/libRender/RadiumNBR/Passes/EmissivityPass.hpp index f229f5ce31b0c2b2804a1c802311006f5f8e554e..a4f333132b887d5844fb1f9e0bb214b0e51088c5 100644 --- a/src/libRender/RadiumNBR/Passes/EmissivityPass.hpp +++ b/src/libRender/RadiumNBR/Passes/EmissivityPass.hpp @@ -42,10 +42,10 @@ class EmissivityPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; diff --git a/src/libRender/RadiumNBR/Passes/EnvLightPass.cpp b/src/libRender/RadiumNBR/Passes/EnvLightPass.cpp index 3b5cf07f3a854d3ac23b1986a9fcf593cadb3398..0e340bd226731282870aa61469e3f8c8098013d5 100644 --- a/src/libRender/RadiumNBR/Passes/EnvLightPass.cpp +++ b/src/libRender/RadiumNBR/Passes/EnvLightPass.cpp @@ -16,7 +16,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; EnvLightPass::EnvLightPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -34,8 +34,8 @@ bool EnvLightPass::initializePass( size_t /* width */, void EnvLightPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& ambientOcclusion ) { - addImportedTexture( {"EnvLight::Depth", depthBuffer.second} ); - addImportedTexture( {"EnvLight::AmbOcc", ambientOcclusion.second} ); + addImportedTexture( { "EnvLight::Depth", depthBuffer.second } ); + addImportedTexture( { "EnvLight::AmbOcc", ambientOcclusion.second } ); m_passParams.addParameter( "amb_occ_sampler", ambientOcclusion.second.get() ); } @@ -80,9 +80,7 @@ void EnvLightPass::execute( const Ra::Engine::Data::ViewingParameters& viewParam m_passParams.addParameter( "envStrength", m_envmap->getEnvStrength() ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( m_passParams, viewParams, passIndex() ); - } + { ro->render( m_passParams, viewParams, passIndex() ); } // Beware of the state left by the pass GL_ASSERT( glDisable( GL_BLEND ) ); @@ -96,15 +94,15 @@ bool EnvLightPass::buildRenderTechnique( const Ra::Engine::Rendering::RenderObje if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"EnvLightPass::" + mat->getMaterialName()} ) ) + { "EnvLightPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"EnvLightPass::" + mat->getMaterialName()}, + { "EnvLightPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/EnvLightPass/envlightpass.vert.glsl", - resourcesRootDir + "Shaders/EnvLightPass/envlightpass.frag.glsl"}; + resourcesRootDir + "Shaders/EnvLightPass/envlightpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/Passes/EnvLightPass.hpp b/src/libRender/RadiumNBR/Passes/EnvLightPass.hpp index bd6b0d7c313be8bbb34620e798e0b49a6236db01..c924a962c55e67217a3b7222e322633327238c8c 100644 --- a/src/libRender/RadiumNBR/Passes/EnvLightPass.hpp +++ b/src/libRender/RadiumNBR/Passes/EnvLightPass.hpp @@ -58,16 +58,16 @@ class EnvLightPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; /// The Environment to used for envmap lighting - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; /// The strength of the envmap float m_envStrength; diff --git a/src/libRender/RadiumNBR/Passes/GeomPrepass.cpp b/src/libRender/RadiumNBR/Passes/GeomPrepass.cpp index ddc175047ed105f488b977d93f5733a321c5da99..de320d08d1472511477c3acc890afc1882015aff 100644 --- a/src/libRender/RadiumNBR/Passes/GeomPrepass.cpp +++ b/src/libRender/RadiumNBR/Passes/GeomPrepass.cpp @@ -16,14 +16,14 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2, - GL_COLOR_ATTACHMENT3, - GL_COLOR_ATTACHMENT4, - GL_COLOR_ATTACHMENT5, - GL_COLOR_ATTACHMENT6, - GL_COLOR_ATTACHMENT7}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3, + GL_COLOR_ATTACHMENT4, + GL_COLOR_ATTACHMENT5, + GL_COLOR_ATTACHMENT6, + GL_COLOR_ATTACHMENT7 }; GeomPrePass::GeomPrePass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -47,18 +47,20 @@ bool GeomPrePass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "GeomPrePass::PosInWorld"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); texparams.minFilter = GL_LINEAR; texparams.magFilter = GL_LINEAR; texparams.name = "GeomPrePass::NormalInWorld"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); return true; } void GeomPrePass::setOutput( const SharedTextures& depthTexture ) { - addImportedTexture( {"GeomPrePass::Depth", depthTexture.second} ); + addImportedTexture( { "GeomPrePass::Depth", depthTexture.second } ); } bool GeomPrePass::update() { @@ -86,7 +88,7 @@ void GeomPrePass::resize( size_t width, size_t height ) { void GeomPrePass::execute( const Ra::Engine::Data::ViewingParameters& viewParams ) const { using ClearColor = Ra::Core::Utils::Color; - static const float clearDepth{1.0f}; + static const float clearDepth{ 1.0f }; m_fbo->bind(); @@ -95,7 +97,7 @@ void GeomPrePass::execute( const Ra::Engine::Data::ViewingParameters& viewParams GL_ASSERT( glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ) ); // only draw into 2 buffers (Normal, Worldpos) GL_ASSERT( glDrawBuffers( 2, buffers ) ); - float pblck[4] = {0, 0, 0, 0}; + float pblck[4] = { 0, 0, 0, 0 }; GL_ASSERT( glClearBufferfv( GL_COLOR, 0, pblck ) ); // Clear World pos GL_ASSERT( glClearBufferfv( GL_COLOR, 1, pblck ) ); // Clear Normals GL_ASSERT( glClearBufferfv( GL_DEPTH, 0, &clearDepth ) ); @@ -105,9 +107,7 @@ void GeomPrePass::execute( const Ra::Engine::Data::ViewingParameters& viewParams glPolygonOffset( 1.1f, 1.f ); glEnable( GL_POLYGON_OFFSET_FILL ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( m_passParams, viewParams, passIndex() ); - } + { ro->render( m_passParams, viewParams, passIndex() ); } // Beware of the state left by the pass : Polygon offset must be enable after this for rendering // coherency @@ -121,15 +121,15 @@ bool GeomPrePass::buildRenderTechnique( const Ra::Engine::Rendering::RenderObjec if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"GeomPrePass::" + mat->getMaterialName()} ) ) + { "GeomPrePass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"GeomPrePass::" + mat->getMaterialName()}, + { "GeomPrePass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/ZPrepass/zprepass.vert.glsl", - resourcesRootDir + "Shaders/ZPrepass/zprepass.frag.glsl"}; + resourcesRootDir + "Shaders/ZPrepass/zprepass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/Passes/GeomPrepass.hpp b/src/libRender/RadiumNBR/Passes/GeomPrepass.hpp index e5433ac4514826a30a2f3e73a3412a22277564ca..aef6ad9a69b595f6a5aed74c2dff6650c23ca478 100644 --- a/src/libRender/RadiumNBR/Passes/GeomPrepass.hpp +++ b/src/libRender/RadiumNBR/Passes/GeomPrepass.hpp @@ -32,9 +32,9 @@ class NodeBasedRenderer_LIBRARY_API GeomPrePass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/ImageProcessPass.cpp b/src/libRender/RadiumNBR/Passes/ImageProcessPass.cpp index a0e2d79dafbfbba8d3b651ab93455f4b8f53915c..d817b69804e914cbe78786e6d71a63a37c65b1e0 100644 --- a/src/libRender/RadiumNBR/Passes/ImageProcessPass.cpp +++ b/src/libRender/RadiumNBR/Passes/ImageProcessPass.cpp @@ -19,7 +19,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffer = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffer = { GL_COLOR_ATTACHMENT0 }; ImageProcessPass::ImageProcessPass( const Ra::Core::Utils::Index& idx ) : RenderPass( "Image processing pass", idx, nullptr ) {} @@ -42,7 +42,8 @@ bool ImageProcessPass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "ImageProcess::Result"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); // The shader caller Ra::Core::Geometry::TriangleMesh mesh = @@ -57,9 +58,9 @@ bool ImageProcessPass::initializePass( size_t width, // in the future, this shader might be user-defined std::string resourcesRootDir = getResourcesDir(); auto added = shaderMngr->addShaderProgram( - {{"ImageProcess(LIC)"}, - resourcesRootDir + "Shaders/ImageProcessingPass/ImageProcess.vert.glsl", - resourcesRootDir + "Shaders/ImageProcessingPass/ImageProcess.frag.glsl"} ); + { { "ImageProcess(LIC)" }, + resourcesRootDir + "Shaders/ImageProcessingPass/ImageProcess.vert.glsl", + resourcesRootDir + "Shaders/ImageProcessingPass/ImageProcess.frag.glsl" } ); if ( added ) { m_shader = added.value(); } else { return false; } @@ -116,8 +117,8 @@ void ImageProcessPass::execute( const Ra::Engine::Data::ViewingParameters& viewP /// positions and normals must be computed in world space void ImageProcessPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& colorBuffer ) { - addImportedTexture( {"ImageProcess::DepthSampler", depthBuffer.second} ); - addImportedTexture( {"ImageProcess::ColorSampler", colorBuffer.second} ); + addImportedTexture( { "ImageProcess::DepthSampler", depthBuffer.second } ); + addImportedTexture( { "ImageProcess::ColorSampler", colorBuffer.second } ); } void ImageProcessPass::setOutput( const SharedTextures& colorBuffer ) { diff --git a/src/libRender/RadiumNBR/Passes/ImageProcessPass.hpp b/src/libRender/RadiumNBR/Passes/ImageProcessPass.hpp index 169ddbe7553eed1d01f28e67f71ef6b4e6d9ce48..06582e3a9ab2588f27b0911f52b3583bc3f3c74a 100644 --- a/src/libRender/RadiumNBR/Passes/ImageProcessPass.hpp +++ b/src/libRender/RadiumNBR/Passes/ImageProcessPass.hpp @@ -40,20 +40,18 @@ class ImageProcessPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; /// The quad to be drawn for shader invocation - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The shader that process the image (the Radium shader manager has ownership) - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; - - + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/LocalLightPass.cpp b/src/libRender/RadiumNBR/Passes/LocalLightPass.cpp index b3f836884ca32335cb76df5683297bc9e4726698..e71133bd1a73828ac669ead34b6f4225aa5d357d 100644 --- a/src/libRender/RadiumNBR/Passes/LocalLightPass.cpp +++ b/src/libRender/RadiumNBR/Passes/LocalLightPass.cpp @@ -18,7 +18,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; LocalLightPass::LocalLightPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -37,8 +37,8 @@ bool LocalLightPass::initializePass( size_t /* width */, void LocalLightPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& ambientOcclusion ) { - addImportedTexture( {"LocalLight::Depth", depthBuffer.second} ); - addImportedTexture( {"LocalLight::AmbOcc", ambientOcclusion.second} ); + addImportedTexture( { "LocalLight::Depth", depthBuffer.second } ); + addImportedTexture( { "LocalLight::AmbOcc", ambientOcclusion.second } ); m_passParams.addParameter( "amb_occ_sampler", ambientOcclusion.second.get() ); } @@ -93,9 +93,7 @@ void LocalLightPass::execute( const Ra::Engine::Data::ViewingParameters& viewPar l->getRenderParameters( passParams ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( passParams, viewParams, passIndex() ); - } + { ro->render( passParams, viewParams, passIndex() ); } } } #ifdef PASSES_LOG @@ -114,16 +112,16 @@ bool LocalLightPass::buildRenderTechnique( const Ra::Engine::Rendering::RenderOb { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"LocalLightPass::" + mat->getMaterialName()} ) ) + { "LocalLightPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { std::string resourcesRootDir = getResourcesDir(); // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"LocalLightPass::" + mat->getMaterialName()}, + { "LocalLightPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/LocalLightPass/lightpass.vert.glsl", - resourcesRootDir + "Shaders/LocalLightPass/lightpass.frag.glsl"}; + resourcesRootDir + "Shaders/LocalLightPass/lightpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/Passes/LocalLightPass.hpp b/src/libRender/RadiumNBR/Passes/LocalLightPass.hpp index bf16f277f0833918c0e8220f83ab62160f7a7763..8307e899a9a5e29daf58dc34420a180c959dc93f 100644 --- a/src/libRender/RadiumNBR/Passes/LocalLightPass.hpp +++ b/src/libRender/RadiumNBR/Passes/LocalLightPass.hpp @@ -45,10 +45,10 @@ class LocalLightPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; diff --git a/src/libRender/RadiumNBR/Passes/TransparencyPass.cpp b/src/libRender/RadiumNBR/Passes/TransparencyPass.cpp index 0deb1bac627cb2f5f80e75aec13d523b343189c7..3dccd19b82600141ae3da5474c16ec2804bc8e8e 100644 --- a/src/libRender/RadiumNBR/Passes/TransparencyPass.cpp +++ b/src/libRender/RadiumNBR/Passes/TransparencyPass.cpp @@ -20,7 +20,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; TransparencyPass::TransparencyPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -45,9 +45,11 @@ bool TransparencyPass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "Transparency::Accum"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); texparams.name = "Transparency::Revealage"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); // The compositer caller Ra::Core::Geometry::TriangleMesh mesh = @@ -57,13 +59,13 @@ bool TransparencyPass::initializePass( size_t width, m_quadMesh = std::move( qm ); m_quadMesh->updateGL(); - const std::string composeVertexShader{"layout (location = 0) in vec3 in_position;\n" - "out vec2 varTexcoord;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(in_position, 1.0);\n" - " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" - "}\n"}; + const std::string composeVertexShader{ "layout (location = 0) in vec3 in_position;\n" + "out vec2 varTexcoord;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_position, 1.0);\n" + " varTexcoord = (in_position.xy + 1.0) * 0.5;\n" + "}\n" }; const std::string composeFragmentShader{ "in vec2 varTexcoord;\n" "out vec4 f_Color;\n" @@ -75,8 +77,8 @@ bool TransparencyPass::initializePass( size_t width, " vec4 accum = texture( u_OITSumColor, varTexcoord );\n" " vec3 avg_color = accum.rgb / max( accum.a, 0.00001 );\n" " f_Color = vec4( avg_color, r );\n" - "}"}; - Ra::Engine::Data::ShaderConfiguration config{"ComposeTransparency"}; + "}" }; + Ra::Engine::Data::ShaderConfiguration config{ "ComposeTransparency" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, composeVertexShader ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, composeFragmentShader ); @@ -90,8 +92,8 @@ bool TransparencyPass::initializePass( size_t width, void TransparencyPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& ambientOcclusion ) { - addImportedTexture( {"Transparency::Depth", depthBuffer.second} ); - addImportedTexture( {"Transparency::AmbOcc", ambientOcclusion.second} ); + addImportedTexture( { "Transparency::Depth", depthBuffer.second } ); + addImportedTexture( { "Transparency::AmbOcc", ambientOcclusion.second } ); } void TransparencyPass::setOutput( const SharedTextures& colorBuffer ) { @@ -163,9 +165,7 @@ void TransparencyPass::execute( const Ra::Engine::Data::ViewingParameters& viewP l->getRenderParameters( passParams ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( passParams, viewParams, passIndex() ); - } + { ro->render( passParams, viewParams, passIndex() ); } } } #ifdef PASSES_LOG @@ -199,16 +199,16 @@ bool TransparencyPass::buildRenderTechnique( const Ra::Engine::Rendering::Render auto mat = const_cast<Ra::Engine::Rendering::RenderObject*>( ro )->getMaterial(); if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"TransparencyPass::" + mat->getMaterialName()} ) ) + { "TransparencyPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { std::string resourcesRootDir = getResourcesDir(); // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"TransparencyPass::" + mat->getMaterialName()}, + { "TransparencyPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/TransparencyPass/oitpass.vert.glsl", - resourcesRootDir + "Shaders/TransparencyPass/oitpass.frag.glsl"}; + resourcesRootDir + "Shaders/TransparencyPass/oitpass.frag.glsl" }; // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT ); diff --git a/src/libRender/RadiumNBR/Passes/TransparencyPass.hpp b/src/libRender/RadiumNBR/Passes/TransparencyPass.hpp index ad972405cfe762b55f8846928a944ef04eba475e..018ef153692a84856a615b02c0ed73212501e366 100644 --- a/src/libRender/RadiumNBR/Passes/TransparencyPass.hpp +++ b/src/libRender/RadiumNBR/Passes/TransparencyPass.hpp @@ -47,20 +47,20 @@ class TransparencyPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The framebuffer to render the Transparent objects - std::unique_ptr<globjects::Framebuffer> m_oitFbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_oitFbo{ nullptr }; /// The quad to be drawn for shader invocation - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The shader that compose the volume onto the color picture (the Radium shader manager has /// ownership) - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; diff --git a/src/libRender/RadiumNBR/Passes/UiPass.cpp b/src/libRender/RadiumNBR/Passes/UiPass.cpp index 3d07d8e514c3db02cc8367b399352e6a81c1d5a3..aa53e79b6f0dc86607325567fd9dc59f8ab9c636 100644 --- a/src/libRender/RadiumNBR/Passes/UiPass.cpp +++ b/src/libRender/RadiumNBR/Passes/UiPass.cpp @@ -16,7 +16,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; #define UI_PASS_ID 31 UIPass::UIPass( const std::vector<RenderObjectPtr>* objectsToRender ) : RenderPass( "User Interface pass", UI_PASS_ID, objectsToRender ) {} @@ -113,7 +113,7 @@ void UIPass::setOutput( const Ra::Engine::Data::Texture* colorBuffer ) { /// These inputs must be computed before executing this pass /// depth buffer ? // TODO verify we need this void UIPass::setInputs( const SharedTextures& depthBuffer ) { - addImportedTexture( {"Ui::Depth", depthBuffer.second} ); + addImportedTexture( { "Ui::Depth", depthBuffer.second } ); } } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/UiPass.hpp b/src/libRender/RadiumNBR/Passes/UiPass.hpp index 0895cadfe99740d1d0b9f5a2962915c45174866d..365a41b5b2d61b33b26959c000d91708f17ece2e 100644 --- a/src/libRender/RadiumNBR/Passes/UiPass.hpp +++ b/src/libRender/RadiumNBR/Passes/UiPass.hpp @@ -16,7 +16,7 @@ namespace RadiumNBR { class UIPass : public RenderPass { public: - UIPass( const std::vector<RenderObjectPtr>* objectsToRender); + UIPass( const std::vector<RenderObjectPtr>* objectsToRender ); ~UIPass() override; bool buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, @@ -37,10 +37,10 @@ class UIPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. const Ra::Engine::Data::Texture* m_outputTexture; diff --git a/src/libRender/RadiumNBR/Passes/VolumePass.cpp b/src/libRender/RadiumNBR/Passes/VolumePass.cpp index ef671b95842d8dfe33241768a76311b5036c01da..48cd3fb0e41207e9f0ef4ed585e3112315210a18 100644 --- a/src/libRender/RadiumNBR/Passes/VolumePass.cpp +++ b/src/libRender/RadiumNBR/Passes/VolumePass.cpp @@ -20,7 +20,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; VolumeLightingPass::VolumeLightingPass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -45,7 +45,8 @@ bool VolumeLightingPass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "VolumeLighting::RawVolume"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); // The shader caller Ra::Core::Geometry::TriangleMesh mesh = @@ -56,13 +57,13 @@ bool VolumeLightingPass::initializePass( size_t width, m_quadMesh->updateGL(); // The shader - const std::string vrtxSrc{"layout (location = 0) in vec3 in_position;\n" - "out vec2 varTexcoord;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(in_position, 1.0);\n" - " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" - "}\n"}; + const std::string vrtxSrc{ "layout (location = 0) in vec3 in_position;\n" + "out vec2 varTexcoord;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_position, 1.0);\n" + " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" + "}\n" }; const std::string frgSrc{ "out vec4 fragColor;\n" "in vec2 varTexcoord;\n" @@ -74,8 +75,8 @@ bool VolumeLightingPass::initializePass( size_t width, " if (volColor.a < 1)\n" " discard;\n" " fragColor = vec4(volColor.rgb, 0);\n" - "}\n"}; - Ra::Engine::Data::ShaderConfiguration config{"ComposeVolume"}; + "}\n" }; + Ra::Engine::Data::ShaderConfiguration config{ "ComposeVolume" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vrtxSrc ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, frgSrc ); auto added = shaderMngr->addShaderProgram( config ); @@ -88,8 +89,8 @@ bool VolumeLightingPass::initializePass( size_t width, void VolumeLightingPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& colorBuffer ) { - addImportedTexture( {"VolumeLighting::Depth", depthBuffer.second} ); - addImportedTexture( {"VolumeLighting::ColorInput", colorBuffer.second} ); + addImportedTexture( { "VolumeLighting::Depth", depthBuffer.second } ); + addImportedTexture( { "VolumeLighting::ColorInput", colorBuffer.second } ); } void VolumeLightingPass::setOutput( const SharedTextures& colorBuffer ) { @@ -151,9 +152,7 @@ void VolumeLightingPass::execute( const Ra::Engine::Data::ViewingParameters& vie l->getRenderParameters( passParams ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( passParams, viewParams, passIndex() ); - } + { ro->render( passParams, viewParams, passIndex() ); } } m_fbo->bind(); GL_ASSERT( glDrawBuffers( 1, buffers ) ); @@ -186,15 +185,15 @@ bool VolumeLightingPass::buildRenderTechnique( const Ra::Engine::Rendering::Rend rt.setConfiguration( *passconfig, passIndex() ); #else if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"VolumeLightingPass::" + mat->getMaterialName()} ) ) + { "VolumeLightingPass::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"VolumeLightingPass::" + mat->getMaterialName()}, + { "VolumeLightingPass::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/VolumeLightingPass/volume.vert.glsl", - resourcesRootDir + "Shaders/VolumeLightingPass/volume.frag.glsl"}; + resourcesRootDir + "Shaders/VolumeLightingPass/volume.frag.glsl" }; /* // add the material interface to the fragment shader theConfig.addInclude( "\"" + mat->getMaterialName() + ".glsl\"", diff --git a/src/libRender/RadiumNBR/Passes/VolumePass.hpp b/src/libRender/RadiumNBR/Passes/VolumePass.hpp index 715ff537fca96f8d49433f82b561428984cf253f..23bffd51b9e8faff6c44857c1c5ad1e196d28c7b 100644 --- a/src/libRender/RadiumNBR/Passes/VolumePass.hpp +++ b/src/libRender/RadiumNBR/Passes/VolumePass.hpp @@ -54,20 +54,20 @@ class VolumeLightingPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The framebuffer to render the volume - std::unique_ptr<globjects::Framebuffer> m_volumeFbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_volumeFbo{ nullptr }; /// The quad to be drawn for shader invocation - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The shader that compose the volume onto the color picture (the Radium shader manager has /// ownership) - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; @@ -76,6 +76,6 @@ class VolumeLightingPass : public RenderPass const Ra::Engine::Scene::LightManager* m_lightmanager; /// The Environment to used for envmap lighting - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Passes/WireframePass.cpp b/src/libRender/RadiumNBR/Passes/WireframePass.cpp index eaa4187850027bc238525d0cf7b5bb9272a483d2..08398996da62748dbc7411e9e71dfbc1502fd290 100644 --- a/src/libRender/RadiumNBR/Passes/WireframePass.cpp +++ b/src/libRender/RadiumNBR/Passes/WireframePass.cpp @@ -19,7 +19,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; WireframePass::WireframePass( const std::vector<RenderObjectPtr>* objectsToRender, const Ra::Core::Utils::Index& idx ) : @@ -37,7 +37,7 @@ bool WireframePass::initializePass( size_t /* width */, } void WireframePass::setInputs( const SharedTextures& depthBuffer ) { - addImportedTexture( {"WireframePass::Depth", depthBuffer.second} ); + addImportedTexture( { "WireframePass::Depth", depthBuffer.second } ); } void WireframePass::setOutput( const SharedTextures& colorBuffer ) { @@ -82,7 +82,7 @@ class VerticesUpdater { public: VerticesUpdater( std::shared_ptr<Ra::Engine::Data::LineMesh> disp, CoreGeometry& core ) : - m_disp{disp}, m_core{core} {}; + m_disp{ disp }, m_core{ core } {}; void operator()() { m_disp->getCoreGeometry().setVertices( m_core.vertices() ); } std::shared_ptr<Ra::Engine::Data::LineMesh> m_disp; @@ -94,7 +94,7 @@ class IndicesUpdater { public: IndicesUpdater( std::shared_ptr<Ra::Engine::Data::LineMesh> disp, CoreGeometry& core ) : - m_disp{disp}, m_core{core} {}; + m_disp{ disp }, m_core{ core } {}; void operator()() { auto lineIndices = m_disp->getCoreGeometry().getIndicesWithLock(); @@ -202,7 +202,7 @@ void WireframePass::execute( const Ra::Engine::Data::ViewingParameters& viewPara shader->setUniform( "transform.proj", viewParams.projMatrix ); shader->setUniform( "transform.view", viewParams.viewMatrix ); shader->setUniform( "transform.model", modelMatrix ); - shader->setUniform( "viewport", Ra::Core::Vector2{m_width, m_height} ); + shader->setUniform( "viewport", Ra::Core::Vector2{ m_width, m_height } ); wro->render( shader ); GL_CHECK_ERROR; } @@ -221,15 +221,15 @@ bool WireframePass::buildRenderTechnique( const Ra::Engine::Rendering::RenderObj if ( mat->getMaterialAspect() == Ra::Engine::Data::Material::MaterialAspect::MAT_DENSITY ) { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"WireframePass::WireframeProgram"} ) ) + { "WireframePass::WireframeProgram" } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { Ra::Engine::Data::ShaderConfiguration theConfig{ - {"WireframePass::WireframeProgram"}, + { "WireframePass::WireframeProgram" }, resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.vert.glsl", - resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.frag.glsl"}; + resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.frag.glsl" }; theConfig.addShader( Ra::Engine::Data::ShaderType_GEOMETRY, resourcesRootDir + "Shaders/WireframePass/Advanced/wireframe.geom.glsl" ); diff --git a/src/libRender/RadiumNBR/Passes/WireframePass.hpp b/src/libRender/RadiumNBR/Passes/WireframePass.hpp index 61305c7c044d13cfdfddbb078856aaf245c7988d..6ea6a31a694fcfa2be5d4d5c1c416d3fa2564880 100644 --- a/src/libRender/RadiumNBR/Passes/WireframePass.hpp +++ b/src/libRender/RadiumNBR/Passes/WireframePass.hpp @@ -38,10 +38,10 @@ class WireframePass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; @@ -49,10 +49,10 @@ class WireframePass : public RenderPass using WireMap = std::map<Ra::Engine::Rendering::RenderObject*, std::shared_ptr<Ra::Engine::Data::Displayable>>; mutable WireMap m_wireframes; - bool m_wireframeAa{true}; - Ra::Core::Utils::Color m_wireframeColor{Ra::Core::Utils::Color::White()}; + bool m_wireframeAa{ true }; + Ra::Core::Utils::Color m_wireframeColor{ Ra::Core::Utils::Color::White() }; - uint m_width{0}; - uint m_height{0}; + uint m_width{ 0 }; + uint m_height{ 0 }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/RenderPass.cpp b/src/libRender/RadiumNBR/RenderPass.cpp index cf29953c123fb6d9169ac7ab7befe898f9b182ba..7cff565813aa6cfc116987ddf185e48f13eed81f 100644 --- a/src/libRender/RadiumNBR/RenderPass.cpp +++ b/src/libRender/RadiumNBR/RenderPass.cpp @@ -6,16 +6,13 @@ namespace RadiumNBR { void RenderPass::resize( size_t width, size_t height ) { for ( auto& t : m_sharedTextures ) - { - t.second->resize( width, height ); - } + { t.second->resize( width, height ); } }; std::vector<RenderPass::SharedTextures> RenderPass::getOutputImages() const { std::vector<SharedTextures> exported; exported.reserve( m_sharedTextures.size() ); - std::copy( - m_sharedTextures.begin(), m_sharedTextures.end(), std::back_inserter( exported ) ); + std::copy( m_sharedTextures.begin(), m_sharedTextures.end(), std::back_inserter( exported ) ); return exported; } diff --git a/src/libRender/RadiumNBR/RenderPass.hpp b/src/libRender/RadiumNBR/RenderPass.hpp index 0925096ebf882af83695c35260694ad2748ceaa3..23e94b470676fc540422bda2442f0a62766c3599 100644 --- a/src/libRender/RadiumNBR/RenderPass.hpp +++ b/src/libRender/RadiumNBR/RenderPass.hpp @@ -45,7 +45,7 @@ class NodeBasedRenderer_LIBRARY_API RenderPass RenderPass( std::string name, const Ra::Core::Utils::Index& idx, const std::vector<RenderObjectPtr>* objectsToRender ) : - m_objectsToRender{objectsToRender}, m_passName{std::move( name )}, m_idx{idx} {} + m_objectsToRender{ objectsToRender }, m_passName{ std::move( name ) }, m_idx{ idx } {} RenderPass( const RenderPass& ) = delete; RenderPass& operator=( const RenderPass& ) = delete; RenderPass( RenderPass&& ) = delete; @@ -127,7 +127,8 @@ class NodeBasedRenderer_LIBRARY_API RenderPass /// @see https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c133-avoid-protected-data protected: /// Access to a shared texture - [[nodiscard]] inline std::optional<SharedTextures> getSharedTexture( const std::string& name ) const { + [[nodiscard]] inline std::optional<SharedTextures> + getSharedTexture( const std::string& name ) const { auto t = m_sharedTextures.find( name ); if ( t != m_sharedTextures.end() ) { return *t; } else @@ -135,12 +136,11 @@ class NodeBasedRenderer_LIBRARY_API RenderPass } /// Add a shared texture - inline void addSharedTexture( const SharedTextures& tex ) { - m_sharedTextures.insert( tex ); - } + inline void addSharedTexture( const SharedTextures& tex ) { m_sharedTextures.insert( tex ); } /// Access to an imported texture - [[nodiscard]] inline std::optional<SharedTextures> getImportedTexture( const std::string& name ) const { + [[nodiscard]] inline std::optional<SharedTextures> + getImportedTexture( const std::string& name ) const { auto t = m_importedTextures.find( name ); if ( t != m_importedTextures.end() ) { return *t; } else @@ -161,16 +161,15 @@ class NodeBasedRenderer_LIBRARY_API RenderPass const Ra::Core::Utils::Index m_idx; /// The base resources directory - std::string resourceDir{"./"}; + std::string resourceDir{ "./" }; /// Active state of the pass - bool m_active{false}; + bool m_active{ false }; /// Textures that are owned and shared by the pass std::map<std::string, std::shared_ptr<Ra::Engine::Data::Texture>> m_sharedTextures; /// These are textures imported from other passes (and shared by these). std::map<std::string, std::shared_ptr<Ra::Engine::Data::Texture>> m_importedTextures; - }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Renderer/MultiPassController.cpp b/src/libRender/RadiumNBR/Renderer/MultiPassController.cpp index cbde80c753c78d8cbca21fee8cf6e608be65db35..92f3c0f933a95d6443243d2bf2d2693b873d9d37 100644 --- a/src/libRender/RadiumNBR/Renderer/MultiPassController.cpp +++ b/src/libRender/RadiumNBR/Renderer/MultiPassController.cpp @@ -28,26 +28,26 @@ namespace RadiumNBR { using namespace gl; void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int w, int h ) { - m_renderer = renderer; + m_renderer = renderer; auto resourcesCheck = Ra::Core::Resources::getResourcesPath( - reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), {"Resources/RadiumNBR"} ); + reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), { "Resources/RadiumNBR" } ); if ( !resourcesCheck ) { LOG( Ra::Core::Utils::logERROR ) << "Unable to find resources for MultiPassController!"; return; } - auto resourcesPath{*resourcesCheck}; + auto resourcesPath{ *resourcesCheck }; auto shaderManager = Ra::Engine::RadiumEngine::getInstance()->getShaderProgramManager(); - auto depthTexture = m_renderer->sharedTextures().find( "Depth (RadiumNBR)" ); - auto colorTexture = m_renderer->sharedTextures().find( "Linear RGB (RadiumNBR)" ); + auto depthTexture = m_renderer->sharedTextures().find( "Depth (RadiumNBR)" ); + auto colorTexture = m_renderer->sharedTextures().find( "Linear RGB (RadiumNBR)" ); /*** * 0 - clear the final picture * Set the background color either to the global background color or to the env-map */ { - m_clearPass = - std::make_shared<ClearPass>( nullptr, MultiPassController::MultiPassControllerPasses::CLEAR_PASS ); + m_clearPass = std::make_shared<ClearPass>( + nullptr, MultiPassController::MultiPassControllerPasses::CLEAR_PASS ); m_clearPass->setOutput( *colorTexture ); m_clearPass->setBackground( m_renderer->getBackgroundColor() ); m_clearPass->initializePass( w, h, shaderManager ); @@ -61,16 +61,15 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int // Zprepass takes all objects but transparent objects are expected to render only their // opaque fragments. m_zPrePass = - std::make_shared<GeomPrePass>( m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::Z_PASS ); + std::make_shared<GeomPrePass>( m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::Z_PASS ); // Add the shared depth texture m_zPrePass->setOutput( *depthTexture ); // configure acces to shader files m_zPrePass->setResourcesDir( resourcesPath ); m_zPrePass->initializePass( w, h, shaderManager ); for ( auto&& t : m_zPrePass->getOutputImages() ) - { - m_renderer->sharedTextures().insert( t ); - } + { m_renderer->sharedTextures().insert( t ); } } /*** @@ -81,7 +80,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int auto sphereSampler = std::make_unique<SphereSampler>( m_aoSamplingMethod, m_aoSamplingPoints ); m_aoPass = std::make_shared<AccessibilityBufferPass>( - m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::ACCESSIBILITY_PASS ); + m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::ACCESSIBILITY_PASS ); m_aoPass->setResourcesDir( resourcesPath ); m_aoPass->setSampler( std::move( sphereSampler ) ); // Connect to the preceeding pass @@ -90,9 +90,7 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int m_aoPass->setInputs( *posTexture, *nrmTexture ); m_aoPass->initializePass( w, h, shaderManager ); for ( auto&& t : m_aoPass->getOutputImages() ) - { - m_renderer->sharedTextures().insert( t ); - } + { m_renderer->sharedTextures().insert( t ); } } auto ambientOcclusionTexture = m_renderer->sharedTextures().find( "SSDO::AOBuffer" ); /*** @@ -103,7 +101,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_emissivityPass = std::make_shared<EmissivityPass>( - m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::EMISSIVITY_PASS ); + m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::EMISSIVITY_PASS ); m_emissivityPass->setResourcesDir( resourcesPath ); m_emissivityPass->setInputs( *depthTexture, *ambientOcclusionTexture ); m_emissivityPass->setOutput( *colorTexture ); @@ -117,7 +116,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_envlightPass = std::make_shared<EnvLightPass>( - m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::ENVMAP_LIGHTING_OPAQUE_PASS ); + m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::ENVMAP_LIGHTING_OPAQUE_PASS ); m_envlightPass->setResourcesDir( resourcesPath ); m_envlightPass->setInputs( *depthTexture, *ambientOcclusionTexture ); m_envlightPass->setOutput( *colorTexture ); @@ -129,7 +129,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_locallightPass = std::make_shared<LocalLightPass>( - m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::LIGHTING_OPAQUE_PASS ); + m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::LIGHTING_OPAQUE_PASS ); m_locallightPass->setResourcesDir( resourcesPath ); m_locallightPass->setInputs( *depthTexture, *ambientOcclusionTexture ); m_locallightPass->setOutput( *colorTexture ); @@ -141,7 +142,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_transparencyPass = std::make_shared<TransparencyPass>( - &m_transparentRenderObjects, MultiPassController::MultiPassControllerPasses::LIGHTING_TRANSPARENT_PASS ); + &m_transparentRenderObjects, + MultiPassController::MultiPassControllerPasses::LIGHTING_TRANSPARENT_PASS ); m_transparencyPass->setResourcesDir( resourcesPath ); m_transparencyPass->setInputs( *depthTexture, *ambientOcclusionTexture ); m_transparencyPass->setOutput( *colorTexture ); @@ -154,7 +156,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_volumelightPass = std::make_shared<VolumeLightingPass>( - &m_volumetricRenderObjects, MultiPassController::MultiPassControllerPasses::LIGHTING_VOLUME_PASS ); + &m_volumetricRenderObjects, + MultiPassController::MultiPassControllerPasses::LIGHTING_VOLUME_PASS ); m_volumelightPass->setResourcesDir( resourcesPath ); m_volumelightPass->setInputs( *depthTexture, *colorTexture ); m_volumelightPass->setOutput( *colorTexture ); @@ -169,7 +172,8 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int */ { m_wireframePass = std::make_shared<WireframePass>( - m_renderer->allRenderObjects(), MultiPassController::MultiPassControllerPasses::WIREFRAME_PASS ); + m_renderer->allRenderObjects(), + MultiPassController::MultiPassControllerPasses::WIREFRAME_PASS ); m_wireframePass->setResourcesDir( resourcesPath ); m_wireframePass->setInputs( *depthTexture ); m_wireframePass->setOutput( *colorTexture ); @@ -203,15 +207,11 @@ void MultiPassController::configure( RadiumNBR::MultiPassRenderer* renderer, int for ( const auto& p : m_renderer->renderPasses() ) { for ( auto&& t : p.second->getOutputImages() ) - { - m_renderer->sharedTextures().insert( t ); - } + { m_renderer->sharedTextures().insert( t ); } } } -void MultiPassController::resize( int w, int h ) { - -} +void MultiPassController::resize( int w, int h ) {} void MultiPassController::update( const Ra::Engine::Data::ViewingParameters& ) { // Split objects into opaque and transparent @@ -246,7 +246,6 @@ void MultiPassController::update( const Ra::Engine::Data::ViewingParameters& ) { } } - void MultiPassController::setEnvMap( const std::string& files ) { if ( files.empty() ) { @@ -329,4 +328,4 @@ void MultiPassController::wireframeMode( bool status ) { m_volumelightPass->activate(); } } -} +} // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Renderer/MultiPassController.hpp b/src/libRender/RadiumNBR/Renderer/MultiPassController.hpp index 2a0000a0e1a183159fbb6c3d3f13bde502e4adf6..5db2e59ad6ef4ccc9d79ef0c7370da707704e3b8 100644 --- a/src/libRender/RadiumNBR/Renderer/MultiPassController.hpp +++ b/src/libRender/RadiumNBR/Renderer/MultiPassController.hpp @@ -1,7 +1,7 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/MultiPassRenderer.hpp> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/SphereSampler.hpp> namespace RadiumNBR { @@ -16,7 +16,8 @@ class TransparencyPass; class WireframePass; class NodeBasedRenderer_LIBRARY_API MultiPassController - : public MultiPassRenderer::RenderControlFunctor { + : public MultiPassRenderer::RenderControlFunctor +{ public: [[nodiscard]] std::string getRendererName() const override { return "MultiPass renderer"; } @@ -70,9 +71,9 @@ class NodeBasedRenderer_LIBRARY_API MultiPassController /// The ambiant occlusion pass std::shared_ptr<AccessibilityBufferPass> m_aoPass; // The sampling method of the sphere sampler - SphereSampler::SamplingMethod m_aoSamplingMethod{SphereSampler::SamplingMethod::HAMMERSLEY}; + SphereSampler::SamplingMethod m_aoSamplingMethod{ SphereSampler::SamplingMethod::HAMMERSLEY }; // The number of points for the sampler - int m_aoSamplingPoints{64}; + int m_aoSamplingPoints{ 64 }; /// clear the final ouput image std::shared_ptr<ClearPass> m_clearPass; @@ -99,9 +100,9 @@ class NodeBasedRenderer_LIBRARY_API MultiPassController std::shared_ptr<WireframePass> m_wireframePass; /// Is an envmap attached to the renderer - bool m_hasEnvMap{false}; + bool m_hasEnvMap{ false }; /// Redundant with the one of Renderer but the latter is protected ... - bool m_wireframe{false}; + bool m_wireframe{ false }; }; -} +} // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Renderer/NodeGraphController.cpp b/src/libRender/RadiumNBR/Renderer/NodeGraphController.cpp index 342006f8c5ac6993334bdec7a980a45d0241dd40..fb9a4e2a5c6dd47ea32028fcf711daba440c3683 100644 --- a/src/libRender/RadiumNBR/Renderer/NodeGraphController.cpp +++ b/src/libRender/RadiumNBR/Renderer/NodeGraphController.cpp @@ -3,22 +3,22 @@ #include <Engine/RadiumEngine.hpp> #include <RadiumNBR/Renderer/NodeGraphController.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EmissivityNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/EnvLightNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Filters/FilterNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/LocalLightNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> -#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/TransparencyNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/UINode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ZGeomPrepassNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/SinkNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp> +#include <RadiumNBR/NodeGraph/PremadeNodes/Sources/TextureNode.hpp> #include <Engine/Data/ViewingParameters.hpp> diff --git a/src/libRender/RadiumNBR/Renderer/NodeGraphController.hpp b/src/libRender/RadiumNBR/Renderer/NodeGraphController.hpp index 4d485feefa0ee7a936071326d428deaedb11f450..ddd575604201e54dab7c17a896d090f1c56bb1aa 100644 --- a/src/libRender/RadiumNBR/Renderer/NodeGraphController.hpp +++ b/src/libRender/RadiumNBR/Renderer/NodeGraphController.hpp @@ -11,9 +11,7 @@ class NodeBasedRenderer_LIBRARY_API NodeGraphController : public RadiumNBR::NodeBasedRenderer::RenderControlFunctor { public: - [[nodiscard]] std::string getRendererName() const override { - return "NodeGraph Renderer"; - } + [[nodiscard]] std::string getRendererName() const override { return "NodeGraph Renderer"; } /* * Called once : configure the renderer by adding passes and allocating controller resources diff --git a/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.cpp b/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.cpp index d116174531edd5911e36069b6a80467d8b95caf9..4467ff0ef950eaedbad06d9d27285156446102f3 100644 --- a/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.cpp +++ b/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.cpp @@ -11,18 +11,20 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { -void SurfaceAttributeVisualizerController::configure( RadiumNBR::MultiPassRenderer* renderer, int w, int h ) { +void SurfaceAttributeVisualizerController::configure( RadiumNBR::MultiPassRenderer* renderer, + int w, + int h ) { m_renderer = renderer; //! [Caching some helpers and data from the Engine and the renderer] auto resourcesCheck = Ra::Core::Resources::getResourcesPath( - reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), {"Resources/RadiumNBR"} ); + reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), { "Resources/RadiumNBR" } ); if ( !resourcesCheck ) { LOG( Ra::Core::Utils::logERROR ) << "Unable to find resources for MultiPassRenderer!"; return; } - auto resourcesPath{*resourcesCheck}; + auto resourcesPath{ *resourcesCheck }; auto shaderManager = Ra::Engine::RadiumEngine::getInstance()->getShaderProgramManager(); auto colortexture = renderer->sharedTextures().find( "Linear RGB (RadiumNBR)" ); auto depthtexture = renderer->sharedTextures().find( "Depth (RadiumNBR)" ); @@ -62,10 +64,9 @@ void SurfaceAttributeVisualizerController::configure( RadiumNBR::MultiPassRender // add the pass to the renderer and activate it renderer->addPass( m_customPass, m_customPass->index() ); // Add the exported (shared) texture to the set of available textures - auto &sharedTextures = renderer->sharedTextures(); - for (auto t : m_customPass->getOutputImages() ) { - sharedTextures.insert( {t.first, t.second} ); - } + auto& sharedTextures = renderer->sharedTextures(); + for ( auto t : m_customPass->getOutputImages() ) + { sharedTextures.insert( { t.first, t.second } ); } m_customPass->activate(); } //! [Adding a CustomAttribToColorPass pass] @@ -73,7 +74,7 @@ void SurfaceAttributeVisualizerController::configure( RadiumNBR::MultiPassRender //! [Adding an image processing pass] { // pass that draw no object and is positioned at rank 0 - m_imageProcessPass = std::make_shared<RadiumNBR::ImageProcessPass>(3 ); + m_imageProcessPass = std::make_shared<RadiumNBR::ImageProcessPass>( 3 ); // set the output of the pass : clear the renderer Linear RGB output texture auto vectorFieldTex = renderer->sharedTextures().find( "CustomAtt2Clr::VectorField" ); m_imageProcessPass->setInputs( *depthtexture, *vectorFieldTex ); @@ -85,10 +86,9 @@ void SurfaceAttributeVisualizerController::configure( RadiumNBR::MultiPassRender renderer->addPass( m_imageProcessPass, m_imageProcessPass->index() ); m_imageProcessPass->activate(); // Add the exported (shared) texture to the set of available textures - auto &sharedTextures = renderer->sharedTextures(); - for (auto t : m_imageProcessPass->getOutputImages() ) { - sharedTextures.insert( {t.first, t.second} ); - } + auto& sharedTextures = renderer->sharedTextures(); + for ( auto t : m_imageProcessPass->getOutputImages() ) + { sharedTextures.insert( { t.first, t.second } ); } } //! [Adding an image processing pass] } @@ -117,9 +117,10 @@ void SurfaceAttributeVisualizerController::resize( int w, int h ){ }; /// Set the custom glsl function for attrib management (vertex) and colorcomputation (fragment) -void SurfaceAttributeVisualizerController::setAttribToColorFunc( const std::string& vertex_source, - const std::string& geometry_source, - const std::string& fragment_source ) { +void SurfaceAttributeVisualizerController::setAttribToColorFunc( + const std::string& vertex_source, + const std::string& geometry_source, + const std::string& fragment_source ) { m_vertexFunction = vertex_source; m_geometryFunction = geometry_source; m_fragmentFunction = fragment_source; @@ -133,7 +134,7 @@ void SurfaceAttributeVisualizerController::setAttribToColorFunc( const std::stri std::tuple<std::string&, std::string&, std::string&> SurfaceAttributeVisualizerController::getAttribToColorFunc() { - return {m_vertexFunction, m_geometryFunction, m_fragmentFunction}; + return { m_vertexFunction, m_geometryFunction, m_fragmentFunction }; } float SurfaceAttributeVisualizerController::getSplatSize() { @@ -146,14 +147,13 @@ void SurfaceAttributeVisualizerController::setSplatSize( float s ) { m_customPass->setSplatSize( s ); }; - void SurfaceAttributeVisualizerController::setEnvMap( const std::string& files ) { if ( files.empty() ) { m_clearPass->setEnvMap( nullptr ); m_customPass->setEnvMap( nullptr ); m_hasEnvMap = false; - m_envmap = nullptr; + m_envmap = nullptr; } else { diff --git a/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.hpp b/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.hpp index 351844590df4ed33a7b33981370f0f1fb4ba1c42..ee7acc5a7412b0eb17af3a3dc288c3a936196c2e 100644 --- a/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.hpp +++ b/src/libRender/RadiumNBR/Renderer/SurfaceAttribVisualization.hpp @@ -9,14 +9,16 @@ class ImageProcessPass; /** * This class parameterize the renderer just after the OpenGL system was initialized. - * when a method of this controller is called, the OpenGL context of the drawing window is activated. + * when a method of this controller is called, the OpenGL context of the drawing window is + * activated. */ class NodeBasedRenderer_LIBRARY_API SurfaceAttributeVisualizerController : public RadiumNBR::MultiPassRenderer::RenderControlFunctor { public: - - [[nodiscard]] std::string getRendererName() const override { return "Surface attribute visualization"; } + [[nodiscard]] std::string getRendererName() const override { + return "Surface attribute visualization"; + } /* * Called once : configure the renderer by adding passes and allocating controler resources @@ -61,12 +63,13 @@ class NodeBasedRenderer_LIBRARY_API SurfaceAttributeVisualizerController /// The image processing pass to render vector field std::shared_ptr<RadiumNBR::ImageProcessPass> m_imageProcessPass; - - /// TODO : this default are the same as in the CustomAttribToColorPass. Use them instead of redefining here - std::string m_vertexFunction{"void outputCustomAttribs() {\n}\n"}; - std::string m_geometryFunction{"void propagateAttributes(){}\n"}; + /// TODO : this default are the same as in the CustomAttribToColorPass. Use them instead of + /// redefining here + std::string m_vertexFunction{ "void outputCustomAttribs() {\n}\n" }; + std::string m_geometryFunction{ "void propagateAttributes(){}\n" }; std::string m_fragmentFunction{ - "\nvec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir, vec3 normal_world) { \n" + "\nvec4 computeCustomColor(Material mat, vec3 lightDir, vec3 viewDir, vec3 normal_world) { " + "\n" "vec3 diffColor; \n" "vec3 specColor; \n" "getSeparateBSDFComponent( mat, getPerVertexTexCoord(), lightDir, viewDir,\n" @@ -83,17 +86,17 @@ class NodeBasedRenderer_LIBRARY_API SurfaceAttributeVisualizerController "out_vector_field = vec4(getWorldSpaceTangent()*0.5+0.5, 1);\n" "#endif\n" "return vec4( finalColor, 1); \n" - "}\n"}; + "}\n" }; RadiumNBR::MultiPassRenderer* m_renderer; - bool m_postProcess{true}; + bool m_postProcess{ true }; /// Is an envmap attached to the renderer - bool m_hasEnvMap{false}; + bool m_hasEnvMap{ false }; /// The Environment to used for skybox display - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/SphereSampler.hpp b/src/libRender/RadiumNBR/SphereSampler.hpp index 253caff5811f500dbe40b87c20f56c21336ec0e8..cefafd9297dea85e339c429117389ba7e98decd0 100644 --- a/src/libRender/RadiumNBR/SphereSampler.hpp +++ b/src/libRender/RadiumNBR/SphereSampler.hpp @@ -10,13 +10,10 @@ namespace RadiumNBR { -Scalar constexpr sqrtNewtonRaphsonhelper(Scalar x, Scalar curr, Scalar prev) -{ - return curr == prev - ? curr - : sqrtNewtonRaphsonhelper(x, 0.5_ra * (curr + x / curr), curr); +Scalar constexpr sqrtNewtonRaphsonhelper( Scalar x, Scalar curr, Scalar prev ) { + return curr == prev ? curr : sqrtNewtonRaphsonhelper( x, 0.5_ra * ( curr + x / curr ), curr ); } -Scalar constexpr ct_sqrt(Scalar x){ +Scalar constexpr ct_sqrt( Scalar x ) { return sqrtNewtonRaphsonhelper( x, x, 0_ra ); } @@ -30,7 +27,7 @@ class NodeBasedRenderer_LIBRARY_API FibonacciSequence int n; public: - explicit FibonacciSequence( int number ) : n{std::max( 5, number )} {}; + explicit FibonacciSequence( int number ) : n{ std::max( 5, number ) } {}; // copyable FibonacciSequence( const FibonacciSequence& ) = default; FibonacciSequence& operator=( const FibonacciSequence& ) = default; @@ -74,7 +71,7 @@ class NodeBasedRenderer_LIBRARY_API FibonacciPointSet int range() { return seq.range(); } Ra::Core::Vector2 operator()( unsigned int i ) { - return {seq( i ), Scalar( i ) / Scalar( range() )}; + return { seq( i ), Scalar( i ) / Scalar( range() ) }; } }; @@ -96,7 +93,7 @@ class NodeBasedRenderer_LIBRARY_API HammersleyPointSet int range() { return n; } Ra::Core::Vector2 operator()( unsigned int i ) { - return {Scalar( i ) / Scalar( range() ), seq( i )}; + return { Scalar( i ) / Scalar( range() ), seq( i ) }; } }; @@ -118,7 +115,7 @@ class NodeBasedRenderer_LIBRARY_API MersenneTwisterPointSet virtual ~MersenneTwisterPointSet() = default; int range() { return n; } - Ra::Core::Vector2 operator()( unsigned int i ) { return {seq( gen ), seq( gen )}; } + Ra::Core::Vector2 operator()( unsigned int i ) { return { seq( gen ), seq( gen ) }; } }; // https://observablehq.com/@mbostock/spherical-fibonacci-lattice @@ -131,9 +128,9 @@ class NodeBasedRenderer_LIBRARY_API SphericalPointSet Ra::Core::Vector3 projectOnSphere( const Ra::Core::Vector2&& pt ) { Scalar theta = std::acos( 2 * pt[1] - 1 ); // 0 <= tetha <= pi Scalar phi = 2_ra * Scalar( M_PI ) * pt[0]; - return {std::sin( theta ) * std::cos( phi ), - std::sin( theta ) * std::sin( phi ), - std::cos( theta )}; + return { std::sin( theta ) * std::cos( phi ), + std::sin( theta ) * std::sin( phi ), + std::cos( theta ) }; } public: @@ -180,7 +177,7 @@ class NodeBasedRenderer_LIBRARY_API SphereSampler private: /// Texture generated on demand to be used with an OpenGL shader - std::unique_ptr<Ra::Engine::Data::Texture> m_texture{nullptr}; + std::unique_ptr<Ra::Engine::Data::Texture> m_texture{ nullptr }; /// Final number of points int m_nbPoints; /// The points on the sphere diff --git a/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.cpp b/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.cpp index db0c56bbe93b63276d80ee506fb57f8bc6254132..7d9294fdd918c31e4d16f53d7b88ddbd55d72453 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.cpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.cpp @@ -9,16 +9,17 @@ namespace RadiumNBR { using namespace Gui; RadiumNBR::Gui::RendererPanel* -buildVolumeVisualizationGui( MultiPassRenderer* renderer, const std::function<void()>& appUpdateCallback ) { +buildVolumeVisualizationGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ) { auto& controller = dynamic_cast<VolumeVisualizationController&>( renderer->getController() ); auto controlPanel = new RendererPanel( renderer->getRendererName() ); auto defColor = Ra::Core::Utils::Color::linearRGBTosRGB( renderer->getBackgroundColor() ); auto clrClbck = [renderer, appUpdateCallback]( const Ra::Core::Utils::Color& clr ) { - // set the background color for all passes that need it - renderer->setBackgroundColor( clr ); - appUpdateCallback(); + // set the background color for all passes that need it + renderer->setBackgroundColor( clr ); + appUpdateCallback(); }; controlPanel->addColorInput( "Background Color", clrClbck, defColor ); @@ -29,24 +30,24 @@ buildVolumeVisualizationGui( MultiPassRenderer* renderer, const std::function<vo controlPanel->addOption( " Post processing", [&controller, appUpdateCallback]( bool b ) { - controller.enablePostProcess( b ); - appUpdateCallback(); + controller.enablePostProcess( b ); + appUpdateCallback(); }, true ); controlPanel->addOption( " Show Debug ", [renderer, appUpdateCallback]( bool b ) { - renderer->showDebug( b ); - appUpdateCallback(); + renderer->showDebug( b ); + appUpdateCallback(); }, false ); controlPanel->addOption( " Show UI ", [renderer, appUpdateCallback]( bool b ) { - renderer->showUI( b ); - appUpdateCallback(); + renderer->showUI( b ); + appUpdateCallback(); }, false ); controlPanel->endLayout( true ); diff --git a/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.hpp b/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.hpp index a146eb13300b61b7ae84fd990bd10053f0b72e31..92c08b19e72111668afbfaab1cc28e29a5a4a01f 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.hpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.hpp @@ -1,11 +1,12 @@ #pragma once -#include <RadiumNBR/NodeBasedRendererMacro.hpp> #include <RadiumNBR/Gui/RendererPanel.hpp> +#include <RadiumNBR/NodeBasedRendererMacro.hpp> namespace RadiumNBR { class MultiPassRenderer; NodeBasedRenderer_LIBRARY_API RadiumNBR::Gui::RendererPanel* -buildVolumeVisualizationGui( MultiPassRenderer* renderer, const std::function<void()>& appUpdateCallback ); +buildVolumeVisualizationGui( MultiPassRenderer* renderer, + const std::function<void()>& appUpdateCallback ); } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.cpp b/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.cpp index 2934465898581ef2de6f57b61411c7283064fa31..771efe275d2119ae8fa0a5c3f6e0804a35edd76a 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.cpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.cpp @@ -20,7 +20,7 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { using namespace gl; -static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; +static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 }; VolumeVisualizationPass::VolumeVisualizationPass( const std::vector<RenderObjectPtr>* objectsToRender, @@ -46,7 +46,8 @@ bool VolumeVisualizationPass::initializePass( size_t width, texparams.format = GL_RGBA; texparams.type = GL_FLOAT; texparams.name = "VolumeVisualization::RawVolume"; - addSharedTexture( {texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams )} ); + addSharedTexture( + { texparams.name, std::make_shared<Ra::Engine::Data::Texture>( texparams ) } ); // The shader caller Ra::Core::Geometry::TriangleMesh mesh = @@ -57,13 +58,13 @@ bool VolumeVisualizationPass::initializePass( size_t width, m_quadMesh->updateGL(); // The shader - const std::string vrtxSrc{"layout (location = 0) in vec3 in_position;\n" - "out vec2 varTexcoord;\n" - "void main()\n" - "{\n" - " gl_Position = vec4(in_position, 1.0);\n" - " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" - "}\n"}; + const std::string vrtxSrc{ "layout (location = 0) in vec3 in_position;\n" + "out vec2 varTexcoord;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_position, 1.0);\n" + " varTexcoord = (in_position.xy + 1.0) / 2.0;\n" + "}\n" }; const std::string frgSrc{ "out vec4 fragColor;\n" "in vec2 varTexcoord;\n" @@ -75,8 +76,8 @@ bool VolumeVisualizationPass::initializePass( size_t width, " if (volColor.a < 1)\n" " discard;\n" " fragColor = vec4(volColor.rgb, 0);\n" - "}\n"}; - Ra::Engine::Data::ShaderConfiguration config{"VolumeVisualization::Compose"}; + "}\n" }; + Ra::Engine::Data::ShaderConfiguration config{ "VolumeVisualization::Compose" }; config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_VERTEX, vrtxSrc ); config.addShaderSource( Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, frgSrc ); auto added = shaderMngr->addShaderProgram( config ); @@ -89,8 +90,8 @@ bool VolumeVisualizationPass::initializePass( size_t width, void VolumeVisualizationPass::setInputs( const SharedTextures& depthBuffer, const SharedTextures& colorBuffer ) { - addImportedTexture( {"VolumeVisualization::Depth", depthBuffer.second} ); - addImportedTexture( {"VolumeVisualization::ColorInput", colorBuffer.second} ); + addImportedTexture( { "VolumeVisualization::Depth", depthBuffer.second } ); + addImportedTexture( { "VolumeVisualization::ColorInput", colorBuffer.second } ); } void VolumeVisualizationPass::setOutput( const SharedTextures& colorBuffer ) { @@ -131,7 +132,7 @@ void VolumeVisualizationPass::resize( size_t width, size_t height ) { void VolumeVisualizationPass::execute( const Ra::Engine::Data::ViewingParameters& viewParams ) const { - static const float clearDepth{1.0f}; + static const float clearDepth{ 1.0f }; if ( m_objectsToRender->empty() ) { return; } @@ -160,9 +161,7 @@ void VolumeVisualizationPass::execute( l->getRenderParameters( passParams ); for ( const auto& ro : *m_objectsToRender ) - { - ro->render( passParams, viewParams, passIndex() ); - } + { ro->render( passParams, viewParams, passIndex() ); } } m_fbo->bind(); GL_ASSERT( glDrawBuffers( 1, buffers ) ); @@ -192,15 +191,15 @@ bool VolumeVisualizationPass::buildRenderTechnique( { return false; } if ( auto cfg = Ra::Engine::Data::ShaderConfigurationFactory::getConfiguration( - {"VolumeVisualization::" + mat->getMaterialName()} ) ) + { "VolumeVisualization::" + mat->getMaterialName() } ) ) { rt.setConfiguration( *cfg, passIndex() ); } else { // Build the shader configuration Ra::Engine::Data::ShaderConfiguration theConfig{ - {"VolumeVisualization::" + mat->getMaterialName()}, + { "VolumeVisualization::" + mat->getMaterialName() }, resourcesRootDir + "Shaders/VolumeVisualization/volviz.vert.glsl", - resourcesRootDir + "Shaders/VolumeVisualization/volviz.frag.glsl"}; + resourcesRootDir + "Shaders/VolumeVisualization/volviz.frag.glsl" }; // Add to the ShaderConfigManager Ra::Engine::Data::ShaderConfigurationFactory::addConfiguration( theConfig ); // Add to the RenderTechniq diff --git a/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.hpp b/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.hpp index 600d6e50da1024d2f9d950fb2ec16632286bc365..4d3fb756815b3bc47534977ac088eb8abe31b326 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.hpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/RenderNode/VolumeVisualizationPass.hpp @@ -26,7 +26,7 @@ class VolumeVisualizationPass : public RenderPass { public: VolumeVisualizationPass( const std::vector<RenderObjectPtr>* objectsToRender, - const Ra::Core::Utils::Index& idx ); + const Ra::Core::Utils::Index& idx ); ~VolumeVisualizationPass() override; bool buildRenderTechnique( const Ra::Engine::Rendering::RenderObject* ro, @@ -54,20 +54,20 @@ class VolumeVisualizationPass : public RenderPass private: /// The framebuffer used to render this pass - std::unique_ptr<globjects::Framebuffer> m_fbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_fbo{ nullptr }; /// The framebuffer to render the volume - std::unique_ptr<globjects::Framebuffer> m_volumeFbo{nullptr}; + std::unique_ptr<globjects::Framebuffer> m_volumeFbo{ nullptr }; /// The quad to be drawn for shader invocation - std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{nullptr}; + std::unique_ptr<Ra::Engine::Data::Displayable> m_quadMesh{ nullptr }; /// The shader that compose the volume onto the color picture (the Radium shader manager has /// ownership) - const Ra::Engine::Data::ShaderProgram* m_shader{nullptr}; + const Ra::Engine::Data::ShaderProgram* m_shader{ nullptr }; /// The Shader manager to use when building shaders - Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{nullptr}; + Ra::Engine::Data::ShaderProgramManager* m_shaderMngr{ nullptr }; /// The color texture for output.Stored here for easy access. SharedTextures m_outputTexture; @@ -76,6 +76,6 @@ class VolumeVisualizationPass : public RenderPass const Ra::Engine::Scene::LightManager* m_lightmanager; /// The Environment to used for envmap lighting - std::shared_ptr<EnvMap> m_envmap{nullptr}; + std::shared_ptr<EnvMap> m_envmap{ nullptr }; }; } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.cpp b/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.cpp index 9694f92677944ceda4bda2b5f6841f97fc1699ab..6640acac04d83b88c70b6c07b3e30f782004ee41 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.cpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.cpp @@ -10,18 +10,20 @@ using namespace Ra::Core::Utils; // log namespace RadiumNBR { -void VolumeVisualizationController::configure( RadiumNBR::MultiPassRenderer* renderer, int w, int h ) { +void VolumeVisualizationController::configure( RadiumNBR::MultiPassRenderer* renderer, + int w, + int h ) { m_renderer = renderer; //! [Caching some helpers and data from the Engine and the renderer] auto resourcesCheck = Ra::Core::Resources::getResourcesPath( - reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), {"Resources/RadiumNBR"} ); + reinterpret_cast<void*>( &RadiumNBR::MultiPassRendererMagic ), { "Resources/RadiumNBR" } ); if ( !resourcesCheck ) { LOG( Ra::Core::Utils::logERROR ) << "Unable to find resources for MultiPassRenderer!"; return; } - auto resourcesPath{*resourcesCheck}; + auto resourcesPath{ *resourcesCheck }; auto shaderManager = Ra::Engine::RadiumEngine::getInstance()->getShaderProgramManager(); auto colortexture = renderer->sharedTextures().find( "Linear RGB (RadiumNBR)" ); auto depthtexture = renderer->sharedTextures().find( "Depth (RadiumNBR)" ); @@ -59,10 +61,9 @@ void VolumeVisualizationController::configure( RadiumNBR::MultiPassRenderer* ren // add the pass to the renderer and activate it renderer->addPass( m_volumePass, m_volumePass->index() ); // Add the exported (shared) texture to the set of available textures - auto &sharedTextures = renderer->sharedTextures(); - for (auto t : m_volumePass->getOutputImages() ) { - sharedTextures.insert( {t.first, t.second} ); - } + auto& sharedTextures = renderer->sharedTextures(); + for ( auto t : m_volumePass->getOutputImages() ) + { sharedTextures.insert( { t.first, t.second } ); } m_volumePass->activate(); } //! [Adding a CustomAttribToColorPass pass] @@ -89,4 +90,4 @@ void VolumeVisualizationController::resize( int w, int h ){ */ }; -} // RadiumNBR +} // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.hpp b/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.hpp index b9de738853d96d9b4eb5e3dd427c54407ecab362..9f4c0c82aa7af2d76219edab63445365835538c6 100644 --- a/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.hpp +++ b/src/libRender/RadiumNBR/VolumeVisualization/VolumeVisualization.hpp @@ -1,6 +1,5 @@ #include <RadiumNBR/MultiPassRenderer.hpp> - namespace RadiumNBR { class ClearPass; class ImageProcessPass; @@ -13,7 +12,6 @@ class NodeBasedRenderer_LIBRARY_API VolumeVisualizationController : public RadiumNBR::MultiPassRenderer::RenderControlFunctor { public: - [[nodiscard]] std::string getRendererName() const override { return "Volume visualization"; } /* @@ -40,8 +38,7 @@ class NodeBasedRenderer_LIBRARY_API VolumeVisualizationController RadiumNBR::MultiPassRenderer* m_renderer; - bool m_postProcess{true}; + bool m_postProcess{ true }; }; - } // namespace RadiumNBR