2006-03-03 03:31:19 +00:00
/*
Copyright ( C ) 1997 - 2001 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2010-01-17 06:42:30 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2006-03-03 03:31:19 +00:00
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2008-02-21 03:19:46 +00:00
// gl_bloom.c: 2D lighting post process effect
2006-03-03 03:31:19 +00:00
2012-01-17 07:57:46 +00:00
/*
info about bloom algo :
bloom is basically smudging .
screen is nearest - downsampled to some usable scale and filtered to remove low - value light ( this is what stops non - bright stuff from blooming )
this filtered image is then downsized multiple times
the downsized image is then blured
the downsized images are then blured horizontally , and then vertically .
final pass simply adds each blured level to the original image .
all samples are then added together for final rendering ( with some kind of tone mapping if you want proper hdr ) .
note : the horizontal / vertical bluring is a guassian filter
note : bloom comes from the fact that the most downsampled image doesn ' t have too many pixels . the pixels that it does have are spread over a large area .
http : //prideout.net/archive/bloom/ contains some sample code
*/
2006-03-03 03:31:19 +00:00
//http://www.quakesrc.org/forums/viewtopic.php?t=4340&start=0
# include "quakedef.h"
2007-05-25 22:16:29 +00:00
2009-11-04 21:16:50 +00:00
# ifdef GLQUAKE
2012-01-17 07:57:46 +00:00
# include "shader.h"
# include "glquake.h"
2012-05-11 01:57:00 +00:00
cvar_t r_bloom = CVARAFD ( " r_bloom " , " 0 " , " gl_bloom " , CVAR_ARCHIVE , " Enables bloom (light bleeding from bright objects). Fractional values reduce the amount shown. " ) ;
cvar_t r_bloom_filter = CVARD ( " r_bloom_filter " , " 0.5 0.5 0.5 " , " Controls how bright the image must get before it will bloom (3 separate values, in RGB order). " ) ;
cvar_t r_bloom_scale = CVARD ( " r_bloom_scale " , " 0.5 " , " Controls the initial downscale size. Smaller values will bloom further but be more random. " ) ;
2012-01-17 07:57:46 +00:00
static shader_t * bloomfilter ;
static shader_t * bloomrescale ;
static shader_t * bloomblur ;
static shader_t * bloomfinal ;
# define MAXLEVELS 3
texid_t scrtex ;
texid_t pingtex [ 2 ] [ MAXLEVELS ] ;
2014-02-07 08:38:40 +00:00
fbostate_t fbo_bloom ;
2012-01-17 07:57:46 +00:00
static int scrwidth , scrheight ;
static int texwidth [ MAXLEVELS ] , texheight [ MAXLEVELS ] ;
void R_BloomRegister ( void )
{
Cvar_Register ( & r_bloom , " bloom " ) ;
2012-05-11 01:57:00 +00:00
Cvar_Register ( & r_bloom_filter , " bloom " ) ;
Cvar_Register ( & r_bloom_scale , " bloom " ) ;
2012-01-17 07:57:46 +00:00
}
static void R_SetupBloomTextures ( int w , int h )
{
int i , j ;
char name [ 64 ] ;
2012-05-11 01:57:00 +00:00
if ( w = = scrwidth & & h = = scrheight & & ! r_bloom_scale . modified )
2012-01-17 07:57:46 +00:00
return ;
2012-05-11 01:57:00 +00:00
r_bloom_scale . modified = false ;
2012-01-17 07:57:46 +00:00
scrwidth = w ;
scrheight = h ;
2012-05-11 01:57:00 +00:00
//I'm depending on npot here
w * = r_bloom_scale . value ;
h * = r_bloom_scale . value ;
2012-01-17 07:57:46 +00:00
for ( i = 0 ; i < MAXLEVELS ; i + + )
{
w / = 2 ;
h / = 2 ;
/*I'm paranoid*/
if ( w < 4 )
w = 4 ;
if ( h < 4 )
h = 4 ;
texwidth [ i ] = w ;
texheight [ i ] = h ;
}
/*we should be doing this outside of this code*/
if ( ! TEXVALID ( scrtex ) )
2013-03-12 23:18:37 +00:00
scrtex = GL_AllocNewTexture ( " " , scrwidth , scrheight , IF_NOMIPMAP | IF_NOPICMIP ) ;
2012-01-17 07:57:46 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , scrtex ) ;
qglTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , scrwidth , scrheight , 0 , GL_RGBA , GL_UNSIGNED_BYTE , NULL ) ;
/*top level uses nearest sampling*/
2012-05-11 01:57:00 +00:00
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;
2012-01-17 07:57:46 +00:00
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE ) ;
/*now create textures for each level*/
for ( j = 0 ; j < MAXLEVELS ; j + + )
{
for ( i = 0 ; i < 2 ; i + + )
{
if ( ! TEXVALID ( pingtex [ i ] [ j ] ) )
{
sprintf ( name , " ***bloom*%c*%i*** " , ' a ' + i , j ) ;
2013-03-12 23:18:37 +00:00
TEXASSIGN ( pingtex [ i ] [ j ] , GL_AllocNewTexture ( name , texwidth [ j ] , texheight [ j ] , IF_NOMIPMAP | IF_NOPICMIP ) ) ;
2012-01-17 07:57:46 +00:00
}
GL_MTBind ( 0 , GL_TEXTURE_2D , pingtex [ i ] [ j ] ) ;
qglTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , texwidth [ j ] , texheight [ j ] , 0 , GL_RGBA , GL_UNSIGNED_BYTE , NULL ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE ) ;
}
}
2013-08-21 07:14:39 +00:00
bloomfilter = R_RegisterShader ( " bloom_filter " , SUF_NONE ,
2012-01-17 07:57:46 +00:00
" { \n "
" cull none \n "
" program bloom_filter \n "
" { \n "
" map $sourcecolour \n "
" } \n "
" } \n " ) ;
2013-08-21 07:14:39 +00:00
bloomrescale = R_RegisterShader ( " bloom_rescale " , SUF_NONE ,
2012-01-17 07:57:46 +00:00
" { \n "
" cull none \n "
" program default2d \n "
" { \n "
" map $sourcecolour \n "
" } \n "
" } \n " ) ;
2013-08-21 07:14:39 +00:00
bloomblur = R_RegisterShader ( " bloom_blur " , SUF_NONE ,
2012-01-17 07:57:46 +00:00
" { \n "
" cull none \n "
" program bloom_blur \n "
" { \n "
" map $sourcecolour \n "
" } \n "
" } \n " ) ;
2013-08-21 07:14:39 +00:00
bloomfinal = R_RegisterShader ( " bloom_final " , SUF_NONE ,
2012-01-17 07:57:46 +00:00
" { \n "
" cull none \n "
" program bloom_final \n "
" { \n "
" map $sourcecolour \n "
" } \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $loweroverlay \n "
" } \n "
" { \n "
" map $upperoverlay \n "
" } \n "
" } \n " ) ;
bloomfinal - > defaulttextures . base = pingtex [ 0 ] [ 0 ] ;
bloomfinal - > defaulttextures . loweroverlay = pingtex [ 0 ] [ 1 ] ;
bloomfinal - > defaulttextures . upperoverlay = pingtex [ 0 ] [ 2 ] ;
}
void R_BloomBlend ( void )
{
int i ;
2014-02-07 08:38:40 +00:00
int oldfbo = 0 ;
2012-01-17 07:57:46 +00:00
if ( ! gl_config . ext_framebuffer_objects )
return ;
if ( ! gl_config . arb_shader_objects )
return ;
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
if ( ! r_config . texture_non_power_of_two )
2012-05-11 01:57:00 +00:00
return ;
2012-01-17 07:57:46 +00:00
/*whu?*/
if ( ! r_refdef . pxrect . width | | ! r_refdef . pxrect . height )
return ;
/*update textures if we need to resize them*/
R_SetupBloomTextures ( r_refdef . pxrect . width , r_refdef . pxrect . height ) ;
/*grab the screen, because we failed to do it earlier*/
GL_MTBind ( 0 , GL_TEXTURE_2D , scrtex ) ;
2013-11-21 23:02:28 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , r_refdef . pxrect . x , r_refdef . pxrect . maxheight - ( r_refdef . pxrect . y + r_refdef . pxrect . height ) , r_refdef . pxrect . width , r_refdef . pxrect . height ) ;
2013-03-12 23:18:37 +00:00
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ;
2012-01-17 07:57:46 +00:00
for ( i = 0 ; i < MAXLEVELS ; i + + )
{
2013-03-12 23:18:37 +00:00
if ( i = = 0 )
{
/*filter the screen into a downscaled image*/
2014-02-07 08:38:40 +00:00
oldfbo = GLBE_FBO_Update ( & fbo_bloom , true , FBO_TEX_COLOUR , pingtex [ 0 ] [ 0 ] , r_nulltex , 0 , 0 ) ;
GLBE_FBO_Sources ( scrtex , r_nulltex ) ;
2013-03-12 23:18:37 +00:00
qglViewport ( 0 , 0 , texwidth [ 0 ] , texheight [ 0 ] ) ;
R2D_ScalePic ( 0 , vid . height , vid . width , - ( int ) vid . height , bloomfilter ) ;
}
else
{
/*simple downscale that multiple times*/
2014-02-07 08:38:40 +00:00
GLBE_FBO_Update ( & fbo_bloom , true , FBO_TEX_COLOUR , pingtex [ 0 ] [ i ] , r_nulltex , 0 , 0 ) ;
GLBE_FBO_Sources ( pingtex [ 0 ] [ i - 1 ] , r_nulltex ) ;
2013-03-12 23:18:37 +00:00
qglViewport ( 0 , 0 , texwidth [ i ] , texheight [ i ] ) ;
R2D_ScalePic ( 0 , vid . height , vid . width , - ( int ) vid . height , bloomrescale ) ;
}
// }
// for (i = 0; i < MAXLEVELS; i++)
// {
/*gaussian filter the mips to bloom more smoothly
the blur is done with two passes . first samples horizontally then vertically .
the 1.2 pixels thing gives us a 5 * 5 filter by weighting the edge accordingly
*/
2012-01-17 07:57:46 +00:00
r_worldentity . glowmod [ 0 ] = 1.2 / texwidth [ i ] ;
r_worldentity . glowmod [ 1 ] = 0 ;
2014-02-07 08:38:40 +00:00
GLBE_FBO_Update ( & fbo_bloom , true , FBO_TEX_COLOUR , pingtex [ 1 ] [ i ] , r_nulltex , 0 , 0 ) ;
GLBE_FBO_Sources ( pingtex [ 0 ] [ i ] , r_nulltex ) ;
2012-01-17 07:57:46 +00:00
qglViewport ( 0 , 0 , texwidth [ i ] , texheight [ i ] ) ;
R2D_ScalePic ( 0 , vid . height , vid . width , - ( int ) vid . height , bloomblur ) ;
2013-03-12 23:18:37 +00:00
2012-01-17 07:57:46 +00:00
r_worldentity . glowmod [ 0 ] = 0 ;
r_worldentity . glowmod [ 1 ] = 1.2 / texheight [ i ] ;
2014-02-07 08:38:40 +00:00
GLBE_FBO_Update ( & fbo_bloom , true , FBO_TEX_COLOUR , pingtex [ 0 ] [ i ] , r_nulltex , 0 , 0 ) ;
GLBE_FBO_Sources ( pingtex [ 1 ] [ i ] , r_nulltex ) ;
2012-01-17 07:57:46 +00:00
qglViewport ( 0 , 0 , texwidth [ i ] , texheight [ i ] ) ;
R2D_ScalePic ( 0 , vid . height , vid . width , - ( int ) vid . height , bloomblur ) ;
}
2013-11-21 23:02:28 +00:00
r_worldentity . glowmod [ 0 ] = 0 ;
r_worldentity . glowmod [ 1 ] = 0 ;
2012-01-17 07:57:46 +00:00
GL_Set2D ( false ) ;
/*combine them onto the screen*/
2014-02-07 08:38:40 +00:00
GLBE_FBO_Pop ( oldfbo ) ;
GLBE_FBO_Sources ( scrtex , r_nulltex ) ;
2012-01-17 07:57:46 +00:00
R2D_ScalePic ( r_refdef . vrect . x , r_refdef . vrect . y + r_refdef . vrect . height , r_refdef . vrect . width , - r_refdef . vrect . height , bloomfinal ) ;
}
void R_InitBloomTextures ( void )
{
bloomfilter = NULL ;
bloomblur = NULL ;
bloomfinal = NULL ;
scrwidth = 0 , scrheight = 0 ;
if ( ! gl_config . ext_framebuffer_objects )
return ;
}
# elif defined(GLQUAKE)
2006-03-03 03:31:19 +00:00
# include "glquake.h"
2010-01-17 06:42:30 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2006-03-03 03:31:19 +00:00
LIGHT BLOOMS
2010-01-17 06:42:30 +00:00
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2010-07-11 02:22:39 +00:00
cvar_t r_bloom = CVARAFD ( " r_bloom " , " 0 " , " gl_bloom " , CVAR_ARCHIVE , " Enables bloom (light bleeding from bright objects) " ) ;
cvar_t r_bloom_alpha = CVAR ( " r_bloom_alpha " , " 0.5 " ) ;
cvar_t r_bloom_diamond_size = CVAR ( " r_bloom_diamond_size " , " 8 " ) ;
cvar_t r_bloom_intensity = CVAR ( " r_bloom_intensity " , " 1 " ) ;
cvar_t r_bloom_darken = CVAR ( " r_bloom_darken " , " 3 " ) ;
cvar_t r_bloom_sample_size = CVARF ( " r_bloom_sample_size " , " 256 " , CVAR_RENDERERLATCH ) ;
cvar_t r_bloom_fast_sample = CVARF ( " r_bloom_fast_sample " , " 0 " , CVAR_RENDERERLATCH ) ;
2008-02-21 03:19:46 +00:00
typedef struct {
//texture numbers
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
texid_t tx_screen ; /*a copy of the screen*/
texid_t tx_effect ; /*blured copy of bright pixels*/
texid_t tx_backup ; /*a copy of the screen to replace the pixels that we'll clobber. FIXME: use a FBO instead*/
2009-11-04 21:16:50 +00:00
texid_t tx_downsample ;
2008-02-21 03:19:46 +00:00
//the viewport dimensions
int vp_x ;
int vp_y ;
int vp_w ;
int vp_h ;
//texture coordinates of screen data inside screentexture
float scr_s ;
float scr_t ;
//dimensions of the screen texture (power of two)
int scr_w ;
int scr_h ;
//downsampled dimensions (will always be smaller than viewport)
int smp_w ;
int smp_h ;
//tex coords to be used for the sample
float smp_s ;
float smp_t ;
int size_downsample ;
int size_backup ;
int size_sample ;
} bloomstate_t ;
static bloomstate_t bs ;
2006-03-03 03:31:19 +00:00
//this macro is in sample size workspace coordinates
2008-02-21 03:19:46 +00:00
# define R_Bloom_SamplePass( xpos, ypos ) \
qglBegin ( GL_QUADS ) ; \
qglTexCoord2f ( 0 , bs . smp_t ) ; \
qglVertex2f ( xpos , ypos ) ; \
qglTexCoord2f ( 0 , 0 ) ; \
qglVertex2f ( xpos , ypos + bs . smp_h ) ; \
qglTexCoord2f ( bs . smp_s , 0 ) ; \
qglVertex2f ( xpos + bs . smp_w , ypos + bs . smp_h ) ; \
qglTexCoord2f ( bs . smp_s , bs . smp_t ) ; \
qglVertex2f ( xpos + bs . smp_w , ypos ) ; \
2006-03-03 03:31:19 +00:00
qglEnd ( ) ;
# define R_Bloom_Quad( x, y, width, height, textwidth, textheight ) \
qglBegin ( GL_QUADS ) ; \
qglTexCoord2f ( 0 , textheight ) ; \
qglVertex2f ( x , y ) ; \
qglTexCoord2f ( 0 , 0 ) ; \
qglVertex2f ( x , y + height ) ; \
qglTexCoord2f ( textwidth , 0 ) ; \
qglVertex2f ( x + width , y + height ) ; \
qglTexCoord2f ( textwidth , textheight ) ; \
qglVertex2f ( x + width , y ) ; \
qglEnd ( ) ;
/*
= = = = = = = = = = = = = = = = =
R_Bloom_InitBackUpTexture
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_InitBackUpTexture ( int widthheight )
2006-03-03 03:31:19 +00:00
{
qbyte * data ;
2010-01-17 06:42:30 +00:00
2008-02-21 03:19:46 +00:00
data = Z_Malloc ( widthheight * widthheight * 4 ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
bs . size_backup = widthheight ;
2009-11-04 21:16:50 +00:00
bs . tx_backup = GL_LoadTexture32 ( " ***bs.tx_backup*** " , bs . size_backup , bs . size_backup , ( unsigned int * ) data , IF_NOMIPMAP | IF_NOALPHA | IF_NOGAMMA ) ;
2010-01-17 06:42:30 +00:00
2008-02-21 03:19:46 +00:00
Z_Free ( data ) ;
2006-03-03 03:31:19 +00:00
}
/*
= = = = = = = = = = = = = = = = =
R_Bloom_InitEffectTexture
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_InitEffectTexture ( void )
2006-03-03 03:31:19 +00:00
{
qbyte * data ;
float bloomsizecheck ;
2010-01-17 06:42:30 +00:00
2008-02-21 03:19:46 +00:00
if ( r_bloom_sample_size . value < 32 )
2006-03-03 03:31:19 +00:00
Cvar_SetValue ( & r_bloom_sample_size , 32 ) ;
//make sure bloom size is a power of 2
2010-01-18 20:09:55 +00:00
bs . size_sample = min ( r_bloom_sample_size . value , gl_max_size . value ) ;
2008-02-21 03:19:46 +00:00
bloomsizecheck = ( float ) bs . size_sample ;
while ( bloomsizecheck > 1.0f ) bloomsizecheck / = 2.0f ;
if ( bloomsizecheck ! = 1.0f )
2006-03-03 03:31:19 +00:00
{
2008-02-21 03:19:46 +00:00
bs . size_sample = 32 ;
while ( bs . size_sample < r_bloom_sample_size . value )
bs . size_sample * = 2 ;
2006-03-03 03:31:19 +00:00
}
//make sure bloom size doesn't have stupid values
2008-02-21 03:19:46 +00:00
if ( bs . size_sample > bs . scr_w | |
bs . size_sample > bs . scr_h )
bs . size_sample = min ( bs . scr_w , bs . scr_h ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
if ( bs . size_sample ! = r_bloom_sample_size . value )
Cvar_SetValue ( & r_bloom_sample_size , bs . size_sample ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
data = Z_Malloc ( bs . size_sample * bs . size_sample * 4 ) ;
2006-03-03 03:31:19 +00:00
2009-11-04 21:16:50 +00:00
bs . tx_effect = GL_LoadTexture32 ( " ***bs.tx_effect*** " , bs . size_sample , bs . size_sample , ( unsigned int * ) data , IF_NOMIPMAP | IF_NOALPHA | IF_NOGAMMA ) ;
2010-01-17 06:42:30 +00:00
2008-02-21 03:19:46 +00:00
Z_Free ( data ) ;
2006-03-03 03:31:19 +00:00
}
/*
= = = = = = = = = = = = = = = = =
R_Bloom_InitTextures
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_InitTextures ( void )
2006-03-03 03:31:19 +00:00
{
qbyte * data ;
int size ;
int maxtexsize ;
2010-01-17 06:42:30 +00:00
//find closer power of 2 to screen size
2009-11-04 21:16:50 +00:00
for ( bs . scr_w = 1 ; bs . scr_w < vid . pixelwidth ; bs . scr_w * = 2 ) ;
for ( bs . scr_h = 1 ; bs . scr_h < vid . pixelheight ; bs . scr_h * = 2 ) ;
2006-03-03 03:31:19 +00:00
//disable blooms if we can't handle a texture of that size
qglGetIntegerv ( GL_MAX_TEXTURE_SIZE , & maxtexsize ) ;
2008-02-21 03:19:46 +00:00
if ( bs . scr_w > maxtexsize | |
bs . scr_h > maxtexsize )
{
bs . scr_w = bs . scr_h = 0 ;
2006-03-03 03:31:19 +00:00
Cvar_SetValue ( & r_bloom , 0 ) ;
2008-02-21 03:19:46 +00:00
Con_Printf ( " WARNING: 'R_InitBloomScreenTexture' too high resolution for Light Bloom. Effect disabled \n " ) ;
2006-03-03 03:31:19 +00:00
return ;
}
//init the screen texture
2008-02-21 03:19:46 +00:00
size = bs . scr_w * bs . scr_h * 4 ;
data = Z_Malloc ( size ) ;
memset ( data , 255 , size ) ;
2009-11-04 21:16:50 +00:00
if ( ! TEXVALID ( bs . tx_screen ) )
2011-10-27 16:16:29 +00:00
bs . tx_screen = GL_AllocNewTexture ( " ***bloom screen*** " , bs . scr_w , bs . scr_h ) ;
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_screen ) ;
2009-11-04 21:16:50 +00:00
qglTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGB , bs . scr_w , bs . scr_h , 0 , GL_RGBA , GL_UNSIGNED_BYTE , data ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST ) ;
qglTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST ) ;
2008-02-21 03:19:46 +00:00
Z_Free ( data ) ;
2006-03-03 03:31:19 +00:00
//validate bloom size and init the bloom effect texture
R_Bloom_InitEffectTexture ( ) ;
//if screensize is more than 2x the bloom effect texture, set up for stepped downsampling
2009-11-04 21:16:50 +00:00
bs . tx_downsample = r_nulltex ;
2008-02-21 03:19:46 +00:00
bs . size_downsample = 0 ;
2009-11-04 21:16:50 +00:00
if ( vid . pixelwidth > ( bs . size_sample * 2 ) & & ! r_bloom_fast_sample . value )
2006-03-03 03:31:19 +00:00
{
2008-02-21 03:19:46 +00:00
bs . size_downsample = ( int ) ( bs . size_sample * 2 ) ;
data = Z_Malloc ( bs . size_downsample * bs . size_downsample * 4 ) ;
2009-11-04 21:16:50 +00:00
bs . tx_downsample = GL_LoadTexture32 ( " ***bs.tx_downsample*** " , bs . size_downsample , bs . size_downsample , ( unsigned int * ) data , IF_NOMIPMAP | IF_NOALPHA | IF_NOGAMMA ) ;
2008-02-21 03:19:46 +00:00
Z_Free ( data ) ;
2006-03-03 03:31:19 +00:00
}
//Init the screen backup texture
2008-02-21 03:19:46 +00:00
if ( bs . size_downsample )
R_Bloom_InitBackUpTexture ( bs . size_downsample ) ;
2006-03-03 03:31:19 +00:00
else
2008-02-21 03:19:46 +00:00
R_Bloom_InitBackUpTexture ( bs . size_sample ) ;
2006-03-03 03:31:19 +00:00
}
void R_BloomRegister ( void )
{
Cvar_Register ( & r_bloom , " bloom " ) ;
Cvar_Register ( & r_bloom_alpha , " bloom " ) ;
Cvar_Register ( & r_bloom_diamond_size , " bloom " ) ;
Cvar_Register ( & r_bloom_intensity , " bloom " ) ;
Cvar_Register ( & r_bloom_darken , " bloom " ) ;
Cvar_Register ( & r_bloom_sample_size , " bloom " ) ;
Cvar_Register ( & r_bloom_fast_sample , " bloom " ) ;
}
/*
= = = = = = = = = = = = = = = = =
R_InitBloomTextures
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_InitBloomTextures ( void )
2006-03-03 03:31:19 +00:00
{
2008-02-21 03:19:46 +00:00
bs . size_sample = 0 ;
2009-11-04 21:16:50 +00:00
if ( ! r_bloom . ival )
2006-03-03 03:31:19 +00:00
return ;
2009-11-04 21:16:50 +00:00
bs . tx_screen = r_nulltex ; //this came from a vid_restart, where none of the textures are valid any more.
2006-03-03 03:31:19 +00:00
R_Bloom_InitTextures ( ) ;
}
/*
= = = = = = = = = = = = = = = = =
R_Bloom_DrawEffect
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_DrawEffect ( void )
2006-03-03 03:31:19 +00:00
{
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_effect ) ;
2006-03-03 03:31:19 +00:00
qglEnable ( GL_BLEND ) ;
qglBlendFunc ( GL_ONE , GL_ONE ) ;
qglColor4f ( r_bloom_alpha . value , r_bloom_alpha . value , r_bloom_alpha . value , 1.0f ) ;
GL_TexEnv ( GL_MODULATE ) ;
2010-01-17 06:42:30 +00:00
qglBegin ( GL_QUADS ) ;
2008-02-21 03:19:46 +00:00
qglTexCoord2f ( 0 , bs . smp_t ) ;
qglVertex2f ( bs . vp_x , bs . vp_y ) ;
qglTexCoord2f ( 0 , 0 ) ;
qglVertex2f ( bs . vp_x , bs . vp_y + bs . vp_h ) ;
qglTexCoord2f ( bs . smp_s , 0 ) ;
qglVertex2f ( bs . vp_x + bs . vp_w , bs . vp_y + bs . vp_h ) ;
qglTexCoord2f ( bs . smp_s , bs . smp_t ) ;
qglVertex2f ( bs . vp_x + bs . vp_w , bs . vp_y ) ;
2006-03-03 03:31:19 +00:00
qglEnd ( ) ;
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
qglDisable ( GL_BLEND ) ;
}
#if 0
/*
= = = = = = = = = = = = = = = = =
R_Bloom_GeneratexCross - alternative bluring method
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_GeneratexCross ( void )
2006-03-03 03:31:19 +00:00
{
int i ;
static int BLOOM_BLUR_RADIUS = 8 ;
//static float BLOOM_BLUR_INTENSITY = 2.5f;
float BLOOM_BLUR_INTENSITY ;
static float intensity ;
static float range ;
//set up sample size workspace
2008-02-21 03:19:46 +00:00
qglViewport ( 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
qglMatrixMode ( GL_PROJECTION ) ;
qglLoadIdentity ( ) ;
2008-02-21 03:19:46 +00:00
qglOrtho ( 0 , bs . smp_w , bs . smp_h , 0 , - 10 , 100 ) ;
2006-03-03 03:31:19 +00:00
qglMatrixMode ( GL_MODELVIEW ) ;
qglLoadIdentity ( ) ;
2008-02-21 03:19:46 +00:00
//copy small scene into bs.tx_effect
GL_Bind ( 0 , bs . tx_effect ) ;
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
//start modifying the small scene corner
qglColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
qglEnable ( GL_BLEND ) ;
//darkening passes
if ( r_bloom_darken . value )
{
qglBlendFunc ( GL_DST_COLOR , GL_ZERO ) ;
GL_TexEnv ( GL_MODULATE ) ;
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
for ( i = 0 ; i < r_bloom_darken - > integer ; i + + ) {
R_Bloom_SamplePass ( 0 , 0 ) ;
}
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
}
//bluring passes
if ( BLOOM_BLUR_RADIUS ) {
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
qglBlendFunc ( GL_ONE , GL_ONE ) ;
range = ( float ) BLOOM_BLUR_RADIUS ;
BLOOM_BLUR_INTENSITY = r_bloom_intensity . value ;
//diagonal-cross draw 4 passes to add initial smooth
qglColor4f ( 0.5f , 0.5f , 0.5f , 1.0 ) ;
R_Bloom_SamplePass ( 1 , 1 ) ;
R_Bloom_SamplePass ( - 1 , 1 ) ;
R_Bloom_SamplePass ( - 1 , - 1 ) ;
R_Bloom_SamplePass ( 1 , - 1 ) ;
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
for ( i = - ( BLOOM_BLUR_RADIUS + 1 ) ; i < BLOOM_BLUR_RADIUS ; i + + ) {
intensity = BLOOM_BLUR_INTENSITY / ( range * 2 + 1 ) * ( 1 - fabs ( i * i ) / ( float ) ( range * range ) ) ;
if ( intensity < 0.05f ) continue ;
qglColor4f ( intensity , intensity , intensity , 1.0f ) ;
R_Bloom_SamplePass ( i , 0 ) ;
//R_Bloom_SamplePass( -i, 0 );
}
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
//for(i=0;i<BLOOM_BLUR_RADIUS;i++) {
for ( i = - ( BLOOM_BLUR_RADIUS + 1 ) ; i < BLOOM_BLUR_RADIUS ; i + + ) {
intensity = BLOOM_BLUR_INTENSITY / ( range * 2 + 1 ) * ( 1 - fabs ( i * i ) / ( float ) ( range * range ) ) ;
if ( intensity < 0.05f ) continue ;
qglColor4f ( intensity , intensity , intensity , 1.0f ) ;
R_Bloom_SamplePass ( 0 , i ) ;
//R_Bloom_SamplePass( 0, -i );
}
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
}
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
//restore full screen workspace
qglViewport ( 0 , 0 , glState . width , glState . height ) ;
qglMatrixMode ( GL_PROJECTION ) ;
qglLoadIdentity ( ) ;
qglOrtho ( 0 , glState . width , glState . height , 0 , - 10 , 100 ) ;
qglMatrixMode ( GL_MODELVIEW ) ;
qglLoadIdentity ( ) ;
}
# endif
/*
= = = = = = = = = = = = = = = = =
R_Bloom_GeneratexDiamonds
= = = = = = = = = = = = = = = = =
*/
2008-02-21 03:19:46 +00:00
void R_Bloom_GeneratexDiamonds ( void )
2006-03-03 03:31:19 +00:00
{
int i , j ;
2008-02-21 03:19:46 +00:00
float intensity ;
2006-03-03 03:31:19 +00:00
//set up sample size workspace
2008-02-21 03:19:46 +00:00
qglViewport ( 0 , 0 , bs . smp_w , bs . smp_h ) ;
qglMatrixMode ( GL_PROJECTION ) ;
qglLoadIdentity ( ) ;
qglOrtho ( 0 , bs . smp_w , bs . smp_h , 0 , - 10 , 100 ) ;
qglMatrixMode ( GL_MODELVIEW ) ;
qglLoadIdentity ( ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
//copy small scene into bs.tx_effect
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_effect ) ;
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
//start modifying the small scene corner
qglColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
qglEnable ( GL_BLEND ) ;
//darkening passes
2008-02-21 03:19:46 +00:00
if ( r_bloom_darken . value )
2006-03-03 03:31:19 +00:00
{
qglBlendFunc ( GL_DST_COLOR , GL_ZERO ) ;
GL_TexEnv ( GL_MODULATE ) ;
2010-01-17 06:42:30 +00:00
2008-02-21 03:19:46 +00:00
for ( i = 0 ; i < r_bloom_darken . value ; i + + )
{
R_Bloom_SamplePass ( 0 , 0 ) ;
2006-03-03 03:31:19 +00:00
}
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
}
//bluring passes
//qglBlendFunc(GL_ONE, GL_ONE);
qglBlendFunc ( GL_ONE , GL_ONE_MINUS_SRC_COLOR ) ;
2008-02-21 03:19:46 +00:00
{
2010-01-18 20:09:55 +00:00
int size = r_bloom_diamond_size . value ;
float rad = r_bloom_diamond_size . value / 2.0f ;
float point = ( r_bloom_diamond_size . value - 1 ) / 2.0f ;
float mult = min ( 1.0f , r_bloom_intensity . value * 2.0f / rad ) ;
2006-03-03 03:31:19 +00:00
2010-01-18 20:09:55 +00:00
for ( i = 0 ; i < size ; i + + )
2008-02-21 03:19:46 +00:00
{
2010-01-18 20:09:55 +00:00
for ( j = 0 ; j < size ; j + + )
2008-02-21 03:19:46 +00:00
{
2010-01-18 20:09:55 +00:00
float f = ( ( point + 1.0f ) - ( fabs ( point - i ) + fabs ( point - j ) ) ) / ( point + 1.0f ) ;
//float f = 1.0f - (fabs(point - i) * fabs(point - j) / (point * point)); // circle/cross?
intensity = mult * f ;
if ( intensity < 0.005f )
2008-02-21 03:19:46 +00:00
continue ;
qglColor4f ( intensity , intensity , intensity , 1.0 ) ;
2010-01-18 20:09:55 +00:00
R_Bloom_SamplePass ( i - rad , j - rad ) ;
2006-03-03 03:31:19 +00:00
}
}
2008-02-21 03:19:46 +00:00
}
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , bs . smp_w , bs . smp_h ) ;
2006-03-03 03:31:19 +00:00
//restore full screen workspace
2009-11-04 21:16:50 +00:00
qglViewport ( 0 , 0 , vid . pixelwidth , vid . pixelheight ) ;
2008-02-21 03:19:46 +00:00
qglMatrixMode ( GL_PROJECTION ) ;
2006-03-03 03:31:19 +00:00
qglLoadIdentity ( ) ;
2009-11-04 21:16:50 +00:00
qglOrtho ( 0 , vid . pixelwidth , vid . pixelheight , 0 , - 10 , 100 ) ;
2008-02-21 03:19:46 +00:00
qglMatrixMode ( GL_MODELVIEW ) ;
2006-03-03 03:31:19 +00:00
qglLoadIdentity ( ) ;
2010-01-17 06:42:30 +00:00
}
2006-03-03 03:31:19 +00:00
/*
= = = = = = = = = = = = = = = = =
R_Bloom_DownsampleView
= = = = = = = = = = = = = = = = =
*/
void R_Bloom_DownsampleView ( void )
{
2008-02-21 03:19:46 +00:00
qglDisable ( GL_BLEND ) ;
qglColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2006-03-03 03:31:19 +00:00
//stepped downsample
2008-02-21 03:19:46 +00:00
if ( bs . size_downsample )
2006-03-03 03:31:19 +00:00
{
2008-02-21 03:19:46 +00:00
int midsample_width = bs . size_downsample * bs . smp_s ;
int midsample_height = bs . size_downsample * bs . smp_t ;
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
//copy the screen and draw resized
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_screen ) ;
2009-11-04 21:16:50 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , bs . vp_x , vid . pixelheight - ( bs . vp_y + bs . vp_h ) , bs . vp_w , bs . vp_h ) ;
2008-02-21 03:19:46 +00:00
2009-11-04 21:16:50 +00:00
R_Bloom_Quad ( 0 , vid . pixelheight - midsample_height , midsample_width , midsample_height , bs . scr_s , bs . scr_t ) ;
2008-02-21 03:19:46 +00:00
2006-03-03 03:31:19 +00:00
//now copy into Downsampling (mid-sized) texture
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_downsample ) ;
2006-03-03 03:31:19 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , midsample_width , midsample_height ) ;
//now draw again in bloom size
2008-02-21 03:19:46 +00:00
qglColor4f ( 0.5f , 0.5f , 0.5f , 1.0f ) ;
2009-11-04 21:16:50 +00:00
R_Bloom_Quad ( 0 , vid . pixelheight - bs . smp_h , bs . smp_w , bs . smp_h , bs . smp_s , bs . smp_t ) ;
2006-04-08 15:16:47 +00:00
2006-03-03 03:31:19 +00:00
//now blend the big screen texture into the bloom generation space (hoping it adds some blur)
2008-02-21 03:19:46 +00:00
qglEnable ( GL_BLEND ) ;
2006-03-03 03:31:19 +00:00
qglBlendFunc ( GL_ONE , GL_ONE ) ;
2008-02-21 03:19:46 +00:00
qglColor4f ( 0.5f , 0.5f , 0.5f , 1.0f ) ;
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_screen ) ;
2009-11-04 21:16:50 +00:00
R_Bloom_Quad ( 0 , vid . pixelheight - bs . smp_h , bs . smp_w , bs . smp_h , bs . scr_s , bs . scr_t ) ;
2008-02-21 03:19:46 +00:00
qglColor4f ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
qglDisable ( GL_BLEND ) ;
}
else
{ //downsample simple
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_screen ) ;
2009-11-04 21:16:50 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , bs . vp_x , vid . pixelheight - ( bs . vp_y + bs . vp_h ) , bs . vp_w , bs . vp_h ) ;
R_Bloom_Quad ( 0 , vid . pixelheight - bs . smp_h , bs . smp_w , bs . smp_h , bs . scr_s , bs . scr_t ) ;
2006-03-03 03:31:19 +00:00
}
}
/*
= = = = = = = = = = = = = = = = =
R_BloomBlend
= = = = = = = = = = = = = = = = =
*/
2010-07-11 02:22:39 +00:00
void R_BloomBlend ( void )
2006-03-03 03:31:19 +00:00
{
2008-02-21 03:19:46 +00:00
int buw , buh ;
2006-03-03 03:31:19 +00:00
2009-11-04 21:16:50 +00:00
if ( ! bs . size_sample | | bs . scr_w < vid . pixelwidth | | bs . scr_h < vid . pixelheight )
2006-03-03 03:31:19 +00:00
R_Bloom_InitTextures ( ) ;
2008-02-21 03:19:46 +00:00
if ( bs . scr_w < bs . size_sample | |
bs . scr_h < bs . size_sample )
2006-03-03 03:31:19 +00:00
return ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
PPL_RevertToKnownState ( ) ;
2011-10-27 16:16:29 +00:00
# ifdef warningmsg
# pragma warningmsg("Note: Bloom doesn't use the backend.")
2011-05-29 04:26:29 +00:00
# endif
2010-03-14 14:35:56 +00:00
2006-03-03 03:31:19 +00:00
//set up full screen workspace
2009-11-04 21:16:50 +00:00
qglViewport ( 0 , 0 , vid . pixelwidth , vid . pixelheight ) ;
2008-02-21 03:19:46 +00:00
qglDisable ( GL_DEPTH_TEST ) ;
qglMatrixMode ( GL_PROJECTION ) ;
qglLoadIdentity ( ) ;
2009-11-04 21:16:50 +00:00
qglOrtho ( 0 , vid . pixelwidth , vid . pixelheight , 0 , - 10 , 100 ) ;
2008-02-21 03:19:46 +00:00
qglMatrixMode ( GL_MODELVIEW ) ;
qglLoadIdentity ( ) ;
2009-11-04 21:16:50 +00:00
GL_CullFace ( 0 ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
qglDisable ( GL_BLEND ) ;
qglEnable ( GL_TEXTURE_2D ) ;
2006-03-03 03:31:19 +00:00
2008-02-21 03:19:46 +00:00
qglColor4f ( 1 , 1 , 1 , 1 ) ;
2006-04-08 15:16:47 +00:00
2006-03-03 03:31:19 +00:00
//set up current sizes
2010-07-11 02:22:39 +00:00
bs . vp_x = r_refdef . pxrect . x ;
bs . vp_y = vid . pixelheight - r_refdef . pxrect . y ;
bs . vp_w = r_refdef . pxrect . width ;
bs . vp_h = r_refdef . pxrect . height ;
2008-02-21 03:19:46 +00:00
bs . scr_s = ( float ) bs . vp_w / ( float ) bs . scr_w ;
bs . scr_t = ( float ) bs . vp_h / ( float ) bs . scr_h ;
if ( bs . vp_h > bs . vp_w )
{
bs . smp_s = ( float ) bs . vp_w / ( float ) bs . vp_h ;
bs . smp_t = 1.0f ;
2006-03-03 03:31:19 +00:00
}
2008-02-21 03:19:46 +00:00
else
{
bs . smp_s = 1.0f ;
bs . smp_t = ( float ) bs . vp_h / ( float ) bs . vp_w ;
}
bs . smp_w = bs . size_sample * bs . smp_s ;
bs . smp_h = bs . size_sample * bs . smp_t ;
2006-04-08 15:16:47 +00:00
2008-02-21 03:19:46 +00:00
bs . smp_s = ( float ) bs . smp_w / bs . size_sample ;
bs . smp_t = ( float ) bs . smp_h / bs . size_sample ;
2010-01-18 20:09:55 +00:00
buw = bs . size_backup * bs . smp_s ;
buh = bs . size_backup * bs . smp_t ;
2010-01-17 06:42:30 +00:00
2006-03-03 03:31:19 +00:00
//copy the screen space we'll use to work into the backup texture
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_backup ) ;
2008-02-21 03:19:46 +00:00
qglCopyTexSubImage2D ( GL_TEXTURE_2D , 0 , 0 , 0 , 0 , 0 , buw , buh ) ;
2006-03-03 03:31:19 +00:00
//create the bloom image
R_Bloom_DownsampleView ( ) ;
2008-02-21 03:19:46 +00:00
2006-03-03 03:31:19 +00:00
R_Bloom_GeneratexDiamonds ( ) ;
//R_Bloom_GeneratexCross();
//restore the screen-backup to the screen
qglDisable ( GL_BLEND ) ;
2011-02-25 04:22:14 +00:00
GL_MTBind ( 0 , GL_TEXTURE_2D , bs . tx_backup ) ;
2008-02-21 03:19:46 +00:00
qglColor4f ( 1 , 1 , 1 , 1 ) ;
2010-01-17 06:42:30 +00:00
R_Bloom_Quad ( 0 ,
2009-11-04 21:16:50 +00:00
vid . pixelheight - ( buh ) ,
2008-02-21 03:19:46 +00:00
buw ,
buh ,
bs . smp_s ,
bs . smp_t ) ;
2006-03-03 03:31:19 +00:00
R_Bloom_DrawEffect ( ) ;
qglBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
2006-04-08 15:16:47 +00:00
2012-04-24 07:59:11 +00:00
checkglerror ( ) ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
PPL_RevertToKnownState ( ) ;
2006-03-04 20:43:48 +00:00
}
2007-03-28 13:27:35 +00:00
# endif