|
@@ -11,7 +11,7 @@ The file contains functions and vars used for the deferred shading/post-processi
|
|
|
|
|
|
|
|
namespace r {
|
|
namespace r {
|
|
|
namespace pps {
|
|
namespace pps {
|
|
|
-namespace bloom {
|
|
|
|
|
|
|
+namespace hdr {
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -21,24 +21,25 @@ VARS
|
|
|
*/
|
|
*/
|
|
|
bool enabled = true;
|
|
bool enabled = true;
|
|
|
|
|
|
|
|
-static fbo_t vblur_fbo, final_fbo; // yet another FBO and another, damn
|
|
|
|
|
|
|
+static fbo_t pass0_fbo, pass1_fbo, pass2_fbo; // yet another FBO and another, damn
|
|
|
|
|
|
|
|
float rendering_quality = 0.25; // 1/4 of the image
|
|
float rendering_quality = 0.25; // 1/4 of the image
|
|
|
static uint wwidth, wheight; // render width and height
|
|
static uint wwidth, wheight; // render width and height
|
|
|
|
|
|
|
|
-// bloom images
|
|
|
|
|
-texture_t vbrur_fai; // for vertical blur pass
|
|
|
|
|
-texture_t final_fai; // with the horizontal blur
|
|
|
|
|
|
|
+// hdr images
|
|
|
|
|
+texture_t pass0_fai; // for vertical blur pass
|
|
|
|
|
+texture_t pass1_fai; // with the horizontal blur
|
|
|
|
|
+texture_t pass2_fai;
|
|
|
|
|
|
|
|
-static shader_prog_t* shdr_pps_bloom_vblur, * shdr_pps_bloom_final; // bloom pass 0 and pass 1 shaders
|
|
|
|
|
|
|
+static shader_prog_t* pass0_shdr, * pass1_shdr, * pass2_shdr; // hdr pass 0 and pass 1 shaders
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
=======================================================================================================================================
|
|
=======================================================================================================================================
|
|
|
-InitFBOP0 =
|
|
|
|
|
|
|
+InitFBOs =
|
|
|
=======================================================================================================================================
|
|
=======================================================================================================================================
|
|
|
*/
|
|
*/
|
|
|
-static void InitFBOs( fbo_t& fbo, texture_t& fai )
|
|
|
|
|
|
|
+static void InitFBOs( fbo_t& fbo, texture_t& fai, int internal_format )
|
|
|
{
|
|
{
|
|
|
// create FBO
|
|
// create FBO
|
|
|
fbo.Create();
|
|
fbo.Create();
|
|
@@ -48,9 +49,7 @@ static void InitFBOs( fbo_t& fbo, texture_t& fai )
|
|
|
fbo.SetNumOfColorAttachements(1);
|
|
fbo.SetNumOfColorAttachements(1);
|
|
|
|
|
|
|
|
// create the texes
|
|
// create the texes
|
|
|
- // we need one chanel onle (red) because the output is grayscale
|
|
|
|
|
- //fai_bloom.CreateEmpty( wwidth, wheight, 1, GL_RED, GL_UNSIGNED_BYTE ); // ORIGINAL BLOOM CODE
|
|
|
|
|
- fai.CreateEmpty( wwidth, wheight, GL_RGB, GL_RGB );
|
|
|
|
|
|
|
+ fai.CreateEmpty( wwidth, wheight, internal_format, GL_RGB );
|
|
|
fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
fai.TexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
|
|
fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
|
fai.TexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
|
|
|
|
|
|
@@ -59,7 +58,7 @@ static void InitFBOs( fbo_t& fbo, texture_t& fai )
|
|
|
|
|
|
|
|
// test if success
|
|
// test if success
|
|
|
if( !fbo.CheckStatus() )
|
|
if( !fbo.CheckStatus() )
|
|
|
- FATAL( "Cannot create deferred shading post-processing stage bloom passes FBO" );
|
|
|
|
|
|
|
+ FATAL( "Cannot create deferred shading post-processing stage HDR passes FBO" );
|
|
|
|
|
|
|
|
// unbind
|
|
// unbind
|
|
|
fbo.Unbind();
|
|
fbo.Unbind();
|
|
@@ -73,16 +72,17 @@ Init
|
|
|
*/
|
|
*/
|
|
|
void Init()
|
|
void Init()
|
|
|
{
|
|
{
|
|
|
- DEBUG_ERR( rendering_quality<0.0 || rendering_quality>1.0 );
|
|
|
|
|
- wwidth = r::rendering_quality * r::pps::ssao::rendering_quality * r::w;
|
|
|
|
|
- wheight = r::rendering_quality * r::pps::ssao::rendering_quality * r::h;
|
|
|
|
|
|
|
+ wwidth = r::rendering_quality * r::pps::hdr::rendering_quality * r::w;
|
|
|
|
|
+ wheight = r::rendering_quality * r::pps::hdr::rendering_quality * r::h;
|
|
|
|
|
|
|
|
- InitFBOs( vblur_fbo, vbrur_fai );
|
|
|
|
|
- InitFBOs( final_fbo, final_fai );
|
|
|
|
|
|
|
+ InitFBOs( pass0_fbo, pass0_fai, GL_RGB );
|
|
|
|
|
+ InitFBOs( pass1_fbo, pass1_fai, GL_RGB );
|
|
|
|
|
+ InitFBOs( pass2_fbo, pass2_fai, GL_RGB );
|
|
|
|
|
|
|
|
// init shaders
|
|
// init shaders
|
|
|
- shdr_pps_bloom_vblur = rsrc::shaders.Load( "shaders/pps_bloom_vblur.glsl" );
|
|
|
|
|
- shdr_pps_bloom_final = rsrc::shaders.Load( "shaders/pps_bloom_final.glsl" );
|
|
|
|
|
|
|
+ pass0_shdr = rsrc::shaders.Load( "shaders/pps_hdr_pass0.glsl" );
|
|
|
|
|
+ pass1_shdr = rsrc::shaders.Load( "shaders/pps_hdr_pass1.glsl" );
|
|
|
|
|
+ pass2_shdr = rsrc::shaders.Load( "shaders/pps_hdr_pass2.glsl" );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -100,42 +100,49 @@ void RunPass( const camera_t& /*cam*/ )
|
|
|
|
|
|
|
|
|
|
|
|
|
// pass 0
|
|
// pass 0
|
|
|
- vblur_fbo.Bind();
|
|
|
|
|
|
|
+ pass0_fbo.Bind();
|
|
|
|
|
|
|
|
- shdr_pps_bloom_vblur->Bind();
|
|
|
|
|
|
|
+ pass0_shdr->Bind();
|
|
|
|
|
|
|
|
- shdr_pps_bloom_vblur->LocTexUnit( shdr_pps_bloom_vblur->GetUniformLocation(0), r::is::fai, 0 );
|
|
|
|
|
|
|
+ pass0_shdr->LocTexUnit( pass0_shdr->GetUniformLocation(0), r::is::fai, 0 );
|
|
|
|
|
|
|
|
// Draw quad
|
|
// Draw quad
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
- glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
-
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
|
|
glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
|
|
|
-
|
|
|
|
|
glDrawArrays( GL_QUADS, 0, 4 );
|
|
glDrawArrays( GL_QUADS, 0, 4 );
|
|
|
-
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
|
|
|
|
|
// pass 1
|
|
// pass 1
|
|
|
- final_fbo.Bind();
|
|
|
|
|
|
|
+ pass1_fbo.Bind();
|
|
|
|
|
|
|
|
- shdr_pps_bloom_final->Bind();
|
|
|
|
|
|
|
+ pass1_shdr->Bind();
|
|
|
|
|
|
|
|
- shdr_pps_bloom_final->LocTexUnit( shdr_pps_bloom_final->GetUniformLocation(0), vbrur_fai, 0 );
|
|
|
|
|
|
|
+ pass1_shdr->LocTexUnit( pass1_shdr->GetUniformLocation(0), pass0_fai, 0 );
|
|
|
|
|
|
|
|
// Draw quad
|
|
// Draw quad
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
- glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
-
|
|
|
|
|
glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
|
|
glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
|
|
|
-
|
|
|
|
|
glDrawArrays( GL_QUADS, 0, 4 );
|
|
glDrawArrays( GL_QUADS, 0, 4 );
|
|
|
|
|
+ glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // pass 2
|
|
|
|
|
+ pass2_fbo.Bind();
|
|
|
|
|
|
|
|
|
|
+ pass2_shdr->Bind();
|
|
|
|
|
+
|
|
|
|
|
+ pass2_shdr->LocTexUnit( pass2_shdr->GetUniformLocation(0), pass1_fai, 0 );
|
|
|
|
|
+
|
|
|
|
|
+ // Draw quad
|
|
|
|
|
+ glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
+ glVertexPointer( 2, GL_FLOAT, 0, quad_vert_cords );
|
|
|
|
|
+ glDrawArrays( GL_QUADS, 0, 4 );
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// end
|
|
// end
|
|
|
- final_fbo.Unbind();
|
|
|
|
|
|
|
+ fbo_t::Unbind();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|