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

View file

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

View file

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