Removed some now-unused code

This commit is contained in:
Emmanuel BENOîT 2017-11-15 17:16:12 +01:00
parent 1d66085483
commit f1d7935421
14 changed files with 0 additions and 787 deletions

View file

@ -37,14 +37,7 @@ COMMON = \
DEMO = \ DEMO = \
main.cc \ main.cc \
\
demo.cc \ demo.cc \
\
raymarcher.cc \
bloom.cc \
dof.cc \
combine.cc \
fxaa.cc \
# END DEMO # END DEMO
PARSERCHECK = \ PARSERCHECK = \

127
bloom.cc
View file

@ -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 );
}

View file

@ -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_;
};

View file

@ -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( );
}
}

View file

@ -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 ];
};

58
demo.cc
View file

@ -15,28 +15,6 @@ T_Demo::T_Demo( const uint32_t width ,
bool T_Demo::initialise( ) 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 ) { if ( !program ) {
loadProgram( ); loadProgram( );
} }
@ -44,28 +22,6 @@ bool T_Demo::initialise( )
return true; 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( ) void T_Demo::render( )
{ {
if ( program && !context ) { if ( program && !context ) {
@ -91,14 +47,6 @@ void T_Demo::render( )
context->aborted = true; context->aborted = true;
} }
} }
#if 0
raymarcher->render( );
dof->render( );
bloom->render( );
combine->render( );
fxaa->render( );
#endif
} }
void T_Demo::handleDND( void T_Demo::handleDND(
@ -108,9 +56,6 @@ void T_Demo::handleDND(
const bool lmb // Left mouse button const bool lmb // Left mouse button
) )
{ {
#if 0
raymarcher->camera( ).handleDND( move , hasCtrl , hasShift , lmb );
#endif
} }
void T_Demo::handleWheel( void T_Demo::handleWheel(
@ -119,9 +64,6 @@ void T_Demo::handleWheel(
const bool hasShift const bool hasShift
) )
{ {
#if 0
raymarcher->camera( ).handleWheel( wheel , hasCtrl , hasShift );
#endif
} }
namespace { namespace {

View file

@ -24,7 +24,6 @@ struct T_Demo
const uint32_t height ); const uint32_t height );
bool initialise( ); bool initialise( );
void makeUI( );
void render( ); void render( );
bool loadProgram( ); bool loadProgram( );
@ -49,13 +48,6 @@ struct T_Demo
bool playing = false; 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_OpProgram > program;
T_OwnPtr< ops::T_OpContext > context; T_OwnPtr< ops::T_OpContext > context;

134
dof.cc
View file

@ -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
}

34
dof.hh
View file

@ -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_;
};

61
fxaa.cc
View file

@ -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." , &parameters_[ 0 ] , .001f , 0 , 1 );
DragFloat( "Edge threshold" , &parameters_[ 1 ] , .0001f , .063 , .333 );
DragFloat( "Edge threshold min" , &parameters_[ 2 ] , .0001f , .0312 , .0833 );
}

22
fxaa.hh
View file

@ -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 ];
};

View file

@ -32,7 +32,6 @@ struct T_Main
uint32_t stopResize = 0; uint32_t stopResize = 0;
ImVec2 prevSize; ImVec2 prevSize;
bool demoCtrl_ = false;
T_Optional< T_Demo > demo; T_Optional< T_Demo > demo;
void initDemo( ); void initDemo( );
@ -179,7 +178,6 @@ void T_Main::makeUI( )
ImGui::SetNextWindowPos( ImVec2( ) , ImGuiSetCond_Once ); ImGui::SetNextWindowPos( ImVec2( ) , ImGuiSetCond_Once );
ImGui::Begin( "Tools" ); ImGui::Begin( "Tools" );
ImGui::Checkbox( "Demo controls" , &demoCtrl_ );
ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) ); ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) );
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) ); ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) ); ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) );
@ -201,10 +199,6 @@ void T_Main::makeUI( )
ImGui::End( ); ImGui::End( );
if ( demo && demoCtrl_ ) {
demo->makeUI( );
}
Globals::Profiler( ).makeUI( ); Globals::Profiler( ).makeUI( );
Globals::ODbg( ).makeUI( ); Globals::ODbg( ).makeUI( );
Globals::Shaders( ).makeUI( ); Globals::Shaders( ).makeUI( );

View file

@ -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" );
}
}

View file

@ -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 );
};