2017-10-01 18:51:02 +02:00
|
|
|
#include "externals.hh"
|
|
|
|
#include "combine.hh"
|
|
|
|
#include "bloom.hh"
|
|
|
|
#include "profiling.hh"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
static const std::string Name_( "Combine" );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PSTART() T_Profiler::Profiler.start( Name_ )
|
|
|
|
#define PEND() do { glFinish( ); T_Profiler::Profiler.end( Name_ ); } while ( 0 )
|
|
|
|
|
|
|
|
|
|
|
|
T_CombinePass::T_CombinePass(
|
|
|
|
__rw__ T_FilesWatcher& watcher ,
|
|
|
|
__rw__ T_Texture& image ,
|
|
|
|
__rw__ T_Texture& bloom )
|
|
|
|
: txImage_( image ) , txBloom_( bloom ) ,
|
|
|
|
program_( GL_FRAGMENT_SHADER , watcher ) ,
|
|
|
|
bloomStrength_( 0.45 ) ,
|
|
|
|
bloomAttenuation_( 0.3 )
|
|
|
|
{
|
|
|
|
program_.addFile( "combine.glsl" );
|
|
|
|
program_.load( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_CombinePass::render( )
|
|
|
|
{
|
|
|
|
PSTART( );
|
|
|
|
T_Rendertarget::MainOutput( );
|
|
|
|
glClearColor( 1 , 0 , 1 , 1 );
|
|
|
|
glClear( GL_COLOR_BUFFER_BIT );
|
|
|
|
if ( program_.activate( ) ) {
|
2017-10-02 14:48:16 +02:00
|
|
|
auto& tm( T_TextureManagement::TM( ) );
|
|
|
|
tm.bind( 0 , txImage_ );
|
|
|
|
tm.bind( 1 , txBloom_ );
|
|
|
|
glUniform1i( 0 , 0 );
|
|
|
|
glUniform1i( 1 , 1 );
|
2017-10-01 18:51:02 +02:00
|
|
|
glUniform2f( 2 , txImage_.width( ) , txImage_.height( ) );
|
|
|
|
glUniform2f( 3 , bloomStrength_ , bloomAttenuation_ );
|
|
|
|
glRectf( -1, -1 , 1 , 1 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D , 0 );
|
|
|
|
}
|
|
|
|
PEND( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_CombinePass::makeUI( )
|
|
|
|
{
|
|
|
|
if ( !ImGui::CollapsingHeader( "Combine" ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::DragFloat( "Bloom strength" , &bloomStrength_ , .001f , 0. , 10 );
|
|
|
|
ImGui::DragFloat( "Bloom attenuation" , &bloomAttenuation_ , .001f , 0. , 1 );
|
|
|
|
}
|
|
|
|
|