Skip to content

Commit

Permalink
Render settings ui wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Oct 30, 2024
1 parent e981d68 commit 1981d19
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 198 deletions.
6 changes: 3 additions & 3 deletions app/bench/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ int main( int, char ** )
= { &representation1, &representation2, &representation3 };
renderer.addProxyRepresentations( representations );

Renderer::Proxy::RenderSettings renderSettings
= { 6.f, 18.f, COLOR_WHITE, COLOR_YELLOW, COLOR_BLACK, 2, 1.f, 1.f,
3, 1000.f, 1000.f, 0.5f, COLOR_RED, 1.f, 1, COLOR_BLUE };
// Renderer::Proxy::RenderSettings renderSettings
// = { 6.f, 18.f, COLOR_WHITE, COLOR_YELLOW, COLOR_BLACK, 2, 1.f, 1.f,
// 3, 1000.f, 1000.f, 0.5f, COLOR_RED, 1.f, 1, COLOR_BLUE };

// renderer.setProxyRenderSettings( renderSettings );

Expand Down
65 changes: 37 additions & 28 deletions lib/app/include/app/component/representation/render_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,99 +23,108 @@ namespace VTX::App::Component::Representation
template<Renderer::E_RENDER_SETTINGS S, typename T>
void set( const T p_value )
{
if constexpr ( S == Renderer::E_RENDER_SETTINGS::SSAO_INTENSITY )
// SSAO.
if constexpr ( S == Renderer::E_RENDER_SETTINGS::ACTIVE_SSAO )
{
_settings.activeSSAO = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::SSAO_INTENSITY )
{
_settings.ssaoIntensity = p_value;
_proxy->onSSAOIntensity( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::BLUR_SIZE )
{
_settings.blurSize = p_value;
_proxy->onBlurSize( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_BACKGROUND )
// Shading.
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::SHADING_MODE )
{
_settings.colorBackground = p_value;
_proxy->onColorBackground( p_value );
_settings.shadingMode = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_LIGHT )
{
_settings.colorLight = p_value;
_proxy->onColorLight( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_FOG )
{
_settings.colorFog = p_value;
_proxy->onColorFog( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::SHADING_MODE )
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_BACKGROUND )
{
_settings.shadingMode = p_value;
_proxy->onShadingMode( p_value );
_settings.colorBackground = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::SPECULAR_FACTOR )
{
_settings.specularFactor = p_value;
_proxy->onSpecularFactor( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::SHININESS )
{
_settings.shininess = p_value;
_proxy->onShininess( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::TOON_STEPS )
{
_settings.toonSteps = p_value;
_proxy->onToonSteps( p_value );
}
// Fog.
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::ACTIVE_FOG )
{
_settings.activeFog = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_FOG )
{
_settings.colorFog = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::FOG_NEAR )
{
_settings.fogNear = p_value;
_proxy->onFogNear( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::FOG_FAR )
{
_settings.fogFar = p_value;
_proxy->onFogFar( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::FOG_DENSITY )
{
_settings.fogDensity = p_value;
_proxy->onFogDensity( p_value );
}
// Outline.
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::ACTIVE_OUTLINE )
{
_settings.activeOutline = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_OUTLINE )
{
_settings.colorOutline = p_value;
_proxy->onColorOutline( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::OUTLINE_SENSITIVITY )
{
_settings.outlineSensitivity = p_value;
_proxy->onOutlineSensitivity( p_value );
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::OUTLINE_THICKNESS )
{
_settings.outlineThickness = p_value;
_proxy->onOutlineThickness( p_value );
}
// Selection.
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::ACTIVE_SELECTION )
{
_settings.activeSelection = p_value;
}
else if constexpr ( S == Renderer::E_RENDER_SETTINGS::COLOR_SELECTION )
{
_settings.colorSelection = p_value;
_proxy->onColorSelection( p_value );
}
// TODO: test this.
else
{
static_assert( true, "Unknown render setting." );
}

getCallback<S, T>()( p_value );
// Trigger UI.
callback<S, T>()( p_value );

// Trigger renderer.
_proxy->onChange<S, T>()( p_value );
}

template<Renderer::E_RENDER_SETTINGS S, typename T>
Util::Callback<T> & getCallback()
Util::Callback<const T> & callback()
{
static Util::Callback<T> callback;
static Util::Callback<const T> callback;
return callback;
}

Expand Down
66 changes: 40 additions & 26 deletions lib/app/src/app/component/representation/render_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,61 @@ namespace VTX::App::Component::Representation
RenderSettings::RenderSettings()
{
using namespace Renderer;
_settings.ssaoIntensity = SSAO_INTENSITY_DEFAULT;
_settings.blurSize = BLUR_SIZE_DEFAULT;
_settings.colorBackground = COLOR_BACKGROUND_DEFAULT;
_settings.colorLight = COLOR_LIGHT_DEFAULT;
_settings.colorFog = COLOR_FOG_DEFAULT;
_settings.shadingMode = uint( SHADING_MODE_DEFAULT );
_settings.specularFactor = SPECULAR_FACTOR_DEFAULT;
_settings.shininess = SHININESS_DEFAULT;
_settings.toonSteps = TOON_STEPS_DEFAULT;
_settings.fogNear = FOG_NEAR_DEFAULT;
_settings.fogFar = FOG_FAR_DEFAULT;
_settings.fogDensity = FOG_DENSITY_DEFAULT;

_settings.shadingMode = uint( SHADING_MODE_DEFAULT );
_settings.colorLight = COLOR_LIGHT_DEFAULT;
_settings.colorBackground = COLOR_BACKGROUND_DEFAULT;
_settings.specularFactor = SPECULAR_FACTOR_DEFAULT;
_settings.shininess = SHININESS_DEFAULT;
_settings.toonSteps = TOON_STEPS_DEFAULT;

_settings.activeSSAO = ACTIVE_SSAO_DEFAULT;
_settings.ssaoIntensity = SSAO_INTENSITY_DEFAULT;
_settings.blurSize = BLUR_SIZE_DEFAULT;

_settings.activeOutline = ACTIVE_OUTLINE_DEFAULT;
_settings.colorOutline = COLOR_OUTLINE_DEFAULT;
_settings.outlineSensitivity = OUTLINE_SENSITIVITY_DEFAULT;
_settings.outlineThickness = OUTLINE_THICKNESS_DEFAULT;
_settings.colorSelection = COLOR_SELECTION_DEFAULT;

_settings.activeFog = ACTIVE_FOG_DEFAULT;
_settings.colorFog = COLOR_FOG_DEFAULT;
_settings.fogNear = FOG_NEAR_DEFAULT;
_settings.fogFar = FOG_FAR_DEFAULT;
_settings.fogDensity = FOG_DENSITY_DEFAULT;

_settings.activeSelection = ACTIVE_SELECTION_DEFAULT;
_settings.colorSelection = COLOR_SELECTION_DEFAULT;
}

void RenderSettings::setupProxy()
{
_proxy = std::make_unique<Renderer::Proxy::RenderSettings>( Renderer::Proxy::RenderSettings {
_settings.ssaoIntensity,
_settings.blurSize,
_settings.colorBackground,
_settings.colorLight,
_settings.colorFog,
//
_settings.shadingMode,
_settings.colorLight,
_settings.colorBackground,
_settings.specularFactor,
_settings.shininess,
_settings.toonSteps,
_settings.fogNear,
_settings.fogFar,
_settings.fogDensity,
//
_settings.activeSSAO,
_settings.ssaoIntensity,
_settings.blurSize,
//
_settings.activeOutline,
_settings.colorOutline,
_settings.outlineSensitivity,
_settings.outlineThickness,
_settings.colorSelection,
} );

// onChange += [ this ]( const size_t ) { _proxy->onChange(); };
// onChangeAll += [ this ]() { _proxy->onChange(); };
//
_settings.activeFog,
_settings.colorFog,
_settings.fogNear,
_settings.fogFar,
_settings.fogDensity,
//
_settings.activeSelection,
_settings.colorSelection } );

RENDERER_SYSTEM().onReady() += [ this ]() { RENDERER_SYSTEM().setProxyRenderSettings( *_proxy ); };
}
Expand Down
30 changes: 21 additions & 9 deletions lib/core/include/core/struct/render_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,36 @@

namespace VTX::Core::Struct
{
// TODO: move default layout to... ?
struct RenderSettings
{
float ssaoIntensity;
float blurSize;
Util::Color::Rgba colorBackground;
Util::Color::Rgba colorLight;
Util::Color::Rgba colorFog;
// Shading.
uint shadingMode;
Util::Color::Rgba colorLight;
Util::Color::Rgba colorBackground;
float specularFactor;
float shininess;
uint toonSteps;
float fogNear;
float fogFar;
float fogDensity;

// SSAO.
bool activeSSAO;
float ssaoIntensity;
float blurSize;

// Outline.
bool activeOutline;
Util::Color::Rgba colorOutline;
float outlineSensitivity;
uint outlineThickness;

// Fog.
bool activeFog;
Util::Color::Rgba colorFog;
float fogNear;
float fogFar;
float fogDensity;

// Selection.
bool activeSelection;
Util::Color::Rgba colorSelection;
};
} // namespace VTX::Core::Struct
Expand Down
4 changes: 0 additions & 4 deletions lib/io/src/io/reader/chemfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <util/string.hpp>

#pragma warning( push, 0 )
#include "chemfiles.hpp"
#include <chemfiles.hpp>
#include "chemfiles.hpp"
#pragma warning( pop )

namespace VTX::IO::Reader
Expand Down Expand Up @@ -505,11 +503,9 @@ namespace VTX::IO::Reader
else
{
throw IOException( "Unknown file format: {}", extension );
return "Unknown";
}
}

void Chemfiles::_warningCallback( const std::string & p_log ) {}

} // namespace VTX::IO::Reader

52 changes: 28 additions & 24 deletions lib/renderer/include/renderer/proxy/render_settings.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __VTX_RENDERER_PROXY_RENDER_SETTINGS__
#define __VTX_RENDERER_PROXY_RENDER_SETTINGS__

#include "renderer/settings.hpp"
#include <util/callback.hpp>
#include <util/types.hpp>

Expand All @@ -13,39 +14,42 @@ namespace VTX::Renderer::Proxy
*/
struct RenderSettings
{
float ssaoIntensity;
float blurSize;
Util::Color::Rgba colorBackground;
Util::Color::Rgba colorLight;
Util::Color::Rgba colorFog;
// Shading.
uint shadingMode;
Util::Color::Rgba colorLight;
Util::Color::Rgba colorBackground;
float specularFactor;
float shininess;
uint toonSteps;
float fogNear;
float fogFar;
float fogDensity;

// SSAO.
bool activeSSAO;
float ssaoIntensity;
float blurSize;

// Outline.
bool activeOutline;
Util::Color::Rgba colorOutline;
float outlineSensitivity;
uint outlineThickness;

// Fog.
bool activeFog;
Util::Color::Rgba colorFog;
float fogNear;
float fogFar;
float fogDensity;

// Selection.
bool activeSelection;
Util::Color::Rgba colorSelection;

Util::Callback<float> onSSAOIntensity;
Util::Callback<float> onBlurSize;
Util::Callback<const Util::Color::Rgba &> onColorBackground;
Util::Callback<const Util::Color::Rgba &> onColorLight;
Util::Callback<const Util::Color::Rgba &> onColorFog;
Util::Callback<uint> onShadingMode;
Util::Callback<float> onSpecularFactor;
Util::Callback<float> onShininess;
Util::Callback<uint> onToonSteps;
Util::Callback<float> onFogNear;
Util::Callback<float> onFogFar;
Util::Callback<float> onFogDensity;
Util::Callback<const Util::Color::Rgba &> onColorOutline;
Util::Callback<float> onOutlineSensitivity;
Util::Callback<uint> onOutlineThickness;
Util::Callback<const Util::Color::Rgba &> onColorSelection;
template<E_RENDER_SETTINGS S, typename T>
Util::Callback<const T> & onChange()
{
static Util::Callback<const T> callback;
return callback;
}

// TODO: callback for each modifiable value?
};
Expand Down
Loading

0 comments on commit 1981d19

Please sign in to comment.