Combine ported

This commit is contained in:
Emmanuel BENOîT 2017-10-04 18:06:39 +02:00
parent 5b3d883488
commit 49663217e2
3 changed files with 16 additions and 12 deletions

View file

@ -16,12 +16,11 @@ T_CombinePass::T_CombinePass(
__rw__ T_Texture& image , __rw__ T_Texture& image ,
__rw__ T_Texture& bloom ) __rw__ T_Texture& bloom )
: txImage_( image ) , txBloom_( bloom ) , : txImage_( image ) , txBloom_( bloom ) ,
program_( GL_FRAGMENT_SHADER ) ,
bloomStrength_( 0.45 ) , bloomStrength_( 0.45 ) ,
bloomAttenuation_( 0.3 ) bloomAttenuation_( 0.3 )
{ {
program_.addFile( "combine.glsl" ); program_ = Globals::Shaders( ).pipeline({
program_.load( ); "fullscreen.v.glsl" , "combine.f.glsl" });
} }
void T_CombinePass::render( ) void T_CombinePass::render( )
@ -30,16 +29,19 @@ void T_CombinePass::render( )
T_Rendertarget::MainOutput( ); T_Rendertarget::MainOutput( );
glClearColor( 1 , 0 , 1 , 1 ); glClearColor( 1 , 0 , 1 , 1 );
glClear( GL_COLOR_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT );
if ( program_.activate( ) ) { if ( program_.valid( ) ) {
auto& tm( Globals::Textures( ) ); auto& tm( Globals::Textures( ) );
tm.bind( 0 , txImage_ ); tm.bind( 0 , txImage_ );
tm.bind( 1 , txBloom_ ); tm.bind( 1 , txBloom_ );
glUniform1i( 0 , 0 );
glUniform1i( 1 , 1 ); const auto id( program_.program( E_ShaderType::FRAGMENT ) );
glUniform2f( 2 , txImage_.width( ) , txImage_.height( ) ); program_.enable( );
glUniform2f( 3 , bloomStrength_ , bloomAttenuation_ ); glProgramUniform1i( id , 0 , 0 );
glRectf( -1, -1 , 1 , 1 ); glProgramUniform1i( id , 1 , 1 );
glBindTexture( GL_TEXTURE_2D , 0 ); glProgramUniform2f( id , 2 , txImage_.width( ) , txImage_.height( ) );
glProgramUniform2f( id , 3 , bloomStrength_ , bloomAttenuation_ );
glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 );
} }
PEND( ); PEND( );
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "rendertarget.hh" #include "rendertarget.hh"
#include "programs.hh" #include "shaders.hh"
struct T_CombinePass struct T_CombinePass
@ -20,7 +20,7 @@ struct T_CombinePass
T_Texture& txImage_; T_Texture& txImage_;
T_Texture& txBloom_; T_Texture& txBloom_;
T_ShaderProgram program_; T_ShaderPipeline program_;
float bloomStrength_; float bloomStrength_;
float bloomAttenuation_; float bloomAttenuation_;

View file

@ -1,5 +1,7 @@
#version 450 core #version 450 core
//! type fragment
layout( location = 0 ) uniform sampler2D u_MainInput; layout( location = 0 ) uniform sampler2D u_MainInput;
layout( location = 1 ) uniform sampler2D u_BlurInput; layout( location = 1 ) uniform sampler2D u_BlurInput;
layout( location = 2 ) uniform vec2 u_OutputSize; layout( location = 2 ) uniform vec2 u_OutputSize;