From f1d793542145a57a43ccc44482c93c6d85e95e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 15 Nov 2017 17:16:12 +0100 Subject: [PATCH] Removed some now-unused code --- Makefile | 7 --- bloom.cc | 127 ----------------------------------------------- bloom.hh | 39 --------------- combine.cc | 114 ------------------------------------------ combine.hh | 40 --------------- demo.cc | 58 ---------------------- demo.hh | 8 --- dof.cc | 134 -------------------------------------------------- dof.hh | 34 ------------- fxaa.cc | 61 ----------------------- fxaa.hh | 22 --------- main.cc | 6 --- raymarcher.cc | 94 ----------------------------------- raymarcher.hh | 43 ---------------- 14 files changed, 787 deletions(-) delete mode 100644 bloom.cc delete mode 100644 bloom.hh delete mode 100644 combine.cc delete mode 100644 combine.hh delete mode 100644 dof.cc delete mode 100644 dof.hh delete mode 100644 fxaa.cc delete mode 100644 fxaa.hh delete mode 100644 raymarcher.cc delete mode 100644 raymarcher.hh diff --git a/Makefile b/Makefile index 7d549f7..85de8c5 100644 --- a/Makefile +++ b/Makefile @@ -37,14 +37,7 @@ COMMON = \ DEMO = \ main.cc \ - \ demo.cc \ - \ - raymarcher.cc \ - bloom.cc \ - dof.cc \ - combine.cc \ - fxaa.cc \ # END DEMO PARSERCHECK = \ diff --git a/bloom.cc b/bloom.cc deleted file mode 100644 index d58b9a1..0000000 --- a/bloom.cc +++ /dev/null @@ -1,127 +0,0 @@ -#include "externals.hh" -#include "bloom.hh" -#include "profiling.hh" -#include "globals.hh" -#include "odbg.hh" - -namespace { - static char const* const Name_( "BLOOOOM!" ); -} - -#define PSTART() Globals::Profiler( ).start( Name_ ) -#define PEND() do { glFinish( ); Globals::Profiler( ).end( Name_ ); } while ( 0 ) - - -T_BloomPass::T_BloomPass( - __rw__ T_Texture& input ) - : input_( input ) , - // - txBlur0_( input.width( ) , input.height( ) , E_TexType::RGB16F , BloomLevels ) , - txBlur1_( input.width( ) , input.height( ) , E_TexType::RGB16F , BloomLevels ) , - // - filterParams_{ 1.6 , 1.2 , .95 } , - blurWeights_{ 0.324 , 0.232 , 0.0855 , 0.0205 } , - blurSize_{ 1.3 } -{ - txBlur0_.wrap( E_TexWrap::CLAMP_EDGE ).samplingMode( E_TexSampling::LINEAR ); - txBlur1_.wrap( E_TexWrap::CLAMP_EDGE ).samplingMode( E_TexSampling::LINEAR ); - Globals::ODbg( ).registerTexture( txBlur0_ , E_ODbgMode::HDR , "Bloom" ); - - for ( auto i = 0u ; i < BloomLevels ; i ++ ) { - rtBlur0_.add( T_RendertargetSetup( ).add( txBlur0_ , i ).create( ) ); - rtBlur1_.add( T_RendertargetSetup( ).add( txBlur1_ , i ).create( ) ); - } - - auto& sm( Globals::Shaders( ) ); - spHighpass_ = sm.pipeline({ "fullscreen.v.glsl" , "bloom-highpass.f.glsl" }); - spDownsample_ = sm.pipeline({ "fullscreen.v.glsl" , "downsample.f.glsl" }); - spBlur_ = sm.pipeline({ "fullscreen.v.glsl" , "blur-pass.f.glsl" }); -} - -void T_BloomPass::render( ) -{ - if ( !( spHighpass_.valid( ) && spBlur_.valid( ) && spDownsample_.valid( ) ) ) { - return; - } - - PSTART( ); - auto& tm( Globals::Textures( ) ); - { - rtBlur0_[ 0 ].activate( ); - const auto hpf( spHighpass_.program( E_ShaderType::FRAGMENT ) ); - enum { - U_TEXTURE = 0 , - U_LOD = 1 , - U_INPUT_SIZE = 2 , - U_PARAMS = 3 , - }; - - tm.bind( 0 , input_ ); - spHighpass_.enable( ); - - glProgramUniform1i( hpf , U_TEXTURE , 0 ); - glProgramUniform1i( hpf , U_LOD , 0 ); - glProgramUniform2f( hpf , U_INPUT_SIZE , - input_.width( ) , - input_.height( ) ); - glProgramUniform3fv( hpf , U_PARAMS , 1 , filterParams_ ); - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - } - - enum { - U_TEXTURE = 0 , - U_OUTPUT_SIZE = 1 , - U_SOURCE_LOD = 2 , - U_DIRECTION = 3 , - U_WEIGHTS = 4 , - }; - - const auto dsf( spDownsample_.program( E_ShaderType::FRAGMENT ) ); - const auto bpf( spBlur_.program( E_ShaderType::FRAGMENT ) ); - glProgramUniform1i( dsf , 0 , 0 ); - glProgramUniform4fv( bpf , U_WEIGHTS , 1 , blurWeights_ ); - glProgramUniform1i( bpf , U_TEXTURE , 0 ); - - for ( auto i = 0u ; i < BloomLevels ; i ++ ) { - if ( i > 0 ) { - spDownsample_.enable( ); - rtBlur0_[ i ].activate( ); - - tm.bind( 0 , txBlur0_ ); - - glProgramUniform2f( dsf , 1 , txBlur0_.width( ) >> i , - txBlur0_.height( ) >> i ); - glProgramUniform1i( dsf , 2 , i - 1 ); - - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - } - - spBlur_.enable( ); - glProgramUniform2f( bpf , U_OUTPUT_SIZE , rtBlur0_[ i ].width( ) , - rtBlur0_[ i ].height( ) ); - glProgramUniform1i( bpf , U_SOURCE_LOD , i ); - - rtBlur1_[ i ].activate( ); - glProgramUniform2f( bpf , U_DIRECTION , blurSize_ , 0 ); - tm.bind( 0 , txBlur0_ ); - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - - rtBlur0_[ i ].activate( ); - glProgramUniform2f( bpf , U_DIRECTION , 0 , blurSize_ ); - tm.bind( 0 , txBlur1_ ); - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - } - - PEND( ); -} - -void T_BloomPass::makeUI( ) -{ - if ( !ImGui::CollapsingHeader( "Bloom" ) ) { - return; - } - - ImGui::DragFloat3( "Filter" , filterParams_ , .01f , 0.1 , 10 ); - ImGui::DragFloat4( "Weights" , blurWeights_ , .001f , 0. , 10 ); - ImGui::DragFloat( "Blur size" , &blurSize_ , .001f , 0. , 10 ); -} diff --git a/bloom.hh b/bloom.hh deleted file mode 100644 index c031fdd..0000000 --- a/bloom.hh +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#ifndef REAL_BUILD -# include "externals.hh" -#endif - -#include "rendertarget.hh" -#include "shaders.hh" - - -struct T_BloomPass -{ - static constexpr uint32_t BloomLevels = 6; - - T_BloomPass( ) = delete; - T_BloomPass( T_BloomPass const& ) = delete; - T_BloomPass( T_BloomPass&& ) = delete; - - T_BloomPass( __rw__ T_Texture& input ); - - void render( ); - void makeUI( ); - - T_Texture& output( ) { return txBlur0_; } - - private: - T_Texture& input_; - - T_ShaderPipeline spHighpass_; - T_ShaderPipeline spDownsample_; - T_ShaderPipeline spBlur_; - - T_TextureSampler sampler_; - T_Texture txBlur0_ , txBlur1_; - T_AutoArray< T_Rendertarget , BloomLevels > rtBlur0_ , rtBlur1_; - - float filterParams_[ 3 ]; - float blurWeights_[ 4 ]; - float blurSize_; -}; diff --git a/combine.cc b/combine.cc deleted file mode 100644 index 9b5efe5..0000000 --- a/combine.cc +++ /dev/null @@ -1,114 +0,0 @@ -#include "externals.hh" -#include "combine.hh" -#include "bloom.hh" -#include "profiling.hh" -#include "odbg.hh" -#include "globals.hh" - -namespace { - static char const* const Name_( "Combine" ); -} - -#define PSTART() Globals::Profiler( ).start( Name_ ) -#define PEND() do { glFinish( ); Globals::Profiler( ).end( Name_ ); } while ( 0 ) - - -T_CombinePass::T_CombinePass( - T_Texture& image , - T_Texture& bloom ) - : txImage_( image ) , txBloom_( bloom ) , - txOutput_( image.width( ) , image.height( ) , E_TexType::RGBA8 ) , - rtOutput_( T_RendertargetSetup( ).add( txOutput_ ).create( ) ) , - bloomStrength_( 0.45 ) , - bloomAttenuation_( 0.3 ) , - vignette_{ - 1 , 8 , .5 , 1 , 0 , 1 - } , - cgLift_{ 0 , 0 , 0 } , - cgGain_{ 1 , 1 , 1 } , - cgGamma_{ 0 , 0 , 0 } -{ - Globals::ODbg( ).registerTexture( txOutput_ , E_ODbgMode::LDR_ALPHA , "Combined" ); - program_ = Globals::Shaders( ).pipeline({ - "fullscreen.v.glsl" , "combine.f.glsl" }); -} - -void T_CombinePass::render( ) -{ - PSTART( ); - rtOutput_.activate( ); - glClearColor( 1 , 0 , 1 , .413f ); - glClear( GL_COLOR_BUFFER_BIT ); - if ( program_.valid( ) ) { - enum { - U_MAIN_INPUT , - U_BLOOM_INPUT , - U_OUTPUT_SIZE , - U_BLOOM_PARAMETERS , - U_VIGNETTE_PARAMETERS_1 , - U_VIGNETTE_PARAMETERS_2 , - U_CG_LIFT , - U_CG_GAIN , - U_CG_GAMMA , - }; - auto& tm( Globals::Textures( ) ); - tm.bind( 0 , txImage_ ); - tm.bind( 1 , txBloom_ ); - - const auto id( program_.program( E_ShaderType::FRAGMENT ) ); - program_.enable( ); - glProgramUniform1i( id , U_MAIN_INPUT , 0 ); - glProgramUniform1i( id , U_BLOOM_INPUT , 1 ); - glProgramUniform2f( id , U_OUTPUT_SIZE , - txImage_.width( ) , txImage_.height( ) ); - glProgramUniform2f( id , U_BLOOM_PARAMETERS , - bloomStrength_ , bloomAttenuation_ ); - glProgramUniform4fv( id , U_VIGNETTE_PARAMETERS_1 , 1 , - vignette_ ); - glProgramUniform2fv( id , U_VIGNETTE_PARAMETERS_2 , 1 , - vignette_ + 4 ); - glProgramUniform3fv( id , U_CG_LIFT , 1 , cgLift_ ); - glProgramUniform3fv( id , U_CG_GAIN , 1 , cgGain_ ); - glProgramUniform3fv( id , U_CG_GAMMA , 1 , cgGamma_ ); - - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - } - PEND( ); -} - -void T_CombinePass::makeUI( ) -{ - using namespace ImGui; - if ( !CollapsingHeader( "Combine" ) ) { - return; - } - - if ( TreeNode( "combine-bloom" , "Bloom" ) ) { - DragFloat( "Strength" , &bloomStrength_ , .001f , 0. , 10 ); - DragFloat( "Attenuation" , &bloomAttenuation_ , .001f , 0. , 1 ); - TreePop( ); - } - - if ( TreeNode( "Vignette" ) ) { - DragFloat( "Shape mult." , &vignette_[ 0 ] , .01f , 0.5 , 20 ); - DragFloat( "Shape power" , &vignette_[ 1 ] , .01f , .5 , 50 ); - DragFloat( "Aspect ratio" , &vignette_[ 2 ] , .001f , 0 , 1 ); - DragFloat( "Shape reverse" , &vignette_[ 3 ] , .001f , .2 , 5 ); - DragFloat( "Apply base" , &vignette_[ 4 ] , .001f , 0 , 1 ); - DragFloat( "Apply max" , &vignette_[ 5 ] , .001f , 0 , 1 ); - TreePop( ); - } - - if ( TreeNode( "Color grading" ) ) { - DragFloat( "Lift / R" , &cgLift_[ 0 ] , .0001f , -1 , 1 ); - DragFloat( "Lift / G" , &cgLift_[ 1 ] , .0001f , -1 , 1 ); - DragFloat( "Lift / B" , &cgLift_[ 2 ] , .0001f , -1 , 1 ); - DragFloat( "Gain / R" , &cgGain_[ 0 ] , .001f , 0 , 2 ); - DragFloat( "Gain / G" , &cgGain_[ 1 ] , .001f , 0 , 2 ); - DragFloat( "Gain / B" , &cgGain_[ 2 ] , .001f , 0 , 2 ); - DragFloat( "Gamma / R" , &cgGamma_[ 0 ] , .001f , -2 , 10 ); - DragFloat( "Gamma / G" , &cgGamma_[ 1 ] , .001f , -2 , 10 ); - DragFloat( "Gamma / B" , &cgGamma_[ 2 ] , .001f , -2 , 10 ); - TreePop( ); - } -} diff --git a/combine.hh b/combine.hh deleted file mode 100644 index a201fec..0000000 --- a/combine.hh +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "rendertarget.hh" -#include "shaders.hh" - - -struct T_CombinePass -{ - T_CombinePass( ) = delete; - T_CombinePass( T_CombinePass const& ) = delete; - T_CombinePass( T_CombinePass&& ) = delete; - - T_CombinePass( T_Texture& image , - T_Texture& bloom ); - - void render( ); - void makeUI( ); - - T_Texture& output( ) - { return txOutput_; } - - private: - T_Texture& txImage_; - T_Texture& txBloom_; - - T_Texture txOutput_; - T_Rendertarget rtOutput_; - - T_ShaderPipeline program_; - - float bloomStrength_; - float bloomAttenuation_; - - float vignette_[ 6 ]; - - float cgLift_[ 3 ]; - float cgGain_[ 3 ]; - float cgGamma_[ 3 ]; -}; - diff --git a/demo.cc b/demo.cc index de356c6..8921c93 100644 --- a/demo.cc +++ b/demo.cc @@ -15,28 +15,6 @@ T_Demo::T_Demo( const uint32_t width , bool T_Demo::initialise( ) { -#if 0 - raymarcher = std::make_unique< T_Raymarcher >( - width , height ); - dof = std::make_unique< T_DoFPass >( - raymarcher->output( ) , raymarcher->depth( ) ); - bloom = std::make_unique< T_BloomPass >( - raymarcher->output( ) ); - combine = std::make_unique< T_CombinePass >( - dof->output( ) , bloom->output( ) ); - fxaa = std::make_unique< T_FXAAPass >( - combine->output( ) ); - - Globals::Sync( ).clearInputs( ); - // XXX should come from program - Globals::Sync( ).addInput( "dof-sharp-distance" , 15 ); - Globals::Sync( ).addInput( "dof-sharp-range" , 5 ); - Globals::Sync( ).addInput( "dof-falloff" , 10 ); - Globals::Sync( ).addInput( "dof-max-blur" , 16 ); - Globals::Sync( ).addInput( "dof-samples" , 16 ); - Globals::Sync( ).updateCurveCaches( ); -#endif - if ( !program ) { loadProgram( ); } @@ -44,28 +22,6 @@ bool T_Demo::initialise( ) return true; } -void T_Demo::makeUI( ) -{ - auto const& dspSize( ImGui::GetIO( ).DisplaySize ); - ImGui::SetNextWindowSize( ImVec2( 300 , dspSize.y - 300 ) , - ImGuiSetCond_Once ); - ImGui::SetNextWindowPos( ImVec2( 0 , 150 ) , - ImGuiSetCond_Once ); - ImGui::Begin( "Demo controls" ); - -#if 0 - raymarcher->makeUI( ); - dof->makeUI( ); - bloom->makeUI( ); - combine->makeUI( ); - fxaa->makeUI( ); -#else - ImGui::Text( "lol, gtfo" ); -#endif - - ImGui::End( ); -} - void T_Demo::render( ) { if ( program && !context ) { @@ -91,14 +47,6 @@ void T_Demo::render( ) context->aborted = true; } } - -#if 0 - raymarcher->render( ); - dof->render( ); - bloom->render( ); - combine->render( ); - fxaa->render( ); -#endif } void T_Demo::handleDND( @@ -108,9 +56,6 @@ void T_Demo::handleDND( const bool lmb // Left mouse button ) { -#if 0 - raymarcher->camera( ).handleDND( move , hasCtrl , hasShift , lmb ); -#endif } void T_Demo::handleWheel( @@ -119,9 +64,6 @@ void T_Demo::handleWheel( const bool hasShift ) { -#if 0 - raymarcher->camera( ).handleWheel( wheel , hasCtrl , hasShift ); -#endif } namespace { diff --git a/demo.hh b/demo.hh index 789307c..4e4d2bf 100644 --- a/demo.hh +++ b/demo.hh @@ -24,7 +24,6 @@ struct T_Demo const uint32_t height ); bool initialise( ); - void makeUI( ); void render( ); bool loadProgram( ); @@ -49,13 +48,6 @@ struct T_Demo bool playing = false; -#if 0 - std::unique_ptr< T_Raymarcher > raymarcher; - std::unique_ptr< T_DoFPass > dof; - std::unique_ptr< T_BloomPass > bloom; - std::unique_ptr< T_CombinePass > combine; - std::unique_ptr< T_FXAAPass > fxaa; -#endif T_OwnPtr< ops::T_OpProgram > program; T_OwnPtr< ops::T_OpContext > context; diff --git a/dof.cc b/dof.cc deleted file mode 100644 index f11075f..0000000 --- a/dof.cc +++ /dev/null @@ -1,134 +0,0 @@ -#include "externals.hh" -#include "dof.hh" -#include "profiling.hh" -#include "globals.hh" -#include "odbg.hh" -#include "sync.hh" - - -namespace { - static char const* const Name_( "DoF" ); -} - -#define PSTART() Globals::Profiler( ).start( Name_ ) -#define PEND() do { glFinish( ); Globals::Profiler( ).end( Name_ ); } while ( 0 ) - - -T_DoFPass::T_DoFPass( - __rw__ T_Texture& imageInput , - __rw__ T_Texture& depthInput ) - : imageInput_( imageInput ) , depthInput_( depthInput ) , - txPass1_( imageInput.width( ) , imageInput.height( ) , - E_TexType::RGB16F ) , - txOutput_( imageInput.width( ) , imageInput.height( ) , - E_TexType::RGB16F ) , - rtPass1_( T_RendertargetSetup( ).add( txPass1_ ).create( ) ) , - rtPass2_( T_RendertargetSetup( ).add( txOutput_ ).create( ) ) -{ - txPass1_.wrap( E_TexWrap::CLAMP_EDGE ); - - Globals::ODbg( ).registerTexture( txPass1_ , E_ODbgMode::HDR , "DoF 1st pass" ); - Globals::ODbg( ).registerTexture( txOutput_ , E_ODbgMode::HDR , "DoF output" ); - - spPass1_ = Globals::Shaders( ).pipeline({ - "fullscreen.v.glsl" , "dof-pass1.f.glsl" }); - spPass2_ = Globals::Shaders( ).pipeline({ - "fullscreen.v.glsl" , "dof-pass2.f.glsl" }); -} - -void T_DoFPass::render( ) -{ - PSTART( ); - enum { - U_INPUT = 0 , - U_DEPTH = 1 , - U_PARAMS = 2 , - U_SAMPLES = 3 , - U_RES_TIME = 4 - }; - - using namespace cops; - auto& tm( Globals::Textures( ) ); - const auto idPass1( spPass1_.program( E_ShaderType::FRAGMENT ) ); - const auto idPass2( spPass2_.program( E_ShaderType::FRAGMENT ) ); - const auto idSampler( tm.sampler( "linear-edge" )->id( ) ); - T_Program program; - program.function( "SetDofUniforms" , 1 ) - << OPLoadVariable( "height" ) - << OPLoadVariable( "width" ) - << OPLoadConstant( 0 ) - << OPLoadConstant( 0 ) - << OPLoadVariable( "time" ) - << OPLoadVariable( "height" ) - << OPLoadVariable( "width" ) - << OPLoadConstant( U_RES_TIME ) - << OPDup( 8 ) - << OPLoadInput( "dof-samples" ) - << OPLoadConstant( U_SAMPLES ) - << OPDup( 11 ) - << OPLoadInput( "dof-max-blur" ) - << OPLoadInput( "dof-falloff" ) - << OPLoadInput( "dof-sharp-range" ) - << OPLoadInput( "dof-sharp-distance" ) - << OPLoadConstant( U_PARAMS ) - << OPDup( 17 ) - << OPLoadConstant( 1 ) - << OPLoadConstant( U_DEPTH ) - << OPDup( 20 ) - << OPLoadConstant( 0 ) - << OPLoadConstant( U_INPUT ) - << OPDup( 23 ) - << OPSetUniform( 1 , true ) - << OPSetUniform( 1 , true ) - << OPSetUniform( 4 , false ) - << OPSetUniform( 1 , false ) - << OPSetUniform( 3 , false ) - << OPSetViewport( ) - ; - - program.main - // First pass - << OPLoadConstant( idPass1 ) - << OPCall( "SetDofUniforms" ) - << OPUseTexture( 0 , imageInput_.id( ) , idSampler ) - << OPUseTexture( 1 , depthInput_.id( ) , idSampler ) - << OPUsePipeline( spPass1_.id( ) ) - << OPUseFramebuffer( rtPass1_.id( ) ) - << OPFullscreen( ) - // Second pass - << OPLoadConstant( idPass2 ) - << OPCall( "SetDofUniforms" ) - << OPUseTexture( 0 , txPass1_.id( ) , idSampler ) - << OPUsePipeline( spPass2_.id( ) ) - << OPUseFramebuffer( rtPass2_.id( ) ) - << OPFullscreen( ) - ; - - GL_CHECK( { - printf( "GL fail in DoF" ); - } ); - - T_Context ctx; - ctx.store( "time" , Globals::Sync( ).time( ) ); - ctx.store( "width" , imageInput_.width( ) ); - ctx.store( "height" , imageInput_.height( ) ); - program.execute( ctx ); - - PEND( ); -} - -void T_DoFPass::makeUI( ) -{ -#if 0 - if ( !ImGui::CollapsingHeader( "Depth of field" ) ) { - return; - } - - ImGui::DragFloat( "Sharp distance" , filterParams_ , .25 , 0.25 , 1000 ); - ImGui::DragFloat( "Sharp range" , &filterParams_[ 1 ] , .1 , 0.1 , 100 ); - ImGui::DragFloat( "Blur falloff" , &filterParams_[ 2 ] , .5 , 0.5 , 1000 ); - ImGui::DragFloat( "Max blur" , &filterParams_[ 3 ] , .1 , .1 , 100 ); - - ImGui::DragInt( "Samples" , &nSamples_ , .2 , 1 , 32 ); -#endif -} diff --git a/dof.hh b/dof.hh deleted file mode 100644 index 1a284d9..0000000 --- a/dof.hh +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "rendertarget.hh" -#include "shaders.hh" -#include "control.hh" - - -struct T_SyncData; - - -struct T_DoFPass -{ - T_DoFPass( ) = delete; - T_DoFPass( T_DoFPass const& ) = delete; - T_DoFPass( T_DoFPass&& ) = delete; - - T_DoFPass( __rw__ T_Texture& imageInput , - __rw__ T_Texture& depthInput ); - - void render( ); - void makeUI( ); - - T_Texture& output( ) { return txOutput_; } - - private: - T_Texture& imageInput_; - T_Texture& depthInput_; - - T_ShaderPipeline spPass1_; - T_ShaderPipeline spPass2_; - - T_Texture txPass1_ , txOutput_; - T_Rendertarget rtPass1_ , rtPass2_; -}; - diff --git a/fxaa.cc b/fxaa.cc deleted file mode 100644 index 93aeced..0000000 --- a/fxaa.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include "externals.hh" -#include "fxaa.hh" -#include "profiling.hh" -#include "globals.hh" - -namespace { - static char const* const Name_( "FXAA" ); -} - -#define PSTART() Globals::Profiler( ).start( Name_ ) -#define PEND() do { glFinish( ); Globals::Profiler( ).end( Name_ ); } while ( 0 ) - - -T_FXAAPass::T_FXAAPass( - __rw__ T_Texture& input ) - : txInput_( input ) , - parameters_{ .5 , .166 , .0833 } -{ - program_ = Globals::Shaders( ).pipeline({ - "fullscreen.v.glsl" , "fxaa.f.glsl" }); -} - -void T_FXAAPass::render( ) -{ - PSTART( ); - T_Rendertarget::MainOutput( ); - glClearColor( 1 , 0 , 1 , 1 ); - glClear( GL_COLOR_BUFFER_BIT ); - if ( program_.valid( ) ) { - enum { - U_INPUT , - U_RESOLUTION , - U_PARAMETERS , - }; - auto& tm( Globals::Textures( ) ); - tm.bind( 0 , txInput_ , *tm.sampler( "linear-border" ) ); - - const auto id( program_.program( E_ShaderType::FRAGMENT ) ); - program_.enable( ); - glProgramUniform1i( id , U_INPUT , 0 ); - glProgramUniform2f( id , U_RESOLUTION , - txInput_.width( ) , txInput_.height( ) ); - glProgramUniform3fv( id , U_PARAMETERS , 1 , parameters_ ); - - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - } - PEND( ); -} - -void T_FXAAPass::makeUI( ) -{ - using namespace ImGui; - if ( !CollapsingHeader( "FXAA" ) ) { - return; - } - - DragFloat( "Sub-pixel q." , ¶meters_[ 0 ] , .001f , 0 , 1 ); - DragFloat( "Edge threshold" , ¶meters_[ 1 ] , .0001f , .063 , .333 ); - DragFloat( "Edge threshold min" , ¶meters_[ 2 ] , .0001f , .0312 , .0833 ); -} - diff --git a/fxaa.hh b/fxaa.hh deleted file mode 100644 index fb27c8b..0000000 --- a/fxaa.hh +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "rendertarget.hh" -#include "shaders.hh" - - -struct T_FXAAPass -{ - T_FXAAPass( ) = delete; - T_FXAAPass( T_FXAAPass const& ) = delete; - T_FXAAPass( T_FXAAPass&& ) = delete; - - T_FXAAPass( __rw__ T_Texture& input ); - - void render( ); - void makeUI( ); - - private: - T_Texture& txInput_; - T_ShaderPipeline program_; - float parameters_[ 3 ]; -}; diff --git a/main.cc b/main.cc index 4da915e..a501939 100644 --- a/main.cc +++ b/main.cc @@ -32,7 +32,6 @@ struct T_Main uint32_t stopResize = 0; ImVec2 prevSize; - bool demoCtrl_ = false; T_Optional< T_Demo > demo; void initDemo( ); @@ -179,7 +178,6 @@ void T_Main::makeUI( ) ImGui::SetNextWindowPos( ImVec2( ) , ImGuiSetCond_Once ); ImGui::Begin( "Tools" ); - ImGui::Checkbox( "Demo controls" , &demoCtrl_ ); ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) ); ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) ); ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) ); @@ -201,10 +199,6 @@ void T_Main::makeUI( ) ImGui::End( ); - if ( demo && demoCtrl_ ) { - demo->makeUI( ); - } - Globals::Profiler( ).makeUI( ); Globals::ODbg( ).makeUI( ); Globals::Shaders( ).makeUI( ); diff --git a/raymarcher.cc b/raymarcher.cc deleted file mode 100644 index d57be17..0000000 --- a/raymarcher.cc +++ /dev/null @@ -1,94 +0,0 @@ -#include "externals.hh" -#include "raymarcher.hh" -#include "profiling.hh" -#include "globals.hh" -#include "odbg.hh" - - -namespace { - static char const* const Name_( "Raymarcher" ); -} - -#define PSTART() Globals::Profiler( ).start( Name_ ) -#define PEND() do { glFinish( ); Globals::Profiler( ).end( Name_ ); } while ( 0 ) - - -T_Raymarcher::T_Raymarcher( - __rd__ const uint32_t width , - __rd__ const uint32_t height ) - : camera_( ) , - txOutput_( width , height , E_TexType::RGB16F ) , - txDepth_( width , height , E_TexType::R16F ) , - rtOutput_( T_RendertargetSetup( ) - .add( txOutput_ ) - .add( txDepth_ ) - .create( ) ) -{ - Globals::ODbg( ).registerTexture( txOutput_ , E_ODbgMode::HDR , "Raymarched image" ); - Globals::ODbg( ).registerTexture( txDepth_ , E_ODbgMode::DEPTH , "Raymarched distance" ); - program_ = Globals::Shaders( ).pipeline({ - "fullscreen.v.glsl" , "scene.f.glsl" }); -} - - -void T_Raymarcher::render( ) -{ - if ( !rtOutput_.activate( ) || !program_.valid( ) ) { - glClearColor( 0 , 0 , 0 , 1 ); - glClear( GL_COLOR_BUFFER_BIT ); - return; - } - - PSTART( ); - program_.enable( ); - - glClearColor( 0 , 0 , 0 , 1 ); - glClear( GL_COLOR_BUFFER_BIT ); - enum { - U_TIME = 0 , - U_RESOLUTION = 1 , - U_CAM_POS = 2 , - U_LOOK_AT = 3 , - U_CAM_UP = 4 , - U_NEAR_PLANE = 5 , - U_RAYMARCHER = 6 , - U_FOG = 7 , - U_CORRECTION = 8 - }; - - const auto id( program_.program( E_ShaderType::FRAGMENT ) ); - glProgramUniform1f( id , U_TIME , 0 ); - glProgramUniform2f( id , U_RESOLUTION , rtOutput_.width( ) , rtOutput_.height( ) ); - - glProgramUniform3fv( id , U_CAM_POS , 1 , &camera_.pos.x ); - glProgramUniform3fv( id , U_LOOK_AT , 1 , &camera_.lookAt.x ); - glProgramUniform3fv( id , U_CAM_UP , 1 , &camera_.up.x ); - glProgramUniform1f( id , U_NEAR_PLANE , camera_.np ); - - glProgramUniform4f( id , U_RAYMARCHER , rmIterations , rmStep , - rmEpsilon , rmMaxDist ); - glProgramUniform1f( id , U_FOG , fog ); - glProgramUniform1i( id , U_CORRECTION , correction_ ); - - glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 ); - - PEND( ); -} - -void T_Raymarcher::makeUI( ) -{ - camera_.makeUI( ); - - if ( ImGui::CollapsingHeader( "Raymarcher" ) ) { - ImGui::DragInt( "Iterations" , &rmIterations , .01 , 1 , 512 ); - ImGui::DragFloat( "Step" , &rmStep , .00005 , .1 , 2 ); - ImGui::DragFloat( "Max. dist." , &rmMaxDist , .1f , - 0.01 , 1000.0 , "%.2f" ); - if ( ImGui::DragFloat( "Epsilon" , &epsLog , .01f , - -10 , -0.5 , "10 ^ %.2f" ) ) { - rmEpsilon = pow( 10 , epsLog ); - } - ImGui::DragInt( "Correction" , &correction_ , .001 , 0 , 50 ); - ImGui::DragFloat( "Fog" , &fog , .000001 , 0 , 1 , "%.5f" ); - } -} diff --git a/raymarcher.hh b/raymarcher.hh deleted file mode 100644 index 9386682..0000000 --- a/raymarcher.hh +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "rendertarget.hh" -#include "shaders.hh" -#include "camera.hh" - - -struct T_Raymarcher -{ - public: - T_Raymarcher( ) = delete; - T_Raymarcher( T_Raymarcher const& ) = delete; - T_Raymarcher( T_Raymarcher&& ) = delete; - - T_Raymarcher( __rd__ const uint32_t width , - __rd__ const uint32_t height ); - - void render( ); - void makeUI( ); - - T_Camera const& camera( ) const noexcept { return camera_; } - T_Camera& camera( ) noexcept { return camera_; } - - T_Texture& output( ) noexcept { return txOutput_; } - T_Texture& depth( ) noexcept { return txDepth_; } - - private: - T_Camera camera_; - - //T_ShaderProgram program_; - T_ShaderPipeline program_; - - T_Texture txOutput_ , txDepth_; - T_Rendertarget rtOutput_; - - int rmIterations = 256; - float rmStep = 1.2; - float rmEpsilon = .00001; - float rmMaxDist = 250; - float fog = .00015; - int correction_ = 10; - float epsLog = log( rmEpsilon ) / log( 10 ); -};