2004-10-19 15:56:22 +00:00
/*
Copyright ( C ) 2002 - 2003 Victor Luchits
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-11-26 06:58:48 +00:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
2004-10-19 15:56:22 +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 .
*/
// r_shader.c - based on code by Stephen C. Taylor
2010-07-11 02:22:39 +00:00
// Ported to FTE from qfusion, there are numerous changes since then.
2004-10-19 15:56:22 +00:00
# include "quakedef.h"
2009-11-04 21:16:50 +00:00
# ifndef SERVERONLY
2004-10-19 15:56:22 +00:00
# include "glquake.h"
# include "shader.h"
2004-11-23 01:23:45 +00:00
# include "hash.h"
2004-10-19 15:56:22 +00:00
2004-12-09 23:42:00 +00:00
# include <ctype.h>
2012-09-30 05:52:03 +00:00
# ifdef D3D9QUAKE
2011-09-03 03:49:43 +00:00
# include <d3d9.h>
extern LPDIRECT3DDEVICE9 pD3DDev9 ;
# endif
2009-11-04 21:16:50 +00:00
extern texid_t missing_texture ;
2012-02-12 05:18:31 +00:00
texid_t r_whiteimage ;
2009-11-04 21:16:50 +00:00
static qboolean shader_reload_needed ;
2010-07-11 02:22:39 +00:00
static qboolean shader_rescan_needed ;
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
sh_config_t sh_config ;
2009-11-04 21:16:50 +00:00
//cvars that affect shader generation
2011-12-05 15:23:40 +00:00
cvar_t r_vertexlight = CVARFD ( " r_vertexlight " , " 0 " , CVAR_SHADERSYSTEM , " Hack loaded shaders to remove detail pass and lightmap sampling for faster rendering. " ) ;
2012-01-17 07:57:46 +00:00
extern cvar_t r_glsl_offsetmapping_reliefmapping ;
2011-04-30 17:21:10 +00:00
extern cvar_t r_deluxemapping ;
2010-07-11 02:22:39 +00:00
extern cvar_t r_fastturb , r_fastsky , r_skyboxname ;
2009-11-04 21:16:50 +00:00
extern cvar_t r_drawflat ;
2014-03-30 08:55:06 +00:00
extern cvar_t r_shaderblobs ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
//backend fills this in to say the max pass count
int be_maxpasses ;
2004-10-19 15:56:22 +00:00
# define Q_stricmp stricmp
2011-12-23 03:12:29 +00:00
# define Q_strnicmp strnicmp
2004-10-19 15:56:22 +00:00
# define clamp(v,min, max) (v) = (((v)<(min))?(min):(((v)>(max))?(max):(v)));
typedef union {
float f ;
unsigned int i ;
} float_int_t ;
qbyte FloatToByte ( float x )
{
static float_int_t f2i ;
// shift float to have 8bit fraction at base of number
f2i . f = x + 32768.0f ;
// then read as integer and kill float bits...
return ( qbyte ) min ( f2i . i & 0x7FFFFF , 255 ) ;
}
cvar_t r_detailtextures ;
------------------------------------------------------------------------
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
# define MAX_TOKEN_CHARS sizeof(com_token)
2004-10-19 15:56:22 +00:00
------------------------------------------------------------------------
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
char * COM_ParseExt ( char * * data_p , qboolean nl , qboolean comma )
2004-10-19 15:56:22 +00:00
{
int c ;
int len ;
char * data ;
qboolean newlines = false ;
data = * data_p ;
len = 0 ;
com_token [ 0 ] = 0 ;
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
if ( ! data )
{
* data_p = NULL ;
return " " ;
}
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
// skip whitespace
skipwhite :
2009-11-04 21:16:50 +00:00
while ( ( c = * data ) < = ' ' )
2004-10-19 15:56:22 +00:00
{
if ( c = = 0 )
{
* data_p = NULL ;
return " " ;
}
if ( c = = ' \n ' )
newlines = true ;
data + + ;
}
2009-11-04 21:16:50 +00:00
if ( newlines & & ! nl )
{
2004-10-19 15:56:22 +00:00
* data_p = data ;
return com_token ;
}
// skip // comments
if ( c = = ' / ' & & data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
// handle quoted strings specially
if ( c = = ' \" ' )
{
data + + ;
while ( 1 )
{
c = * data + + ;
if ( c = = ' \" ' | | ! c )
{
com_token [ len ] = 0 ;
* data_p = data ;
return com_token ;
}
if ( len < MAX_TOKEN_CHARS )
{
com_token [ len ] = c ;
len + + ;
}
}
}
// parse a regular word
do
{
if ( len < MAX_TOKEN_CHARS )
{
com_token [ len ] = c ;
len + + ;
}
data + + ;
c = * data ;
------------------------------------------------------------------------
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 ( c = = ' , ' & & len & & comma )
2011-02-25 04:22:14 +00:00
break ;
2004-10-19 15:56:22 +00:00
} while ( c > 32 ) ;
if ( len = = MAX_TOKEN_CHARS )
{
2013-03-12 22:47:42 +00:00
Con_DPrintf ( " Token exceeded %i chars, discarded. \n " , ( int ) MAX_TOKEN_CHARS ) ;
2004-10-19 15:56:22 +00:00
len = 0 ;
}
com_token [ len ] = 0 ;
* data_p = data ;
return com_token ;
}
2013-03-12 23:13:39 +00:00
static float Shader_FloatArgument ( shader_t * shader , char * arg )
{
char * var ;
int arglen = strlen ( arg ) ;
2004-10-19 15:56:22 +00:00
2013-03-12 23:13:39 +00:00
//grab an argument instead, otherwise 0
var = shader - > name ;
2013-05-11 05:03:07 +00:00
while ( ( var = strchr ( var , ' # ' ) ) )
2013-03-12 23:13:39 +00:00
{
if ( ! strnicmp ( var , arg , arglen ) )
{
if ( var [ arglen ] = = ' = ' )
return strtod ( var + arglen + 1 , NULL ) ;
if ( var [ arglen ] = = ' # ' | | ! var [ arglen ] )
return 1 ; //present, but no value
}
var + + ;
}
return 0 ; //not present.
}
2004-10-19 15:56:22 +00:00
# define HASH_SIZE 128
2014-03-30 08:55:06 +00:00
enum shaderparsemode_e
{
SPM_DEFAULT , /*quake3/fte internal*/
SPM_DOOM3 ,
} ;
static struct
{
enum shaderparsemode_e mode ;
} parsestate ;
2004-10-19 15:56:22 +00:00
typedef struct shaderkey_s
{
char * keyword ;
void ( * func ) ( shader_t * shader , shaderpass_t * pass , char * * ptr ) ;
} shaderkey_t ;
2014-03-30 08:55:06 +00:00
typedef struct shadercachefile_s {
char * data ;
size_t length ;
enum shaderparsemode_e parsemode ;
struct shadercachefile_s * next ;
char name [ 1 ] ;
} shadercachefile_t ;
2004-10-19 15:56:22 +00:00
typedef struct shadercache_s {
2014-03-30 08:55:06 +00:00
shadercachefile_t * source ;
size_t offset ;
2004-10-19 15:56:22 +00:00
struct shadercache_s * hash_next ;
2014-03-30 08:55:06 +00:00
char name [ 1 ] ;
2004-10-19 15:56:22 +00:00
} shadercache_t ;
2014-03-30 08:55:06 +00:00
static shadercachefile_t * shaderfiles ; //contents of a .shader file
static shadercache_t * * shader_hash ; //locations of known inactive shaders.
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
unsigned int r_numshaders ; //number of active slots in r_shaders array.
unsigned int r_maxshaders ; //max length of r_shaders array. resized if exceeded.
shader_t * * r_shaders ; //list of active shaders for a id->shader lookup
static hashtable_t shader_active_hash ; //list of active shaders for a name->shader lookup
2010-07-11 02:22:39 +00:00
void * shader_active_hash_mem ;
2004-10-19 15:56:22 +00:00
2004-12-09 23:42:00 +00:00
//static char r_skyboxname[MAX_QPATH];
//static float r_skyheight;
2004-10-19 15:56:22 +00:00
char * Shader_Skip ( char * ptr ) ;
2013-03-12 23:13:39 +00:00
static qboolean Shader_Parsetok ( shader_t * shader , shaderpass_t * pass , shaderkey_t * keys , char * token , char * * ptr ) ;
static void Shader_ParseFunc ( shader_t * shader , char * * args , shaderfunc_t * func ) ;
2014-03-30 08:55:06 +00:00
static void Shader_MakeCache ( const char * path ) ;
static qboolean Shader_LocateSource ( char * name , char * * buf , size_t * bufsize , size_t * offset , enum shaderparsemode_e * parsemode ) ;
2011-12-05 15:23:40 +00:00
static void Shader_ReadShader ( shader_t * s , char * shadersource , int parsemode ) ;
2014-03-30 08:55:06 +00:00
static qboolean Shader_ParseShader ( char * parsename , shader_t * s ) ;
2004-10-19 15:56:22 +00:00
//===========================================================================
------------------------------------------------------------------------
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
static qboolean Shader_EvaluateCondition ( shader_t * shader , char * * ptr )
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
{
char * token ;
cvar_t * cv ;
qboolean conditiontrue = true ;
------------------------------------------------------------------------
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
token = COM_ParseExt ( ptr , false , false ) ;
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
if ( * token = = ' ! ' )
{
conditiontrue = false ;
token + + ;
}
if ( * token = = ' $ ' )
{
token + + ;
2013-03-12 23:13:39 +00:00
if ( * token = = ' # ' )
conditiontrue = conditiontrue = = ! ! Shader_FloatArgument ( shader , token ) ;
else if ( ! Q_stricmp ( token , " lpp " ) )
2011-12-23 03:12:29 +00:00
conditiontrue = conditiontrue = = r_lightprepass . ival ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " lightmap " ) )
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
conditiontrue = conditiontrue = = ! r_fullbright . value ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " deluxmap " ) )
2011-10-27 16:16:29 +00:00
conditiontrue = conditiontrue = = r_deluxemapping . ival ;
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
//normalmaps are generated if they're not already known.
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " normalmap " ) )
2011-10-27 16:16:29 +00:00
conditiontrue = conditiontrue = = r_loadbumpmapping ;
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
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " opengl " ) )
2012-09-30 05:52:03 +00:00
conditiontrue = conditiontrue = = ( qrenderer = = QR_OPENGL ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " d3d9 " ) )
2012-09-30 05:52:03 +00:00
conditiontrue = conditiontrue = = ( qrenderer = = QR_DIRECT3D9 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " d3d11 " ) )
2012-09-30 05:52:03 +00:00
conditiontrue = conditiontrue = = ( qrenderer = = QR_DIRECT3D11 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " gles " ) )
2014-03-30 08:55:06 +00:00
conditiontrue = conditiontrue = = ( ( qrenderer = = QR_OPENGL ) & & sh_config . minver = = 100 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " nofixed " ) )
2014-03-30 08:55:06 +00:00
conditiontrue = conditiontrue = = sh_config . progs_required ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " glsl " ) )
2014-03-30 08:55:06 +00:00
conditiontrue = conditiontrue = = ( ( qrenderer = = QR_OPENGL ) & & sh_config . progs_supported ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " hlsl " ) )
2014-03-30 08:55:06 +00:00
conditiontrue = conditiontrue = = ( ( qrenderer = = QR_DIRECT3D9 | | qrenderer = = QR_DIRECT3D11 ) & & sh_config . progs_supported ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " haveprogram " ) )
------------------------------------------------------------------------
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
conditiontrue = conditiontrue = = ! ! shader - > prog ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " programs " ) )
2014-03-30 08:55:06 +00:00
conditiontrue = conditiontrue = = sh_config . progs_supported ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " diffuse " ) )
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
conditiontrue = conditiontrue = = true ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " specular " ) )
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
conditiontrue = conditiontrue = = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " fullbright " ) )
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
conditiontrue = conditiontrue = = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " topoverlay " ) )
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
conditiontrue = conditiontrue = = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " loweroverlay " ) )
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
conditiontrue = conditiontrue = = false ;
else
2011-03-12 13:51:40 +00:00
{
Con_Printf ( " Unrecognised builtin shader condition '%s' \n " , token ) ;
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
conditiontrue = conditiontrue = = false ;
2011-03-12 13:51:40 +00:00
}
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
}
else
{
2014-08-25 07:35:41 +00:00
float lhs ;
2014-08-27 08:41:31 +00:00
if ( * token > = ' 0 ' & & * token < = ' 9 ' )
lhs = strtod ( token , NULL ) ;
2014-08-25 07:35:41 +00:00
else
{
2014-08-27 08:41:31 +00:00
cv = Cvar_Get ( token , " " , 0 , " Shader Conditions " ) ;
if ( cv )
{
cv - > flags | = CVAR_SHADERSYSTEM ;
lhs = cv - > value ;
}
else
2014-08-25 07:35:41 +00:00
{
Con_Printf ( " Shader_EvaluateCondition: '%s' is not a cvar \n " , token ) ;
return conditiontrue ;
}
2012-04-09 19:12:12 +00:00
}
2013-04-06 03:36:00 +00:00
if ( * token )
token = COM_ParseExt ( ptr , false , false ) ;
2010-11-10 03:32:47 +00:00
if ( * token )
{
float rhs ;
char cmp [ 4 ] ;
memcpy ( cmp , token , 4 ) ;
------------------------------------------------------------------------
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
token = COM_ParseExt ( ptr , false , false ) ;
2010-11-10 03:32:47 +00:00
rhs = atof ( token ) ;
if ( ! strcmp ( cmp , " != " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs ! = rhs ;
2010-11-10 03:32:47 +00:00
else if ( ! strcmp ( cmp , " == " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs = = rhs ;
2010-11-10 03:32:47 +00:00
else if ( ! strcmp ( cmp , " < " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs < rhs ;
2010-11-10 03:32:47 +00:00
else if ( ! strcmp ( cmp , " <= " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs < = rhs ;
2010-11-10 03:32:47 +00:00
else if ( ! strcmp ( cmp , " > " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs > rhs ;
2010-11-10 03:32:47 +00:00
else if ( ! strcmp ( cmp , " >= " ) )
2014-08-25 07:35:41 +00:00
conditiontrue = lhs > = rhs ;
2010-11-10 03:32:47 +00:00
else
conditiontrue = false ;
}
else
{
2014-09-02 02:44:43 +00:00
conditiontrue = conditiontrue = = ! ! lhs ;
2010-11-10 03:32:47 +00:00
}
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
}
2013-04-06 03:36:00 +00:00
if ( * token )
token = COM_ParseExt ( ptr , false , false ) ;
2011-03-12 13:51:40 +00:00
if ( ! strcmp ( token , " && " ) )
------------------------------------------------------------------------
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
return Shader_EvaluateCondition ( shader , ptr ) & & conditiontrue ;
2011-03-12 13:51:40 +00:00
if ( ! strcmp ( token , " || " ) )
------------------------------------------------------------------------
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
return Shader_EvaluateCondition ( shader , ptr ) | | conditiontrue ;
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
return conditiontrue ;
}
------------------------------------------------------------------------
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
static char * Shader_ParseExactString ( char * * ptr )
{
char * token ;
2013-03-12 23:13:39 +00:00
if ( ! ptr | | ! ( * ptr ) )
------------------------------------------------------------------------
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
return " " ;
2013-03-12 23:13:39 +00:00
if ( ! * * ptr | | * * ptr = = ' } ' )
------------------------------------------------------------------------
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
return " " ;
token = COM_ParseExt ( ptr , false , false ) ;
return token ;
}
2013-03-12 23:13:39 +00:00
static char * Shader_ParseString ( char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2013-03-12 23:13:39 +00:00
if ( ! ptr | | ! ( * ptr ) )
2004-10-19 15:56:22 +00:00
return " " ;
2013-03-12 23:13:39 +00:00
if ( ! * * ptr | | * * ptr = = ' } ' )
2004-10-19 15:56:22 +00:00
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
token = COM_ParseExt ( ptr , false , true ) ;
2005-01-24 23:47:32 +00:00
Q_strlwr ( token ) ;
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
return token ;
}
2013-03-12 23:13:39 +00:00
static char * Shader_ParseSensString ( char * * ptr )
2010-07-11 02:22:39 +00:00
{
char * token ;
2013-03-12 23:13:39 +00:00
if ( ! ptr | | ! ( * ptr ) )
2010-07-11 02:22:39 +00:00
return " " ;
2013-03-12 23:13:39 +00:00
if ( ! * * ptr | | * * ptr = = ' } ' )
2010-07-11 02:22:39 +00:00
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
token = COM_ParseExt ( ptr , false , true ) ;
2010-11-26 06:58:48 +00:00
2010-07-11 02:22:39 +00:00
return token ;
}
2013-03-12 23:13:39 +00:00
static float Shader_ParseFloat ( shader_t * shader , char * * ptr )
2004-10-19 15:56:22 +00:00
{
2010-11-22 02:03:28 +00:00
char * token ;
if ( ! ptr | | ! ( * ptr ) )
2004-10-19 15:56:22 +00:00
return 0 ;
2010-11-22 02:03:28 +00:00
if ( ! * * ptr | | * * ptr = = ' } ' )
2004-10-19 15:56:22 +00:00
return 0 ;
------------------------------------------------------------------------
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
token = COM_ParseExt ( ptr , false , true ) ;
2010-11-22 02:03:28 +00:00
if ( * token = = ' $ ' )
{
2013-03-12 23:13:39 +00:00
if ( token [ 1 ] = = ' # ' )
{
return Shader_FloatArgument ( shader , token + 1 ) ;
}
else
{
cvar_t * var ;
var = Cvar_FindVar ( token + 1 ) ;
if ( var )
return var - > value ;
}
2010-11-22 02:03:28 +00:00
}
return atof ( token ) ;
2004-10-19 15:56:22 +00:00
}
2013-03-12 23:13:39 +00:00
static void Shader_ParseVector ( shader_t * shader , char * * ptr , vec3_t v )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
char * scratch ;
2004-10-19 15:56:22 +00:00
char * token ;
qboolean bracket ;
2013-12-29 22:48:28 +00:00
qboolean fromcvar = false ;
2004-10-19 15:56:22 +00:00
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
2009-11-04 21:16:50 +00:00
if ( * token = = ' $ ' )
{
cvar_t * var ;
var = Cvar_FindVar ( token + 1 ) ;
if ( ! var )
{
v [ 0 ] = 1 ;
v [ 1 ] = 1 ;
v [ 2 ] = 1 ;
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
var - > flags | = CVAR_SHADERSYSTEM ;
2009-11-04 21:16:50 +00:00
ptr = & scratch ;
scratch = var - > string ;
2010-07-11 02:22:39 +00:00
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
2013-12-29 22:48:28 +00:00
fromcvar = true ;
2009-11-04 21:16:50 +00:00
}
2013-03-12 23:13:39 +00:00
if ( ! Q_stricmp ( token , " ( " ) )
{
2004-10-19 15:56:22 +00:00
bracket = true ;
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
}
else if ( token [ 0 ] = = ' ( ' )
{
2004-10-19 15:56:22 +00:00
bracket = true ;
token = & token [ 1 ] ;
}
2013-03-12 23:13:39 +00:00
else
bracket = false ;
2004-10-19 15:56:22 +00:00
v [ 0 ] = atof ( token ) ;
2013-12-29 22:48:28 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! token [ 0 ] ) {
v [ 1 ] = fromcvar ? v [ 0 ] : 0 ;
} else if ( bracket & & token [ strlen ( token ) - 1 ] = = ' ) ' ) {
bracket = false ;
token [ strlen ( token ) - 1 ] = 0 ;
v [ 1 ] = atof ( token ) ;
} else {
v [ 1 ] = atof ( token ) ;
}
2004-10-19 15:56:22 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! token [ 0 ] ) {
2013-12-29 22:48:28 +00:00
v [ 2 ] = fromcvar ? v [ 1 ] : 0 ;
} else if ( bracket & & token [ strlen ( token ) - 1 ] = = ' ) ' ) {
2004-10-19 15:56:22 +00:00
token [ strlen ( token ) - 1 ] = 0 ;
v [ 2 ] = atof ( token ) ;
} else {
v [ 2 ] = atof ( token ) ;
if ( bracket ) {
Shader_ParseString ( ptr ) ;
}
}
2009-11-04 21:16:50 +00:00
if ( v [ 0 ] > 5 | | v [ 1 ] > 5 | | v [ 2 ] > 5 )
{
VectorScale ( v , 1.0f / 255 , v ) ;
}
2004-10-19 15:56:22 +00:00
}
2010-07-11 02:22:39 +00:00
qboolean Shader_ParseSkySides ( char * shadername , char * texturename , texid_t * images )
2004-10-19 15:56:22 +00:00
{
2010-07-11 02:22:39 +00:00
qboolean allokay = true ;
2009-11-04 21:16:50 +00:00
int i , ss , sp ;
2004-10-19 15:56:22 +00:00
char path [ MAX_QPATH ] ;
2009-11-04 21:16:50 +00:00
static char * skyname_suffix [ ] [ 6 ] = {
{ " rt " , " bk " , " lf " , " ft " , " up " , " dn " } ,
{ " px " , " py " , " nx " , " ny " , " pz " , " nz " } ,
{ " posx " , " posy " , " negx " , " negy " , " posz " , " negz " } ,
{ " _px " , " _py " , " _nx " , " _ny " , " _pz " , " _nz " } ,
{ " _posx " , " _posy " , " _negx " , " _negy " , " _posz " , " _negz " } ,
{ " _rt " , " _bk " , " _lf " , " _ft " , " _up " , " _dn " }
} ;
static char * skyname_pattern [ ] = {
" %s_%s " ,
" %s%s " ,
" env/%s%s " ,
" gfx/env/%s%s "
} ;
2004-10-19 15:56:22 +00:00
2010-07-11 02:22:39 +00:00
if ( * texturename = = ' $ ' )
2009-11-04 21:16:50 +00:00
{
cvar_t * v ;
2010-07-11 02:22:39 +00:00
v = Cvar_FindVar ( texturename + 1 ) ;
2009-11-04 21:16:50 +00:00
if ( v )
2010-07-11 02:22:39 +00:00
texturename = v - > string ;
2009-11-04 21:16:50 +00:00
}
2010-07-11 02:22:39 +00:00
if ( ! * texturename )
texturename = " - " ;
2004-10-19 15:56:22 +00:00
for ( i = 0 ; i < 6 ; i + + )
{
2010-07-11 02:22:39 +00:00
if ( texturename [ 0 ] = = ' - ' )
{
2009-11-04 21:16:50 +00:00
images [ i ] = r_nulltex ;
2010-07-11 02:22:39 +00:00
}
else
{
2009-11-04 21:16:50 +00:00
for ( sp = 0 ; sp < sizeof ( skyname_pattern ) / sizeof ( skyname_pattern [ 0 ] ) ; sp + + )
{
for ( ss = 0 ; ss < sizeof ( skyname_suffix ) / sizeof ( skyname_suffix [ 0 ] ) ; ss + + )
{
2014-03-30 08:55:06 +00:00
Q_snprintfz ( path , sizeof ( path ) , skyname_pattern [ sp ] , texturename , skyname_suffix [ ss ] [ i ] ) ;
2013-03-12 23:24:15 +00:00
images [ i ] = R_LoadHiResTexture ( path , NULL , IF_NOALPHA | IF_CLAMP ) ;
2009-11-04 21:16:50 +00:00
if ( TEXVALID ( images [ i ] ) )
break ;
}
if ( TEXVALID ( images [ i ] ) )
break ;
}
if ( ! TEXVALID ( images [ i ] ) )
2009-01-15 04:58:12 +00:00
{
2010-07-11 02:22:39 +00:00
Con_Printf ( " Sky \" %s \" missing texture: %s \n " , shadername , path ) ;
2006-01-12 22:24:06 +00:00
images [ i ] = missing_texture ;
2010-07-11 02:22:39 +00:00
allokay = false ;
2009-01-15 04:58:12 +00:00
}
2004-10-19 15:56:22 +00:00
}
}
2010-07-11 02:22:39 +00:00
return allokay ;
2004-10-19 15:56:22 +00:00
}
2005-04-16 16:21:27 +00:00
2013-03-12 23:13:39 +00:00
static void Shader_ParseFunc ( shader_t * shader , char * * ptr , shaderfunc_t * func )
2004-10-19 15:56:22 +00:00
{
char * token ;
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " sin " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_SIN ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " triangle " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_TRIANGLE ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " square " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_SQUARE ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " sawtooth " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_SAWTOOTH ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " inversesawtooth " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_INVERSESAWTOOTH ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " noise " ) )
2004-10-19 15:56:22 +00:00
func - > type = SHADER_FUNC_NOISE ;
2013-03-12 23:13:39 +00:00
func - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
func - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
func - > args [ 2 ] = Shader_ParseFloat ( shader , ptr ) ;
func - > args [ 3 ] = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
}
//===========================================================================
2012-09-30 05:52:03 +00:00
static int Shader_SetImageFlags ( shader_t * shader , shaderpass_t * pass , char * * name )
2004-10-19 15:56:22 +00:00
{
int flags = 0 ;
2011-12-23 03:12:29 +00:00
while ( name )
{
2014-08-03 14:47:47 +00:00
if ( ! Q_strnicmp ( * name , " $rt: " , 4 ) )
{
* name + = 4 ;
flags | = IF_RENDERTARGET ;
}
else if ( ! Q_strnicmp ( * name , " $clamp: " , 7 ) )
{
* name + = 7 ;
flags | = IF_CLAMP ;
}
else if ( ! Q_strnicmp ( * name , " $3d: " , 4 ) )
2011-12-23 03:12:29 +00:00
{
* name + = 4 ;
2013-06-23 02:17:02 +00:00
flags = ( flags & ~ IF_TEXTYPE ) | IF_3DMAP ;
}
else if ( ! Q_strnicmp ( * name , " $cube: " , 6 ) )
{
* name + = 6 ;
flags = ( flags & ~ IF_TEXTYPE ) | IF_CUBEMAP ;
2011-12-23 03:12:29 +00:00
}
2012-09-30 05:52:03 +00:00
else if ( ! Q_strnicmp ( * name , " $nearest: " , 9 ) )
{
* name + = 9 ;
flags | = IF_NEAREST ;
pass - > flags | = SHADER_PASS_NEAREST ;
}
2011-12-23 03:12:29 +00:00
else
name = NULL ;
}
2009-11-04 21:16:50 +00:00
// if (shader->flags & SHADER_SKY)
// flags |= IF_SKY;
if ( shader - > flags & SHADER_NOMIPMAPS )
flags | = IF_NOMIPMAP ;
if ( shader - > flags & SHADER_NOPICMIP )
flags | = IF_NOPICMIP ;
2004-10-19 15:56:22 +00:00
return flags ;
}
2009-11-04 21:16:50 +00:00
static texid_t Shader_FindImage ( char * name , int flags )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
if ( parsestate . mode = = SPM_DOOM3 )
2011-12-05 15:23:40 +00:00
{
if ( ! Q_stricmp ( name , " _default " ) )
return r_whiteimage ; /*fixme*/
if ( ! Q_stricmp ( name , " _white " ) )
return r_whiteimage ;
if ( ! Q_stricmp ( name , " _black " ) )
{
int wibuf [ 16 ] = { 0 } ;
2011-12-23 03:12:29 +00:00
return R_LoadTexture ( " $blackimage " , 4 , 4 , TF_RGBA32 , wibuf , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA ) ;
2011-12-05 15:23:40 +00:00
}
}
2009-11-04 21:16:50 +00:00
else
2011-12-05 15:23:40 +00:00
{
if ( ! Q_stricmp ( name , " $whiteimage " ) )
return r_whiteimage ;
}
2014-08-03 14:47:47 +00:00
if ( flags & IF_RENDERTARGET )
{
texid_t tid = R_FindTexture ( name , ( flags & ~ IF_RENDERTARGET ) | IF_NOMIPMAP ) ;
if ( ! TEXVALID ( tid ) )
tid = R_AllocNewTexture ( name , 0 , 0 , ( flags & ~ IF_RENDERTARGET ) | IF_NOMIPMAP ) ;
return tid ;
}
2011-12-05 15:23:40 +00:00
return R_LoadHiResTexture ( name , NULL , flags ) ;
2004-10-19 15:56:22 +00:00
}
/****************** shader keyword functions ************************/
static void Shader_Cull ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
shader - > flags & = ~ ( SHADER_CULL_FRONT | SHADER_CULL_BACK ) ;
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " disable " ) | | ! Q_stricmp ( token , " none " ) | | ! Q_stricmp ( token , " twosided " ) ) {
} else if ( ! Q_stricmp ( token , " front " ) ) {
shader - > flags | = SHADER_CULL_FRONT ;
} else if ( ! Q_stricmp ( token , " back " ) | | ! Q_stricmp ( token , " backside " ) | | ! Q_stricmp ( token , " backsided " ) ) {
shader - > flags | = SHADER_CULL_BACK ;
} else {
shader - > flags | = SHADER_CULL_FRONT ;
}
}
static void Shader_NoMipMaps ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = ( SHADER_NOMIPMAPS | SHADER_NOPICMIP ) ;
}
static void Shader_NoPicMip ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = SHADER_NOPICMIP ;
}
static void Shader_DeformVertexes ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
deformv_t * deformv ;
2013-03-12 23:13:39 +00:00
if ( shader - > numdeforms > = SHADER_DEFORM_MAX )
2004-10-19 15:56:22 +00:00
return ;
deformv = & shader - > deforms [ shader - > numdeforms ] ;
token = Shader_ParseString ( ptr ) ;
2013-03-12 23:13:39 +00:00
if ( ! Q_stricmp ( token , " wave " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_WAVE ;
2013-03-12 23:13:39 +00:00
deformv - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
if ( deformv - > args [ 0 ] )
2004-10-19 15:56:22 +00:00
deformv - > args [ 0 ] = 1.0f / deformv - > args [ 0 ] ;
2013-03-12 23:13:39 +00:00
Shader_ParseFunc ( shader , ptr , & deformv - > func ) ;
}
else if ( ! Q_stricmp ( token , " normal " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_NORMAL ;
2013-03-12 23:13:39 +00:00
deformv - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
deformv - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
}
else if ( ! Q_stricmp ( token , " bulge " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_BULGE ;
2013-03-12 23:13:39 +00:00
Shader_ParseVector ( shader , ptr , deformv - > args ) ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_DEFORMV_BULGE ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " move " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_MOVE ;
2013-03-12 23:13:39 +00:00
Shader_ParseVector ( shader , ptr , deformv - > args ) ;
Shader_ParseFunc ( shader , ptr , & deformv - > func ) ;
}
else if ( ! Q_stricmp ( token , " autosprite " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_AUTOSPRITE ;
shader - > flags | = SHADER_AUTOSPRITE ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " autosprite2 " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_AUTOSPRITE2 ;
shader - > flags | = SHADER_AUTOSPRITE ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " projectionShadow " ) )
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_PROJECTION_SHADOW ;
2013-03-12 23:13:39 +00:00
else
2004-10-19 15:56:22 +00:00
return ;
shader - > numdeforms + + ;
}
2010-07-11 02:22:39 +00:00
static void Shader_SkyParms ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
skydome_t * skydome ;
float skyheight ;
2010-07-11 02:22:39 +00:00
char * boxname ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
if ( shader - > skydome )
{
2010-07-11 02:22:39 +00:00
Z_Free ( shader - > skydome ) ;
2004-10-19 15:56:22 +00:00
}
2010-07-11 02:22:39 +00:00
skydome = ( skydome_t * ) Z_Malloc ( sizeof ( skydome_t ) ) ;
2004-10-19 15:56:22 +00:00
shader - > skydome = skydome ;
2010-07-11 02:22:39 +00:00
boxname = Shader_ParseString ( ptr ) ;
Shader_ParseSkySides ( shader - > name , boxname , skydome - > farbox_textures ) ;
2004-10-19 15:56:22 +00:00
2013-03-12 23:13:39 +00:00
skyheight = Shader_ParseFloat ( shader , ptr ) ;
2010-07-11 02:22:39 +00:00
if ( ! skyheight )
{
2004-10-19 15:56:22 +00:00
skyheight = 512.0f ;
}
2010-07-11 02:22:39 +00:00
boxname = Shader_ParseString ( ptr ) ;
Shader_ParseSkySides ( shader - > name , boxname , skydome - > nearbox_textures ) ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_SKY ;
shader - > sort = SHADER_SORT_SKY ;
}
static void Shader_FogParms ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
float div ;
vec3_t color , fcolor ;
// if ( !r_ignorehwgamma->value )
// div = 1.0f / pow(2, max(0, floor(r_overbrightbits->value)));
// else
div = 1.0f ;
2013-03-12 23:13:39 +00:00
Shader_ParseVector ( shader , ptr , color ) ;
2004-10-19 15:56:22 +00:00
VectorScale ( color , div , color ) ;
ColorNormalize ( color , fcolor ) ;
shader - > fog_color [ 0 ] = FloatToByte ( fcolor [ 0 ] ) ;
shader - > fog_color [ 1 ] = FloatToByte ( fcolor [ 1 ] ) ;
shader - > fog_color [ 2 ] = FloatToByte ( fcolor [ 2 ] ) ;
2010-11-26 06:58:48 +00:00
shader - > fog_color [ 3 ] = 255 ;
2013-03-12 23:13:39 +00:00
shader - > fog_dist = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
if ( shader - > fog_dist < = 0.0f ) {
shader - > fog_dist = 128.0f ;
}
shader - > fog_dist = 1.0f / shader - > fog_dist ;
2013-11-21 23:02:28 +00:00
shader - > flags | = SHADER_NODLIGHT | SHADER_NOSHADOWS ;
2004-10-19 15:56:22 +00:00
}
2005-05-26 12:55:34 +00:00
static void Shader_SurfaceParm ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " nodraw " ) )
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
shader - > flags | = SHADER_NODRAW ;
2014-06-08 20:27:35 +00:00
else if ( ! Q_stricmp ( token , " nodraw2 " ) )
shader - > flags | = SHADER_NODRAW ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " nodlight " ) )
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
shader - > flags | = SHADER_NODLIGHT ;
2005-05-26 12:55:34 +00:00
}
2004-10-19 15:56:22 +00:00
static void Shader_Sort ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
token = Shader_ParseString ( ptr ) ;
2011-09-03 03:49:43 +00:00
if ( ! Q_stricmp ( token , " portal " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_PORTAL ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " sky " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_SKY ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " opaque " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_OPAQUE ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " decal " ) )
2010-07-11 02:22:39 +00:00
shader - > sort = SHADER_SORT_DECAL ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " seethrough " ) )
2010-07-11 02:22:39 +00:00
shader - > sort = SHADER_SORT_SEETHROUGH ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " banner " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_BANNER ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " additive " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_ADDITIVE ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " underwater " ) )
2010-07-11 02:22:39 +00:00
shader - > sort = SHADER_SORT_UNDERWATER ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " nearest " ) )
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_NEAREST ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " blend " ) )
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
shader - > sort = SHADER_SORT_BLEND ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " lpp_light " ) )
shader - > sort = SHADER_SORT_PRELIGHT ;
2012-05-14 01:41:08 +00:00
else if ( ! Q_stricmp ( token , " ripple " ) )
shader - > sort = SHADER_SORT_RIPPLE ;
2011-09-03 03:49:43 +00:00
else
{
2004-10-19 15:56:22 +00:00
shader - > sort = atoi ( token ) ;
clamp ( shader - > sort , SHADER_SORT_NONE , SHADER_SORT_NEAREST ) ;
}
}
2011-09-03 03:49:43 +00:00
static void Shader_Prelight ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > sort = SHADER_SORT_PRELIGHT ;
}
2004-10-19 15:56:22 +00:00
static void Shader_Portal ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > sort = SHADER_SORT_PORTAL ;
}
static void Shader_PolygonOffset ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
2009-11-04 21:16:50 +00:00
/*the q3 defaults*/
shader - > polyoffset . factor = - 0.05 ;
shader - > polyoffset . unit = - 25 ;
2004-10-19 15:56:22 +00:00
}
static void Shader_EntityMergable ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = SHADER_ENTITY_MERGABLE ;
}
2011-01-23 03:44:49 +00:00
/*program text is already loaded, this function parses the 'header' of it to see which permutations it provides, and how many times we need to recompile it*/
2014-03-30 08:55:06 +00:00
static qboolean Shader_LoadPermutations ( char * name , program_t * prog , char * script , int qrtype , int ver , char * blobfilename )
2010-08-28 17:14:38 +00:00
{
2011-01-23 03:44:49 +00:00
static char * permutationname [ ] =
{
2010-08-28 17:14:38 +00:00
" #define BUMP \n " ,
2011-01-23 03:44:49 +00:00
" #define FULLBRIGHT \n " ,
2012-04-24 07:59:11 +00:00
" #define UPPERLOWER \n " ,
2012-09-30 05:52:03 +00:00
" #define DELUXE \n " ,
2011-07-30 14:14:56 +00:00
" #define SKELETAL \n " ,
2011-12-23 03:12:29 +00:00
" #define FOG \n " ,
2012-04-24 07:59:11 +00:00
" #define FRAMEBLEND \n " ,
2012-07-05 19:42:36 +00:00
" #define LIGHTSTYLED \n " ,
2011-01-23 03:44:49 +00:00
NULL
} ;
2013-10-08 14:28:11 +00:00
# define MAXMODIFIERS 64
2014-08-15 02:20:41 +00:00
const char * permutationdefines [ sizeof ( permutationname ) / sizeof ( permutationname [ 0 ] ) + MAXMODIFIERS + 1 ] ;
2011-01-23 03:44:49 +00:00
unsigned int nopermutation = ~ 0u ;
2013-10-08 14:28:11 +00:00
int nummodifiers = 0 ;
2011-01-23 03:44:49 +00:00
int p , n , pn ;
char * end ;
2014-03-30 08:55:06 +00:00
vfsfile_t * blobfile ;
unsigned int permuoffsets [ PERMUTATIONS ] , initoffset = 0 ;
unsigned int blobheaderoffset = 0 ;
qboolean blobadded ;
qboolean tess = false ;
2011-01-23 03:44:49 +00:00
2011-12-23 03:12:29 +00:00
char * cvarnames [ 64 ] ;
int cvartypes [ 64 ] ;
int cvarcount = 0 ;
2012-01-17 07:57:46 +00:00
qboolean onefailed = false ;
2012-11-29 13:37:48 +00:00
extern cvar_t gl_specular ;
2011-04-30 17:21:10 +00:00
2014-06-08 09:36:15 +00:00
ver = 0 ;
2012-09-30 05:52:03 +00:00
if ( qrenderer ! = qrtype )
{
return false ;
}
2011-12-23 03:12:29 +00:00
cvarnames [ cvarcount ] = NULL ;
2011-04-30 17:21:10 +00:00
2012-04-24 07:59:11 +00:00
prog - > nofixedcompat = true ;
2011-01-23 03:44:49 +00:00
for ( ; ; )
{
while ( * script = = ' ' | | * script = = ' \r ' | | * script = = ' \n ' | | * script = = ' \t ' )
script + + ;
2012-04-24 07:59:11 +00:00
if ( ! strncmp ( script , " !!fixed " , 7 ) )
2014-03-30 08:55:06 +00:00
{
2012-04-24 07:59:11 +00:00
prog - > nofixedcompat = false ;
2014-03-30 08:55:06 +00:00
script + = 7 ;
while ( * script & & * script ! = ' \n ' )
script + + ;
}
else if ( ! strncmp ( script , " !!tess " , 6 ) )
{
tess = true ;
script + = 6 ;
while ( * script & & * script ! = ' \n ' )
script + + ;
}
2013-10-08 14:28:11 +00:00
else if ( ! strncmp ( script , " !!cvardf " , 8 ) )
{
script + = 8 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
if ( nummodifiers < MAXMODIFIERS & & end - script < 64 )
{
cvar_t * var ;
char namebuf [ 64 ] ;
memcpy ( namebuf , script , end - script ) ;
namebuf [ end - script ] = 0 ;
var = Cvar_Get ( namebuf , " 0 " , CVAR_SHADERSYSTEM , " GLSL Variables " ) ;
if ( var )
permutationdefines [ nummodifiers + + ] = Z_StrDup ( va ( " #define %s %g \n " , namebuf , var - > value ) ) ;
}
script = end ;
}
2012-04-24 07:59:11 +00:00
else if ( ! strncmp ( script , " !!cvarf " , 7 ) )
2011-04-30 17:21:10 +00:00
{
script + = 7 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
2011-12-23 03:12:29 +00:00
if ( cvarcount + 1 ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
{
cvartypes [ cvarcount ] = SP_CVARF ;
cvarnames [ cvarcount + + ] = script ;
cvarnames [ cvarcount ] = NULL ;
}
script = end ;
}
------------------------------------------------------------------------
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
else if ( ! strncmp ( script , " !!cvari " , 7 ) )
{
script + = 7 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
if ( cvarcount + 1 ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
{
cvartypes [ cvarcount ] = SP_CVARI ;
cvarnames [ cvarcount + + ] = script ;
cvarnames [ cvarcount ] = NULL ;
}
script = end ;
}
2011-12-23 03:12:29 +00:00
else if ( ! strncmp ( script , " !!cvarv " , 7 ) )
{
script + = 7 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
if ( cvarcount + 1 ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
{
cvartypes [ cvarcount ] = SP_CVAR3F ;
cvarnames [ cvarcount + + ] = script ;
cvarnames [ cvarcount ] = NULL ;
}
2011-04-30 17:21:10 +00:00
script = end ;
}
else if ( ! strncmp ( script , " !!permu " , 7 ) )
2011-01-23 03:44:49 +00:00
{
script + = 7 ;
2011-04-30 17:21:10 +00:00
while ( * script = = ' ' | | * script = = ' \t ' )
2011-01-23 03:44:49 +00:00
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
for ( p = 0 ; permutationname [ p ] ; p + + )
{
if ( ! strncmp ( permutationname [ p ] + 8 , script , end - script ) & & permutationname [ p ] [ 8 + end - script ] = = ' \n ' )
2012-04-24 07:59:11 +00:00
{
2011-01-23 03:44:49 +00:00
nopermutation & = ~ ( 1u < < p ) ;
2012-04-24 07:59:11 +00:00
break ;
}
2011-01-23 03:44:49 +00:00
}
2012-04-24 07:59:11 +00:00
if ( ! permutationname [ p ] )
Con_DPrintf ( " Unknown pemutation in glsl program %s \n " , name ) ;
2011-01-23 03:44:49 +00:00
script = end ;
}
2011-05-26 16:46:43 +00:00
else if ( ! strncmp ( script , " !!ver " , 5 ) )
{
script + = 5 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
ver = strtol ( script , NULL , 0 ) ;
script = end ;
}
2011-01-23 03:44:49 +00:00
else
break ;
2010-08-28 17:14:38 +00:00
} ;
2014-03-30 08:55:06 +00:00
if ( sh_config . pLoadBlob & & blobfilename & & * blobfilename )
blobfile = FS_OpenVFS ( blobfilename , " w+b " , FS_GAMEONLY ) ;
else
blobfile = NULL ;
if ( blobfile )
{
unsigned int magic ;
unsigned int corrupt = false ;
2014-06-08 09:36:15 +00:00
char ever [ MAX_QPATH ] ;
char * thisever = version_string ( ) ;
2014-03-30 08:55:06 +00:00
corrupt | = VFS_READ ( blobfile , & magic , sizeof ( magic ) ) ! = sizeof ( magic ) ;
corrupt | = magic ! = * ( unsigned int * ) " FBLB " ;
corrupt | = VFS_READ ( blobfile , & blobheaderoffset , sizeof ( blobheaderoffset ) ) ! = sizeof ( blobheaderoffset ) ;
2014-06-08 09:36:15 +00:00
corrupt | = VFS_READ ( blobfile , ever , sizeof ( ever ) ) ! = sizeof ( ever ) ;
2014-03-30 08:55:06 +00:00
2014-06-08 09:36:15 +00:00
corrupt | = strcmp ( ever , thisever ) ;
2014-03-30 08:55:06 +00:00
//if the magic or header didn't read properly then the file is corrupt
if ( corrupt )
{
//close and reopen it without the + flag, to replace it with a new file.
VFS_CLOSE ( blobfile ) ;
blobfile = FS_OpenVFS ( blobfilename , " wb " , FS_GAMEONLY ) ;
if ( blobfile )
{
VFS_SEEK ( blobfile , 0 ) ;
magic = * ( unsigned int * ) " FBLB " ; //magic
VFS_WRITE ( blobfile , & magic , sizeof ( magic ) ) ;
2014-06-08 09:36:15 +00:00
memset ( ever , 0 , sizeof ( ever ) ) ; //make sure we don't leak stuff.
Q_strncpyz ( ever , thisever , sizeof ( ever ) ) ;
VFS_WRITE ( blobfile , ever , sizeof ( ever ) ) ;
2014-03-30 08:55:06 +00:00
blobheaderoffset = 0 ;
}
}
}
blobadded = false ;
2012-12-04 19:37:57 +00:00
if ( gl_specular . value )
2013-10-08 14:28:11 +00:00
{
if ( nummodifiers < MAXMODIFIERS )
permutationdefines [ nummodifiers + + ] = Z_StrDup ( " #define SPECULAR \n " ) ;
}
2011-12-27 08:35:19 +00:00
for ( end = strchr ( name , ' # ' ) ; end & & * end ; )
{
2014-08-15 02:20:41 +00:00
char * start = end + 1 , * d ;
2011-12-27 08:35:19 +00:00
end = strchr ( start , ' # ' ) ;
if ( ! end )
end = start + strlen ( start ) ;
2013-10-08 14:28:11 +00:00
if ( nummodifiers < MAXMODIFIERS )
2012-01-17 07:57:46 +00:00
{
2014-08-15 02:20:41 +00:00
permutationdefines [ nummodifiers ] = d = BZ_Malloc ( 10 + end - start ) ;
memcpy ( d , " #define " , 8 ) ;
memcpy ( d + 8 , start , end - start ) ;
memcpy ( d + 8 + ( end - start ) , " \n " , 2 ) ;
2012-01-17 07:57:46 +00:00
2014-08-15 02:20:41 +00:00
start = strchr ( d + 8 , ' = ' ) ;
2012-05-11 01:57:00 +00:00
if ( start )
* start = ' ' ;
2014-08-15 02:20:41 +00:00
for ( start = d + 8 ; * start ; start + + )
2012-01-17 07:57:46 +00:00
* start = toupper ( * start ) ;
nummodifiers + + ;
permutationdefines [ nummodifiers ] = NULL ;
}
2011-12-27 08:35:19 +00:00
}
2012-01-17 07:57:46 +00:00
2014-03-30 08:55:06 +00:00
if ( blobfile )
{
unsigned int next ;
unsigned int argsz ;
2014-08-15 02:20:41 +00:00
char * args , * mp ;
const char * mv ;
2014-03-30 08:55:06 +00:00
int ml , mi ;
unsigned int bloblink = 4 ;
//walk through looking for an argset match
while ( blobheaderoffset )
{
VFS_SEEK ( blobfile , blobheaderoffset ) ;
VFS_READ ( blobfile , & next , sizeof ( next ) ) ;
VFS_READ ( blobfile , & argsz , sizeof ( argsz ) ) ;
args = Z_Malloc ( argsz + 1 ) ;
VFS_READ ( blobfile , args , argsz ) ;
args [ argsz ] = 0 ;
for ( mi = 0 , mp = args ; mi < nummodifiers ; mi + + )
{
mv = permutationdefines [ mi ] + 8 ;
ml = strlen ( mv ) ;
if ( mp + ml > args + argsz )
break ;
if ( strncmp ( mp , mv , ml ) )
break ;
mp + = ml ;
}
//this one is a match.
if ( mi = = nummodifiers & & mp = = args + argsz )
{
blobheaderoffset = VFS_TELL ( blobfile ) ;
VFS_READ ( blobfile , permuoffsets , sizeof ( permuoffsets ) ) ;
break ;
}
bloblink = blobheaderoffset ;
blobheaderoffset = next ;
}
//these arguments have never been seen before. add a new argset.
if ( ! blobheaderoffset )
{
unsigned int link = 0 ;
initoffset = VFS_GETLEN ( blobfile ) ;
VFS_SEEK ( blobfile , initoffset ) ;
VFS_WRITE ( blobfile , & link , sizeof ( link ) ) ;
for ( mi = 0 , argsz = 0 ; mi < nummodifiers ; mi + + )
{
mv = permutationdefines [ mi ] + 8 ;
ml = strlen ( mv ) ;
argsz + = ml ;
}
VFS_WRITE ( blobfile , & argsz , sizeof ( argsz ) ) ;
for ( mi = 0 ; mi < nummodifiers ; mi + + )
{
mv = permutationdefines [ mi ] + 8 ;
ml = strlen ( mv ) ;
VFS_WRITE ( blobfile , mv , ml ) ;
}
//and the offsets come here
blobheaderoffset = VFS_TELL ( blobfile ) ;
memset ( permuoffsets , 0 , sizeof ( permuoffsets ) ) ;
VFS_WRITE ( blobfile , permuoffsets , sizeof ( permuoffsets ) ) ;
//now rewrite the link to add us. the value in the file should always be set to 0.
VFS_SEEK ( blobfile , bloblink ) ;
VFS_WRITE ( blobfile , & initoffset , sizeof ( initoffset ) ) ;
}
}
2010-08-28 17:14:38 +00:00
for ( p = 0 ; p < PERMUTATIONS ; p + + )
{
2012-11-27 03:23:19 +00:00
memset ( & prog - > permu [ p ] . handle , 0 , sizeof ( prog - > permu [ p ] . handle ) ) ;
2012-01-17 07:57:46 +00:00
if ( nopermutation & p )
{
continue ;
}
pn = nummodifiers ;
for ( n = 0 ; permutationname [ n ] ; n + + )
{
if ( p & ( 1u < < n ) )
permutationdefines [ pn + + ] = permutationname [ n ] ;
}
2013-03-12 23:14:57 +00:00
if ( p & PERMUTATION_UPPERLOWER )
permutationdefines [ pn + + ] = " #define UPPER \n #define LOWER \n " ;
2012-09-30 05:52:03 +00:00
if ( p & PERMUTATION_BUMPMAP )
{
if ( r_glsl_offsetmapping . ival )
{
permutationdefines [ pn + + ] = " #define OFFSETMAPPING \n " ;
if ( r_glsl_offsetmapping_reliefmapping . ival & & ( p & PERMUTATION_BUMPMAP ) )
permutationdefines [ pn + + ] = " #define RELIEFMAPPING \n " ;
}
}
2012-01-17 07:57:46 +00:00
permutationdefines [ pn + + ] = NULL ;
2014-03-30 08:55:06 +00:00
if ( blobfile & & permuoffsets [ p ] )
2010-08-28 17:14:38 +00:00
{
2014-03-30 08:55:06 +00:00
VFS_SEEK ( blobfile , permuoffsets [ p ] ) ;
if ( sh_config . pLoadBlob ( prog , name , p , blobfile ) )
continue ; //blob was loaded from disk, yay.
//otherwise fall through.
2010-08-28 17:14:38 +00:00
}
2014-03-30 08:55:06 +00:00
if ( blobfile )
2011-01-23 03:44:49 +00:00
{
2014-03-30 08:55:06 +00:00
initoffset = VFS_GETLEN ( blobfile ) ;
VFS_SEEK ( blobfile , initoffset ) ;
2011-01-23 03:44:49 +00:00
}
2014-06-08 09:36:15 +00:00
if ( ! sh_config . pCreateProgram ( prog , name , p , ver , permutationdefines , script , tess ? script : NULL , tess ? script : NULL , script , ( p & PERMUTATION_SKELETAL ) ? true : onefailed , blobfile ) )
2011-03-31 02:32:32 +00:00
{
2014-03-30 08:55:06 +00:00
if ( ! ( p & PERMUTATION_SKELETAL ) )
onefailed = true ; //don't flag it if skeletal failed.
if ( ! p ) //give up if permutation 0 failed. that one failing is fatal.
2012-09-30 05:52:03 +00:00
break ;
}
2014-03-30 08:55:06 +00:00
if ( blobfile & & initoffset ! = VFS_GETLEN ( blobfile ) )
2012-09-30 05:52:03 +00:00
{
2014-03-30 08:55:06 +00:00
permuoffsets [ p ] = initoffset ;
blobadded = true ;
2011-03-31 02:32:32 +00:00
}
2010-08-28 17:14:38 +00:00
}
2011-12-27 08:35:19 +00:00
while ( nummodifiers )
2014-08-15 02:20:41 +00:00
Z_Free ( ( char * ) permutationdefines [ - - nummodifiers ] ) ;
2011-02-25 04:22:14 +00:00
2014-03-30 08:55:06 +00:00
if ( sh_config . pProgAutoFields )
sh_config . pProgAutoFields ( prog , cvarnames , cvartypes ) ;
if ( blobfile & & blobadded )
{
VFS_SEEK ( blobfile , blobheaderoffset ) ;
VFS_WRITE ( blobfile , permuoffsets , sizeof ( permuoffsets ) ) ;
}
if ( blobfile )
VFS_CLOSE ( blobfile ) ;
2012-01-16 06:22:06 +00:00
if ( p = = PERMUTATIONS )
return true ;
return false ;
2010-08-28 17:14:38 +00:00
}
2011-01-23 03:44:49 +00:00
typedef struct sgeneric_s
{
2013-11-21 23:02:28 +00:00
program_t prog ;
2011-01-23 03:44:49 +00:00
struct sgeneric_s * next ;
2012-01-01 02:26:42 +00:00
char * name ;
2011-02-25 04:22:14 +00:00
qboolean failed ;
2011-01-23 03:44:49 +00:00
} sgeneric_t ;
static sgeneric_t * sgenerics ;
struct sbuiltin_s
{
int qrtype ;
int apiver ;
char name [ MAX_QPATH ] ;
char * body ;
2011-05-15 13:23:13 +00:00
} sbuiltins [ ] =
2011-01-23 03:44:49 +00:00
{
2012-01-17 07:57:46 +00:00
# include "r_bishaders.h"
2011-01-23 03:44:49 +00:00
{ QR_NONE }
} ;
2012-01-01 02:26:42 +00:00
void Shader_UnloadProg ( program_t * prog )
2011-06-05 23:53:33 +00:00
{
2014-03-30 08:55:06 +00:00
if ( sh_config . pDeleteProg )
2012-09-30 05:52:03 +00:00
{
int p ;
for ( p = 0 ; p < PERMUTATIONS ; p + + )
2014-03-30 08:55:06 +00:00
sh_config . pDeleteProg ( prog , p ) ;
2012-09-30 05:52:03 +00:00
}
2014-03-30 08:55:06 +00:00
2012-09-30 05:52:03 +00:00
free ( prog ) ;
2011-06-05 23:53:33 +00:00
}
2011-01-23 03:44:49 +00:00
static void Shader_FlushGenerics ( void )
{
sgeneric_t * g ;
while ( sgenerics )
{
g = sgenerics ;
sgenerics = g - > next ;
2011-06-04 16:11:35 +00:00
if ( g - > prog . refs = = 1 )
2012-01-01 02:26:42 +00:00
{
g - > prog . refs - - ;
2013-11-21 23:02:28 +00:00
Shader_UnloadProg ( & g - > prog ) ;
2012-01-01 02:26:42 +00:00
}
2011-06-04 16:11:35 +00:00
else
Con_Printf ( " generic shader still used \n " ) ;
2011-01-23 03:44:49 +00:00
}
}
2012-09-30 05:52:03 +00:00
static void Shader_LoadGeneric ( sgeneric_t * g , int qrtype )
2011-01-23 03:44:49 +00:00
{
unsigned int i ;
void * file ;
2012-05-11 01:57:00 +00:00
char basicname [ MAX_QPATH ] ;
2014-03-30 08:55:06 +00:00
char blobname [ MAX_QPATH ] ;
2012-05-11 01:57:00 +00:00
char * h ;
2011-02-06 20:56:39 +00:00
2012-09-30 05:52:03 +00:00
g - > failed = true ;
2011-02-25 04:22:14 +00:00
2012-05-11 01:57:00 +00:00
basicname [ 1 ] = 0 ;
2012-09-30 05:52:03 +00:00
Q_strncpyz ( basicname , g - > name , sizeof ( basicname ) ) ;
2012-05-11 01:57:00 +00:00
h = strchr ( basicname + 1 , ' # ' ) ;
if ( h )
* h = ' \0 ' ;
if ( strchr ( basicname , ' / ' ) | | strchr ( basicname , ' . ' ) )
2014-03-30 08:55:06 +00:00
{
2012-05-11 01:57:00 +00:00
FS_LoadFile ( basicname , & file ) ;
2014-03-30 08:55:06 +00:00
* blobname = 0 ;
}
else
2011-09-03 03:49:43 +00:00
{
2014-03-30 08:55:06 +00:00
if ( sh_config . progpath )
2014-08-25 07:35:41 +00:00
{
Q_snprintfz ( blobname , sizeof ( blobname ) , sh_config . progpath , basicname ) ;
FS_LoadFile ( blobname , & file ) ;
}
2011-09-03 03:49:43 +00:00
else
2014-03-30 08:55:06 +00:00
file = NULL ;
if ( sh_config . blobpath & & r_shaderblobs . ival )
Q_snprintfz ( blobname , sizeof ( blobname ) , sh_config . blobpath , basicname ) ;
else
* blobname = 0 ;
2011-09-03 03:49:43 +00:00
}
2014-03-30 08:55:06 +00:00
2011-01-23 03:44:49 +00:00
if ( file )
{
2012-05-11 01:57:00 +00:00
Con_DPrintf ( " Loaded %s from disk \n " , basicname ) ;
2014-03-30 08:55:06 +00:00
g - > failed = ! Shader_LoadPermutations ( g - > name , & g - > prog , file , qrtype , 0 , blobname ) ;
2011-01-23 03:44:49 +00:00
FS_FreeFile ( file ) ;
2012-09-30 05:52:03 +00:00
return ;
2011-01-23 03:44:49 +00:00
}
else
{
2012-04-24 07:59:11 +00:00
int ver ;
2011-01-23 03:44:49 +00:00
for ( i = 0 ; * sbuiltins [ i ] . name ; i + + )
{
2012-05-11 01:57:00 +00:00
if ( sbuiltins [ i ] . qrtype = = qrenderer & & ! strcmp ( sbuiltins [ i ] . name , basicname ) )
2011-01-23 03:44:49 +00:00
{
2012-04-24 07:59:11 +00:00
ver = sbuiltins [ i ] . apiver ;
2014-03-30 08:55:06 +00:00
if ( ver < sh_config . minver | | ver > sh_config . maxver )
continue ;
g - > failed = ! Shader_LoadPermutations ( g - > name , & g - > prog , sbuiltins [ i ] . body , sbuiltins [ i ] . qrtype , ver , blobname ) ;
2012-04-24 07:59:11 +00:00
if ( g - > failed )
continue ;
2011-02-25 04:22:14 +00:00
2012-09-30 05:52:03 +00:00
return ;
2011-01-23 03:44:49 +00:00
}
}
}
2012-09-30 05:52:03 +00:00
}
static void Shader_ReloadGenerics ( void )
{
sgeneric_t * g ;
for ( g = sgenerics ; g ; g = g - > next )
{
Shader_LoadGeneric ( g , qrenderer ) ;
}
}
static program_t * Shader_FindGeneric ( char * name , int qrtype )
{
sgeneric_t * g ;
for ( g = sgenerics ; g ; g = g - > next )
{
if ( ! strcmp ( name , g - > name ) )
{
if ( g - > failed )
return NULL ;
g - > prog . refs + + ;
return & g - > prog ;
}
}
2014-03-30 08:55:06 +00:00
//don't even try if we know it won't work.
if ( ! sh_config . progs_supported )
return NULL ;
2012-09-30 05:52:03 +00:00
g = malloc ( sizeof ( * g ) + strlen ( name ) + 1 ) ;
memset ( g , 0 , sizeof ( * g ) ) ;
g - > name = ( char * ) ( g + 1 ) ;
strcpy ( g - > name , name ) ;
g - > next = sgenerics ;
sgenerics = g ;
g - > prog . refs = 1 ;
Shader_LoadGeneric ( g , qrtype ) ;
if ( g - > failed )
return NULL ;
g - > prog . refs + + ;
return & g - > prog ;
2011-01-23 03:44:49 +00:00
}
2011-09-03 03:49:43 +00:00
void Shader_WriteOutGenerics_f ( void )
{
int i ;
char * name ;
for ( i = 0 ; * sbuiltins [ i ] . name ; i + + )
{
name = NULL ;
if ( sbuiltins [ i ] . qrtype = = QR_OPENGL )
{
if ( sbuiltins [ i ] . apiver = = 100 )
2013-03-12 23:13:39 +00:00
name = va ( " gles/eg_%s.glsl " , sbuiltins [ i ] . name ) ;
2011-09-03 03:49:43 +00:00
else
2013-03-12 23:13:39 +00:00
name = va ( " glsl/eg_%s.glsl " , sbuiltins [ i ] . name ) ;
2011-09-03 03:49:43 +00:00
}
2012-09-30 05:52:03 +00:00
else if ( sbuiltins [ i ] . qrtype = = QR_DIRECT3D9 )
2013-03-12 23:13:39 +00:00
name = va ( " hlsl/eg_%s.hlsl " , sbuiltins [ i ] . name ) ;
2012-09-30 05:52:03 +00:00
else if ( sbuiltins [ i ] . qrtype = = QR_DIRECT3D11 )
2013-03-12 23:13:39 +00:00
name = va ( " hlsl11/eg_%s.hlsl " , sbuiltins [ i ] . name ) ;
2011-09-03 03:49:43 +00:00
if ( name )
{
vfsfile_t * f = FS_OpenVFS ( name , " rb " , FS_GAMEONLY ) ;
if ( f )
{
int len = VFS_GETLEN ( f ) ;
char * buf = Hunk_TempAlloc ( len ) ;
VFS_READ ( f , buf , len ) ;
if ( len ! = strlen ( sbuiltins [ i ] . body ) | | memcmp ( buf , sbuiltins [ i ] . body , len ) )
Con_Printf ( " Not writing %s - modified version in the way \n " , name ) ;
else
Con_Printf ( " %s is unmodified \n " , name ) ;
VFS_CLOSE ( f ) ;
}
else
{
Con_Printf ( " Writing %s \n " , name ) ;
FS_WriteFile ( name , sbuiltins [ i ] . body , strlen ( sbuiltins [ i ] . body ) , FS_GAMEONLY ) ;
}
}
}
}
2012-04-24 07:59:11 +00:00
struct shader_field_names_s shader_attr_names [ ] =
2011-09-03 03:49:43 +00:00
{
/*vertex attributes*/
2013-10-08 14:28:11 +00:00
{ " v_position1 " , VATTR_VERTEX1 } ,
2012-04-24 07:59:11 +00:00
{ " v_position2 " , VATTR_VERTEX2 } ,
{ " v_colour " , VATTR_COLOUR } ,
{ " v_texcoord " , VATTR_TEXCOORD } ,
{ " v_lmcoord " , VATTR_LMCOORD } ,
{ " v_normal " , VATTR_NORMALS } ,
{ " v_svector " , VATTR_SNORMALS } ,
{ " v_tvector " , VATTR_TNORMALS } ,
{ " v_bone " , VATTR_BONENUMS } ,
{ " v_weight " , VATTR_BONEWEIGHTS } ,
2013-10-08 14:28:11 +00:00
# if MAXRLIGHTMAPS > 1
{ " v_lmcoord1 " , VATTR_LMCOORD } ,
2012-07-05 19:42:36 +00:00
{ " v_lmcoord2 " , VATTR_LMCOORD2 } ,
{ " v_lmcoord3 " , VATTR_LMCOORD3 } ,
{ " v_lmcoord4 " , VATTR_LMCOORD4 } ,
2013-10-08 14:28:11 +00:00
{ " v_colour1 " , VATTR_COLOUR } ,
{ " v_colour2 " , VATTR_COLOUR2 } ,
{ " v_colour3 " , VATTR_COLOUR3 } ,
{ " v_colour4 " , VATTR_COLOUR4 } ,
# endif
2012-04-24 07:59:11 +00:00
{ NULL }
} ;
2011-09-03 03:49:43 +00:00
2012-04-24 07:59:11 +00:00
struct shader_field_names_s shader_unif_names [ ] =
{
2011-09-03 03:49:43 +00:00
/*matricies*/
{ " m_model " , SP_M_MODEL } ,
{ " m_view " , SP_M_VIEW } ,
{ " m_modelview " , SP_M_MODELVIEW } ,
{ " m_projection " , SP_M_PROJECTION } ,
{ " m_modelviewprojection " , SP_M_MODELVIEWPROJECTION } ,
{ " m_bones " , SP_M_ENTBONES } ,
{ " m_invviewprojection " , SP_M_INVVIEWPROJECTION } ,
{ " m_invmodelviewprojection " , SP_M_INVMODELVIEWPROJECTION } ,
/*viewer properties*/
{ " v_eyepos " , SP_V_EYEPOS } ,
2011-12-23 03:12:29 +00:00
{ " w_fog " , SP_W_FOG } ,
2011-09-03 03:49:43 +00:00
/*ent properties*/
2012-04-24 07:59:11 +00:00
{ " e_vblend " , SP_E_VBLEND } ,
2014-03-30 08:55:06 +00:00
{ " e_lmscale " , SP_E_LMSCALE } , /*overbright shifting*/
{ " e_origin " , SP_E_ORIGIN } ,
{ " e_time " , SP_E_TIME } ,
{ " e_eyepos " , SP_E_EYEPOS } ,
{ " e_colour " , SP_E_COLOURS } ,
{ " e_colourident " , SP_E_COLOURSIDENT } ,
{ " e_glowmod " , SP_E_GLOWMOD } ,
{ " e_uppercolour " , SP_E_TOPCOLOURS } ,
{ " e_lowercolour " , SP_E_BOTTOMCOLOURS } ,
{ " e_light_dir " , SP_E_L_DIR } ,
{ " e_light_mul " , SP_E_L_MUL } ,
{ " e_light_ambient " , SP_E_L_AMBIENT } ,
/*rtlight properties, use with caution*/
{ " l_lightscreen " , SP_LIGHTSCREEN } ,
{ " l_lightradius " , SP_LIGHTRADIUS } ,
{ " l_lightcolour " , SP_LIGHTCOLOUR } ,
{ " l_lightposition " , SP_LIGHTPOSITION } ,
{ " l_lightcolourscale " , SP_LIGHTCOLOURSCALE } ,
{ " l_cubematrix " , SP_LIGHTCUBEMATRIX } ,
{ " l_shadowmapproj " , SP_LIGHTSHADOWMAPPROJ } ,
{ " l_shadowmapscale " , SP_LIGHTSHADOWMAPSCALE } ,
{ " e_rendertexturescale " , SP_RENDERTEXTURESCALE } ,
{ NULL }
} ;
2010-08-28 17:14:38 +00:00
2013-10-29 17:38:22 +00:00
static char * Shader_ParseBody ( char * debugname , char * * ptr )
2006-03-11 03:12:10 +00:00
{
2013-10-29 17:38:22 +00:00
char * body ;
2011-01-23 03:44:49 +00:00
char * start , * end ;
2009-07-05 18:45:53 +00:00
2011-01-23 03:44:49 +00:00
end = * ptr ;
while ( * end = = ' ' | | * end = = ' \t ' | | * end = = ' \r ' )
end + + ;
if ( * end = = ' \n ' )
2009-07-05 18:45:53 +00:00
{
int count ;
2011-01-23 03:44:49 +00:00
end + + ;
while ( * end = = ' ' | | * end = = ' \t ' )
end + + ;
if ( * end ! = ' { ' )
2009-07-05 18:45:53 +00:00
{
2013-10-29 17:38:22 +00:00
Con_Printf ( " shader \" %s \" missing program string \n " , debugname ) ;
2009-07-05 18:45:53 +00:00
}
else
{
2011-01-23 03:44:49 +00:00
end + + ;
start = end ;
for ( count = 1 ; * end ; end + + )
2009-07-05 18:45:53 +00:00
{
2011-01-23 03:44:49 +00:00
if ( * end = = ' } ' )
2009-07-05 18:45:53 +00:00
{
count - - ;
if ( ! count )
break ;
}
2011-01-23 03:44:49 +00:00
else if ( * end = = ' { ' )
2009-07-05 18:45:53 +00:00
count + + ;
}
2013-10-29 17:38:22 +00:00
body = BZ_Malloc ( end - start + 1 ) ;
memcpy ( body , start , end - start ) ;
body [ end - start ] = 0 ;
2011-01-23 03:44:49 +00:00
* ptr = end + 1 ; /*skip over it all*/
2010-08-28 17:14:38 +00:00
2013-10-29 17:38:22 +00:00
return body ;
}
}
return NULL ;
}
2009-07-05 18:45:53 +00:00
2013-10-29 17:38:22 +00:00
static void Shader_SLProgramName ( shader_t * shader , shaderpass_t * pass , char * * ptr , int qrtype )
{
/*accepts:
program
{
BLAH
}
where BLAH is both vertex + frag with # ifdefs
or
program fname
on one line .
*/
char * programbody ;
char * hash ;
programbody = Shader_ParseBody ( shader - > name , ptr ) ;
if ( programbody )
{
shader - > prog = malloc ( sizeof ( * shader - > prog ) ) ;
memset ( shader - > prog , 0 , sizeof ( * shader - > prog ) ) ;
shader - > prog - > refs = 1 ;
2014-03-30 08:55:06 +00:00
if ( ! Shader_LoadPermutations ( shader - > name , shader - > prog , programbody , qrtype , 0 , NULL ) )
2013-10-29 17:38:22 +00:00
{
free ( shader - > prog ) ;
shader - > prog = NULL ;
2009-07-05 18:45:53 +00:00
}
2013-10-29 17:38:22 +00:00
BZ_Free ( programbody ) ;
2010-08-28 17:14:38 +00:00
return ;
2009-11-04 21:16:50 +00:00
}
2010-08-28 17:14:38 +00:00
2012-12-04 19:37:57 +00:00
hash = strchr ( shader - > name , ' # ' ) ;
if ( hash )
{
//pass the # postfixes from the shader name onto the generic glsl to use
char newname [ 512 ] ;
------------------------------------------------------------------------
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
Q_snprintfz ( newname , sizeof ( newname ) , " %s%s " , Shader_ParseExactString ( ptr ) , hash ) ;
2012-12-04 19:37:57 +00:00
shader - > prog = Shader_FindGeneric ( newname , qrtype ) ;
}
else
------------------------------------------------------------------------
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
shader - > prog = Shader_FindGeneric ( Shader_ParseExactString ( ptr ) , qrtype ) ;
2006-03-11 03:12:10 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shader_GLSLProgramName ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
Shader_SLProgramName ( shader , pass , ptr , QR_OPENGL ) ;
}
2011-03-31 02:32:32 +00:00
static void Shader_ProgramName ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
Shader_SLProgramName ( shader , pass , ptr , qrenderer ) ;
}
2013-11-21 23:02:28 +00:00
static void Shader_HLSL9ProgramName ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2009-11-04 21:16:50 +00:00
{
2012-09-30 05:52:03 +00:00
Shader_SLProgramName ( shader , pass , ptr , QR_DIRECT3D9 ) ;
2009-11-04 21:16:50 +00:00
}
2013-11-21 23:02:28 +00:00
static void Shader_HLSL11ProgramName ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
Shader_SLProgramName ( shader , pass , ptr , QR_DIRECT3D11 ) ;
}
2009-11-04 21:16:50 +00:00
2006-03-11 03:12:10 +00:00
static void Shader_ProgramParam ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
2010-08-28 17:14:38 +00:00
cvar_t * cv = NULL ;
2006-03-11 03:12:10 +00:00
int specialint = 0 ;
float specialfloat = 0 ;
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
vec3_t specialvec = { 0 } ;
2006-03-11 03:12:10 +00:00
enum shaderprogparmtype_e parmtype = SP_BAD ;
char * token ;
2009-11-04 21:16:50 +00:00
qboolean silent = false ;
2011-01-23 03:44:49 +00:00
char * forcename = NULL ;
2006-03-11 03:12:10 +00:00
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " opt " ) )
{
silent = true ;
token = Shader_ParseString ( ptr ) ;
}
2006-03-11 03:12:10 +00:00
if ( ! Q_stricmp ( token , " texture " ) )
{
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2006-03-11 03:12:10 +00:00
specialint = atoi ( token ) ;
parmtype = SP_TEXTURE ;
}
2010-11-10 03:32:47 +00:00
else if ( ! Q_stricmp ( token , " consti " ) )
{
token = Shader_ParseSensString ( ptr ) ;
specialint = atoi ( token ) ;
parmtype = SP_CONSTI ;
}
else if ( ! Q_stricmp ( token , " constf " ) )
{
token = Shader_ParseSensString ( ptr ) ;
specialfloat = atof ( token ) ;
parmtype = SP_CONSTF ;
}
2006-03-11 03:12:10 +00:00
else if ( ! Q_stricmp ( token , " cvari " ) )
{
2010-07-11 02:22:39 +00:00
token = Shader_ParseSensString ( ptr ) ;
2006-03-11 03:12:10 +00:00
cv = Cvar_Get ( token , " " , 0 , " GLSL Shader parameters " ) ;
2010-08-28 17:14:38 +00:00
if ( ! cv )
return ;
2006-03-11 03:12:10 +00:00
parmtype = SP_CVARI ;
}
else if ( ! Q_stricmp ( token , " cvarf " ) )
{
2010-07-11 02:22:39 +00:00
token = Shader_ParseSensString ( ptr ) ;
2006-03-11 03:12:10 +00:00
cv = Cvar_Get ( token , " " , 0 , " GLSL Shader parameters " ) ;
2010-08-28 17:14:38 +00:00
if ( ! cv )
return ;
2006-03-11 03:12:10 +00:00
parmtype = SP_CVARF ;
}
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
else if ( ! Q_stricmp ( token , " cvar3f " ) )
{
token = Shader_ParseSensString ( ptr ) ;
cv = Cvar_Get ( token , " " , 0 , " GLSL Shader parameters " ) ;
2010-08-28 17:14:38 +00:00
if ( ! cv )
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
parmtype = SP_CVAR3F ;
}
2006-03-11 03:12:10 +00:00
else if ( ! Q_stricmp ( token , " time " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_E_TIME ;
2008-12-23 02:55:20 +00:00
else if ( ! Q_stricmp ( token , " eyepos " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_E_EYEPOS ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " entmatrix " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_M_MODEL ;
2008-12-23 02:55:20 +00:00
else if ( ! Q_stricmp ( token , " colours " ) | | ! Q_stricmp ( token , " colors " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_E_COLOURS ;
2008-12-23 02:55:20 +00:00
else if ( ! Q_stricmp ( token , " upper " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_E_TOPCOLOURS ;
2008-12-23 02:55:20 +00:00
else if ( ! Q_stricmp ( token , " lower " ) )
2011-09-03 03:49:43 +00:00
parmtype = SP_E_BOTTOMCOLOURS ;
2009-07-18 20:46:42 +00:00
else if ( ! Q_stricmp ( token , " lightradius " ) )
parmtype = SP_LIGHTRADIUS ;
else if ( ! Q_stricmp ( token , " lightcolour " ) )
parmtype = SP_LIGHTCOLOUR ;
else if ( ! Q_stricmp ( token , " lightpos " ) )
parmtype = SP_LIGHTPOSITION ;
2010-07-25 15:12:12 +00:00
else if ( ! Q_stricmp ( token , " rendertexturescale " ) )
parmtype = SP_RENDERTEXTURESCALE ;
2009-07-18 20:46:42 +00:00
else
Con_Printf ( " shader %s: parameter type \" %s \" not known \n " , shader - > name , token ) ;
2006-03-11 03:12:10 +00:00
2011-01-23 03:44:49 +00:00
if ( forcename )
token = forcename ;
else
token = Shader_ParseSensString ( ptr ) ;
2006-03-11 03:12:10 +00:00
2009-11-04 21:16:50 +00:00
# ifdef GLQUAKE
if ( qrenderer = = QR_OPENGL )
{
2010-11-02 23:17:25 +00:00
int p ;
qboolean foundone ;
2009-11-04 21:16:50 +00:00
unsigned int uniformloc ;
2011-02-25 04:22:14 +00:00
program_t * prog = shader - > prog ;
if ( ! prog )
2006-03-11 03:12:10 +00:00
{
2009-11-04 21:16:50 +00:00
Con_Printf ( " shader %s: param without program set \n " , shader - > name ) ;
2006-03-11 03:12:10 +00:00
}
2011-02-25 04:22:14 +00:00
else if ( prog - > numparams = = SHADER_PROGPARMS_MAX )
2010-08-28 17:14:38 +00:00
Con_Printf ( " shader %s: too many parms \n " , shader - > name ) ;
2006-03-11 03:12:10 +00:00
else
{
2011-02-25 04:22:14 +00:00
if ( prog - > refs ! = 1 )
Con_Printf ( " shader %s: parms on shared shader \n " , shader - > name ) ;
2010-08-28 17:14:38 +00:00
foundone = false ;
2011-02-25 04:22:14 +00:00
prog - > parm [ prog - > numparams ] . type = parmtype ;
2010-08-28 17:14:38 +00:00
for ( p = 0 ; p < PERMUTATIONS ; p + + )
2009-11-04 21:16:50 +00:00
{
2012-11-27 03:23:19 +00:00
if ( ! prog - > permu [ p ] . handle . glsl )
2010-08-28 17:14:38 +00:00
continue ;
2012-11-27 03:23:19 +00:00
GLSlang_UseProgram ( prog - > permu [ p ] . handle . glsl ) ;
2012-04-24 07:59:11 +00:00
2012-11-27 03:23:19 +00:00
uniformloc = qglGetUniformLocationARB ( prog - > permu [ p ] . handle . glsl , token ) ;
prog - > permu [ p ] . parm [ prog - > numparams ] = uniformloc ;
2012-04-24 07:59:11 +00:00
2010-08-28 17:14:38 +00:00
if ( uniformloc ! = - 1 )
2009-11-04 21:16:50 +00:00
{
2010-08-28 17:14:38 +00:00
foundone = true ;
switch ( parmtype )
{
case SP_BAD :
foundone = false ;
break ;
case SP_TEXTURE :
2010-11-10 03:32:47 +00:00
case SP_CONSTI :
2011-02-25 04:22:14 +00:00
prog - > parm [ prog - > numparams ] . ival = specialint ;
2010-08-28 17:14:38 +00:00
break ;
2010-11-10 03:32:47 +00:00
case SP_CONSTF :
2011-02-25 04:22:14 +00:00
prog - > parm [ prog - > numparams ] . fval = specialfloat ;
2010-11-10 03:32:47 +00:00
break ;
2010-08-28 17:14:38 +00:00
case SP_CVARF :
case SP_CVARI :
2011-02-25 04:22:14 +00:00
prog - > parm [ prog - > numparams ] . pval = cv ;
2010-08-28 17:14:38 +00:00
break ;
case SP_CVAR3F :
2011-02-25 04:22:14 +00:00
prog - > parm [ prog - > numparams ] . pval = cv ;
2010-08-28 17:14:38 +00:00
qglUniform3fvARB ( uniformloc , 1 , specialvec ) ;
break ;
default :
break ;
}
2009-11-04 21:16:50 +00:00
}
2006-03-11 03:12:10 +00:00
}
2011-10-27 16:16:29 +00:00
if ( ! foundone )
{
if ( ! silent )
Con_Printf ( " shader %s: param \" %s \" not found \n " , shader - > name , token ) ;
}
2010-08-28 17:14:38 +00:00
else
2011-02-25 04:22:14 +00:00
prog - > numparams + + ;
2010-08-28 17:14:38 +00:00
2009-11-04 21:16:50 +00:00
GLSlang_UseProgram ( 0 ) ;
2006-03-11 03:12:10 +00:00
}
}
2009-11-04 21:16:50 +00:00
# endif
2006-03-11 03:12:10 +00:00
}
2011-02-25 04:22:14 +00:00
static void Shader_DiffuseMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
token = Shader_ParseString ( ptr ) ;
shader - > defaulttextures . base = R_LoadHiResTexture ( token , NULL , 0 ) ;
}
static void Shader_Translucent ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = SHADER_BLEND ;
}
2012-09-30 05:52:03 +00:00
static void Shader_DP_Camera ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > sort = SHADER_SORT_PORTAL ;
}
2013-10-29 17:38:22 +00:00
static void Shader_BEMode ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
int mode ;
char tokencopy [ 1024 ] ;
char * token ;
char * embed = NULL ;
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " rtlight " ) )
mode = - 1 ; //all light types
else if ( ! Q_stricmp ( token , " rtlight_only " ) )
mode = LSHADER_STANDARD ;
else if ( ! Q_stricmp ( token , " rtlight_smap " ) )
mode = LSHADER_SMAP ;
else if ( ! Q_stricmp ( token , " rtlight_spot " ) )
mode = LSHADER_SPOT ;
else if ( ! Q_stricmp ( token , " rtlight_cube " ) )
mode = LSHADER_CUBE ;
else if ( ! Q_stricmp ( token , " rtlight_cube_smap " ) )
mode = LSHADER_CUBE | LSHADER_SMAP ;
else if ( ! Q_stricmp ( token , " rtlight_cube_spot " ) ) //doesn't make sense.
mode = LSHADER_CUBE | LSHADER_SPOT ;
else if ( ! Q_stricmp ( token , " rtlight_spot_smap " ) )
mode = LSHADER_SMAP | LSHADER_SPOT ;
else if ( ! Q_stricmp ( token , " rtlight_cube_spot_smap " ) ) //doesn't make sense.
mode = LSHADER_CUBE | LSHADER_SPOT | LSHADER_SMAP ;
else if ( ! Q_stricmp ( token , " crepuscular " ) )
mode = bemoverride_crepuscular ;
else if ( ! Q_stricmp ( token , " depthonly " ) )
mode = bemoverride_depthonly ;
else if ( ! Q_stricmp ( token , " depthdark " ) )
mode = bemoverride_depthdark ;
else if ( ! Q_stricmp ( token , " prelight " ) )
mode = bemoverride_prelight ;
else if ( ! Q_stricmp ( token , " fog " ) )
mode = bemoverride_fog ;
else
{
Con_DPrintf ( CON_WARNING " Shader %s specifies unknown bemode %s. \n " , shader - > name , token ) ;
return ; //not supported.
}
embed = Shader_ParseBody ( shader - > name , ptr ) ;
if ( embed )
{
int l = strlen ( embed ) + 6 ;
char * b = BZ_Malloc ( l ) ;
Q_snprintfz ( b , l , " { \n %s \n } \n " , embed ) ;
BZ_Free ( embed ) ;
embed = b ;
//generate a unique name
Q_snprintfz ( tokencopy , sizeof ( tokencopy ) , " %s_mode%i " , shader - > name , mode ) ;
}
else
{
token = Shader_ParseString ( ptr ) ;
Q_strncpyz ( tokencopy , token , sizeof ( tokencopy ) ) ; //make sure things don't go squiff.
}
if ( mode = = - 1 )
{
//shorthand for rtlights
for ( mode = 0 ; mode < LSHADER_MODES ; mode + + )
{
if ( ( mode & LSHADER_CUBE ) & & ( mode & LSHADER_SPOT ) )
continue ;
shader - > bemoverrides [ mode ] = R_RegisterCustom ( va ( " %s%s%s%s " ,
tokencopy ,
( mode & LSHADER_SMAP ) ? " #PCF " : " " ,
( mode & LSHADER_SPOT ) ? " #SPOT " : " " ,
( mode & LSHADER_CUBE ) ? " #CUBE " : " " )
, shader - > usageflags , embed ? Shader_DefaultScript : NULL , embed ) ;
}
}
else
{
shader - > bemoverrides [ mode ] = R_RegisterCustom ( tokencopy , shader - > usageflags , embed ? Shader_DefaultScript : NULL , embed ) ;
}
if ( embed )
BZ_Free ( embed ) ;
}
2004-10-19 15:56:22 +00:00
static shaderkey_t shaderkeys [ ] =
{
2011-03-12 13:51:40 +00:00
{ " cull " , Shader_Cull } ,
{ " skyparms " , Shader_SkyParms } ,
2009-11-04 21:16:50 +00:00
{ " fogparms " , Shader_FogParms } ,
{ " surfaceparm " , Shader_SurfaceParm } ,
2011-03-12 13:51:40 +00:00
{ " nomipmaps " , Shader_NoMipMaps } ,
2009-11-04 21:16:50 +00:00
{ " nopicmip " , Shader_NoPicMip } ,
{ " polygonoffset " , Shader_PolygonOffset } ,
{ " sort " , Shader_Sort } ,
2011-03-12 13:51:40 +00:00
{ " deformvertexes " , Shader_DeformVertexes } ,
2009-11-04 21:16:50 +00:00
{ " portal " , Shader_Portal } ,
{ " entitymergable " , Shader_EntityMergable } ,
2013-10-29 17:38:22 +00:00
//fte extensions
{ " lpp_light " , Shader_Prelight } ,
2009-11-04 21:16:50 +00:00
{ " glslprogram " , Shader_GLSLProgramName } ,
2013-10-29 17:38:22 +00:00
{ " program " , Shader_ProgramName } , //gl or d3d
2013-11-21 23:02:28 +00:00
{ " hlslprogram " , Shader_HLSL9ProgramName } , //for d3d
{ " hlsl11program " , Shader_HLSL11ProgramName } , //for d3d
2013-10-29 17:38:22 +00:00
{ " param " , Shader_ProgramParam } , //legacy
{ " bemode " , Shader_BEMode } ,
2006-03-11 03:12:10 +00:00
2012-09-30 05:52:03 +00:00
//dp compat
{ " dp_camera " , Shader_DP_Camera } ,
2011-02-25 04:22:14 +00:00
/*doom3 compat*/
2013-07-29 17:36:44 +00:00
{ " diffusemap " , Shader_DiffuseMap } , //macro for "{\nstage diffusemap\nmap <map>\n}"
{ " bumpmap " , NULL } , //macro for "{\nstage bumpmap\nmap <map>\n}"
{ " specularmap " , NULL } , //macro for "{\nstage specularmap\nmap <map>\n}"
{ " discrete " , NULL } ,
2011-02-25 04:22:14 +00:00
{ " nonsolid " , NULL } ,
{ " noimpact " , NULL } ,
{ " translucent " , Shader_Translucent } ,
{ " noshadows " , NULL } ,
{ " nooverlays " , NULL } ,
{ " nofragment " , NULL } ,
2011-03-12 13:51:40 +00:00
{ NULL , NULL }
2004-10-19 15:56:22 +00:00
} ;
2013-07-29 17:36:44 +00:00
static struct
{
char * name ;
char * body ;
} shadermacros [ ] =
{
{ " decal_macro " , " polygonOffset 1 \n discrete \n sort decal \n noShadows " } ,
// {"diffusemap", "{\nblend diffusemap\nmap %1\n}"},
// {"bumpmap", "{\nblend bumpmap\nmap %1\n}"},
// {"specularmap", "{\nblend specularmap\nmap %1\n}"},
{ NULL }
} ;
2004-10-19 15:56:22 +00:00
// ===============================================================
2012-09-30 05:52:03 +00:00
static qboolean Shaderpass_MapGen ( shader_t * shader , shaderpass_t * pass , char * tname )
2004-10-19 15:56:22 +00:00
{
2010-11-22 02:03:28 +00:00
if ( ! Q_stricmp ( tname , " $lightmap " ) )
2005-01-07 03:10:11 +00:00
{
2004-10-19 15:56:22 +00:00
pass - > tcgen = TC_GEN_LIGHTMAP ;
2010-11-02 23:17:25 +00:00
pass - > flags | = SHADER_PASS_LIGHTMAP | SHADER_PASS_NOMIPMAP ;
2009-11-04 21:16:50 +00:00
pass - > texgen = T_GEN_LIGHTMAP ;
shader - > flags | = SHADER_HASLIGHTMAP ;
2005-01-07 03:10:11 +00:00
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $deluxmap " ) )
2005-01-07 03:10:11 +00:00
{
pass - > tcgen = TC_GEN_LIGHTMAP ;
2010-11-02 23:17:25 +00:00
pass - > flags | = SHADER_PASS_DELUXMAP | SHADER_PASS_NOMIPMAP ;
2009-11-04 21:16:50 +00:00
pass - > texgen = T_GEN_DELUXMAP ;
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $diffuse " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_DIFFUSE ;
pass - > tcgen = TC_GEN_BASE ;
2011-05-20 04:10:46 +00:00
shader - > flags | = SHADER_NOIMAGE ;
2009-11-04 21:16:50 +00:00
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $normalmap " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_NORMALMAP ;
pass - > tcgen = TC_GEN_BASE ;
2012-05-11 01:57:00 +00:00
shader - > flags | = SHADER_HASNORMALMAP ;
2009-11-04 21:16:50 +00:00
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $specular " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_SPECULAR ;
pass - > tcgen = TC_GEN_BASE ;
2012-11-27 03:23:19 +00:00
shader - > flags | = SHADER_HASGLOSS ;
2009-11-04 21:16:50 +00:00
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $fullbright " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_FULLBRIGHT ;
pass - > tcgen = TC_GEN_BASE ;
2014-06-22 23:44:30 +00:00
shader - > flags | = SHADER_HASFULLBRIGHT ;
2009-11-04 21:16:50 +00:00
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $upperoverlay " ) )
2009-11-04 21:16:50 +00:00
{
2010-07-18 12:52:24 +00:00
shader - > flags | = SHADER_HASTOPBOTTOM ;
2009-11-04 21:16:50 +00:00
pass - > texgen = T_GEN_UPPEROVERLAY ;
pass - > tcgen = TC_GEN_BASE ;
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $loweroverlay " ) )
2009-11-04 21:16:50 +00:00
{
2010-07-18 12:52:24 +00:00
shader - > flags | = SHADER_HASTOPBOTTOM ;
2009-11-04 21:16:50 +00:00
pass - > texgen = T_GEN_LOWEROVERLAY ;
pass - > tcgen = TC_GEN_BASE ;
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $shadowmap " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_SHADOWMAP ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
2013-11-21 23:02:28 +00:00
pass - > flags | = SHADER_PASS_DEPTHCMP ;
2009-11-04 21:16:50 +00:00
}
2011-12-27 08:35:19 +00:00
else if ( ! Q_stricmp ( tname , " $lightcubemap " ) )
{
pass - > texgen = T_GEN_LIGHTCUBEMAP ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2010-11-22 02:03:28 +00:00
else if ( ! Q_stricmp ( tname , " $currentrender " ) )
2009-11-04 21:16:50 +00:00
{
pass - > texgen = T_GEN_CURRENTRENDER ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
2005-01-07 03:10:11 +00:00
}
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( tname , " $sourcecolour " ) )
{
pass - > texgen = T_GEN_SOURCECOLOUR ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2011-10-27 16:16:29 +00:00
else if ( ! Q_stricmp ( tname , " $sourcecube " ) )
{
pass - > texgen = T_GEN_SOURCECUBE ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( tname , " $sourcedepth " ) )
{
pass - > texgen = T_GEN_SOURCEDEPTH ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2012-05-09 15:30:53 +00:00
else if ( ! Q_stricmp ( tname , " $reflection " ) )
{
shader - > flags | = SHADER_HASREFLECT ;
pass - > texgen = T_GEN_REFLECTION ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
else if ( ! Q_stricmp ( tname , " $refraction " ) )
{
shader - > flags | = SHADER_HASREFRACT ;
pass - > texgen = T_GEN_REFRACTION ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( tname , " $refractiondepth " ) )
{
shader - > flags | = SHADER_HASREFRACT ;
pass - > texgen = T_GEN_REFRACTIONDEPTH ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2012-05-14 01:41:08 +00:00
else if ( ! Q_stricmp ( tname , " $ripplemap " ) )
{
shader - > flags | = SHADER_HASRIPPLEMAP ;
pass - > texgen = T_GEN_RIPPLEMAP ;
pass - > tcgen = TC_GEN_BASE ; //FIXME: moo!
}
2005-01-07 03:10:11 +00:00
else
2010-11-22 02:03:28 +00:00
return false ;
return true ;
}
static void Shaderpass_Map ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
int flags ;
char * token ;
pass - > anim_frames [ 0 ] = r_nulltex ;
token = Shader_ParseString ( ptr ) ;
2012-09-30 05:52:03 +00:00
flags = Shader_SetImageFlags ( shader , pass , & token ) ;
if ( ! Shaderpass_MapGen ( shader , pass , token ) )
2005-01-07 03:10:11 +00:00
{
2013-06-23 02:17:02 +00:00
switch ( ( flags & IF_TEXTYPE ) > > IF_TEXTYPESHIFT )
{
case 0 :
2011-12-23 03:12:29 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
2013-06-23 02:17:02 +00:00
break ;
case 1 :
pass - > texgen = T_GEN_3DMAP ;
break ;
default :
pass - > texgen = T_GEN_CUBEMAP ;
break ;
}
2004-10-19 15:56:22 +00:00
pass - > tcgen = TC_GEN_BASE ;
2009-11-04 21:16:50 +00:00
pass - > anim_frames [ 0 ] = Shader_FindImage ( token , flags ) ;
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_AnimMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
2011-03-12 13:51:40 +00:00
int flags ;
2004-10-19 15:56:22 +00:00
char * token ;
2009-11-04 21:16:50 +00:00
texid_t image ;
2004-10-19 15:56:22 +00:00
2012-09-30 05:52:03 +00:00
flags = Shader_SetImageFlags ( shader , pass , NULL ) ;
2004-10-19 15:56:22 +00:00
pass - > tcgen = TC_GEN_BASE ;
2011-03-12 13:51:40 +00:00
pass - > flags | = SHADER_PASS_ANIMMAP ;
2009-11-04 21:16:50 +00:00
pass - > texgen = T_GEN_ANIMMAP ;
2013-03-12 23:13:39 +00:00
pass - > anim_fps = ( int ) Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
pass - > anim_numframes = 0 ;
2011-03-12 13:51:40 +00:00
for ( ; ; )
2009-11-04 21:16:50 +00:00
{
token = Shader_ParseString ( ptr ) ;
if ( ! token [ 0 ] )
{
2004-10-19 15:56:22 +00:00
break ;
}
2013-06-23 02:17:02 +00:00
if ( pass - > anim_numframes < SHADER_MAX_ANIMFRAMES )
2009-11-04 21:16:50 +00:00
{
image = Shader_FindImage ( token , flags ) ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
if ( ! TEXVALID ( image ) )
{
2006-03-06 01:41:09 +00:00
pass - > anim_frames [ pass - > anim_numframes + + ] = missing_texture ;
2007-09-23 15:28:06 +00:00
Con_DPrintf ( CON_WARNING " Shader %s has an animmap with no image: %s. \n " , shader - > name , token ) ;
2009-11-04 21:16:50 +00:00
}
else
{
2004-10-19 15:56:22 +00:00
pass - > anim_frames [ pass - > anim_numframes + + ] = image ;
}
}
}
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_ClampMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
int flags ;
char * token ;
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2004-10-19 15:56:22 +00:00
2012-09-30 05:52:03 +00:00
flags = Shader_SetImageFlags ( shader , pass , & token ) ;
if ( ! Shaderpass_MapGen ( shader , pass , token ) )
2009-11-04 21:16:50 +00:00
{
2010-11-22 02:03:28 +00:00
pass - > tcgen = TC_GEN_BASE ;
pass - > anim_frames [ 0 ] = Shader_FindImage ( token , flags | IF_CLAMP ) ;
2013-06-23 02:17:02 +00:00
switch ( ( flags & IF_TEXTYPE ) > > IF_TEXTYPESHIFT )
{
case 0 :
2011-12-23 03:12:29 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
2013-06-23 02:17:02 +00:00
break ;
case 1 :
pass - > texgen = T_GEN_3DMAP ;
break ;
default :
pass - > texgen = T_GEN_CUBEMAP ;
break ;
}
2010-11-22 02:03:28 +00:00
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
2011-12-23 03:12:29 +00:00
if ( flags & ( IF_3DMAP | IF_CUBEMAP ) )
pass - > anim_frames [ 0 ] = r_nulltex ;
else
pass - > anim_frames [ 0 ] = missing_texture ;
2010-11-22 02:03:28 +00:00
Con_DPrintf ( CON_WARNING " Shader %s has a stage with no image: %s. \n " , shader - > name , token ) ;
}
}
pass - > flags | = SHADER_PASS_CLAMP ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_VideoMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
2006-03-06 01:41:09 +00:00
char * token ;
2004-10-19 15:56:22 +00:00
2012-10-08 04:36:10 +00:00
token = Shader_ParseSensString ( ptr ) ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
# ifdef NOMEDIA
# else
if ( pass - > cin )
Z_Free ( pass - > cin ) ;
2004-10-19 15:56:22 +00:00
2006-03-06 01:41:09 +00:00
pass - > cin = Media_StartCin ( token ) ;
if ( ! pass - > cin )
pass - > cin = Media_StartCin ( va ( " video/%s.roq " , token ) ) ;
2012-04-24 07:59:11 +00:00
if ( ! pass - > cin )
2009-11-04 21:16:50 +00:00
Con_DPrintf ( CON_WARNING " (shader %s) Couldn't load video %s \n " , shader - > name , token ) ;
2006-03-06 01:41:09 +00:00
2010-05-01 22:47:47 +00:00
if ( pass - > cin )
{
pass - > flags | = SHADER_PASS_VIDEOMAP ;
shader - > flags | = SHADER_VIDEOMAP ;
pass - > texgen = T_GEN_VIDEOMAP ;
}
else
{
pass - > texgen = T_GEN_DIFFUSE ;
pass - > rgbgen = RGB_GEN_CONST ;
pass - > rgbgen_func . type = SHADER_FUNC_CONSTANT ;
pass - > rgbgen_func . args [ 0 ] = pass - > rgbgen_func . args [ 1 ] = pass - > rgbgen_func . args [ 2 ] = 0 ;
}
2009-11-04 21:16:50 +00:00
# endif
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_RGBGen ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " identitylighting " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_IDENTITY_LIGHTING ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " identity " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_IDENTITY ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " wave " ) )
2005-02-06 02:47:36 +00:00
{
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_WAVE ;
2013-03-12 23:13:39 +00:00
Shader_ParseFunc ( shader , ptr , & pass - > rgbgen_func ) ;
2005-02-06 02:47:36 +00:00
}
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " entity " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_ENTITY ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " oneMinusEntity " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_ONE_MINUS_ENTITY ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " vertex " ) )
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " oneMinusVertex " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_ONE_MINUS_VERTEX ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " lightingDiffuse " ) )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_LIGHTING_DIFFUSE ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " exactvertex " ) )
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_EXACT ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " const " ) | | ! Q_stricmp ( token , " constant " ) )
2005-02-06 02:47:36 +00:00
{
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_CONST ;
pass - > rgbgen_func . type = SHADER_FUNC_CONSTANT ;
2013-03-12 23:13:39 +00:00
Shader_ParseVector ( shader , ptr , pass - > rgbgen_func . args ) ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " topcolor " ) )
2005-02-06 02:47:36 +00:00
pass - > rgbgen = RGB_GEN_TOPCOLOR ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " bottomcolor " ) )
2005-02-06 02:47:36 +00:00
pass - > rgbgen = RGB_GEN_BOTTOMCOLOR ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_AlphaGen ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " portal " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_PORTAL ;
2013-03-12 23:13:39 +00:00
shader - > portaldist = Shader_ParseFloat ( shader , ptr ) ;
2010-07-11 02:22:39 +00:00
if ( ! shader - > portaldist )
shader - > portaldist = 256 ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_AGEN_PORTAL ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " vertex " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_VERTEX ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " entity " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_ENTITY ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " wave " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_WAVE ;
2013-03-12 23:13:39 +00:00
Shader_ParseFunc ( shader , ptr , & pass - > alphagen_func ) ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " lightingspecular " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_SPECULAR ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " const " ) | | ! Q_stricmp ( token , " constant " ) )
{
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_CONST ;
pass - > alphagen_func . type = SHADER_FUNC_CONSTANT ;
2013-03-12 23:13:39 +00:00
pass - > alphagen_func . args [ 0 ] = fabs ( Shader_ParseFloat ( shader , ptr ) ) ;
2004-10-19 15:56:22 +00:00
}
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_AlphaShift ( shader_t * shader , shaderpass_t * pass , char * * ptr ) //for alienarena
2006-02-27 00:42:25 +00:00
{
float speed ;
float min , max ;
pass - > alphagen = ALPHA_GEN_WAVE ;
pass - > alphagen_func . type = SHADER_FUNC_SIN ;
//arg0 = add
//arg1 = scale
//arg2 = timeshift
//arg3 = timescale
2013-03-12 23:13:39 +00:00
speed = Shader_ParseFloat ( shader , ptr ) ;
min = Shader_ParseFloat ( shader , ptr ) ;
max = Shader_ParseFloat ( shader , ptr ) ;
2006-02-27 00:42:25 +00:00
pass - > alphagen_func . args [ 0 ] = min + ( max - min ) / 2 ;
pass - > alphagen_func . args [ 1 ] = ( max - min ) / 2 ;
pass - > alphagen_func . args [ 2 ] = 0 ;
pass - > alphagen_func . args [ 3 ] = 1 / speed ;
}
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
static int Shader_BlendFactor ( char * name , qboolean dstnotsrc )
{
int factor ;
if ( ! strnicmp ( name , " gl_ " , 3 ) )
name + = 3 ;
if ( ! Q_stricmp ( name , " zero " ) )
factor = SBITS_SRCBLEND_ZERO ;
else if ( ! Q_stricmp ( name , " one " ) )
factor = SBITS_SRCBLEND_ONE ;
else if ( ! Q_stricmp ( name , " dst_color " ) )
factor = SBITS_SRCBLEND_DST_COLOR ;
else if ( ! Q_stricmp ( name , " one_minus_src_alpha " ) )
factor = SBITS_SRCBLEND_ONE_MINUS_SRC_ALPHA ;
else if ( ! Q_stricmp ( name , " src_alpha " ) )
factor = SBITS_SRCBLEND_SRC_ALPHA ;
else if ( ! Q_stricmp ( name , " src_color " ) )
factor = SBITS_SRCBLEND_SRC_COLOR_INVALID ;
else if ( ! Q_stricmp ( name , " one_minus_dst_color " ) )
factor = SBITS_SRCBLEND_ONE_MINUS_DST_COLOR ;
else if ( ! Q_stricmp ( name , " one_minus_src_color " ) )
factor = SBITS_SRCBLEND_ONE_MINUS_SRC_COLOR_INVALID ;
else if ( ! Q_stricmp ( name , " dst_alpha " ) )
factor = SBITS_SRCBLEND_DST_ALPHA ;
else if ( ! Q_stricmp ( name , " one_minus_dst_alpha " ) )
factor = SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA ;
else
factor = SBITS_SRCBLEND_NONE ;
if ( dstnotsrc )
{
//dest factors are shifted
factor < < = 4 ;
/*gl doesn't accept dst_color for destinations*/
if ( factor = = SBITS_DSTBLEND_NONE | |
factor = = SBITS_DSTBLEND_DST_COLOR_INVALID | |
factor = = SBITS_DSTBLEND_ONE_MINUS_DST_COLOR_INVALID | |
factor = = SBITS_DSTBLEND_ALPHA_SATURATE_INVALID )
{
Con_DPrintf ( " Invalid shader dst blend \" %s \" \n " , name ) ;
factor = SBITS_DSTBLEND_ONE ;
}
}
else
{
/*gl doesn't accept src_color for sources*/
if ( factor = = SBITS_SRCBLEND_NONE | |
factor = = SBITS_SRCBLEND_SRC_COLOR_INVALID | |
factor = = SBITS_SRCBLEND_ONE_MINUS_SRC_COLOR_INVALID )
{
Con_DPrintf ( " Unrecognised shader src blend \" %s \" \n " , name ) ;
factor = SBITS_SRCBLEND_ONE ;
}
}
return factor ;
}
static void Shaderpass_BlendFunc ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2013-07-29 17:36:44 +00:00
//reset to defaults
2009-11-04 21:16:50 +00:00
pass - > shaderbits & = ~ ( SBITS_BLEND_BITS ) ;
2013-07-29 17:36:44 +00:00
pass - > stagetype = ST_AMBIENT ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2013-07-29 17:36:44 +00:00
if ( ! Q_stricmp ( token , " bumpmap " ) ) //doom3 is awkward...
pass - > stagetype = ST_BUMPMAP ;
else if ( ! Q_stricmp ( token , " specularmap " ) ) //doom3 is awkward...
pass - > stagetype = ST_SPECULARMAP ;
else if ( ! Q_stricmp ( token , " diffusemap " ) ) //doom3 is awkward...
pass - > stagetype = ST_DIFFUSEMAP ;
2011-02-25 04:22:14 +00:00
else if ( ! Q_stricmp ( token , " blend " ) )
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_SRCBLEND_SRC_ALPHA | SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA ;
else if ( ! Q_stricmp ( token , " filter " ) )
pass - > shaderbits | = SBITS_SRCBLEND_DST_COLOR | SBITS_DSTBLEND_ZERO ;
else if ( ! Q_stricmp ( token , " add " ) )
2010-11-07 02:53:46 +00:00
pass - > shaderbits | = SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE ;
2009-11-04 21:16:50 +00:00
else if ( ! Q_stricmp ( token , " replace " ) )
pass - > shaderbits | = SBITS_SRCBLEND_NONE | SBITS_DSTBLEND_NONE ;
else
{
pass - > shaderbits | = Shader_BlendFactor ( token , false ) ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2011-02-25 04:22:14 +00:00
if ( * token = = ' , ' )
token = Shader_ParseString ( ptr ) ;
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = Shader_BlendFactor ( token , true ) ;
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_AlphaFunc ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2009-11-04 21:16:50 +00:00
pass - > shaderbits & = ~ SBITS_ATEST_BITS ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2011-03-12 13:51:40 +00:00
if ( ! Q_stricmp ( token , " gt0 " ) )
2009-11-04 21:16:50 +00:00
{
pass - > shaderbits = SBITS_ATEST_GT0 ;
}
else if ( ! Q_stricmp ( token , " lt128 " ) )
{
pass - > shaderbits = SBITS_ATEST_LT128 ;
}
else if ( ! Q_stricmp ( token , " ge128 " ) )
{
pass - > shaderbits = SBITS_ATEST_GE128 ;
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_DepthFunc ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
char * token ;
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
2011-03-12 13:51:40 +00:00
if ( ! Q_stricmp ( token , " equal " ) )
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHEQUALONLY ;
2011-03-12 13:51:40 +00:00
else if ( ! Q_stricmp ( token , " lequal " ) )
2009-11-04 21:16:50 +00:00
pass - > shaderbits & = ~ SBITS_MISC_DEPTHEQUALONLY ;
else
Con_DPrintf ( " Invalid depth func %s \n " , token ) ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_DepthWrite ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
2011-03-12 13:51:40 +00:00
shader - > flags | = SHADER_DEPTHWRITE ;
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2004-10-19 15:56:22 +00:00
}
2011-10-27 16:16:29 +00:00
static void Shaderpass_NoDepthTest ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = SHADER_DEPTHWRITE ;
pass - > shaderbits | = SBITS_MISC_NODEPTHTEST ;
}
static void Shaderpass_NoDepth ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
shader - > flags | = SHADER_DEPTHWRITE ;
}
2009-11-04 21:16:50 +00:00
static void Shaderpass_TcMod ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2004-10-19 15:56:22 +00:00
{
int i ;
tcmod_t * tcmod ;
char * token ;
2011-09-03 03:49:43 +00:00
if ( pass - > numtcmods > = SHADER_MAX_TC_MODS )
2009-11-04 21:16:50 +00:00
{
2004-10-19 15:56:22 +00:00
return ;
}
tcmod = & pass - > tcmods [ pass - > numtcmods ] ;
2009-11-04 21:16:50 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " rotate " ) )
{
2013-03-12 23:13:39 +00:00
tcmod - > args [ 0 ] = - Shader_ParseFloat ( shader , ptr ) / 360.0f ;
2009-11-04 21:16:50 +00:00
if ( ! tcmod - > args [ 0 ] )
{
2004-10-19 15:56:22 +00:00
return ;
}
tcmod - > type = SHADER_TCMOD_ROTATE ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " scale " ) )
{
2013-03-12 23:13:39 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
tcmod - > type = SHADER_TCMOD_SCALE ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " scroll " ) )
{
2013-03-12 23:13:39 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
tcmod - > type = SHADER_TCMOD_SCROLL ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " stretch " ) )
{
2004-10-19 15:56:22 +00:00
shaderfunc_t func ;
2013-03-12 23:13:39 +00:00
Shader_ParseFunc ( shader , ptr , & func ) ;
2004-10-19 15:56:22 +00:00
tcmod - > args [ 0 ] = func . type ;
for ( i = 1 ; i < 5 ; + + i )
tcmod - > args [ i ] = func . args [ i - 1 ] ;
tcmod - > type = SHADER_TCMOD_STRETCH ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " transform " ) )
{
2004-10-19 15:56:22 +00:00
for ( i = 0 ; i < 6 ; + + i )
2013-03-12 23:13:39 +00:00
tcmod - > args [ i ] = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
tcmod - > type = SHADER_TCMOD_TRANSFORM ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " turb " ) )
{
2004-10-19 15:56:22 +00:00
for ( i = 0 ; i < 4 ; i + + )
2013-03-12 23:13:39 +00:00
tcmod - > args [ i ] = Shader_ParseFloat ( shader , ptr ) ;
2004-10-19 15:56:22 +00:00
tcmod - > type = SHADER_TCMOD_TURB ;
2009-11-04 21:16:50 +00:00
}
else
{
2004-10-19 15:56:22 +00:00
return ;
}
pass - > numtcmods + + ;
}
2006-02-27 00:42:25 +00:00
static void Shaderpass_Scale ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
//seperate x and y
char * token ;
tcmod_t * tcmod ;
tcmod = & pass - > tcmods [ pass - > numtcmods ] ;
2011-02-25 04:22:14 +00:00
tcmod - > type = SHADER_TCMOD_SCALE ;
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
2006-02-27 00:42:25 +00:00
if ( ! strcmp ( token , " static " ) )
{
2013-03-12 23:13:39 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
2006-02-27 00:42:25 +00:00
}
else
{
2011-02-25 04:22:14 +00:00
tcmod - > args [ 0 ] = atof ( token ) ;
2006-02-27 00:42:25 +00:00
}
2011-05-15 13:23:13 +00:00
2011-02-25 04:22:14 +00:00
while ( * * ptr = = ' ' | | * * ptr = = ' \t ' )
* ptr + = 1 ;
if ( * * ptr = = ' , ' )
* ptr + = 1 ;
2006-02-27 00:42:25 +00:00
2013-03-12 23:13:39 +00:00
token = Shader_ParseString ( ptr ) ;
2006-02-27 00:42:25 +00:00
if ( ! strcmp ( token , " static " ) )
{
2013-03-12 23:13:39 +00:00
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
2006-02-27 00:42:25 +00:00
}
else
{
2011-02-25 04:22:14 +00:00
tcmod - > args [ 1 ] = atof ( token ) ;
2006-02-27 00:42:25 +00:00
}
pass - > numtcmods + + ;
}
2013-03-12 23:13:39 +00:00
static void Shaderpass_Scroll ( shader_t * shader , shaderpass_t * pass , char * * ptr )
2006-02-27 00:42:25 +00:00
{
//seperate x and y
char * token ;
tcmod_t * tcmod ;
tcmod = & pass - > tcmods [ pass - > numtcmods ] ;
token = Shader_ParseString ( ptr ) ;
if ( ! strcmp ( token , " static " ) )
{
tcmod - > type = SHADER_TCMOD_SCROLL ;
2013-03-12 23:13:39 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
2006-02-27 00:42:25 +00:00
}
else
{
Con_Printf ( " Bad shader scale \n " ) ;
return ;
}
token = Shader_ParseString ( ptr ) ;
if ( ! strcmp ( token , " static " ) )
{
tcmod - > type = SHADER_TCMOD_SCROLL ;
2013-03-12 23:13:39 +00:00
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
2006-02-27 00:42:25 +00:00
}
else
{
Con_Printf ( " Bad shader scale \n " ) ;
return ;
}
pass - > numtcmods + + ;
}
2004-10-19 15:56:22 +00:00
static void Shaderpass_TcGen ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token ;
token = Shader_ParseString ( ptr ) ;
if ( ! Q_stricmp ( token , " base " ) ) {
pass - > tcgen = TC_GEN_BASE ;
} else if ( ! Q_stricmp ( token , " lightmap " ) ) {
pass - > tcgen = TC_GEN_LIGHTMAP ;
} else if ( ! Q_stricmp ( token , " environment " ) ) {
pass - > tcgen = TC_GEN_ENVIRONMENT ;
} else if ( ! Q_stricmp ( token , " vector " ) ) {
pass - > tcgen = TC_GEN_BASE ;
2009-07-05 18:45:53 +00:00
} else if ( ! Q_stricmp ( token , " normal " ) ) {
pass - > tcgen = TC_GEN_NORMAL ;
} else if ( ! Q_stricmp ( token , " svector " ) ) {
pass - > tcgen = TC_GEN_SVECTOR ;
} else if ( ! Q_stricmp ( token , " tvector " ) ) {
pass - > tcgen = TC_GEN_TVECTOR ;
2004-10-19 15:56:22 +00:00
}
}
2006-02-27 00:42:25 +00:00
static void Shaderpass_EnvMap ( shader_t * shader , shaderpass_t * pass , char * * ptr ) //for alienarena
{
pass - > tcgen = TC_GEN_ENVIRONMENT ;
}
2004-10-19 15:56:22 +00:00
static void Shaderpass_Detail ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > flags | = SHADER_PASS_DETAIL ;
}
2006-02-27 00:42:25 +00:00
static void Shaderpass_AlphaMask ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
2009-11-04 21:16:50 +00:00
pass - > shaderbits & = ~ SBITS_ATEST_BITS ;
pass - > shaderbits | = SBITS_ATEST_GE128 ;
2006-02-27 00:42:25 +00:00
}
static void Shaderpass_NoLightMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > rgbgen = RGB_GEN_IDENTITY ;
}
2011-12-05 15:23:40 +00:00
static void Shaderpass_Red ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > rgbgen = RGB_GEN_CONST ;
2013-03-12 23:13:39 +00:00
pass - > rgbgen_func . args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
2011-12-05 15:23:40 +00:00
}
static void Shaderpass_Green ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > rgbgen = RGB_GEN_CONST ;
2013-03-12 23:13:39 +00:00
pass - > rgbgen_func . args [ 1 ] = Shader_ParseFloat ( shader , ptr ) ;
2011-12-05 15:23:40 +00:00
}
static void Shaderpass_Blue ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > rgbgen = RGB_GEN_CONST ;
2013-03-12 23:13:39 +00:00
pass - > rgbgen_func . args [ 2 ] = Shader_ParseFloat ( shader , ptr ) ;
2011-12-05 15:23:40 +00:00
}
static void Shaderpass_Alpha ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > alphagen = ALPHA_GEN_CONST ;
2013-03-12 23:13:39 +00:00
pass - > alphagen_func . args [ 0 ] = Shader_ParseFloat ( shader , ptr ) ;
2011-12-05 15:23:40 +00:00
}
2011-02-25 04:22:14 +00:00
static void Shaderpass_MaskColor ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > shaderbits | = SBITS_MASK_RED | SBITS_MASK_GREEN | SBITS_MASK_BLUE ;
}
static void Shaderpass_MaskRed ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > shaderbits | = SBITS_MASK_RED ;
}
static void Shaderpass_MaskGreen ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > shaderbits | = SBITS_MASK_GREEN ;
}
static void Shaderpass_MaskBlue ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > shaderbits | = SBITS_MASK_BLUE ;
}
static void Shaderpass_MaskAlpha ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
pass - > shaderbits | = SBITS_MASK_ALPHA ;
}
static void Shaderpass_AlphaTest ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
2013-03-12 23:13:39 +00:00
if ( Shader_ParseFloat ( shader , ptr ) = = 0.5 )
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_ATEST_GE128 ;
else
Con_Printf ( " unsupported alphatest value \n " ) ;
}
static void Shaderpass_TexGen ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
char * token = Shader_ParseString ( ptr ) ;
if ( ! strcmp ( token , " normal " ) )
pass - > tcgen = TC_GEN_NORMAL ;
else if ( ! strcmp ( token , " skybox " ) )
pass - > tcgen = TC_GEN_SKYBOX ;
else if ( ! strcmp ( token , " wobblesky " ) )
{
pass - > tcgen = TC_GEN_WOBBLESKY ;
token = Shader_ParseString ( ptr ) ;
token = Shader_ParseString ( ptr ) ;
token = Shader_ParseString ( ptr ) ;
}
else if ( ! strcmp ( token , " reflect " ) )
pass - > tcgen = TC_GEN_REFLECT ;
else
{
Con_Printf ( " texgen token not understood \n " ) ;
}
}
static void Shaderpass_CubeMap ( shader_t * shader , shaderpass_t * pass , char * * ptr )
{
2011-12-23 03:12:29 +00:00
char * token = Shader_ParseString ( ptr ) ;
2011-02-25 04:22:14 +00:00
if ( pass - > tcgen = = TC_GEN_BASE )
pass - > tcgen = TC_GEN_SKYBOX ;
2011-12-23 03:12:29 +00:00
pass - > texgen = T_GEN_CUBEMAP ;
pass - > anim_frames [ 0 ] = Shader_FindImage ( token , IF_CUBEMAP ) ;
2011-02-25 04:22:14 +00:00
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
pass - > texgen = T_GEN_SINGLEMAP ;
pass - > anim_frames [ 0 ] = missing_texture ;
}
}
2004-10-19 15:56:22 +00:00
static shaderkey_t shaderpasskeys [ ] =
{
2011-03-12 13:51:40 +00:00
{ " rgbgen " , Shaderpass_RGBGen } ,
{ " blendfunc " , Shaderpass_BlendFunc } ,
{ " depthfunc " , Shaderpass_DepthFunc } ,
{ " depthwrite " , Shaderpass_DepthWrite } ,
2011-10-27 16:16:29 +00:00
{ " nodepthtest " , Shaderpass_NoDepthTest } ,
{ " nodepth " , Shaderpass_NoDepth } ,
2011-03-12 13:51:40 +00:00
{ " alphafunc " , Shaderpass_AlphaFunc } ,
{ " tcmod " , Shaderpass_TcMod } ,
{ " map " , Shaderpass_Map } ,
{ " animmap " , Shaderpass_AnimMap } ,
{ " clampmap " , Shaderpass_ClampMap } ,
{ " videomap " , Shaderpass_VideoMap } ,
{ " tcgen " , Shaderpass_TcGen } ,
{ " envmap " , Shaderpass_EnvMap } , //for alienarena
{ " nolightmap " , Shaderpass_NoLightMap } , //for alienarena
{ " scale " , Shaderpass_Scale } , //for alienarena
{ " scroll " , Shaderpass_Scroll } , //for alienarena
{ " alphagen " , Shaderpass_AlphaGen } ,
{ " alphashift " , Shaderpass_AlphaShift } , //for alienarena
{ " alphamask " , Shaderpass_AlphaMask } , //for alienarena
{ " detail " , Shaderpass_Detail } ,
2011-02-25 04:22:14 +00:00
/*doom3 compat*/
{ " blend " , Shaderpass_BlendFunc } ,
{ " maskcolor " , Shaderpass_MaskColor } ,
{ " maskred " , Shaderpass_MaskRed } ,
{ " maskgreen " , Shaderpass_MaskGreen } ,
{ " maskblue " , Shaderpass_MaskBlue } ,
{ " maskalpha " , Shaderpass_MaskAlpha } ,
{ " alphatest " , Shaderpass_AlphaTest } ,
{ " texgen " , Shaderpass_TexGen } ,
2014-02-07 08:38:40 +00:00
{ " cubemap " , Shaderpass_CubeMap } , //one of these is wrong
{ " cameracubemap " , Shaderpass_CubeMap } , //one of these is wrong
2011-12-05 15:23:40 +00:00
{ " red " , Shaderpass_Red } ,
{ " green " , Shaderpass_Green } ,
{ " blue " , Shaderpass_Blue } ,
{ " alpha " , Shaderpass_Alpha } ,
2011-03-12 13:51:40 +00:00
{ NULL , NULL }
2004-10-19 15:56:22 +00:00
} ;
// ===============================================================
2011-06-04 16:11:35 +00:00
void Shader_FreePass ( shaderpass_t * pass )
{
# ifndef NOMEDIA
if ( pass - > flags & SHADER_PASS_VIDEOMAP )
{
Media_ShutdownCin ( pass - > cin ) ;
pass - > cin = NULL ;
}
# endif
}
void Shader_Free ( shader_t * shader )
{
int i ;
shaderpass_t * pass ;
if ( shader - > bucket . data = = shader )
Hash_RemoveData ( & shader_active_hash , shader - > name , shader ) ;
shader - > bucket . data = NULL ;
2011-06-05 23:53:33 +00:00
if ( shader - > prog )
2012-09-30 05:52:03 +00:00
{
if ( shader - > prog - > refs - - = = 1 )
Shader_UnloadProg ( shader - > prog ) ;
}
2011-06-05 23:53:33 +00:00
shader - > prog = NULL ;
2011-06-04 16:11:35 +00:00
if ( shader - > skydome )
{
Z_Free ( shader - > skydome ) ;
}
pass = shader - > passes ;
for ( i = 0 ; i < shader - > numpasses ; i + + , pass + + )
{
Shader_FreePass ( pass ) ;
}
shader - > numpasses = 0 ;
2011-12-05 15:23:40 +00:00
if ( shader - > genargs )
{
free ( shader - > genargs ) ;
shader - > genargs = NULL ;
}
shader - > uses = 0 ;
2013-05-11 14:02:55 +00:00
memset ( & shader - > defaulttextures , 0 , sizeof ( shader - > defaulttextures ) ) ;
2011-06-04 16:11:35 +00:00
}
2014-02-07 08:38:40 +00:00
int QDECL Shader_InitCallback ( const char * name , qofs_t size , void * param , searchpathfuncs_t * spath )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
Shader_MakeCache ( name ) ;
2004-10-19 15:56:22 +00:00
return true ;
}
qboolean Shader_Init ( void )
{
2011-10-27 16:16:29 +00:00
int wibuf [ 16 ] ;
2005-03-28 00:11:59 +00:00
2011-06-05 23:53:33 +00:00
if ( ! r_shaders )
{
2013-10-29 17:38:22 +00:00
r_numshaders = 0 ;
r_maxshaders = 256 ;
r_shaders = calloc ( r_maxshaders , sizeof ( * r_shaders ) ) ;
2010-05-01 22:47:47 +00:00
2011-06-05 23:53:33 +00:00
shader_hash = calloc ( HASH_SIZE , sizeof ( * shader_hash ) ) ;
2010-05-01 22:47:47 +00:00
2011-06-05 23:53:33 +00:00
shader_active_hash_mem = malloc ( Hash_BytesForBuckets ( 1024 ) ) ;
memset ( shader_active_hash_mem , 0 , Hash_BytesForBuckets ( 1024 ) ) ;
Hash_InitTable ( & shader_active_hash , 1024 , shader_active_hash_mem ) ;
2004-10-19 15:56:22 +00:00
2011-06-05 23:53:33 +00:00
Shader_FlushGenerics ( ) ;
2011-06-04 16:11:35 +00:00
}
2011-12-05 15:23:40 +00:00
Shader_NeedReload ( true ) ;
2010-03-14 14:35:56 +00:00
Shader_DoReload ( ) ;
2011-10-27 16:16:29 +00:00
memset ( wibuf , 0xff , sizeof ( wibuf ) ) ;
if ( ! qrenderer )
r_whiteimage = r_nulltex ;
else
r_whiteimage = R_LoadTexture ( " $whiteimage " , 4 , 4 , TF_RGBA32 , wibuf , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA ) ;
2004-10-19 15:56:22 +00:00
return true ;
}
2014-03-30 08:55:06 +00:00
void Shader_FlushCache ( void )
{
shadercachefile_t * sf ;
shadercache_t * cache , * cache_next ;
int i ;
for ( i = 0 ; i < HASH_SIZE ; i + + )
{
cache = shader_hash [ i ] ;
2014-06-21 17:58:17 +00:00
shader_hash [ i ] = NULL ;
2014-03-30 08:55:06 +00:00
for ( ; cache ; cache = cache_next )
{
cache_next = cache - > hash_next ;
cache - > hash_next = NULL ;
Z_Free ( cache ) ;
}
}
while ( shaderfiles )
{
sf = shaderfiles ;
shaderfiles = sf - > next ;
if ( sf - > data )
FS_FreeFile ( sf - > data ) ;
Z_Free ( sf ) ;
}
}
static void Shader_MakeCache ( const char * path )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
unsigned int key ;
char * buf , * ptr , * token ;
2004-10-19 15:56:22 +00:00
shadercache_t * cache ;
2014-03-30 08:55:06 +00:00
shadercachefile_t * cachefile , * filelink = NULL ;
qofs_t size ;
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
for ( cachefile = shaderfiles ; cachefile ; cachefile = cachefile - > next )
{
if ( ! Q_stricmp ( cachefile - > name , path ) )
return ; //already loaded. there's no source package or anything.
filelink = cachefile ;
}
Con_DPrintf ( " ...loading '%s' \n " , path ) ;
cachefile = Z_Malloc ( sizeof ( * cachefile ) + strlen ( path ) ) ;
strcpy ( cachefile - > name , path ) ;
size = FS_LoadFile ( path , ( void * * ) & cachefile - > data ) ;
cachefile - > length = size ;
if ( filelink )
filelink - > next = cachefile ;
else
shaderfiles = cachefile ;
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
if ( qofs_Error ( size ) )
{
Con_Printf ( " Unable to read %s \n " , path ) ;
cachefile - > length = 0 ;
return ;
}
if ( size > 1024 * 1024 * 64 ) //sanity limit
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
Con_Printf ( " Refusing to parse %s due to size \n " , path ) ;
cachefile - > length = 0 ;
FS_FreeFile ( cachefile - > data ) ;
cachefile - > data = NULL ;
2004-10-19 15:56:22 +00:00
return ;
}
2014-03-30 08:55:06 +00:00
ptr = buf = cachefile - > data ;
size = cachefile - > length ;
2004-10-19 15:56:22 +00:00
do
{
if ( ptr - buf > = size )
break ;
------------------------------------------------------------------------
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
token = COM_ParseExt ( & ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
if ( ! token [ 0 ] | | ptr - buf > = size )
break ;
2005-08-26 22:56:51 +00:00
COM_CleanUpPath ( token ) ;
2014-03-30 08:55:06 +00:00
if ( Shader_LocateSource ( token , NULL , NULL , NULL , NULL ) )
2009-11-04 21:16:50 +00:00
{
2004-10-19 15:56:22 +00:00
ptr = Shader_Skip ( ptr ) ;
continue ;
}
key = Hash_Key ( token , HASH_SIZE ) ;
2014-03-30 08:55:06 +00:00
cache = ( shadercache_t * ) Z_Malloc ( sizeof ( shadercache_t ) + strlen ( token ) ) ;
strcpy ( cache - > name , token ) ;
2004-10-19 15:56:22 +00:00
cache - > hash_next = shader_hash [ key ] ;
2014-03-30 08:55:06 +00:00
cache - > source = cachefile ;
cache - > offset = ptr - cachefile - > data ;
2004-10-19 15:56:22 +00:00
shader_hash [ key ] = cache ;
ptr = Shader_Skip ( ptr ) ;
} while ( ptr ) ;
2014-03-30 08:55:06 +00:00
}
static qboolean Shader_LocateSource ( char * name , char * * buf , size_t * bufsize , size_t * offset , enum shaderparsemode_e * parsemode )
{
unsigned int key ;
shadercache_t * cache ;
key = Hash_Key ( name , HASH_SIZE ) ;
cache = shader_hash [ key ] ;
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
for ( ; cache ; cache = cache - > hash_next )
{
if ( ! Q_stricmp ( cache - > name , name ) )
{
if ( buf )
{
* buf = cache - > source - > data ;
* bufsize = cache - > source - > length ;
* offset = cache - > offset ;
* parsemode = cache - > source - > parsemode ;
}
return true ;
}
}
return false ;
2004-10-19 15:56:22 +00:00
}
char * Shader_Skip ( char * ptr )
2010-11-26 06:58:48 +00:00
{
2004-10-19 15:56:22 +00:00
char * tok ;
2011-03-12 13:51:40 +00:00
int brace_count ;
2004-10-19 15:56:22 +00:00
// Opening brace
------------------------------------------------------------------------
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
tok = COM_ParseExt ( & ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
if ( ! ptr )
return NULL ;
2010-11-26 06:58:48 +00:00
2009-11-04 21:16:50 +00:00
if ( tok [ 0 ] ! = ' { ' )
{
------------------------------------------------------------------------
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
tok = COM_ParseExt ( & ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
}
2011-03-12 13:51:40 +00:00
for ( brace_count = 1 ; brace_count > 0 ; ptr + + )
{
------------------------------------------------------------------------
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
tok = COM_ParseExt ( & ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
if ( ! tok [ 0 ] )
return NULL ;
2009-11-04 21:16:50 +00:00
if ( tok [ 0 ] = = ' { ' )
{
2004-10-19 15:56:22 +00:00
brace_count + + ;
2009-11-04 21:16:50 +00:00
} else if ( tok [ 0 ] = = ' } ' )
{
2004-10-19 15:56:22 +00:00
brace_count - - ;
}
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
return ptr ;
}
2011-05-20 04:10:46 +00:00
void Shader_Reset ( shader_t * s )
{
char name [ MAX_QPATH ] ;
2014-02-07 08:38:40 +00:00
int id = s - > id ;
2011-05-20 04:10:46 +00:00
int uses = s - > uses ;
shader_gen_t * defaultgen = s - > generator ;
2011-12-05 15:23:40 +00:00
char * genargs = s - > genargs ;
2011-05-20 04:10:46 +00:00
texnums_t dt = s - > defaulttextures ;
2013-05-11 14:02:55 +00:00
int w = s - > width ;
int h = s - > height ;
2013-08-21 07:14:39 +00:00
unsigned int uf = s - > usageflags ;
2011-05-20 04:10:46 +00:00
Q_strncpyz ( name , s - > name , sizeof ( name ) ) ;
2011-12-05 15:23:40 +00:00
s - > genargs = NULL ;
2011-05-20 04:10:46 +00:00
Shader_Free ( s ) ;
memset ( s , 0 , sizeof ( * s ) ) ;
2014-02-13 23:54:57 +00:00
s - > remapto = s ;
2014-02-07 08:38:40 +00:00
s - > id = id ;
2013-05-11 14:02:55 +00:00
s - > width = w ;
s - > height = h ;
2011-05-20 04:10:46 +00:00
s - > defaulttextures = dt ;
s - > generator = defaultgen ;
s - > genargs = genargs ;
2013-08-21 07:14:39 +00:00
s - > usageflags = uf ;
2011-05-20 04:10:46 +00:00
s - > uses = uses ;
Q_strncpyz ( s - > name , name , sizeof ( s - > name ) ) ;
Hash_Add ( & shader_active_hash , s - > name , s , & s - > bucket ) ;
}
2004-10-19 15:56:22 +00:00
void Shader_Shutdown ( void )
{
int i ;
shader_t * shader ;
2010-07-25 15:12:12 +00:00
if ( ! r_shaders )
return ; /*nothing needs freeing yet*/
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < r_numshaders ; i + + )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
shader = r_shaders [ i ] ;
2014-06-30 21:57:35 +00:00
if ( ! shader )
2004-10-19 15:56:22 +00:00
continue ;
2009-11-04 21:16:50 +00:00
2011-06-05 23:53:33 +00:00
Shader_Free ( shader ) ;
2013-10-29 17:38:22 +00:00
Z_Free ( r_shaders [ i ] ) ;
r_shaders [ i ] = NULL ;
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
Shader_FlushCache ( ) ;
2012-07-05 19:42:36 +00:00
Shader_FlushGenerics ( ) ;
2013-10-29 17:38:22 +00:00
r_maxshaders = 0 ;
r_numshaders = 0 ;
2010-07-11 02:22:39 +00:00
free ( r_shaders ) ;
2010-05-01 22:47:47 +00:00
r_shaders = NULL ;
2010-07-11 02:22:39 +00:00
free ( shader_hash ) ;
2010-05-01 22:47:47 +00:00
shader_hash = NULL ;
2010-07-11 02:22:39 +00:00
free ( shader_active_hash_mem ) ;
shader_active_hash_mem = NULL ;
2009-11-04 21:16:50 +00:00
shader_reload_needed = false ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
void Shader_SetBlendmode ( shaderpass_t * pass )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( pass - > texgen = = T_GEN_DELUXMAP )
{
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_DOTPRODUCT ;
2009-11-04 21:16:50 +00:00
return ;
}
if ( pass - > texgen < T_GEN_DIFFUSE & & ! TEXVALID ( pass - > anim_frames [ 0 ] ) & & ! ( pass - > flags & SHADER_PASS_LIGHTMAP ) )
{
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_MODULATE ;
2004-10-19 15:56:22 +00:00
return ;
}
2010-05-01 22:47:47 +00:00
if ( ! ( pass - > shaderbits & SBITS_BLEND_BITS ) )
2009-11-04 21:16:50 +00:00
{
if ( ( pass - > rgbgen = = RGB_GEN_IDENTITY ) & & ( pass - > alphagen = = ALPHA_GEN_IDENTITY ) )
{
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_REPLACE ;
2011-10-27 16:16:29 +00:00
return ;
}
else if ( ( pass - > rgbgen = = RGB_GEN_IDENTITY_LIGHTING ) & & ( pass - > alphagen = = ALPHA_GEN_IDENTITY ) )
{
pass - > shaderbits & = ~ SBITS_BLEND_BITS ;
pass - > shaderbits | = SBITS_SRCBLEND_ONE ;
pass - > shaderbits | = SBITS_DSTBLEND_ZERO ;
pass - > blendmode = PBM_REPLACELIGHT ;
2009-11-04 21:16:50 +00:00
}
else
{
pass - > shaderbits & = ~ SBITS_BLEND_BITS ;
pass - > shaderbits | = SBITS_SRCBLEND_ONE ;
pass - > shaderbits | = SBITS_DSTBLEND_ZERO ;
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_MODULATE ;
2004-10-19 15:56:22 +00:00
}
return ;
}
2009-11-04 21:16:50 +00:00
if ( ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_ZERO | SBITS_DSTBLEND_SRC_COLOR ) ) | |
( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_DST_COLOR | SBITS_DSTBLEND_ZERO ) ) )
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_MODULATE ;
2009-11-04 21:16:50 +00:00
else if ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE ) )
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_ADD ;
2009-11-04 21:16:50 +00:00
else if ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_SRC_ALPHA | SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) )
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_DECAL ;
2004-10-19 15:56:22 +00:00
else
2011-03-02 03:43:38 +00:00
pass - > blendmode = PBM_MODULATE ;
2004-10-19 15:56:22 +00:00
}
void Shader_Readpass ( shader_t * shader , char * * ptr )
{
2011-03-12 13:51:40 +00:00
char * token ;
2004-10-19 15:56:22 +00:00
shaderpass_t * pass ;
qboolean ignore ;
static shader_t dummy ;
2013-03-12 23:16:55 +00:00
int conddepth = 0 ;
int cond [ 8 ] = { 0 } ;
# define COND_IGNORE 1
# define COND_IGNOREPARENT 2
# define COND_ALLOWELSE 4
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
if ( shader - > numpasses > = SHADER_PASS_MAX )
{
2004-10-19 15:56:22 +00:00
ignore = true ;
shader = & dummy ;
shader - > numpasses = 1 ;
pass = shader - > passes ;
2009-11-04 21:16:50 +00:00
}
else
{
2004-10-19 15:56:22 +00:00
ignore = false ;
pass = & shader - > passes [ shader - > numpasses + + ] ;
}
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
// Set defaults
2011-03-12 13:51:40 +00:00
pass - > flags = 0 ;
pass - > anim_frames [ 0 ] = r_nulltex ;
2004-10-19 15:56:22 +00:00
pass - > anim_numframes = 0 ;
2011-03-12 13:51:40 +00:00
pass - > rgbgen = RGB_GEN_UNKNOWN ;
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > tcgen = TC_GEN_BASE ;
pass - > numtcmods = 0 ;
pass - > numMergedPasses = 1 ;
2013-07-29 17:36:44 +00:00
pass - > stagetype = ST_AMBIENT ;
2004-10-19 15:56:22 +00:00
2010-11-02 23:17:25 +00:00
if ( shader - > flags & SHADER_NOMIPMAPS )
pass - > flags | = SHADER_PASS_NOMIPMAP ;
2010-07-11 02:22:39 +00:00
while ( * ptr )
2004-10-19 15:56:22 +00:00
{
------------------------------------------------------------------------
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
token = COM_ParseExt ( ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
if ( ! token [ 0 ] )
{
2004-10-19 15:56:22 +00:00
continue ;
2009-11-04 21:16:50 +00:00
}
2013-03-12 23:16:55 +00:00
else if ( ! Q_stricmp ( token , " if " ) )
2009-11-04 21:16:50 +00:00
{
2013-03-12 23:16:55 +00:00
if ( conddepth + 1 = = sizeof ( cond ) / sizeof ( cond [ 0 ] ) )
{
Con_Printf ( " if statements nest too deeply in shader %s \n " , shader - > name ) ;
break ;
}
conddepth + + ;
cond [ conddepth ] = ( Shader_EvaluateCondition ( shader , ptr ) ? 0 : COND_IGNORE ) ;
cond [ conddepth ] | = COND_ALLOWELSE ;
if ( cond [ conddepth - 1 ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
cond [ conddepth ] | = COND_IGNOREPARENT ;
2009-11-04 21:16:50 +00:00
}
2013-03-12 23:16:55 +00:00
else if ( ! Q_stricmp ( token , " endif " ) )
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
{
2013-03-12 23:16:55 +00:00
if ( ! conddepth )
{
Con_Printf ( " endif without if in shader %s \n " , shader - > name ) ;
break ;
}
conddepth - - ;
}
else if ( ! Q_stricmp ( token , " else " ) )
{
if ( cond [ conddepth ] & COND_ALLOWELSE )
{
cond [ conddepth ] ^ = COND_IGNORE ;
cond [ conddepth ] & = ~ COND_ALLOWELSE ;
}
else
Con_Printf ( " unexpected else statement in shader %s \n " , shader - > name ) ;
}
else if ( cond [ conddepth ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
{
//eat it
while ( ptr )
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
{
2013-03-12 23:16:55 +00:00
token = COM_ParseExt ( ptr , false , true ) ;
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
if ( ! token [ 0 ] )
2013-03-12 23:16:55 +00:00
break ;
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
}
}
2013-03-12 23:16:55 +00:00
else
2009-11-04 21:16:50 +00:00
{
2013-03-12 23:16:55 +00:00
if ( token [ 0 ] = = ' } ' )
break ;
else if ( Shader_Parsetok ( shader , pass , shaderpasskeys , token , ptr ) )
break ;
2004-10-19 15:56:22 +00:00
}
}
2013-03-12 23:16:55 +00:00
if ( conddepth )
{
Con_Printf ( " if statements without endif in shader %s \n " , shader - > name ) ;
}
2013-07-29 17:36:44 +00:00
if ( ! ignore )
{
switch ( pass - > stagetype )
{
case ST_DIFFUSEMAP :
if ( pass - > texgen = = T_GEN_SINGLEMAP )
2014-03-30 08:55:06 +00:00
shader - > defaulttextures . base = pass - > anim_frames [ 0 ] ;
2013-07-29 17:36:44 +00:00
break ;
case ST_AMBIENT :
break ;
case ST_BUMPMAP :
if ( pass - > texgen = = T_GEN_SINGLEMAP )
shader - > defaulttextures . bump = pass - > anim_frames [ 0 ] ;
ignore = true ;
break ;
case ST_SPECULARMAP :
if ( pass - > texgen = = T_GEN_SINGLEMAP )
shader - > defaulttextures . specular = pass - > anim_frames [ 0 ] ;
ignore = true ;
break ;
}
}
2010-11-26 06:58:48 +00:00
// check some things
2013-07-29 17:36:44 +00:00
if ( ignore )
2009-11-04 21:16:50 +00:00
{
2011-10-27 16:16:29 +00:00
Shader_FreePass ( pass ) ;
shader - > numpasses - - ;
2004-10-19 15:56:22 +00:00
return ;
}
2009-11-04 21:16:50 +00:00
if ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ZERO ) )
{
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_DEPTHWRITE ;
}
switch ( pass - > rgbgen )
{
case RGB_GEN_IDENTITY_LIGHTING :
case RGB_GEN_IDENTITY :
case RGB_GEN_CONST :
case RGB_GEN_WAVE :
case RGB_GEN_ENTITY :
case RGB_GEN_ONE_MINUS_ENTITY :
case RGB_GEN_UNKNOWN : // assume RGB_GEN_IDENTITY or RGB_GEN_IDENTITY_LIGHTING
switch ( pass - > alphagen )
{
case ALPHA_GEN_IDENTITY :
case ALPHA_GEN_CONST :
case ALPHA_GEN_WAVE :
case ALPHA_GEN_ENTITY :
pass - > flags | = SHADER_PASS_NOCOLORARRAY ;
break ;
default :
break ;
}
break ;
default :
break ;
}
2012-02-14 15:50:34 +00:00
/*if ((shader->flags & SHADER_SKY) && (shader->flags & SHADER_DEPTHWRITE))
2009-11-04 21:16:50 +00:00
{
2011-10-27 16:16:29 +00:00
# ifdef warningmsg
# pragma warningmsg("is this valid?")
2011-05-29 04:26:29 +00:00
# endif
2009-11-04 21:16:50 +00:00
pass - > shaderbits & = ~ SBITS_MISC_DEPTHWRITE ;
}
2012-02-14 15:50:34 +00:00
*/
2009-11-04 21:16:50 +00:00
}
2004-10-19 15:56:22 +00:00
static qboolean Shader_Parsetok ( shader_t * shader , shaderpass_t * pass , shaderkey_t * keys , char * token , char * * ptr )
{
2011-03-12 13:51:40 +00:00
shaderkey_t * key ;
2004-10-19 15:56:22 +00:00
for ( key = keys ; key - > keyword ! = NULL ; key + + )
{
if ( ! Q_stricmp ( token , key - > keyword ) )
{
if ( key - > func )
key - > func ( shader , pass , ptr ) ;
return ( ptr & & * ptr & & * * ptr = = ' } ' ) ;
}
}
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
// Con_Printf("Unknown shader directive: \"%s\"\n", token);
2004-10-19 15:56:22 +00:00
// Next Line
while ( ptr )
{
------------------------------------------------------------------------
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
token = COM_ParseExt ( ptr , false , true ) ;
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
if ( ! token [ 0 ] )
{
2004-10-19 15:56:22 +00:00
break ;
}
}
return false ;
}
2009-11-04 21:16:50 +00:00
void Shader_SetPassFlush ( shaderpass_t * pass , shaderpass_t * pass2 )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( ( ( pass - > flags & SHADER_PASS_DETAIL ) & & ! r_detailtextures . value ) | |
2004-10-19 15:56:22 +00:00
( ( pass2 - > flags & SHADER_PASS_DETAIL ) & & ! r_detailtextures . value ) | |
2010-08-14 00:15:07 +00:00
( pass - > flags & SHADER_PASS_VIDEOMAP ) | | ( pass2 - > flags & SHADER_PASS_VIDEOMAP ) )
2009-11-04 21:16:50 +00:00
{
2004-10-19 15:56:22 +00:00
return ;
}
2011-04-30 17:21:10 +00:00
/*identity alpha is required for merging*/
if ( pass - > alphagen ! = ALPHA_GEN_IDENTITY | | pass2 - > alphagen ! = ALPHA_GEN_IDENTITY )
2004-10-19 15:56:22 +00:00
return ;
2011-04-30 17:21:10 +00:00
/*rgbgen must be identity too except if the later pass is identity_ligting, in which case all is well and we can switch the first pass to identity_lighting instead*/
if ( pass2 - > rgbgen = = RGB_GEN_IDENTITY_LIGHTING & & pass2 - > blendmode = = PBM_MODULATE & & pass - > rgbgen = = RGB_GEN_IDENTITY )
{
pass - > blendmode = PBM_REPLACELIGHT ;
pass - > rgbgen = RGB_GEN_IDENTITY_LIGHTING ;
pass2 - > rgbgen = RGB_GEN_IDENTITY ;
}
/*rgbgen must be identity (or the first is identity_lighting)*/
else if ( pass2 - > rgbgen ! = RGB_GEN_IDENTITY | | ( pass - > rgbgen ! = RGB_GEN_IDENTITY & & pass - > rgbgen ! = RGB_GEN_IDENTITY_LIGHTING ) )
2004-10-19 15:56:22 +00:00
return ;
2010-08-14 00:15:07 +00:00
/*if its alphatest, don't merge with anything other than lightmap*/
if ( ( pass - > shaderbits & SBITS_ATEST_BITS ) & & ( ! ( pass2 - > shaderbits & SBITS_MISC_DEPTHEQUALONLY ) | | pass2 - > texgen ! = T_GEN_LIGHTMAP ) )
return ;
2011-02-25 04:22:14 +00:00
if ( ( pass - > shaderbits & SBITS_MASK_BITS ) ! = ( pass2 - > shaderbits & SBITS_MASK_BITS ) )
return ;
2012-01-16 06:22:06 +00:00
/*don't merge passes if the hardware cannot support it*/
if ( pass - > numMergedPasses > = be_maxpasses )
return ;
2009-11-04 21:16:50 +00:00
// check if we can use multiple passes
2011-03-02 03:43:38 +00:00
if ( pass2 - > blendmode = = PBM_DOTPRODUCT )
2009-11-04 21:16:50 +00:00
{
pass - > numMergedPasses + + ;
}
2010-11-13 17:22:46 +00:00
else if ( pass - > numMergedPasses < be_maxpasses )
2004-10-19 15:56:22 +00:00
{
2011-04-30 17:21:10 +00:00
if ( pass - > blendmode = = PBM_REPLACE | | pass - > blendmode = = PBM_REPLACELIGHT )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
if ( ( pass2 - > blendmode = = PBM_DECAL & & sh_config . tex_env_combine ) | |
( pass2 - > blendmode = = PBM_ADD & & sh_config . env_add ) | |
( pass2 - > blendmode & & pass2 - > blendmode ! = PBM_ADD ) | | sh_config . nv_tex_env_combine4 )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
pass - > numMergedPasses + + ;
2004-10-19 15:56:22 +00:00
}
}
2011-03-02 03:43:38 +00:00
else if ( pass - > blendmode = = PBM_ADD & &
2014-03-30 08:55:06 +00:00
pass2 - > blendmode = = PBM_ADD & & sh_config . env_add )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
pass - > numMergedPasses + + ;
}
2011-03-02 03:43:38 +00:00
else if ( pass - > blendmode = = PBM_MODULATE & & pass2 - > blendmode = = PBM_MODULATE )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
pass - > numMergedPasses + + ;
2004-10-19 15:56:22 +00:00
}
2011-03-02 03:43:38 +00:00
else
return ;
2004-10-19 15:56:22 +00:00
}
2011-03-02 03:43:38 +00:00
else return ;
2014-03-30 08:55:06 +00:00
if ( pass - > texgen = = T_GEN_LIGHTMAP & & pass - > blendmode = = PBM_REPLACELIGHT & & pass2 - > blendmode = = PBM_MODULATE & & sh_config . tex_env_combine )
2013-08-27 13:18:09 +00:00
{
if ( pass - > rgbgen = = RGB_GEN_IDENTITY )
pass - > rgbgen = RGB_GEN_IDENTITY_OVERBRIGHT ; //get the light levels right
2012-07-05 19:42:36 +00:00
pass2 - > blendmode = PBM_OVERBRIGHT ;
2013-08-27 13:18:09 +00:00
}
2014-03-30 08:55:06 +00:00
if ( pass2 - > texgen = = T_GEN_LIGHTMAP & & pass2 - > blendmode = = PBM_MODULATE & & sh_config . tex_env_combine )
2013-08-27 13:18:09 +00:00
{
if ( pass - > rgbgen = = RGB_GEN_IDENTITY )
pass - > rgbgen = RGB_GEN_IDENTITY_OVERBRIGHT ; //get the light levels right
pass - > blendmode = PBM_REPLACELIGHT ;
2011-03-02 03:43:38 +00:00
pass2 - > blendmode = PBM_OVERBRIGHT ;
2013-08-27 13:18:09 +00:00
}
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
const char * Shader_AlphaMaskProgArgs ( shader_t * s )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
if ( s - > numpasses )
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
//alpha mask values ALWAYS come from the first pass.
shaderpass_t * pass = & s - > passes [ 0 ] ;
switch ( pass - > shaderbits & SBITS_ATEST_BITS )
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
default :
break ;
//cases inverted. the test is to enable
case SBITS_ATEST_GT0 :
return " #MASK=0.0#MASKOP=> " ;
case SBITS_ATEST_LT128 :
return " #MASK=0.5#MASKOP=< " ;
case SBITS_ATEST_GE128 :
return " #MASK=0.5 " ;
2004-10-19 15:56:22 +00:00
}
}
2014-03-30 08:55:06 +00:00
return " " ;
}
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
void Shader_Programify ( shader_t * s )
{
char * prog = NULL ;
const char * mask ;
2014-08-15 02:20:41 +00:00
/* enum
2014-03-30 08:55:06 +00:00
{
T_UNKNOWN ,
T_WALL ,
T_MODEL
2014-08-15 02:20:41 +00:00
} type = 0 ; */
2014-03-30 08:55:06 +00:00
int i ;
shaderpass_t * pass , * lightmap = NULL , * modellighting = NULL ;
for ( i = 0 ; i < s - > numpasses ; i + + )
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
pass = & s - > passes [ i ] ;
if ( pass - > rgbgen = = RGB_GEN_LIGHTING_DIFFUSE )
modellighting = pass ;
else if ( pass - > texgen = = T_GEN_LIGHTMAP & & pass - > tcgen = = TC_GEN_LIGHTMAP )
lightmap = pass ;
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
if ( modellighting )
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
pass = modellighting ;
prog = " defaultskin " ;
}
else if ( lightmap )
{
pass = modellighting ;
prog = " defaultwall " ;
}
else
{
pass = NULL ;
prog = " default2d " ;
return ;
}
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
mask = Shader_AlphaMaskProgArgs ( s ) ;
2004-10-19 15:56:22 +00:00
2014-03-30 08:55:06 +00:00
s - > prog = Shader_FindGeneric ( va ( " %s%s " , prog , mask ) , qrenderer ) ;
s - > numpasses = 0 ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_DIFFUSE ;
if ( lightmap )
{
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_LIGHTMAP ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_NORMALMAP ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_DELUXMAP ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_FULLBRIGHT ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_SPECULAR ;
}
if ( modellighting )
{
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_LOWEROVERLAY ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_UPPEROVERLAY ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_FULLBRIGHT ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_NORMALMAP ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_SPECULAR ;
2004-10-19 15:56:22 +00:00
}
}
2009-11-04 21:16:50 +00:00
void Shader_Finish ( shader_t * s )
2004-10-19 15:56:22 +00:00
{
int i ;
shaderpass_t * pass ;
2013-07-29 17:36:44 +00:00
//FIXME: reorder doom3 stages.
//put diffuse first. give it a lightmap pass also, if we found a diffuse one with no lightmap.
//then the ambient stages.
//and forget about the bump/specular stages as we don't support them and already stripped them.
2004-10-19 15:56:22 +00:00
2010-12-05 02:46:07 +00:00
if ( s - > flags & SHADER_SKY )
2009-11-04 21:16:50 +00:00
{
2010-12-05 02:46:07 +00:00
/*skies go all black if fastsky is set*/
if ( r_fastsky . ival )
s - > flags = 0 ;
/*or if its purely a skybox and has missing textures*/
2012-04-09 19:12:12 +00:00
// if (!s->numpasses)
// for (i = 0; i < 6; i++)
// if (missing_texture.ref == s->skydome->farbox_textures[i].ref)
// s->flags = 0;
2010-12-05 02:46:07 +00:00
if ( ! ( s - > flags & SHADER_SKY ) )
{
2011-05-20 04:10:46 +00:00
Shader_Reset ( s ) ;
2011-04-30 17:21:10 +00:00
2011-05-20 04:10:46 +00:00
Shader_DefaultScript ( s - > name , s ,
2009-11-04 21:16:50 +00:00
" { \n "
2010-12-05 02:46:07 +00:00
" sort sky \n "
" { \n "
" map $whiteimage \n "
" rgbgen const $r_fastskycolour \n "
" } \n "
" surfaceparm nodlight \n "
2009-11-04 21:16:50 +00:00
" } \n "
2010-12-05 02:46:07 +00:00
) ;
return ;
}
2004-10-19 15:56:22 +00:00
}
2011-05-20 04:10:46 +00:00
if ( TEXVALID ( s - > defaulttextures . base ) )
s - > flags & = ~ SHADER_NOIMAGE ;
2011-12-23 03:12:29 +00:00
if ( ! s - > numpasses & & s - > sort ! = SHADER_SORT_PORTAL & & ! ( s - > flags & ( SHADER_NODRAW | SHADER_SKY ) ) & & ! s - > fog_dist & & ! s - > prog )
2005-05-26 12:55:34 +00:00
{
pass = & s - > passes [ s - > numpasses + + ] ;
pass = & s - > passes [ 0 ] ;
pass - > tcgen = TC_GEN_BASE ;
2011-02-25 04:22:14 +00:00
if ( TEXVALID ( s - > defaulttextures . base ) )
pass - > texgen = T_GEN_DIFFUSE ;
else
2009-01-15 04:58:12 +00:00
{
2011-02-25 04:22:14 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
2011-10-27 16:16:29 +00:00
TEXASSIGN ( pass - > anim_frames [ 0 ] , R_LoadHiResTexture ( s - > name , NULL , IF_NOALPHA ) ) ;
2011-02-25 04:22:14 +00:00
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
Con_Printf ( " Shader %s failed to load default texture \n " , s - > name ) ;
pass - > anim_frames [ 0 ] = missing_texture ;
}
Con_Printf ( " Shader %s with no passes and no surfaceparm nodraw, inserting pass \n " , s - > name ) ;
2009-01-15 04:58:12 +00:00
}
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2005-05-26 12:55:34 +00:00
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numMergedPasses = 1 ;
2009-11-04 21:16:50 +00:00
Shader_SetBlendmode ( pass ) ;
2005-05-26 12:55:34 +00:00
}
2009-11-04 21:16:50 +00:00
if ( ! Q_stricmp ( s - > name , " flareShader " ) )
{
s - > flags | = SHADER_FLARE ;
2010-11-22 02:03:28 +00:00
s - > flags | = SHADER_NODRAW ;
2009-11-04 21:16:50 +00:00
}
if ( ! s - > numpasses & & ! s - > sort )
{
2004-10-19 15:56:22 +00:00
s - > sort = SHADER_SORT_ADDITIVE ;
return ;
}
2009-11-04 21:16:50 +00:00
if ( ! s - > sort & & s - > passes - > texgen = = T_GEN_CURRENTRENDER )
s - > sort = SHADER_SORT_NEAREST ;
if ( ( s - > polyoffset . unit < 0 ) & & ! s - > sort )
{
s - > sort = SHADER_SORT_DECAL ;
2004-10-19 15:56:22 +00:00
}
2013-08-27 13:18:09 +00:00
if ( ( r_vertexlight . value | | ! ( s - > usageflags & SUF_LIGHTMAP ) ) & & ! s - > prog )
2004-10-19 15:56:22 +00:00
{
// do we have a lightmap pass?
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( pass - > flags & SHADER_PASS_LIGHTMAP )
2004-10-19 15:56:22 +00:00
break ;
}
2009-11-04 21:16:50 +00:00
if ( i = = s - > numpasses )
2004-10-19 15:56:22 +00:00
{
goto done ;
}
// try to find pass with rgbgen set to RGB_GEN_VERTEX
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
2004-10-19 15:56:22 +00:00
{
2011-10-27 16:16:29 +00:00
if ( pass - > rgbgen = = RGB_GEN_VERTEX_LIGHTING )
2004-10-19 15:56:22 +00:00
break ;
}
2009-11-04 21:16:50 +00:00
if ( i < s - > numpasses )
2004-10-19 15:56:22 +00:00
{ // we found it
pass - > flags | = SHADER_CULL_FRONT ;
2009-11-04 21:16:50 +00:00
pass - > flags & = ~ SHADER_PASS_ANIMMAP ;
pass - > shaderbits & = ~ SBITS_BLEND_BITS ;
2004-10-19 15:56:22 +00:00
pass - > blendmode = 0 ;
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2004-10-19 15:56:22 +00:00
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numMergedPasses = 1 ;
s - > flags | = SHADER_DEPTHWRITE ;
s - > sort = SHADER_SORT_OPAQUE ;
s - > numpasses = 1 ;
2009-11-04 21:16:50 +00:00
memcpy ( & s - > passes [ 0 ] , pass , sizeof ( shaderpass_t ) ) ;
2004-10-19 15:56:22 +00:00
}
else
{ // we didn't find it - simply remove all lightmap passes
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( pass - > flags & SHADER_PASS_LIGHTMAP )
2004-10-19 15:56:22 +00:00
break ;
}
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
if ( i = = s - > numpasses - 1 )
{
s - > numpasses - - ;
}
else if ( i < s - > numpasses - 1 )
{
for ( ; i < s - > numpasses - 1 ; i + + , pass + + )
{
memcpy ( pass , & s - > passes [ i + 1 ] , sizeof ( shaderpass_t ) ) ;
}
s - > numpasses - - ;
}
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
if ( s - > passes [ 0 ] . numtcmods )
{
pass = s - > passes ;
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
{
if ( ! pass - > numtcmods )
break ;
}
2010-11-26 06:58:48 +00:00
2004-10-19 15:56:22 +00:00
memcpy ( & s - > passes [ 0 ] , pass , sizeof ( shaderpass_t ) ) ;
}
2010-11-26 06:58:48 +00:00
2011-10-27 16:16:29 +00:00
s - > passes [ 0 ] . rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2004-10-19 15:56:22 +00:00
s - > passes [ 0 ] . alphagen = ALPHA_GEN_IDENTITY ;
s - > passes [ 0 ] . blendmode = 0 ;
2009-11-04 21:16:50 +00:00
s - > passes [ 0 ] . flags & = ~ ( SHADER_PASS_ANIMMAP | SHADER_PASS_NOCOLORARRAY ) ;
2013-08-27 13:18:09 +00:00
s - > passes [ 0 ] . shaderbits & = ~ SBITS_BLEND_BITS ;
2009-11-04 21:16:50 +00:00
s - > passes [ 0 ] . shaderbits | = SBITS_MISC_DEPTHWRITE ;
2004-10-19 15:56:22 +00:00
s - > passes [ 0 ] . numMergedPasses = 1 ;
s - > numpasses = 1 ;
s - > flags | = SHADER_DEPTHWRITE ;
}
}
done : ;
2014-03-30 08:55:06 +00:00
//if we've no specular map, try and find whatever the q3 syntax said. hopefully it'll be compatible...
if ( ! TEXVALID ( s - > defaulttextures . specular ) )
{
for ( pass = s - > passes , i = 0 ; i < s - > numpasses ; i + + , pass + + )
{
if ( pass - > alphagen = = ALPHA_GEN_SPECULAR )
if ( pass - > texgen = = T_GEN_ANIMMAP | | pass - > texgen = = T_GEN_SINGLEMAP )
s - > defaulttextures . specular = pass - > anim_frames [ 0 ] ;
}
}
if ( ! TEXVALID ( s - > defaulttextures . base ) )
2012-01-17 07:57:46 +00:00
{
2014-03-30 08:55:06 +00:00
shaderpass_t * best = NULL ;
int bestweight = 9999999 ;
int weight ;
for ( pass = s - > passes , i = 0 ; i < s - > numpasses ; i + + , pass + + )
{
weight = 0 ;
if ( pass - > flags & SHADER_PASS_DETAIL )
weight + = 500 ; //prefer not to use a detail pass. these are generally useless.
if ( pass - > numtcmods | | pass - > tcgen ! = TC_GEN_BASE )
weight + = 200 ;
if ( pass - > rgbgen ! = RGB_GEN_IDENTITY & & pass - > rgbgen ! = RGB_GEN_IDENTITY_OVERBRIGHT & & pass - > rgbgen ! = RGB_GEN_IDENTITY_LIGHTING )
weight + = 100 ;
if ( pass - > texgen ! = T_GEN_ANIMMAP & & pass - > texgen ! = T_GEN_SINGLEMAP & & pass - > texgen ! = T_GEN_VIDEOMAP )
weight + = 1000 ;
if ( weight < bestweight )
{
bestweight = weight ;
best = pass ;
}
}
if ( best )
{
if ( best - > texgen = = T_GEN_ANIMMAP | | best - > texgen = = T_GEN_SINGLEMAP )
s - > defaulttextures . base = best - > anim_frames [ 0 ] ;
2012-01-18 04:15:16 +00:00
# ifndef NOMEDIA
2014-03-30 08:55:06 +00:00
else if ( pass - > texgen = = T_GEN_VIDEOMAP & & pass - > cin )
s - > defaulttextures . base = Media_UpdateForShader ( best - > cin ) ;
2012-01-18 04:15:16 +00:00
# endif
2014-03-30 08:55:06 +00:00
}
2012-01-17 07:57:46 +00:00
}
2004-10-19 15:56:22 +00:00
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
{
2011-02-25 04:22:14 +00:00
if ( ! ( pass - > shaderbits & ( SBITS_BLEND_BITS | SBITS_MASK_BITS ) ) )
2009-11-04 21:16:50 +00:00
{
2004-10-19 15:56:22 +00:00
break ;
}
}
// all passes have blendfuncs
2009-11-04 21:16:50 +00:00
if ( i = = s - > numpasses )
{
2004-10-19 15:56:22 +00:00
int opaque ;
opaque = - 1 ;
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; i + + , pass + + )
{
2010-07-11 02:22:39 +00:00
if ( pass - > shaderbits & SBITS_ATEST_BITS )
2009-11-04 21:16:50 +00:00
{
2004-10-19 15:56:22 +00:00
opaque = i ;
}
2009-11-04 21:16:50 +00:00
if ( pass - > rgbgen = = RGB_GEN_UNKNOWN )
2010-11-26 06:58:48 +00:00
{
2011-10-27 16:16:29 +00:00
if ( ( pass - > shaderbits & SBITS_SRCBLEND_BITS ) = = 0
| | ( pass - > shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_ONE
| | ( pass - > shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_SRC_ALPHA )
2004-10-19 15:56:22 +00:00
pass - > rgbgen = RGB_GEN_IDENTITY_LIGHTING ;
else
pass - > rgbgen = RGB_GEN_IDENTITY ;
}
2009-11-04 21:16:50 +00:00
Shader_SetBlendmode ( pass ) ;
2012-01-01 11:22:24 +00:00
if ( pass - > blendmode = = PBM_ADD )
s - > defaulttextures . fullbright = pass - > anim_frames [ 0 ] ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
if ( ! ( s - > flags & SHADER_SKY ) & & ! s - > sort )
{
if ( opaque = = - 1 )
2010-07-11 02:22:39 +00:00
s - > sort = SHADER_SORT_BLEND ;
2004-10-19 15:56:22 +00:00
else
2010-07-11 02:22:39 +00:00
s - > sort = SHADER_SORT_SEETHROUGH ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
}
else
{
2004-10-19 15:56:22 +00:00
int j ;
shaderpass_t * sp ;
sp = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( j = 0 ; j < s - > numpasses ; j + + , sp + + )
{
if ( sp - > rgbgen = = RGB_GEN_UNKNOWN )
2010-11-26 06:58:48 +00:00
{
2011-04-30 17:21:10 +00:00
if ( sp - > flags & SHADER_PASS_LIGHTMAP )
sp - > rgbgen = RGB_GEN_IDENTITY_LIGHTING ;
else
sp - > rgbgen = RGB_GEN_IDENTITY ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
Shader_SetBlendmode ( sp ) ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
if ( ! s - > sort )
{
if ( pass - > shaderbits & SBITS_ATEST_BITS )
2010-07-11 02:22:39 +00:00
s - > sort = SHADER_SORT_SEETHROUGH ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
if ( ! ( s - > flags & SHADER_DEPTHWRITE ) & &
! ( s - > flags & SHADER_SKY ) )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2004-10-19 15:56:22 +00:00
s - > flags | = SHADER_DEPTHWRITE ;
}
}
2009-11-04 21:16:50 +00:00
if ( s - > numpasses > = 2 )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
int j ;
2004-10-19 15:56:22 +00:00
pass = s - > passes ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < s - > numpasses ; )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( i = = s - > numpasses - 1 )
2004-10-19 15:56:22 +00:00
break ;
pass = s - > passes + i ;
2009-11-04 21:16:50 +00:00
for ( j = 1 ; j < s - > numpasses - i & & j = = i + pass - > numMergedPasses & & j < be_maxpasses ; j + + )
Shader_SetPassFlush ( pass , pass + j ) ;
2004-10-19 15:56:22 +00:00
i + = pass - > numMergedPasses ;
}
}
2009-11-04 21:16:50 +00:00
if ( ! s - > sort )
{
2004-10-19 15:56:22 +00:00
s - > sort = SHADER_SORT_OPAQUE ;
}
2009-11-04 21:16:50 +00:00
if ( ( s - > flags & SHADER_SKY ) & & ( s - > flags & SHADER_DEPTHWRITE ) )
{
2004-10-19 15:56:22 +00:00
s - > flags & = ~ SHADER_DEPTHWRITE ;
}
2014-03-30 08:55:06 +00:00
if ( ! s - > bemoverrides [ bemoverride_depthonly ] )
{
const char * mask = Shader_AlphaMaskProgArgs ( s ) ;
if ( * mask )
s - > bemoverrides [ bemoverride_depthonly ] = R_RegisterShader ( va ( " depthonly%s " , mask ) , SUF_NONE ,
" { \n "
" program depthonly \n "
" { \n "
" map $diffuse \n "
" depthwrite \n "
" maskcolor \n "
" } \n "
" } \n " ) ;
}
if ( ! s - > prog & & sh_config . progs_required )
Shader_Programify ( s ) ;
2011-02-25 04:22:14 +00:00
if ( s - > prog )
2006-03-11 03:12:10 +00:00
{
if ( ! s - > numpasses )
2014-03-30 08:55:06 +00:00
{
s - > passes [ 0 ] . texgen = T_GEN_DIFFUSE ;
2006-03-11 03:12:10 +00:00
s - > numpasses = 1 ;
2014-03-30 08:55:06 +00:00
}
2006-03-11 03:12:10 +00:00
s - > passes - > numMergedPasses = s - > numpasses ;
}
2004-10-19 15:56:22 +00:00
}
/*
void Shader_UpdateRegistration ( void )
{
int i , j , l ;
shader_t * shader ;
shaderpass_t * pass ;
shader = r_shaders ;
for ( i = 0 ; i < MAX_SHADERS ; i + + , shader + + )
{
2009-11-04 21:16:50 +00:00
if ( ! shader - > registration_sequence )
2004-10-19 15:56:22 +00:00
continue ;
2009-11-04 21:16:50 +00:00
if ( shader - > registration_sequence ! = registration_sequence )
{
2004-10-19 15:56:22 +00:00
Shader_Free ( shader ) ;
shader - > registration_sequence = 0 ;
continue ;
}
pass = shader - > passes ;
for ( j = 0 ; j < shader - > numpasses ; j + + , pass + + )
{
2009-11-04 21:16:50 +00:00
if ( pass - > flags & SHADER_PASS_ANIMMAP )
{
2010-11-26 06:58:48 +00:00
for ( l = 0 ; l < pass - > anim_numframes ; l + + )
2004-10-19 15:56:22 +00:00
{
2009-11-04 21:16:50 +00:00
if ( pass - > anim_frames [ l ] )
2004-10-19 15:56:22 +00:00
pass - > anim_frames [ l ] - > registration_sequence = registration_sequence ;
}
2009-11-04 21:16:50 +00:00
}
else if ( pass - > flags & SHADER_PASS_VIDEOMAP )
{
2004-10-19 15:56:22 +00:00
// Shader_RunCinematic will do the job
// pass->cin->frame = -1;
2009-11-04 21:16:50 +00:00
}
else if ( ! ( pass - > flags & SHADER_PASS_LIGHTMAP ) )
{
2004-10-19 15:56:22 +00:00
if ( pass - > anim_frames [ 0 ] )
pass - > anim_frames [ 0 ] - > registration_sequence = registration_sequence ;
2010-11-26 06:58:48 +00:00
}
2004-10-19 15:56:22 +00:00
}
}
}
*/
2014-04-24 01:53:01 +00:00
void QDECL R_BuildDefaultTexnums ( texnums_t * tn , shader_t * shader )
2004-10-19 15:56:22 +00:00
{
2014-02-07 08:38:40 +00:00
char * h ;
char imagename [ MAX_QPATH ] ;
strcpy ( imagename , shader - > name ) ;
h = strchr ( imagename , ' # ' ) ;
if ( h )
* h = 0 ;
2012-02-12 05:18:31 +00:00
if ( ! tn )
tn = & shader - > defaulttextures ;
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( shader - > defaulttextures . base ) )
2011-05-20 04:10:46 +00:00
{
2012-01-17 07:57:46 +00:00
/*dlights/realtime lighting needs some stuff*/
if ( ! TEXVALID ( tn - > base ) )
{
2014-02-07 08:38:40 +00:00
tn - > base = R_LoadHiResTexture ( imagename , NULL , IF_NOALPHA ) ;
2012-01-17 07:57:46 +00:00
}
if ( TEXVALID ( tn - > base ) )
shader - > flags & = ~ SHADER_NOIMAGE ;
TEXASSIGN ( shader - > defaulttextures . base , tn - > base ) ;
2011-05-20 04:10:46 +00:00
}
2004-10-19 15:56:22 +00:00
2014-02-07 08:38:40 +00:00
COM_StripExtension ( imagename , imagename , sizeof ( imagename ) ) ;
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( shader - > defaulttextures . bump ) )
2010-07-18 12:52:24 +00:00
{
2012-01-17 07:57:46 +00:00
if ( r_loadbumpmapping )
{
if ( ! TEXVALID ( tn - > bump ) )
2014-02-07 08:38:40 +00:00
tn - > bump = R_LoadHiResTexture ( va ( " %s_norm " , imagename ) , NULL , IF_NOALPHA ) ;
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( tn - > bump ) )
2014-02-07 08:38:40 +00:00
tn - > bump = R_LoadHiResTexture ( va ( " %s_bump " , imagename ) , NULL , IF_NOALPHA ) ;
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( tn - > bump ) )
2014-02-07 08:38:40 +00:00
tn - > bump = R_LoadHiResTexture ( va ( " normalmaps/%s " , imagename ) , NULL , IF_NOALPHA ) ;
2012-01-17 07:57:46 +00:00
}
TEXASSIGN ( shader - > defaulttextures . bump , tn - > bump ) ;
2010-07-18 12:52:24 +00:00
}
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( shader - > defaulttextures . loweroverlay ) )
2010-07-18 12:52:24 +00:00
{
2012-01-17 07:57:46 +00:00
if ( shader - > flags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tn - > loweroverlay ) )
2014-02-07 08:38:40 +00:00
tn - > loweroverlay = R_LoadHiResTexture ( va ( " %s_pants " , imagename ) , NULL , 0 ) ; /*how rude*/
2012-01-17 07:57:46 +00:00
}
TEXASSIGN ( shader - > defaulttextures . loweroverlay , tn - > loweroverlay ) ;
}
if ( ! TEXVALID ( shader - > defaulttextures . upperoverlay ) )
{
if ( shader - > flags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tn - > upperoverlay ) )
2014-02-07 08:38:40 +00:00
tn - > upperoverlay = R_LoadHiResTexture ( va ( " %s_shirt " , imagename ) , NULL , 0 ) ;
2012-01-17 07:57:46 +00:00
}
TEXASSIGN ( shader - > defaulttextures . upperoverlay , tn - > upperoverlay ) ;
2010-07-18 12:52:24 +00:00
}
2004-10-19 15:56:22 +00:00
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( shader - > defaulttextures . specular ) )
2012-11-27 03:23:19 +00:00
{
extern cvar_t gl_specular ;
if ( ( shader - > flags & SHADER_HASGLOSS ) & & gl_specular . value & & gl_load24bit . value )
{
if ( ! TEXVALID ( tn - > specular ) )
2014-02-07 08:38:40 +00:00
tn - > specular = R_LoadHiResTexture ( va ( " %s_gloss " , imagename ) , NULL , 0 ) ;
2012-11-27 03:23:19 +00:00
}
2012-01-17 07:57:46 +00:00
TEXASSIGN ( shader - > defaulttextures . specular , tn - > specular ) ;
2012-11-27 03:23:19 +00:00
}
2014-06-22 23:44:30 +00:00
2012-01-17 07:57:46 +00:00
if ( ! TEXVALID ( shader - > defaulttextures . fullbright ) )
2014-06-22 23:44:30 +00:00
{
2014-06-22 23:45:30 +00:00
extern cvar_t r_fb_bmodels ;
2014-06-22 23:44:30 +00:00
if ( ( shader - > flags & SHADER_HASFULLBRIGHT ) & & r_fb_bmodels . value & & gl_load24bit . value )
{
if ( ! TEXVALID ( tn - > fullbright ) )
tn - > specular = R_LoadHiResTexture ( va ( " %s_luma " , imagename ) , NULL , 0 ) ;
}
2012-01-17 07:57:46 +00:00
TEXASSIGN ( shader - > defaulttextures . fullbright , tn - > fullbright ) ;
2014-06-22 23:44:30 +00:00
}
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
void Shader_DefaultScript ( const char * shortname , shader_t * s , const void * args )
2005-03-20 02:57:11 +00:00
{
2009-11-04 21:16:50 +00:00
const char * f = args ;
if ( ! args )
return ;
while ( * f = = ' ' | | * f = = ' \t ' | | * f = = ' \n ' | | * f = = ' \r ' )
f + + ;
if ( * f = = ' { ' )
2009-07-18 20:46:42 +00:00
{
2009-11-04 21:16:50 +00:00
f + + ;
2011-12-05 15:23:40 +00:00
Shader_ReadShader ( s , ( void * ) f , SPM_DEFAULT ) ;
2009-07-18 20:46:42 +00:00
}
2009-11-04 21:16:50 +00:00
} ;
2009-07-18 20:46:42 +00:00
2014-03-30 08:55:06 +00:00
void Shader_DefaultBSPLM ( const char * shortname , shader_t * s , const void * args )
2009-11-04 21:16:50 +00:00
{
char * builtin = NULL ;
2012-08-04 01:35:52 +00:00
if ( ! builtin & & r_drawflat . ival )
2010-07-11 02:22:39 +00:00
builtin = (
" { \n "
2011-12-23 03:12:29 +00:00
" program drawflat_wall \n "
2010-07-11 02:22:39 +00:00
" { \n "
" map $lightmap \n "
" tcgen lightmap \n "
" rgbgen const $r_floorcolour \n "
" } \n "
" } \n "
) ;
2012-09-30 05:52:03 +00:00
# ifdef D3D11QUAKE
if ( qrenderer = = QR_DIRECT3D11 )
{
if ( ! builtin )
builtin = (
" { \n "
" program defaultwall \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $lightmap \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $deluxmap \n "
" } \n "
" { \n "
" map $fullbright \n "
" } \n "
2012-11-27 03:23:19 +00:00
" { \n "
" map $specular \n "
" } \n "
" } \n "
) ;
}
# endif
#if 0 //def D3D9QUAKE
if ( qrenderer = = QR_DIRECT3D9 )
{
if ( ! builtin )
builtin = (
" { \n "
" program defaultwall \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $lightmap \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $deluxmap \n "
" } \n "
" { \n "
" map $fullbright \n "
" } \n "
" { \n "
" map $specular \n "
" } \n "
2012-09-30 05:52:03 +00:00
" } \n "
) ;
}
# endif
2012-11-27 03:23:19 +00:00
2011-01-23 03:44:49 +00:00
# ifdef GLQUAKE
2011-12-23 03:12:29 +00:00
if ( qrenderer = = QR_OPENGL )
2010-08-28 17:14:38 +00:00
{
2011-12-23 03:12:29 +00:00
if ( ! builtin & & r_lightprepass . ival )
{
builtin = (
2010-08-28 17:14:38 +00:00
" { \n "
2011-12-23 03:12:29 +00:00
" program lpp_wall \n "
" { \n "
" map $sourcecolour \n "
" } \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $lightmap \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $deluxmap \n "
" } \n "
" { \n "
" map $fullbright \n "
" } \n "
2010-08-28 17:14:38 +00:00
" } \n "
2011-12-23 03:12:29 +00:00
) ;
}
if ( ! builtin & & gl_config . arb_shader_objects )
{
builtin = (
2010-08-28 17:14:38 +00:00
" { \n "
2011-12-23 03:12:29 +00:00
" program defaultwall \n "
" { \n "
" map $diffuse \n "
" } \n "
" { \n "
" map $lightmap \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $deluxmap \n "
" } \n "
" { \n "
" map $fullbright \n "
" } \n "
2012-11-27 03:23:19 +00:00
" { \n "
" map $specular \n "
" } \n "
2010-08-28 17:14:38 +00:00
" } \n "
2011-12-23 03:12:29 +00:00
) ;
}
2010-08-28 17:14:38 +00:00
}
2011-01-23 03:44:49 +00:00
# endif
2010-07-11 02:22:39 +00:00
if ( ! builtin )
builtin = (
" { \n "
2012-07-05 19:42:36 +00:00
/* "if $deluxmap\n"
2010-07-11 02:22:39 +00:00
" { \n "
" map $normalmap \n "
" tcgen base \n "
2010-07-18 08:42:59 +00:00
" depthwrite \n "
2010-07-11 02:22:39 +00:00
" } \n "
" { \n "
" map $deluxmap \n "
" tcgen lightmap \n "
" } \n "
2013-03-12 23:16:55 +00:00
" endif \n "
*/ // "if !r_fullbright\n"
2012-07-05 19:42:36 +00:00
" { \n "
" map $lightmap \n "
// "if $deluxmap\n"
// "blendfunc gl_dst_color gl_zero\n"
2013-03-12 23:16:55 +00:00
// "endif\n"
2012-07-05 19:42:36 +00:00
" } \n "
2013-03-12 23:16:55 +00:00
// "endif\n"
2010-07-11 02:22:39 +00:00
" { \n "
" map $diffuse \n "
" tcgen base \n "
2012-07-05 19:42:36 +00:00
// "if $deluxmap || !r_fullbright\n"
// "blendfunc gl_dst_color gl_zero\n"
" blendfunc filter \n "
2013-03-12 23:16:55 +00:00
// "endif\n"
2010-07-11 02:22:39 +00:00
" } \n "
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
" if gl_fb_bmodels \n "
2010-07-18 08:42:59 +00:00
" { \n "
" map $fullbright \n "
" blendfunc add \n "
" depthfunc equal \n "
" } \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2010-07-11 02:22:39 +00:00
" } \n "
) ;
Shader_DefaultScript ( shortname , s , builtin ) ;
}
2014-03-30 08:55:06 +00:00
void Shader_DefaultCinematic ( const char * shortname , shader_t * s , const void * args )
2010-07-11 02:22:39 +00:00
{
Shader_DefaultScript ( shortname , s ,
va (
" { \n "
2013-05-11 14:02:55 +00:00
" program default2d \n "
2010-07-11 02:22:39 +00:00
" { \n "
2014-02-07 08:38:40 +00:00
" videomap \" %s \" \n "
2010-07-11 02:22:39 +00:00
" } \n "
" } \n "
2011-01-29 19:53:38 +00:00
, ( const char * ) args )
2010-07-11 02:22:39 +00:00
) ;
}
/*shortname should begin with 'skybox_'*/
2014-03-30 08:55:06 +00:00
void Shader_DefaultSkybox ( const char * shortname , shader_t * s , const void * args )
2010-07-11 02:22:39 +00:00
{
Shader_DefaultScript ( shortname , s ,
va (
" { \n "
" skyparms %s - - \n "
" } \n "
, shortname + 7 )
) ;
}
2014-08-25 07:35:41 +00:00
char * Shader_DefaultBSPWater ( shader_t * s , const char * shortname )
2010-07-11 02:22:39 +00:00
{
2012-07-05 19:42:36 +00:00
int wstyle ;
2014-08-25 07:35:41 +00:00
int type ;
float alpha ;
qboolean explicitalpha = false ;
cvar_t * alphavars [ ] = { & r_wateralpha , & r_lavaalpha , & r_slimealpha , & r_telealpha } ;
cvar_t * stylevars [ ] = { & r_waterstyle , & r_lavastyle , & r_slimestyle , & r_telestyle } ;
if ( ! strncmp ( shortname , " *lava " , 5 ) )
type = 1 ;
else if ( ! strncmp ( shortname , " *slime " , 6 ) )
type = 2 ;
else if ( ! strncmp ( shortname , " *tele " , 5 ) )
type = 3 ;
else
type = 0 ;
alpha = Shader_FloatArgument ( s , " ALPHA " ) ;
if ( alpha )
explicitalpha = true ;
else
alpha = * alphavars [ type ] - > string ? alphavars [ type ] - > value : alphavars [ 0 ] - > value ;
2013-03-12 23:13:39 +00:00
2014-08-25 07:35:41 +00:00
if ( alpha < = 0 )
2012-07-05 19:42:36 +00:00
wstyle = - 1 ;
else if ( r_fastturb . ival )
wstyle = 0 ;
# ifdef GLQUAKE
2014-08-25 07:35:41 +00:00
else if ( qrenderer = = QR_OPENGL & & gl_config . arb_shader_objects & & * stylevars [ type ] - > string )
wstyle = stylevars [ type ] - > ival ;
else if ( qrenderer = = QR_OPENGL & & gl_config . arb_shader_objects & & stylevars [ 0 ] - > ival > 0 )
wstyle = stylevars [ 0 ] - > ival ;
2012-07-05 19:42:36 +00:00
# endif
else
wstyle = 1 ;
2013-03-12 23:09:25 +00:00
# ifdef GLQUAKE
2013-03-12 23:13:39 +00:00
if ( wstyle > 2 & & ! gl_config . ext_framebuffer_objects )
wstyle = 2 ;
2013-03-12 23:09:25 +00:00
# endif
2013-03-12 23:13:39 +00:00
switch ( wstyle )
{
case - 1 : //invisible
return (
" { \n "
" surfaceparm nodraw \n "
" surfaceparm nodlight \n "
" } \n "
) ;
2014-04-12 03:31:59 +00:00
case - 2 : //regular with r_wateralpha forced off.
return (
" { \n "
" program defaultwarp \n "
" { \n "
" map $diffuse \n "
" tcmod turb 0.02 0.1 0.5 0.1 \n "
" } \n "
" surfaceparm nodlight \n "
" } \n "
) ;
2013-03-12 23:13:39 +00:00
case 0 : //fastturb
return (
" { \n "
2012-07-05 19:42:36 +00:00
" { \n "
2013-03-12 23:13:39 +00:00
" map $whiteimage \n "
" rgbgen const $r_fastturbcolour \n "
2012-07-05 19:42:36 +00:00
" } \n "
2013-03-12 23:13:39 +00:00
" surfaceparm nodlight \n "
" } \n "
) ;
default :
case 1 : //vanilla style
2014-08-25 07:35:41 +00:00
return va (
2010-07-11 02:22:39 +00:00
" { \n "
2014-08-25 07:35:41 +00:00
" program defaultwarp%s \n "
2014-08-15 02:20:41 +00:00
" { \n "
" map $diffuse \n "
" tcmod turb 0.02 0.1 0.5 0.1 \n "
2014-08-25 07:35:41 +00:00
" if %g < 1 \n "
" alphagen const %g \n "
" blendfunc gl_src_alpha gl_one_minus_src_alpha \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2014-08-15 02:20:41 +00:00
" } \n "
" surfaceparm nodlight \n "
" } \n "
2014-08-25 07:35:41 +00:00
, explicitalpha ? " " : va ( " #ALPHA=%g " , alpha ) , alpha , alpha ) ;
2013-03-12 23:13:39 +00:00
case 2 : //refraction of the underwater surface, with a fresnel
return (
" { \n "
" surfaceparm nodlight \n "
2012-07-05 19:42:36 +00:00
" { \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
2012-07-05 19:42:36 +00:00
" } \n "
" { \n "
2013-03-12 23:13:39 +00:00
" map $normalmap \n "
2012-08-04 01:35:52 +00:00
" } \n "
" { \n "
2013-03-12 23:13:39 +00:00
" map $diffuse \n "
2012-07-05 19:42:36 +00:00
" } \n "
2013-03-12 23:13:39 +00:00
// "{\n"
// "map $refractiondepth\n"
// "}\n"
" program altwater#FRESNEL=4 \n "
" } \n "
) ;
case 3 : //reflections
return (
" { \n "
" surfaceparm nodlight \n "
2012-07-05 19:42:36 +00:00
" { \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
2010-07-11 02:22:39 +00:00
" } \n "
2013-03-12 23:13:39 +00:00
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $reflection \n "
" } \n "
// "{\n"
// "map $refractiondepth\n"
// "}\n"
" program altwater#REFLECT#FRESNEL=4 \n "
" } \n "
) ;
case 4 : //ripples
return (
" { \n "
" surfaceparm nodlight \n "
" { \n "
" map $refraction \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $diffuse \n "
" } \n "
// "{\n"
// "map $refractiondepth\n"
// "}\n"
" { \n "
" map $ripplemap \n "
" } \n "
" program altwater#RIPPLEMAP#FRESNEL=4 \n "
" } \n "
) ;
case 5 : //ripples+reflections
return (
" { \n "
" surfaceparm nodlight \n "
" { \n "
" map $refraction \n "
" } \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $reflection \n "
" } \n "
// "{\n"
// "map $refractiondepth\n"
// "}\n"
" { \n "
" map $ripplemap \n "
" } \n "
" program altwater#REFLECT#RIPPLEMAP#FRESNEL=4 \n "
" } \n "
) ;
2012-07-05 19:42:36 +00:00
}
}
2014-03-30 08:55:06 +00:00
void Shader_DefaultWaterShader ( const char * shortname , shader_t * s , const void * args )
2013-11-21 23:02:28 +00:00
{
2014-08-25 07:35:41 +00:00
Shader_DefaultScript ( shortname , s , Shader_DefaultBSPWater ( s , shortname ) ) ;
2013-11-21 23:02:28 +00:00
}
2014-03-30 08:55:06 +00:00
void Shader_DefaultBSPQ2 ( const char * shortname , shader_t * s , const void * args )
2012-07-05 19:42:36 +00:00
{
if ( ! strncmp ( shortname , " sky/ " , 4 ) )
{
Shader_DefaultScript ( shortname , s ,
" { \n "
" surfaceparm nodlight \n "
" skyparms - - - \n "
" } \n "
) ;
}
2013-03-12 23:13:39 +00:00
else if ( ! strncmp ( shortname , " warp/ " , 5 ) | | ! strncmp ( shortname , " warp33/ " , 7 ) | | ! strncmp ( shortname , " warp66/ " , 7 ) )
2012-07-05 19:42:36 +00:00
{
2014-08-25 07:35:41 +00:00
Shader_DefaultScript ( shortname , s , Shader_DefaultBSPWater ( s , shortname ) ) ;
2010-07-11 02:22:39 +00:00
}
2013-03-12 23:13:39 +00:00
else if ( ! strncmp ( shortname , " trans/ " , 6 ) )
2010-07-11 02:22:39 +00:00
Shader_DefaultScript ( shortname , s ,
" { \n "
" { \n "
" map $diffuse \n "
2013-03-12 23:13:39 +00:00
" alphagen const $#ALPHA \n "
2010-07-11 02:22:39 +00:00
" blendfunc blend \n "
" } \n "
" } \n "
) ;
else
Shader_DefaultBSPLM ( shortname , s , args ) ;
}
2009-07-18 20:46:42 +00:00
2014-03-30 08:55:06 +00:00
void Shader_DefaultBSPQ1 ( const char * shortname , shader_t * s , const void * args )
2010-07-11 02:22:39 +00:00
{
char * builtin = NULL ;
if ( r_mirroralpha . value < 1 & & ! strcmp ( shortname , " window02_1 " ) )
2005-03-20 02:57:11 +00:00
{
2010-07-11 02:22:39 +00:00
if ( r_mirroralpha . value < 0 )
2009-06-21 17:45:33 +00:00
{
2010-07-11 02:22:39 +00:00
builtin = " { \n "
" portal \n "
" { \n "
" map $diffuse \n "
" blendfunc blend \n "
" alphagen portal 512 \n "
" depthwrite \n "
" } \n "
" } \n " ;
2009-06-21 17:45:33 +00:00
}
2006-03-06 01:41:09 +00:00
else
2010-07-11 02:22:39 +00:00
{
builtin = " { \n "
" portal \n "
" { \n "
" map $diffuse \n "
" blendfunc blend \n "
" alphagen const $r_mirroralpha \n "
" depthwrite \n "
" } \n "
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
" surfaceparm nodlight \n "
2010-07-11 02:22:39 +00:00
" } \n " ;
}
2006-03-06 01:41:09 +00:00
2005-03-20 02:57:11 +00:00
}
2006-03-06 01:41:09 +00:00
2009-11-04 21:16:50 +00:00
if ( ! builtin & & ( * shortname = = ' * ' ) )
2009-07-18 20:46:42 +00:00
{
2014-08-25 07:35:41 +00:00
builtin = Shader_DefaultBSPWater ( s , shortname ) ;
2009-11-04 21:16:50 +00:00
}
if ( ! builtin & & ! strncmp ( shortname , " sky " , 3 ) )
2005-03-20 02:57:11 +00:00
{
2009-11-04 21:16:50 +00:00
//q1 sky
if ( r_fastsky . ival )
2010-12-05 02:46:07 +00:00
{
2009-11-04 21:16:50 +00:00
builtin = (
" { \n "
2010-11-28 19:10:34 +00:00
" sort sky \n "
2009-11-04 21:16:50 +00:00
" { \n "
" map $whiteimage \n "
2010-07-11 02:22:39 +00:00
" rgbgen const $r_fastskycolour \n "
2009-11-04 21:16:50 +00:00
" } \n "
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
" surfaceparm nodlight \n "
2009-11-04 21:16:50 +00:00
" } \n "
) ;
2010-12-05 02:46:07 +00:00
}
2009-11-04 21:16:50 +00:00
else if ( * r_skyboxname . string )
2010-12-05 02:46:07 +00:00
{
2009-11-04 21:16:50 +00:00
builtin = (
" { \n "
2010-11-28 19:10:34 +00:00
" sort sky \n "
2009-11-04 21:16:50 +00:00
" skyparms $r_skybox - - \n "
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
" surfaceparm nodlight \n "
2009-11-04 21:16:50 +00:00
" } \n "
) ;
2010-12-05 02:46:07 +00:00
Shader_DefaultScript ( shortname , s , builtin ) ;
if ( s - > flags & SHADER_SKY )
return ;
builtin = NULL ;
/*if the r_skybox failed to load or whatever, reset and fall through and just use the regular sky*/
2011-05-20 04:10:46 +00:00
Shader_Reset ( s ) ;
2010-12-05 02:46:07 +00:00
}
if ( ! builtin )
2010-07-11 02:22:39 +00:00
builtin = (
" { \n "
2010-11-28 19:10:34 +00:00
" sort sky \n "
2011-03-31 02:32:32 +00:00
" program defaultsky \n "
2010-07-11 02:22:39 +00:00
" skyparms - 512 - \n "
/*WARNING: these values are not authentic quake, only close aproximations*/
" { \n "
" map $diffuse \n "
" tcmod scale 10 10 \n "
" tcmod scroll 0.04 0.04 \n "
2012-02-14 15:50:34 +00:00
" depthwrite \n "
2010-07-11 02:22:39 +00:00
" } \n "
" { \n "
" map $fullbright \n "
" blendfunc blend \n "
" tcmod scale 10 10 \n "
" tcmod scroll 0.02 0.02 \n "
" } \n "
" } \n "
) ;
2009-11-04 21:16:50 +00:00
}
if ( ! builtin & & * shortname = = ' { ' )
2006-03-06 01:41:09 +00:00
{
2009-11-04 21:16:50 +00:00
/*alpha test*/
builtin = (
" { \n "
/* "if $deluxmap\n"
" { \n "
" map $normalmap \n "
" tcgen base \n "
" } \n "
" { \n "
" map $deluxmap \n "
" tcgen lightmap \n "
" } \n "
2013-03-12 23:16:55 +00:00
" endif \n " */
2009-11-04 21:16:50 +00:00
" { \n "
" map $diffuse \n "
" tcgen base \n "
2012-05-09 15:30:53 +00:00
" alphamask \n "
2009-11-04 21:16:50 +00:00
" } \n "
" if $lightmap \n "
" { \n "
" map $lightmap \n "
" blendfunc gl_dst_color gl_zero \n "
" depthfunc equal \n "
" } \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2009-11-04 21:16:50 +00:00
" { \n "
" map $fullbright \n "
" blendfunc add \n "
" depthfunc equal \n "
" } \n "
" } \n "
) ;
}
/*Hack: note that halflife would normally expect you to use rendermode/renderampt*/
2010-07-11 02:22:39 +00:00
if ( ! builtin & & ( ! strncmp ( shortname , " glass " , 5 ) /* || !strncmp(shortname, "window", 6)*/ ) )
2005-05-26 12:55:34 +00:00
{
2009-11-04 21:16:50 +00:00
/*alpha bended*/
builtin = (
" { \n "
" { \n "
" map $diffuse \n "
" tcgen base \n "
" blendfunc blend \n "
" } \n "
" } \n "
) ;
}
2010-07-11 02:22:39 +00:00
if ( builtin )
Shader_DefaultScript ( shortname , s , builtin ) ;
else
Shader_DefaultBSPLM ( shortname , s , args ) ;
2009-11-04 21:16:50 +00:00
}
2014-08-15 02:20:41 +00:00
void Shader_DefaultBSPVertex ( const char * shortname , shader_t * s , const void * args )
2005-03-20 02:57:11 +00:00
{
shaderpass_t * pass ;
2011-12-05 15:23:40 +00:00
s - > defaulttextures . base = R_LoadHiResTexture ( va ( " %s_d.tga " , shortname ) , NULL , 0 ) ;
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( " defaultflare " , s ) )
return ;
2005-03-20 02:57:11 +00:00
pass = & s - > passes [ 0 ] ;
pass - > tcgen = TC_GEN_BASE ;
2009-11-04 21:16:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2005-03-20 02:57:11 +00:00
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numMergedPasses = 1 ;
2009-11-04 21:16:50 +00:00
Shader_SetBlendmode ( pass ) ;
2005-03-20 02:57:11 +00:00
2011-12-05 15:23:40 +00:00
if ( TEXVALID ( s - > defaulttextures . base ) )
2009-11-04 21:16:50 +00:00
{
2011-12-05 15:23:40 +00:00
pass - > texgen = T_GEN_DIFFUSE ;
}
else
{
pass - > anim_frames [ 0 ] = R_LoadHiResTexture ( shortname , NULL , 0 ) ;
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
Con_DPrintf ( CON_WARNING " Shader %s has a stage with no image: %s. \n " , s - > name , shortname ) ;
pass - > anim_frames [ 0 ] = missing_texture ;
}
2005-03-20 02:57:11 +00:00
}
s - > numpasses = 1 ;
s - > numdeforms = 0 ;
s - > flags = SHADER_DEPTHWRITE | SHADER_CULL_FRONT ;
s - > sort = SHADER_SORT_OPAQUE ;
2010-07-11 02:22:39 +00:00
s - > uses = 1 ;
2005-03-20 02:57:11 +00:00
}
2014-08-15 02:20:41 +00:00
void Shader_DefaultBSPFlare ( const char * shortname , shader_t * s , const void * args )
2005-03-20 02:57:11 +00:00
{
shaderpass_t * pass ;
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( " defaultflare " , s ) )
return ;
2005-03-20 02:57:11 +00:00
pass = & s - > passes [ 0 ] ;
2009-11-04 21:16:50 +00:00
pass - > flags = SHADER_PASS_NOCOLORARRAY ;
pass - > shaderbits | = SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE ;
pass - > anim_frames [ 0 ] = R_LoadHiResTexture ( shortname , NULL , 0 ) ;
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2005-03-20 02:57:11 +00:00
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numtcmods = 0 ;
pass - > tcgen = TC_GEN_BASE ;
pass - > numMergedPasses = 1 ;
2009-11-04 21:16:50 +00:00
Shader_SetBlendmode ( pass ) ;
2005-03-20 02:57:11 +00:00
2009-11-04 21:16:50 +00:00
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
2007-09-23 15:28:06 +00:00
Con_DPrintf ( CON_WARNING " Shader %s has a stage with no image: %s. \n " , s - > name , shortname ) ;
2006-03-06 01:41:09 +00:00
pass - > anim_frames [ 0 ] = missing_texture ;
2005-03-20 02:57:11 +00:00
}
s - > numpasses = 1 ;
s - > numdeforms = 0 ;
s - > flags = SHADER_FLARE ;
s - > sort = SHADER_SORT_ADDITIVE ;
2010-07-11 02:22:39 +00:00
s - > uses = 1 ;
2010-11-22 02:03:28 +00:00
s - > flags | = SHADER_NODRAW ;
2005-03-20 02:57:11 +00:00
}
2014-08-15 02:20:41 +00:00
void Shader_DefaultSkin ( const char * shortname , shader_t * s , const void * args )
2009-11-04 21:16:50 +00:00
{
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( " defaultskin " , s ) )
return ;
2010-11-26 06:58:48 +00:00
Shader_DefaultScript ( shortname , s ,
2009-11-04 21:16:50 +00:00
" { \n "
2011-09-03 03:49:43 +00:00
" if $lpp \n "
" program lpp_skin \n "
2013-03-12 23:16:55 +00:00
" else \n "
2011-12-23 03:12:29 +00:00
" program defaultskin \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2014-03-30 08:55:06 +00:00
" if gl_affinemodels \n "
" affine \n "
" endif \n "
2009-11-04 21:16:50 +00:00
" { \n "
" map $diffuse \n "
" rgbgen lightingDiffuse \n "
" } \n "
" { \n "
" map $loweroverlay \n "
" rgbgen bottomcolor \n "
2010-07-11 02:22:39 +00:00
" blendfunc gl_src_alpha gl_one \n "
2009-11-04 21:16:50 +00:00
" } \n "
" { \n "
" map $upperoverlay \n "
2010-07-11 02:22:39 +00:00
" rgbgen topcolor \n "
" blendfunc gl_src_alpha gl_one \n "
2009-11-04 21:16:50 +00:00
" } \n "
" { \n "
" map $fullbright \n "
" blendfunc add \n "
" } \n "
------------------------------------------------------------------------
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 $haveprogram \n "
" { \n "
" map $normalmap \n "
" } \n "
" { \n "
" map $specular \n "
" } \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2009-11-04 21:16:50 +00:00
" } \n "
) ;
2014-01-13 02:42:25 +00:00
s - > flags | = SHADER_NOIMAGE ;
2009-11-04 21:16:50 +00:00
}
2014-03-30 08:55:06 +00:00
void Shader_DefaultSkinShell ( const char * shortname , shader_t * s , const void * args )
2005-03-20 02:57:11 +00:00
{
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( " defaultskinshell " , s ) )
return ;
2011-04-23 20:37:20 +00:00
Shader_DefaultScript ( shortname , s ,
" { \n "
2014-05-10 13:42:13 +00:00
" sort seethrough \n " //before blend, but after other stuff. should fix most issues with shotgun etc effects obscuring it.
// "deformvertexes normal 1 1\n"
//draw it with depth but no colours at all
2011-04-23 20:37:20 +00:00
" { \n "
2014-05-10 13:42:13 +00:00
" map $whiteimage \n "
" maskcolor \n "
" depthwrite \n "
" } \n "
//now draw it again, depthfunc = equal should fill only the near-side, avoiding any excess-brightness issues with overlapping triangles
" { \n "
" map $whiteimage \n "
2011-04-23 20:37:20 +00:00
" rgbgen entity \n "
" alphagen entity \n "
" blendfunc blend \n "
" } \n "
" } \n "
) ;
2005-03-20 02:57:11 +00:00
}
2014-08-15 02:20:41 +00:00
void Shader_Default2D ( const char * shortname , shader_t * s , const void * genargs )
2005-03-20 02:57:11 +00:00
{
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( " default2d " , s ) )
return ;
2010-11-26 06:58:48 +00:00
Shader_DefaultScript ( shortname , s ,
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
" { \n "
2011-05-20 04:10:46 +00:00
" if $nofixed \n "
" program default2d \n "
2013-03-12 23:16:55 +00:00
" endif \n "
2014-03-30 08:55:06 +00:00
" affine \n "
2010-11-02 23:17:25 +00:00
" nomipmaps \n "
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
" { \n "
2010-11-22 02:03:28 +00:00
" clampmap $diffuse \n "
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
" rgbgen vertex \n "
" alphagen vertex \n "
" blendfunc gl_src_alpha gl_one_minus_src_alpha \n "
" } \n "
" sort additive \n "
" } \n "
) ;
2013-06-23 02:17:02 +00:00
TEXASSIGN ( s - > defaulttextures . base , R_LoadHiResTexture ( shortname , NULL , IF_UIPIC | IF_NOPICMIP | IF_NOMIPMAP | IF_CLAMP ) ) ;
2010-11-02 23:17:25 +00:00
if ( ! TEXVALID ( s - > defaulttextures . base ) )
{
unsigned char data [ 4 * 4 ] = { 0 } ;
2011-10-27 16:16:29 +00:00
TEXASSIGN ( s - > defaulttextures . base , R_LoadTexture8 ( " black " , 4 , 4 , data , 0 , 0 ) ) ;
2011-05-20 04:10:46 +00:00
s - > flags | = SHADER_NOIMAGE ;
}
else
{
s - > flags & = ~ SHADER_NOIMAGE ;
s - > width = image_width ;
s - > height = image_height ;
2010-11-02 23:17:25 +00:00
}
2005-03-20 02:57:11 +00:00
}
2013-07-29 17:36:44 +00:00
qboolean Shader_ReadShaderTerms ( shader_t * s , char * * shadersource , int parsemode , int * conddepth , int maxconddepth , int * cond )
2009-11-04 21:16:50 +00:00
{
char * token ;
2013-07-29 17:36:44 +00:00
2013-03-12 23:16:55 +00:00
# define COND_IGNORE 1
# define COND_IGNOREPARENT 2
# define COND_ALLOWELSE 4
2009-11-04 21:16:50 +00:00
2013-08-27 13:18:09 +00:00
if ( ! * shadersource )
2013-08-21 07:14:39 +00:00
return false ;
2013-07-29 17:36:44 +00:00
token = COM_ParseExt ( shadersource , true , true ) ;
2011-12-05 15:23:40 +00:00
2013-07-29 17:36:44 +00:00
if ( ! token [ 0 ] )
return true ;
else if ( ! Q_stricmp ( token , " if " ) )
2009-11-04 21:16:50 +00:00
{
2013-07-29 17:36:44 +00:00
if ( * conddepth + 1 = = maxconddepth )
2009-11-04 21:16:50 +00:00
{
2013-07-29 17:36:44 +00:00
Con_Printf ( " if statements nest too deeply in shader %s \n " , s - > name ) ;
return false ;
2013-03-12 23:16:55 +00:00
}
2013-07-29 17:36:44 +00:00
* conddepth + = 1 ;
cond [ * conddepth ] = ( ! Shader_EvaluateCondition ( s , shadersource ) ? COND_IGNORE : 0 ) ;
cond [ * conddepth ] | = COND_ALLOWELSE ;
if ( cond [ * conddepth - 1 ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
cond [ * conddepth ] | = COND_IGNOREPARENT ;
}
else if ( ! Q_stricmp ( token , " endif " ) )
{
if ( ! * conddepth )
2013-03-12 23:16:55 +00:00
{
2013-07-29 17:36:44 +00:00
Con_Printf ( " endif without if in shader %s \n " , s - > name ) ;
return false ;
2013-03-12 23:16:55 +00:00
}
2013-07-29 17:36:44 +00:00
* conddepth - = 1 ;
}
else if ( ! Q_stricmp ( token , " else " ) )
{
if ( cond [ * conddepth ] & COND_ALLOWELSE )
2013-03-12 23:16:55 +00:00
{
2013-07-29 17:36:44 +00:00
cond [ * conddepth ] ^ = COND_IGNORE ;
cond [ * conddepth ] & = ~ COND_ALLOWELSE ;
2013-03-12 23:16:55 +00:00
}
2013-07-29 17:36:44 +00:00
else
Con_Printf ( " unexpected else statement in shader %s \n " , s - > name ) ;
}
else if ( cond [ * conddepth ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
{
//eat it.
while ( * * shadersource )
2013-03-12 23:16:55 +00:00
{
2013-07-29 17:36:44 +00:00
token = COM_ParseExt ( shadersource , false , true ) ;
if ( ! token [ 0 ] )
break ;
}
}
else
{
int i ;
for ( i = 0 ; shadermacros [ i ] . name ; i + + )
{
if ( ! Q_stricmp ( token , shadermacros [ i ] . name ) )
2009-11-04 21:16:50 +00:00
{
2013-07-29 17:36:44 +00:00
# define SHADER_MACRO_ARGS 6
int argn = 0 ;
char * body ;
char arg [ SHADER_MACRO_ARGS ] [ 256 ] ;
int cond = 0 ;
//parse args until the end of the line
while ( * shadersource )
2009-11-04 21:16:50 +00:00
{
2013-07-29 17:36:44 +00:00
token = COM_ParseExt ( shadersource , false , true ) ;
if ( ! token [ 0 ] )
{
break ;
}
if ( argn < = SHADER_MACRO_ARGS )
{
Q_strncpyz ( arg [ argn ] , token , sizeof ( arg [ argn ] ) ) ;
argn + + ;
}
2009-11-04 21:16:50 +00:00
}
2013-07-29 17:36:44 +00:00
body = shadermacros [ i ] . body ;
Shader_ReadShaderTerms ( s , & body , parsemode , & cond , 0 , & cond ) ;
return true ;
2009-11-04 21:16:50 +00:00
}
}
2013-07-29 17:36:44 +00:00
if ( token [ 0 ] = = ' } ' )
return false ;
else if ( token [ 0 ] = = ' { ' )
Shader_Readpass ( s , shadersource ) ;
else if ( Shader_Parsetok ( s , NULL , shaderkeys , token , shadersource ) )
return false ;
}
return true ;
}
//loads a shader string into an existing shader object, and finalises it and stuff
static void Shader_ReadShader ( shader_t * s , char * shadersource , int parsemode )
{
int conddepth = 0 ;
int cond [ 8 ] ;
cond [ 0 ] = 0 ;
2014-03-30 08:55:06 +00:00
memset ( & parsestate , 0 , sizeof ( parsestate ) ) ;
parsestate . mode = parsemode ;
2013-07-29 17:36:44 +00:00
// set defaults
s - > flags = SHADER_CULL_FRONT ;
s - > uses = 1 ;
while ( Shader_ReadShaderTerms ( s , & shadersource , parsemode , & conddepth , sizeof ( cond ) / sizeof ( cond [ 0 ] ) , cond ) )
{
2013-03-12 23:16:55 +00:00
}
if ( conddepth )
{
Con_Printf ( " if statements without endif in shader %s \n " , s - > name ) ;
2009-11-04 21:16:50 +00:00
}
Shader_Finish ( s ) ;
}
2014-03-30 08:55:06 +00:00
static qboolean Shader_ParseShader ( char * parsename , shader_t * s )
2006-03-11 03:12:10 +00:00
{
2014-03-30 08:55:06 +00:00
size_t offset = 0 , length ;
char * buf = NULL ;
enum shaderparsemode_e parsemode = SPM_DEFAULT ;
2006-03-11 03:12:10 +00:00
2014-03-30 08:55:06 +00:00
if ( Shader_LocateSource ( parsename , & buf , & length , & offset , & parsemode ) )
2006-03-11 03:12:10 +00:00
{
2014-03-30 08:55:06 +00:00
// the shader is in the shader scripts
if ( buf & & offset < length )
{
char * file , * token ;
2006-03-11 03:12:10 +00:00
2014-03-30 08:55:06 +00:00
file = buf + offset ;
token = COM_ParseExt ( & file , true , true ) ;
if ( ! file | | token [ 0 ] ! = ' { ' )
{
FS_FreeFile ( buf ) ;
return false ;
}
2006-03-11 03:12:10 +00:00
2014-03-30 08:55:06 +00:00
Shader_Reset ( s ) ;
2006-03-11 03:12:10 +00:00
2014-03-30 08:55:06 +00:00
Shader_ReadShader ( s , file , parsemode ) ;
2006-03-11 03:12:10 +00:00
2014-03-30 08:55:06 +00:00
return true ;
}
2006-03-11 03:12:10 +00:00
}
return false ;
}
2010-07-11 02:22:39 +00:00
void R_UnloadShader ( shader_t * shader )
{
if ( shader - > uses - - = = 1 )
Shader_Free ( shader ) ;
}
2014-02-13 23:54:57 +00:00
static shader_t * R_LoadShader ( const char * name , unsigned int usageflags , shader_gen_t * defaultgen , const char * genargs )
2004-10-19 15:56:22 +00:00
{
int i , f = - 1 ;
2014-02-07 08:38:40 +00:00
char cleanname [ MAX_QPATH ] ;
2006-03-11 03:12:10 +00:00
char shortname [ MAX_QPATH ] ;
2014-02-07 08:38:40 +00:00
char * argsstart ;
2004-10-19 15:56:22 +00:00
shader_t * s ;
2011-05-20 04:10:46 +00:00
if ( ! * name )
2014-03-30 08:55:06 +00:00
name = " gfx/unspecified " ;
2011-05-20 04:10:46 +00:00
2014-02-07 08:38:40 +00:00
Q_strncpyz ( cleanname , name , sizeof ( cleanname ) ) ;
COM_CleanUpPath ( cleanname ) ;
2005-08-26 22:56:51 +00:00
2010-07-11 02:22:39 +00:00
// check the hash first
2014-02-07 08:38:40 +00:00
s = Hash_Get ( & shader_active_hash , cleanname ) ;
2013-08-21 07:14:39 +00:00
while ( s )
2010-07-11 02:22:39 +00:00
{
2013-08-21 07:14:39 +00:00
//make sure the same texture can be used as either a lightmap or vertexlit shader
//if it has an explicit shader overriding it then that still takes precidence. we might just have multiple copies of it.
//q3 has a separate (internal) shader for every lightmap.
2013-08-27 13:18:09 +00:00
if ( ! ( ( s - > usageflags ^ usageflags ) & SUF_LIGHTMAP ) )
2013-08-21 07:14:39 +00:00
{
2013-10-29 17:38:22 +00:00
s - > uses + + ;
return s ;
2013-08-21 07:14:39 +00:00
}
2014-02-07 08:38:40 +00:00
s = Hash_GetNext ( & shader_active_hash , cleanname , s ) ;
2010-07-11 02:22:39 +00:00
}
// not loaded, find a free slot
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < r_numshaders ; i + + )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
if ( ! r_shaders [ i ] | | ! r_shaders [ i ] - > uses )
2004-10-19 15:56:22 +00:00
{
if ( f = = - 1 ) // free shader
2010-07-11 02:22:39 +00:00
{
2004-10-19 15:56:22 +00:00
f = i ;
2010-07-11 02:22:39 +00:00
break ;
}
2004-10-19 15:56:22 +00:00
}
}
2013-10-29 17:38:22 +00:00
if ( f = = - 1 )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
shader_t * * n ;
int nm ;
f = r_numshaders ;
if ( f = = r_maxshaders )
{
2014-06-30 21:57:35 +00:00
if ( ! r_maxshaders )
Sys_Error ( " R_LoadShader: shader system not inited. " ) ;
2013-10-29 17:38:22 +00:00
nm = r_maxshaders * 2 ;
n = realloc ( r_shaders , nm * sizeof ( * n ) ) ;
if ( ! n )
{
Sys_Error ( " R_LoadShader: Shader limit exceeded. " ) ;
return NULL ;
}
memset ( n + r_maxshaders , 0 , ( nm - r_maxshaders ) * sizeof ( * n ) ) ;
r_shaders = n ;
r_maxshaders = nm ;
}
2004-10-19 15:56:22 +00:00
}
2014-02-07 08:38:40 +00:00
if ( strlen ( cleanname ) > = sizeof ( s - > name ) )
{
Sys_Error ( " R_LoadShader: Shader name too long. " ) ;
return NULL ;
}
2004-10-19 15:56:22 +00:00
2013-10-29 17:38:22 +00:00
s = r_shaders [ f ] ;
if ( ! s )
s = r_shaders [ f ] = Z_Malloc ( sizeof ( * s ) ) ;
s - > id = f ;
if ( r_numshaders < f + 1 )
r_numshaders = f + 1 ;
2004-10-19 15:56:22 +00:00
2014-02-07 08:38:40 +00:00
Q_strncpyz ( s - > name , cleanname , sizeof ( s - > name ) ) ;
2013-08-21 07:14:39 +00:00
s - > usageflags = usageflags ;
2011-05-20 04:10:46 +00:00
s - > generator = defaultgen ;
2011-12-05 15:23:40 +00:00
if ( genargs )
s - > genargs = strdup ( genargs ) ;
else
s - > genargs = NULL ;
2011-05-20 04:10:46 +00:00
2014-02-07 08:38:40 +00:00
//now determine the 'short name'. ie: the shader that is loaded off disk (no args, no extension)
argsstart = strchr ( cleanname , ' # ' ) ;
if ( argsstart )
* argsstart = 0 ;
COM_StripExtension ( cleanname , shortname , sizeof ( shortname ) ) ;
2013-10-29 17:38:22 +00:00
2009-11-04 21:16:50 +00:00
if ( ruleset_allow_shaders . ival )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
if ( sh_config . shadernamefmt )
2012-09-30 05:52:03 +00:00
{
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( va ( sh_config . shadernamefmt , shortname ) , s ) )
2012-09-30 05:52:03 +00:00
{
2014-03-30 08:55:06 +00:00
return s ;
2012-09-30 05:52:03 +00:00
}
}
2014-03-30 08:55:06 +00:00
if ( Shader_ParseShader ( shortname , s ) )
2009-11-04 21:16:50 +00:00
{
2013-10-29 17:38:22 +00:00
return s ;
2009-11-04 21:16:50 +00:00
}
2006-03-11 03:12:10 +00:00
}
2004-10-19 15:56:22 +00:00
2006-03-11 03:12:10 +00:00
// make a default shader
2004-10-19 15:56:22 +00:00
2011-05-20 04:10:46 +00:00
if ( s - > generator )
2004-10-19 15:56:22 +00:00
{
2011-05-20 04:10:46 +00:00
Shader_Reset ( s ) ;
2011-02-25 04:22:14 +00:00
if ( ! strcmp ( shortname , " textures/common/clip " ) )
2014-02-07 08:38:40 +00:00
Shader_DefaultScript ( cleanname , s ,
2011-02-25 04:22:14 +00:00
" { \n "
" surfaceparm nodraw \n "
" surfaceparm nodlight \n "
" } \n " ) ;
else
2014-02-07 08:38:40 +00:00
s - > generator ( cleanname , s , s - > genargs ) ;
2013-10-29 17:38:22 +00:00
return s ;
2006-03-11 03:12:10 +00:00
}
2011-05-20 04:10:46 +00:00
else
{
2011-12-05 15:23:40 +00:00
Shader_Free ( s ) ;
2011-05-20 04:10:46 +00:00
}
2013-10-29 17:38:22 +00:00
return NULL ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
void Shader_DoReload ( void )
{
shader_t * s ;
unsigned int i ;
char shortname [ MAX_QPATH ] ;
2013-03-12 23:10:44 +00:00
int oldsort ;
qboolean resort = false ;
2009-11-04 21:16:50 +00:00
2010-07-11 02:22:39 +00:00
if ( shader_rescan_needed & & ruleset_allow_shaders . ival )
{
2014-06-21 17:58:17 +00:00
Shader_FlushCache ( ) ;
2011-02-25 04:22:14 +00:00
COM_EnumerateFiles ( " materials/*.mtr " , Shader_InitCallback , NULL ) ;
2010-07-11 02:22:39 +00:00
COM_EnumerateFiles ( " shaders/*.shader " , Shader_InitCallback , NULL ) ;
COM_EnumerateFiles ( " scripts/*.shader " , Shader_InitCallback , NULL ) ;
2011-03-02 03:43:38 +00:00
COM_EnumerateFiles ( " scripts/*.rscript " , Shader_InitCallback , NULL ) ;
2010-07-11 02:22:39 +00:00
shader_reload_needed = true ;
shader_rescan_needed = false ;
}
2009-11-04 21:16:50 +00:00
if ( ! shader_reload_needed )
return ;
shader_reload_needed = false ;
2010-03-14 14:35:56 +00:00
Font_InvalidateColour ( ) ;
2012-09-30 05:52:03 +00:00
Shader_ReloadGenerics ( ) ;
2009-11-04 21:16:50 +00:00
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < r_numshaders ; i + + )
2009-11-04 21:16:50 +00:00
{
2013-10-29 17:38:22 +00:00
s = r_shaders [ i ] ;
if ( ! s | | ! s - > uses )
2009-11-04 21:16:50 +00:00
continue ;
strcpy ( shortname , s - > name ) ;
if ( ruleset_allow_shaders . ival )
{
2014-03-30 08:55:06 +00:00
if ( sh_config . shadernamefmt & & Shader_ParseShader ( va ( sh_config . shadernamefmt , shortname ) , s ) )
continue ;
if ( Shader_ParseShader ( shortname , s ) )
2009-11-04 21:16:50 +00:00
continue ;
}
if ( s - > generator )
{
2013-03-12 23:10:44 +00:00
oldsort = s - > sort ;
2011-05-20 04:10:46 +00:00
Shader_Reset ( s ) ;
2010-12-05 02:46:07 +00:00
2011-05-20 04:10:46 +00:00
s - > generator ( shortname , s , s - > genargs ) ;
2013-03-12 23:10:44 +00:00
if ( s - > sort ! = oldsort )
resort = true ;
2009-11-04 21:16:50 +00:00
}
}
2013-03-12 23:10:44 +00:00
if ( resort )
{
2013-07-14 12:22:51 +00:00
Mod_ResortShaders ( ) ;
2013-03-12 23:10:44 +00:00
}
2009-11-04 21:16:50 +00:00
}
2011-12-05 15:23:40 +00:00
void Shader_NeedReload ( qboolean rescanfs )
2009-11-04 21:16:50 +00:00
{
2011-12-05 15:23:40 +00:00
if ( rescanfs )
shader_rescan_needed = true ;
2009-11-04 21:16:50 +00:00
shader_reload_needed = true ;
}
2010-07-11 02:22:39 +00:00
cin_t * R_ShaderGetCinematic ( shader_t * s )
{
# ifndef NOMEDIA
int j ;
if ( ! s )
return NULL ;
for ( j = 0 ; j < s - > numpasses ; j + + )
if ( s - > passes [ j ] . cin )
return s - > passes [ j ] . cin ;
# endif
/*no cinematic in this shader!*/
return NULL ;
}
2014-03-30 08:55:06 +00:00
cin_t * R_ShaderFindCinematic ( const char * name )
2008-11-09 22:29:28 +00:00
{
2009-11-04 21:16:50 +00:00
# ifdef NOMEDIA
return NULL ;
# else
2010-07-11 02:22:39 +00:00
int i ;
char shortname [ MAX_QPATH ] ;
2013-10-29 17:38:22 +00:00
shader_t * s ;
2008-11-09 22:29:28 +00:00
2013-03-12 22:44:00 +00:00
if ( ! r_shaders )
return NULL ;
2008-11-09 22:29:28 +00:00
COM_StripExtension ( name , shortname , sizeof ( shortname ) ) ;
COM_CleanUpPath ( shortname ) ;
//try and find it
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < r_numshaders ; i + + )
2008-11-09 22:29:28 +00:00
{
2013-10-29 17:38:22 +00:00
s = r_shaders [ i ] ;
if ( ! s | | ! s - > uses )
2008-11-09 22:29:28 +00:00
continue ;
2013-10-29 17:38:22 +00:00
if ( ! Q_stricmp ( shortname , s - > name ) )
return R_ShaderGetCinematic ( s ) ;
2008-11-09 22:29:28 +00:00
}
2013-10-29 17:38:22 +00:00
return NULL ;
2009-11-04 21:16:50 +00:00
# endif
2008-11-09 22:29:28 +00:00
}
2014-02-14 09:59:32 +00:00
void Shader_ResetRemaps ( void )
{
shader_t * s ;
int i ;
for ( i = 0 ; i < r_numshaders ; i + + )
{
s = r_shaders [ i ] ;
if ( ! s )
continue ;
s - > remapto = s ;
s - > remaptime = 0 ;
}
}
2014-02-13 23:54:57 +00:00
void R_RemapShader ( const char * sourcename , const char * destname , float timeoffset )
{
shader_t * o ;
shader_t * n ;
//make sure all types of the shader are remapped properly.
//if there's a .shader file with it then it should 'just work'.
o = R_LoadShader ( sourcename , SUF_NONE , NULL , NULL ) ;
n = R_LoadShader ( destname , SUF_NONE , NULL , NULL ) ;
if ( o )
{
if ( ! n )
n = o ;
o - > remapto = n ;
o - > remaptime = timeoffset ; //this just feels wrong.
}
o = R_LoadShader ( sourcename , SUF_2D , NULL , NULL ) ;
n = R_LoadShader ( destname , SUF_2D , NULL , NULL ) ;
if ( o )
{
if ( ! n )
n = o ;
o - > remapto = n ;
o - > remaptime = timeoffset ;
}
o = R_LoadShader ( sourcename , SUF_LIGHTMAP , NULL , NULL ) ;
n = R_LoadShader ( destname , SUF_LIGHTMAP , NULL , NULL ) ;
if ( o )
{
if ( ! n )
2014-06-04 16:08:30 +00:00
{
n = R_LoadShader ( destname , SUF_2D , NULL , NULL ) ;
if ( ! n )
n = o ;
}
2014-02-13 23:54:57 +00:00
o - > remapto = n ;
o - > remaptime = timeoffset ;
}
}
void Shader_RemapShader_f ( void )
{
char * sourcename = Cmd_Argv ( 1 ) ;
char * destname = Cmd_Argv ( 2 ) ;
float timeoffset = atof ( Cmd_Argv ( 3 ) ) ;
2014-06-04 16:08:30 +00:00
if ( ! Cmd_FromGamecode ( ) & & strcmp ( Info_ValueForKey ( cl . serverinfo , " *cheats " ) , " ON " ) )
2014-02-13 23:54:57 +00:00
{
Con_Printf ( " %s may only be used from gamecode, or when cheats are enabled \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
if ( ! * sourcename )
{
Con_Printf ( " %s originalshader remappedshader starttime \n " , Cmd_Argv ( 0 ) ) ;
return ;
}
R_RemapShader ( sourcename , destname , timeoffset ) ;
}
2014-03-30 08:55:06 +00:00
shader_t * R_RegisterPic ( const char * name )
2004-10-19 15:56:22 +00:00
{
2011-12-26 15:19:13 +00:00
shader_t * shader ;
/*don't get confused by other shaders*/
image_width = 64 ;
image_height = 64 ;
2013-10-29 17:38:22 +00:00
shader = R_LoadShader ( name , SUF_2D , Shader_Default2D , NULL ) ;
2011-12-26 15:19:13 +00:00
/*worth a try*/
if ( shader - > width < = 0 )
shader - > width = image_width ;
if ( shader - > height < = 0 )
shader - > height = image_height ;
/*last ditch attempt*/
if ( shader - > width < = 0 )
shader - > width = 64 ;
if ( shader - > height < = 0 )
shader - > height = 64 ;
return shader ;
2004-10-19 15:56:22 +00:00
}
2014-04-24 01:53:01 +00:00
shader_t * QDECL R_RegisterShader ( const char * name , unsigned int usageflags , const char * shaderscript )
2009-11-04 21:16:50 +00:00
{
2013-10-29 17:38:22 +00:00
return R_LoadShader ( name , usageflags , Shader_DefaultScript , shaderscript ) ;
2009-11-04 21:16:50 +00:00
}
2014-03-30 08:55:06 +00:00
shader_t * R_RegisterShader_Lightmap ( const char * name )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
return R_LoadShader ( name , SUF_LIGHTMAP , Shader_DefaultBSPLM , NULL ) ;
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
shader_t * R_RegisterShader_Vertex ( const char * name )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
return R_LoadShader ( name , 0 , Shader_DefaultBSPVertex , NULL ) ;
2004-10-19 15:56:22 +00:00
}
2014-03-30 08:55:06 +00:00
shader_t * R_RegisterShader_Flare ( const char * name )
2004-10-19 15:56:22 +00:00
{
2013-10-29 17:38:22 +00:00
return R_LoadShader ( name , 0 , Shader_DefaultBSPFlare , NULL ) ;
2004-10-19 15:56:22 +00:00
}
2014-04-24 01:53:01 +00:00
shader_t * QDECL R_RegisterSkin ( const char * shadername , const char * modname )
2004-10-19 15:56:22 +00:00
{
2011-07-30 14:14:56 +00:00
shader_t * shader ;
2014-03-30 08:55:06 +00:00
# ifdef _DEBUG
if ( shadername = = com_token )
Con_Printf ( " R_RegisterSkin was passed com_token. that will bug out. \n " ) ;
# endif
if ( modname & & ! strchr ( shadername , ' / ' ) & & * shadername )
2011-07-30 14:14:56 +00:00
{
char newsname [ MAX_QPATH ] ;
char * b = COM_SkipPath ( modname ) ;
if ( b ! = modname & & b - modname + strlen ( shadername ) + 1 < sizeof ( newsname ) )
{
memcpy ( newsname , modname , b - modname ) ;
memcpy ( newsname + ( b - modname ) , shadername , strlen ( shadername ) + 1 ) ;
/*if the specified shader does not contain a path, try and load one relative to the name of the model*/
2013-10-29 17:38:22 +00:00
shader = R_LoadShader ( newsname , 0 , Shader_DefaultSkin , NULL ) ;
2011-07-30 14:14:56 +00:00
R_BuildDefaultTexnums ( & shader - > defaulttextures , shader ) ;
/*if its a valid shader with valid textures, use it*/
if ( ! ( shader - > flags & SHADER_NOIMAGE ) )
return shader ;
}
}
2013-10-29 17:38:22 +00:00
shader = R_LoadShader ( shadername , 0 , Shader_DefaultSkin , NULL ) ;
2011-07-30 14:14:56 +00:00
return shader ;
2005-03-20 02:57:11 +00:00
}
2014-03-30 08:55:06 +00:00
shader_t * R_RegisterCustom ( const char * name , unsigned int usageflags , shader_gen_t * defaultgen , const void * args )
2005-03-20 02:57:11 +00:00
{
2013-10-29 17:38:22 +00:00
return R_LoadShader ( name , usageflags , defaultgen , args ) ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
# endif //SERVERONLY