DoF parameters moved to sync system

This commit is contained in:
Emmanuel BENOîT 2017-10-30 19:04:10 +01:00
parent 59128de38f
commit e58b88737c
4 changed files with 22 additions and 12 deletions

View file

@ -22,6 +22,14 @@ bool T_Demo::initialise( )
dof->output( ) , bloom->output( ) ); dof->output( ) , bloom->output( ) );
fxaa = std::make_unique< T_FXAAPass >( fxaa = std::make_unique< T_FXAAPass >(
combine->output( ) ); combine->output( ) );
Globals::Sync( ).clearInputs( );
Globals::Sync( ).addInput( "dof:sharp-distance" , 15 );
Globals::Sync( ).addInput( "dof:sharp-range" , 25 );
Globals::Sync( ).addInput( "dof:falloff" , 100 );
Globals::Sync( ).addInput( "dof:max-blur" , 16 );
Globals::Sync( ).addInput( "dof:samples" , 16 );
return true; return true;
} }

16
dof.cc
View file

@ -23,9 +23,7 @@ T_DoFPass::T_DoFPass(
txOutput_( imageInput.width( ) , imageInput.height( ) , txOutput_( imageInput.width( ) , imageInput.height( ) ,
E_TexType::RGB16F ) , E_TexType::RGB16F ) ,
rtPass1_( T_RendertargetSetup( ).add( txPass1_ ).create( ) ) , rtPass1_( T_RendertargetSetup( ).add( txPass1_ ).create( ) ) ,
rtPass2_( T_RendertargetSetup( ).add( txOutput_ ).create( ) ) , rtPass2_( T_RendertargetSetup( ).add( txOutput_ ).create( ) )
filterParams_{ 15 , 25 , 100 , 16 } ,
nSamples_( 16 )
{ {
txPass1_.wrap( E_TexWrap::CLAMP_EDGE ); txPass1_.wrap( E_TexWrap::CLAMP_EDGE );
@ -65,13 +63,13 @@ void T_DoFPass::render( )
<< OPLoadVariable( "width" ) << OPLoadVariable( "width" )
<< OPLoadConstant( U_RES_TIME ) << OPLoadConstant( U_RES_TIME )
<< OPDup( 8 ) << OPDup( 8 )
<< OPLoadConstant( nSamples_ ) << OPLoadInput( "dof:samples" )
<< OPLoadConstant( U_SAMPLES ) << OPLoadConstant( U_SAMPLES )
<< OPDup( 11 ) << OPDup( 11 )
<< OPLoadConstant( filterParams_[ 3 ] ) << OPLoadInput( "dof:max-blur" )
<< OPLoadConstant( filterParams_[ 2 ] ) << OPLoadInput( "dof:falloff" )
<< OPLoadConstant( filterParams_[ 1 ] ) << OPLoadInput( "dof:sharp-distance" )
<< OPLoadConstant( filterParams_[ 0 ] ) << OPLoadInput( "dof:sharp-range" )
<< OPLoadConstant( U_PARAMS ) << OPLoadConstant( U_PARAMS )
<< OPDup( 17 ) << OPDup( 17 )
<< OPLoadConstant( 1 ) << OPLoadConstant( 1 )
@ -121,6 +119,7 @@ void T_DoFPass::render( )
void T_DoFPass::makeUI( ) void T_DoFPass::makeUI( )
{ {
#if 0
if ( !ImGui::CollapsingHeader( "Depth of field" ) ) { if ( !ImGui::CollapsingHeader( "Depth of field" ) ) {
return; return;
} }
@ -131,4 +130,5 @@ void T_DoFPass::makeUI( )
ImGui::DragFloat( "Max blur" , &filterParams_[ 3 ] , .1 , .1 , 100 ); ImGui::DragFloat( "Max blur" , &filterParams_[ 3 ] , .1 , .1 , 100 );
ImGui::DragInt( "Samples" , &nSamples_ , .2 , 1 , 32 ); ImGui::DragInt( "Samples" , &nSamples_ , .2 , 1 , 32 );
#endif
} }

4
dof.hh
View file

@ -30,9 +30,5 @@ struct T_DoFPass
T_Texture txPass1_ , txOutput_; T_Texture txPass1_ , txOutput_;
T_Rendertarget rtPass1_ , rtPass2_; T_Rendertarget rtPass1_ , rtPass2_;
// SharpDist/SharpRange/Falloff/MaxBlur
float filterParams_[ 4 ];
int nSamples_;
}; };

View file

@ -160,6 +160,12 @@ struct T_SyncManager
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Value access // Value access
void clearInputs( )
{ values_.clear( ); }
bool addInput( __rd__ std::string const& name ,
__rd__ const float initial = 0.f ) noexcept
{ return values_.addValue( name , initial ); }
uint32_t inputPos( __rd__ std::string const& name ) const noexcept uint32_t inputPos( __rd__ std::string const& name ) const noexcept
{ return values_.indexOf( name ); } { return values_.indexOf( name ); }
std::vector< float > const& inputs( ) const noexcept std::vector< float > const& inputs( ) const noexcept