/* ================= R_InitBloomTextures ================= */ void R_InitBloomTextures( void ) { if( !r_bloom->integer ) return; memset( &bloom, 0, sizeof( bloom )); R_Bloom_InitTextures (); }
/* ================= R_InitBloomTextures ================= */ void R_InitBloomTextures( void ) { BLOOM_SIZE = 0; if( !r_bloom->integer ) return; R_Bloom_InitTextures(); }
/* ================= R_BloomScreen ================= */ void R_BloomScreen( void ) { if( !r_bloom->integer ) return; if(r_bloom_sky_only->integer) return; if ( backEnd.doneBloom ) return; if ( !backEnd.doneSurfaces ) return; backEnd.doneBloom = qtrue; if( !bloom.started ) { R_Bloom_InitTextures(); if( !bloom.started ) return; } if ( !backEnd.projection2D ) RB_SetGL2D(); #if 0 // set up full screen workspace GL_TexEnv( GL_MODULATE ); qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglMatrixMode( GL_PROJECTION ); qglLoadIdentity (); qglOrtho( 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 ); qglMatrixMode( GL_MODELVIEW ); qglLoadIdentity (); GL_Cull( CT_TWO_SIDED ); #endif qglColor4f( 1, 1, 1, 1 ); //Backup the old screen in a texture R_Bloom_BackupScreen(); // create the bloom texture using one of a few methods if(r_bloom_cascade->integer) R_Bloom_Cascaded(); else R_Bloom_WarsowEffect (); // R_Bloom_CreateEffect(); // restore the screen-backup to the screen R_Bloom_RestoreScreen(); // Do the final pass using the bloom texture for the final effect R_Bloom_DrawEffect (); // LEILEI - Lens Bloom Hack // The concept of this is to inverse the coordinates on both X and Y, // then scale outward using the offset value applied, as well as the modulated color // applied to give a rainbow streak effect. Most effective with high bloom darkness // values. if(r_bloom_reflection->integer) R_Bloom_LensEffect (); }
// ================= // R_InitBloomTextures // ================= void R_InitBloomTextures( void ) { BLOOM_SIZE = 0; if( !r_bloom.value ) { return; } r_bloomscreentexture = 0; // This came from a vid_restart, where none of the textures are valid any more. R_Bloom_InitTextures (); }
/* ================= R_InitBloomTextures ================= */ void R_InitBloomTextures( void ) { //r_bloom = Cvar_Get( "r_bloom", "0", CVAR_ARCHIVE ); r_bloom_alpha = Cvar_Get( "r_bloom_alpha", "0.2", CVAR_ARCHIVE ); r_bloom_diamond_size = Cvar_Get( "r_bloom_diamond_size", "8", CVAR_ARCHIVE ); r_bloom_intensity = Cvar_Get( "r_bloom_intensity", "0.6", CVAR_ARCHIVE ); r_bloom_threshold = Cvar_Get( "r_bloom_threshold", "0.08", CVAR_ARCHIVE ); r_bloom_darken = Cvar_Get( "r_bloom_darken", "4", CVAR_ARCHIVE ); r_bloom_sample_size = Cvar_Get( "r_bloom_sample_size", "128", CVAR_ARCHIVE ); r_bloom_fast_sample = Cvar_Get( "r_bloom_fast_sample", "0", CVAR_ARCHIVE ); BLOOM_SIZE = 0; if (!r_bloom->value) return; R_Bloom_InitTextures (); }
/* ================= R_InitBloomTextures ================= */ void R_InitBloomTextures( void ) { BLOOM_SIZE = 0; if( r_bloomscreentexture ) FREE_TEXTURE( r_bloomscreentexture ); if( r_bloomeffecttexture ) FREE_TEXTURE( r_bloomeffecttexture ); if( r_bloombackuptexture ) FREE_TEXTURE( r_bloombackuptexture ); if( r_bloomdownsamplingtexture ) FREE_TEXTURE( r_bloomdownsamplingtexture ); r_bloomscreentexture = r_bloomeffecttexture = 0; r_bloombackuptexture = r_bloomdownsamplingtexture = 0; if( !r_bloom->value ) return; R_Bloom_InitTextures(); }
// ================= // R_BloomBlend // ================= void R_BloomBlend (void) { extern vrect_t scr_vrect; if( !r_bloom.value ) { return; } if( !BLOOM_SIZE || screen_texture_width < glwidth || screen_texture_height < glheight) { R_Bloom_InitTextures(); } if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) { return; } // Set up full screen workspace. glViewport( 0, 0, glwidth, glheight ); glDisable( GL_DEPTH_TEST ); glMatrixMode( GL_PROJECTION ); glLoadIdentity (); glOrtho(0, glwidth, glheight, 0, -10, 100); glMatrixMode( GL_MODELVIEW ); glLoadIdentity (); glDisable(GL_CULL_FACE); glDisable( GL_BLEND ); glEnable( GL_TEXTURE_2D ); glColor4f( 1, 1, 1, 1 ); // Setup current sizes curView_x = scr_vrect.x * ((float)glwidth / vid.width); curView_y = scr_vrect.y * ((float)glheight / vid.height); curView_width = scr_vrect.width * ((float)glwidth / vid.width); curView_height = scr_vrect.height * ((float)glheight / vid.height); screenText_tcw = ((float)curView_width / (float)screen_texture_width); screenText_tch = ((float)curView_height / (float)screen_texture_height); if( scr_vrect.height > scr_vrect.width ) { sampleText_tcw = ((float)scr_vrect.width / (float)scr_vrect.height); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; sampleText_tch = ((float)scr_vrect.height / (float)scr_vrect.width); } sample_width = BLOOM_SIZE * sampleText_tcw; sample_height = BLOOM_SIZE * sampleText_tch; // Copy the screen space we'll use to work into the backup texture. GL_Bind(r_bloombackuptexture); //glBindTexture(GL_TEXTURE_2D, r_bloombackuptexture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_size * sampleText_tcw, r_screenbackuptexture_size * sampleText_tch); // Create the bloom image. R_Bloom_DownsampleView(); R_Bloom_GeneratexDiamonds(); //R_Bloom_GeneratexCross(); // Restore the screen-backup to the screen. glDisable(GL_BLEND); GL_Bind(r_bloombackuptexture); glColor4f( 1, 1, 1, 1 ); R_Bloom_Quad( 0, glheight - (r_screenbackuptexture_size * sampleText_tch), r_screenbackuptexture_size * sampleText_tcw, r_screenbackuptexture_size * sampleText_tch, sampleText_tcw, sampleText_tch ); R_Bloom_DrawEffect(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }
/* * R_BloomBlend */ void R_BloomBlend( const refdef_t *fd ) { if( !( fd->rdflags & RDF_BLOOM ) || !r_bloom->integer ) return; if( !BLOOM_SIZE ) R_Bloom_InitTextures(); if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) return; // set up full screen workspace GL_Scissor( 0, 0, glState.width, glState.height ); GL_Viewport( 0, 0, glState.width, glState.height ); qglMatrixMode( GL_PROJECTION ); qglLoadIdentity(); qglOrtho( 0, glState.width, glState.height, 0, -10, 100 ); qglMatrixMode( GL_MODELVIEW ); qglLoadIdentity(); GL_Cull( 0 ); GL_SetState( GLSTATE_NO_DEPTH_TEST ); qglColor4f( 1, 1, 1, 1 ); // set up current sizes curView_x = fd->x; curView_y = fd->y; curView_width = fd->width; curView_height = fd->height; screenTex_tcw = ( (float)curView_width / (float)screen_texture_width ); screenTex_tch = ( (float)curView_height / (float)screen_texture_height ); if( curView_height > curView_width ) { sampleText_tcw = ( (float)curView_width / (float)curView_height ); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; sampleText_tch = ( (float)curView_height / (float)curView_width ); } sample_width = ( BLOOM_SIZE * sampleText_tcw ); sample_height = ( BLOOM_SIZE * sampleText_tch ); // copy the screen space we'll use to work into the backup texture GL_Bind( 0, r_bloombackuptexture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_width, r_screenbackuptexture_height ); // create the bloom image R_Bloom_DownsampleView(); R_Bloom_GeneratexDiamonds(); // restore the screen-backup to the screen GL_SetState( GLSTATE_NO_DEPTH_TEST ); GL_Bind( 0, r_bloombackuptexture ); qglColor4f( 1, 1, 1, 1 ); R_Bloom_Quad( 0, 0, r_screenbackuptexture_width, r_screenbackuptexture_height, 1.0f, 1.0f ); GL_Scissor( ri.scissor[0], ri.scissor[1], ri.scissor[2], ri.scissor[3] ); R_Bloom_DrawEffect(); GL_Viewport( ri.viewport[0], ri.viewport[1], ri.viewport[2], ri.viewport[3] ); }
/* * R_InitBloomTextures */ void R_InitBloomTextures( void ) { BLOOM_SIZE = 0; R_Bloom_InitTextures(); }
/* ================= R_BloomBlend ================= */ void R_BloomBlend( const ref_params_t *fd ) { if( !r_bloom->value ) return; if( !BLOOM_SIZE ) R_Bloom_InitTextures(); if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) return; // set up full screen workspace pglScissor( 0, 0, glState.width, glState.height ); pglViewport( 0, 0, glState.width, glState.height ); pglMatrixMode( GL_PROJECTION ); pglLoadIdentity(); pglOrtho( 0, glState.width, glState.height, 0, -10, 100 ); pglMatrixMode( GL_MODELVIEW ); pglLoadIdentity(); pglDisable( GL_DEPTH_TEST ); pglDisable( GL_ALPHA_TEST ); pglDepthMask( GL_FALSE ); pglDisable( GL_BLEND ); GL_Cull( 0 ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // set up current sizes curView_x = fd->viewport[0]; curView_y = fd->viewport[1]; curView_width = fd->viewport[2]; curView_height = fd->viewport[3]; screenTex_tcw = ( (float)curView_width / (float)screen_texture_width ); screenTex_tch = ( (float)curView_height / (float)screen_texture_height ); if( curView_height > curView_width ) { sampleText_tcw = ( (float)curView_width / (float)curView_height ); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; sampleText_tch = ( (float)curView_height / (float)curView_width ); } sample_width = ( BLOOM_SIZE * sampleText_tcw ); sample_height = ( BLOOM_SIZE * sampleText_tch ); // copy the screen space we'll use to work into the backup texture GL_Bind( GL_TEXTURE0, r_bloombackuptexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_width * sampleText_tcw, r_screenbackuptexture_height * sampleText_tch ); // create the bloom image R_Bloom_DownsampleView(); R_Bloom_GeneratexDiamonds(); pglDisable( GL_BLEND ); // restore the screen-backup to the screen GL_Bind( GL_TEXTURE0, r_bloombackuptexture ); pglColor4f( 1, 1, 1, 1 ); R_Bloom_Quad( 0, glState.height - (r_screenbackuptexture_height * sampleText_tch), r_screenbackuptexture_width * sampleText_tcw, r_screenbackuptexture_height * sampleText_tch, sampleText_tcw, sampleText_tch ); pglScissor( RI.scissor[0], RI.scissor[1], RI.scissor[2], RI.scissor[3] ); R_Bloom_DrawEffect(); pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] ); pglMatrixMode( GL_PROJECTION ); GL_LoadMatrix( RI.projectionMatrix ); pglMatrixMode( GL_MODELVIEW ); GL_LoadMatrix( RI.worldviewMatrix ); pglEnable( GL_DEPTH_TEST ); pglDepthMask( GL_TRUE ); pglDisable( GL_BLEND ); GL_Cull( GL_FRONT ); }
void R_BloomBlend ( refdef_t *fd ) { if( !(fd->rdflags & RDF_BLOOM) || !r_bloom->value || r_showtris->value ) return; if( !BLOOM_SIZE ) R_Bloom_InitTextures(); if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) return; //set up full screen workspace qglViewport ( 0, 0, vid.width, vid.height ); GL_TexEnv (GL_REPLACE); // Knightmare added GL_Disable (GL_DEPTH_TEST); qglMatrixMode (GL_PROJECTION); qglLoadIdentity (); qglOrtho(0, vid.width, vid.height, 0, -10, 100); qglMatrixMode (GL_MODELVIEW); qglLoadIdentity (); GL_Disable (GL_CULL_FACE); GL_Disable (GL_BLEND); qglEnable (GL_TEXTURE_2D); qglColor4f (1, 1, 1, 1); //set up current sizes curView_x = fd->x; curView_y = fd->y; curView_width = fd->width; curView_height = fd->height; screenText_tcw = ((float)fd->width / (float)screen_texture_width); screenText_tch = ((float)fd->height / (float)screen_texture_height); if( fd->height > fd->width ) { sampleText_tcw = ((float)fd->width / (float)fd->height); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; sampleText_tch = ((float)fd->height / (float)fd->width); } sample_width = BLOOM_SIZE * sampleText_tcw; sample_height = BLOOM_SIZE * sampleText_tch; //copy the screen space we'll use to work into the backup texture GL_Bind(r_bloombackuptexture->texnum); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_size * sampleText_tcw, r_screenbackuptexture_size * sampleText_tch); //create the bloom image R_Bloom_DownsampleView(); R_Bloom_GeneratexDiamonds( fd ); //R_Bloom_GeneratexCross(); //restore the screen-backup to the screen GL_Disable(GL_BLEND); GL_Bind(r_bloombackuptexture->texnum); qglColor4f( 1, 1, 1, 1 ); R_Bloom_Quad( 0, vid.height - (r_screenbackuptexture_size * sampleText_tch), r_screenbackuptexture_size * sampleText_tcw, r_screenbackuptexture_size * sampleText_tch, sampleText_tcw, sampleText_tch ); R_Bloom_DrawEffect( fd ); // Knightmare added R_SetupGL (); GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qglEnable (GL_TEXTURE_2D); qglColor4f(1,1,1,1); }