2017-10-02 13:51:08 +02:00
|
|
|
#include "externals.hh"
|
|
|
|
#include "demo.hh"
|
2017-10-30 18:29:52 +01:00
|
|
|
#include "sync.hh"
|
|
|
|
#include "globals.hh"
|
2017-10-02 13:51:08 +02:00
|
|
|
|
|
|
|
|
2017-10-04 11:20:27 +02:00
|
|
|
T_Demo::T_Demo( __rd__ const uint32_t width ,
|
2017-10-02 13:51:08 +02:00
|
|
|
__rd__ const uint32_t height )
|
2017-10-04 11:20:27 +02:00
|
|
|
: width( width ) , height( height )
|
2017-10-02 13:51:08 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
bool T_Demo::initialise( )
|
|
|
|
{
|
|
|
|
raymarcher = std::make_unique< T_Raymarcher >(
|
2017-10-04 11:20:27 +02:00
|
|
|
width , height );
|
|
|
|
dof = std::make_unique< T_DoFPass >(
|
2017-10-02 13:51:08 +02:00
|
|
|
raymarcher->output( ) , raymarcher->depth( ) );
|
2017-10-04 11:20:27 +02:00
|
|
|
bloom = std::make_unique< T_BloomPass >(
|
2017-10-02 13:51:08 +02:00
|
|
|
raymarcher->output( ) );
|
2017-10-04 11:20:27 +02:00
|
|
|
combine = std::make_unique< T_CombinePass >(
|
2017-10-02 13:51:08 +02:00
|
|
|
dof->output( ) , bloom->output( ) );
|
2017-10-05 18:35:35 +02:00
|
|
|
fxaa = std::make_unique< T_FXAAPass >(
|
|
|
|
combine->output( ) );
|
2017-10-30 19:04:10 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2017-10-02 13:51:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::makeUI( )
|
|
|
|
{
|
2017-10-06 14:29:01 +02:00
|
|
|
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
|
2017-10-06 14:45:00 +02:00
|
|
|
ImGui::SetNextWindowSize( ImVec2( 300 , dspSize.y - 300 ) ,
|
2017-10-06 14:29:01 +02:00
|
|
|
ImGuiSetCond_Once );
|
|
|
|
ImGui::SetNextWindowPos( ImVec2( 0 , 150 ) ,
|
|
|
|
ImGuiSetCond_Once );
|
|
|
|
ImGui::Begin( "Demo controls" );
|
|
|
|
|
2017-10-02 13:51:08 +02:00
|
|
|
raymarcher->makeUI( );
|
|
|
|
dof->makeUI( );
|
|
|
|
bloom->makeUI( );
|
|
|
|
combine->makeUI( );
|
2017-10-05 18:35:35 +02:00
|
|
|
fxaa->makeUI( );
|
2017-10-06 14:29:01 +02:00
|
|
|
|
|
|
|
ImGui::End( );
|
2017-10-02 13:51:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::render( )
|
|
|
|
{
|
2017-10-30 18:29:52 +01:00
|
|
|
auto& sync( Globals::Sync( ) );
|
2017-10-07 17:39:38 +02:00
|
|
|
if ( playing ) {
|
|
|
|
const float time = SDL_GetTicks( ) * 1e-3;
|
|
|
|
if ( playingPrevious ) {
|
2017-10-30 18:29:52 +01:00
|
|
|
sync.timeDelta( time - lastFrame );
|
|
|
|
playing = !sync.finished( );
|
2017-10-07 17:39:38 +02:00
|
|
|
}
|
|
|
|
lastFrame = time;
|
|
|
|
}
|
|
|
|
playingPrevious = playing;
|
|
|
|
|
2017-10-02 13:51:08 +02:00
|
|
|
raymarcher->render( );
|
2017-10-30 18:29:52 +01:00
|
|
|
dof->render( );
|
2017-10-02 13:51:08 +02:00
|
|
|
bloom->render( );
|
|
|
|
combine->render( );
|
2017-10-05 18:35:35 +02:00
|
|
|
fxaa->render( );
|
2017-10-02 13:51:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::handleDND(
|
|
|
|
__rd__ ImVec2 const& move ,
|
|
|
|
__rd__ const bool hasCtrl ,
|
|
|
|
__rd__ const bool hasShift ,
|
|
|
|
__rd__ const bool lmb // Left mouse button
|
|
|
|
)
|
|
|
|
{
|
|
|
|
raymarcher->camera( ).handleDND( move , hasCtrl , hasShift , lmb );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::handleWheel(
|
|
|
|
__rd__ const float wheel ,
|
|
|
|
__rd__ const bool hasCtrl ,
|
|
|
|
__rd__ const bool hasShift
|
|
|
|
)
|
|
|
|
{
|
|
|
|
raymarcher->camera( ).handleWheel( wheel , hasCtrl , hasShift );
|
|
|
|
}
|