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
2019-03-12 05:04:27 +00:00
2004-12-09 23:42:00 +00:00
# include <ctype.h>
2009-11-04 21:16:50 +00:00
extern texid_t missing_texture ;
2018-11-27 16:48:19 +00:00
texid_t r_whiteimage , r_blackimage ;
2015-07-03 02:07:41 +00:00
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. " ) ;
2015-09-07 14:34:39 +00:00
cvar_t r_forceprogramify = CVARAFD ( " r_forceprogramify " , " 0 " , " dpcompat_makeshitup " , CVAR_SHADERSYSTEM , " Reduce the shader to a single texture, and then make stuff up about its mother. The resulting fist fight results in more colour when you shine a light upon its face. \n Set to 2 to ignore 'depthfunc equal' and 'tcmod scale' in order to tolerate bizzare shaders made for a bizzare engine. \n Because most shaders made for DP are by people who _clearly_ have no idea what the heck they're doing, you'll typically need the '2' setting. " ) ;
2021-05-19 04:49:15 +00:00
# ifdef HAVE_LEGACY
2017-08-29 02:29:06 +00:00
cvar_t dpcompat_nopremulpics = CVARFD ( " dpcompat_nopremulpics " , " 0 " , CVAR_SHADERSYSTEM , " By default FTE uses premultiplied alpha for hud/2d images, while DP does not (which results in halos with low-res content). Unfortunately DDS files would need to be recompressed, resulting in visible issues. " ) ;
2021-05-19 04:49:15 +00:00
# endif
cvar_t r_glsl_precache = CVARFD ( " r_glsl_precache " , " 0 " , CVAR_SHADERSYSTEM , " Force all relevant glsl permutations to load upfront. " ) ;
2020-03-29 18:37:10 +00:00
2012-01-17 07:57:46 +00:00
extern cvar_t r_glsl_offsetmapping_reliefmapping ;
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 ;
2017-02-11 16:14:06 +00:00
extern cvar_t r_tessellation ;
2018-01-22 19:18:04 +00:00
extern cvar_t gl_compress ;
2004-10-19 15:56:22 +00:00
2018-01-22 19:18:04 +00:00
//backend fills this in to say the max fixed-function pass count (often 1, where its emulated by us, because we're too lazy).
2009-11-04 21:16:50 +00:00
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
2020-06-12 23:29:58 +00:00
char * COM_ParseExt ( const char * * data_p , qboolean nl , qboolean comma )
2004-10-19 15:56:22 +00:00
{
int c ;
int len ;
2020-06-12 23:29:58 +00:00
const char * data ;
2004-10-19 15:56:22 +00:00
2016-07-12 00:40:13 +00:00
COM_AssertMainThread ( " COM_ParseExt " ) ;
2004-10-19 15:56:22 +00:00
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 :
2016-07-12 00:40:13 +00:00
while ( ( c = ( unsigned char ) * data ) < = ' ' )
2004-10-19 15:56:22 +00:00
{
if ( c = = 0 )
{
* data_p = NULL ;
return " " ;
}
2017-10-31 22:52:58 +00:00
if ( c = = ' \n ' & & ! nl )
{
* data_p = data ;
return com_token ;
}
2004-10-19 15:56:22 +00:00
data + + ;
}
// skip // comments
if ( c = = ' / ' & & data [ 1 ] = = ' / ' )
{
while ( * data & & * data ! = ' \n ' )
data + + ;
goto skipwhite ;
}
2016-07-12 00:40:13 +00:00
// skip /* comments
if ( c = = ' / ' & & data [ 1 ] = = ' * ' )
{
2020-06-12 23:29:58 +00:00
const char * start = data ;
2016-07-12 00:40:13 +00:00
data + = 2 ;
for ( ; data [ 0 ] ; )
{
if ( data [ 0 ] = = ' * ' & & data [ 1 ] = = ' / ' )
{
data + = 2 ;
break ;
}
2017-10-31 22:52:58 +00:00
if ( * data = = ' \n ' & & ! nl )
{
* data_p = start ;
return com_token ;
}
2016-07-12 00:40:13 +00:00
data + + ;
}
goto skipwhite ;
}
2004-10-19 15:56:22 +00:00
// 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 ;
}
2019-04-16 22:40:05 +00:00
static float Com_FloatArgument ( const char * shadername , char * arg , size_t arglen , float def )
2013-03-12 23:13:39 +00:00
{
2018-11-27 16:48:19 +00:00
const char * var ;
2004-10-19 15:56:22 +00:00
2013-03-12 23:13:39 +00:00
//grab an argument instead, otherwise 0
2018-11-27 16:48:19 +00:00
var = shadername ;
2013-05-11 05:03:07 +00:00
while ( ( var = strchr ( var , ' # ' ) ) )
2013-03-12 23:13:39 +00:00
{
2018-11-27 16:48:19 +00:00
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 + + ;
}
2019-04-16 22:40:05 +00:00
return def ; //not present.
2013-03-12 23:13:39 +00:00
}
2019-04-16 22:40:05 +00:00
# define Shader_FloatArgument(s,k) (Com_FloatArgument(s->name,k,strlen(k),0))
2004-10-19 15:56:22 +00:00
# define HASH_SIZE 128
2018-04-27 16:40:50 +00:00
# define SPF_DEFAULT 0u /*quake3/fte internal*/
2020-03-25 21:29:30 +00:00
# define SPF_PROGRAMIFY (1u<<0) /*automatically replace known glsl, pulling in additional textures+effects from a single primary pass*/
2018-04-27 16:40:50 +00:00
# define SPF_DOOM3 (1u<<1) /*any commands, args, etc, should be interpretted according to doom3's norms*/
2014-03-30 08:55:06 +00:00
2019-03-12 05:04:27 +00:00
typedef struct shaderparsestate_s
2014-03-30 08:55:06 +00:00
{
2018-04-27 16:40:50 +00:00
shader_t * s ; //the shader we're parsing
shaderpass_t * pass ; //the pass we're currently parsing
2020-06-12 23:29:58 +00:00
const char * ptr ; //the src file pointer we're at
2019-12-16 17:25:59 +00:00
char * sourcename ; //the name of the shader file being read (or '<code>')
2018-04-27 16:40:50 +00:00
const char * forcedshader ;
unsigned int parseflags ; //SPF_*
2016-12-07 18:45:25 +00:00
qboolean droppass ;
2016-08-25 00:12:14 +00:00
//for dpwater compat, used to generate a program
2016-12-07 18:45:25 +00:00
int dpwatertype ;
2016-08-25 00:12:14 +00:00
float reflectmin ;
float reflectmax ;
float reflectfactor ;
float refractfactor ;
vec3_t refractcolour ;
vec3_t reflectcolour ;
float wateralpha ;
2017-08-29 02:29:06 +00:00
2019-03-12 05:04:27 +00:00
char * * saveshaderbody ;
2017-10-12 12:02:25 +00:00
//FIXME: rtlights can't respond to these
int offsetmappingmode ;
float offsetmappingscale ;
float offsetmappingbias ;
2017-08-29 02:29:06 +00:00
float specularexpscale ; //*32 ish
float specularvalscale ; //*1 ish
2018-04-27 16:40:50 +00:00
} parsestate_t ;
2014-03-30 08:55:06 +00:00
2004-10-19 15:56:22 +00:00
typedef struct shaderkey_s
{
2016-07-12 00:40:13 +00:00
char * keyword ;
2020-06-12 23:29:58 +00:00
void ( * func ) ( parsestate_t * ps , const char * * ptr ) ;
2015-03-03 00:14:43 +00:00
char * prefix ;
2004-10-19 15:56:22 +00:00
} shaderkey_t ;
2014-03-30 08:55:06 +00:00
typedef struct shadercachefile_s {
char * data ;
size_t length ;
2018-04-27 16:40:50 +00:00
unsigned int parseflags ;
char forcedshadername [ 64 ] ;
2014-03-30 08:55:06 +00:00
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
2020-06-12 23:29:58 +00:00
static const char * Shader_Skip ( const char * file , const char * shadername , const char * ptr ) ;
static qboolean Shader_Parsetok ( parsestate_t * ps , shaderkey_t * keys , const char * token ) ;
static void Shader_ParseFunc ( parsestate_t * ps , const char * functype , const char * * args , shaderfunc_t * func ) ;
2018-04-27 16:40:50 +00:00
static void Shader_MakeCache ( const char * path , unsigned int parseflags ) ;
2020-06-12 23:29:58 +00:00
static qboolean Shader_LocateSource ( const char * name , const char * * buf , size_t * bufsize , size_t * offset , shadercachefile_t * * sourcefile ) ;
static void Shader_ReadShader ( parsestate_t * ps , const char * shadersource , shadercachefile_t * sourcefile ) ;
static qboolean Shader_ParseShader ( parsestate_t * ps , const char * parsename ) ;
2004-10-19 15:56:22 +00:00
//===========================================================================
2020-06-12 23:29:58 +00:00
static qboolean Shader_EvaluateCondition ( shader_t * shader , const 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 ;
2017-10-13 17:50:28 +00:00
float lhs ;
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
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 + + ;
2017-10-31 22:52:58 +00:00
if ( ! * token )
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
}
2017-10-13 17:50:28 +00:00
if ( * token > = ' 0 ' & & * token < = ' 9 ' )
lhs = strtod ( token , NULL ) ;
else
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
{
2017-10-13 17:50:28 +00:00
if ( * token = = ' $ ' )
token + + ;
2013-03-12 23:13:39 +00:00
if ( * token = = ' # ' )
2018-11-27 16:48:19 +00:00
lhs = ! ! Shader_FloatArgument ( shader , token + 1 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " lpp " ) )
2017-10-31 22:52:58 +00:00
lhs = r_lightprepass ;
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( token , " lightmap " ) )
2017-10-31 22:52:58 +00:00
lhs = ! r_fullbright . value ;
else if ( ! Q_stricmp ( token , " deluxmap " ) | | ! Q_stricmp ( token , " deluxe " ) )
2018-07-05 16:21:44 +00:00
lhs = r_deluxemapping ;
2015-08-07 17:49:49 +00:00
else if ( ! Q_stricmp ( token , " softwarebanding " ) )
2017-10-31 22:52:58 +00:00
lhs = r_softwarebanding ;
2020-10-26 06:30:35 +00:00
else if ( ! Q_stricmp ( token , " unmaskedsky " ) )
lhs = cls . allow_unmaskedskyboxes ; //can/should skip writing depth values for sky surfaces.
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 " ) )
2017-10-31 22:52:58 +00:00
lhs = 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
2016-07-12 00:40:13 +00:00
else if ( ! Q_stricmp ( token , " vulkan " ) )
2017-10-31 22:52:58 +00:00
lhs = ( qrenderer = = QR_VULKAN ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " opengl " ) )
2017-10-31 22:52:58 +00:00
lhs = ( qrenderer = = QR_OPENGL ) ;
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
else if ( ! Q_stricmp ( token , " d3d8 " ) )
2017-10-31 22:52:58 +00:00
lhs = ( qrenderer = = QR_DIRECT3D8 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " d3d9 " ) )
2017-10-31 22:52:58 +00:00
lhs = ( qrenderer = = QR_DIRECT3D9 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " d3d11 " ) )
2017-10-31 22:52:58 +00:00
lhs = ( qrenderer = = QR_DIRECT3D11 ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " gles " ) )
2018-10-13 12:19:58 +00:00
{
# ifdef GLQUAKE
lhs = ( ( qrenderer = = QR_OPENGL ) & & gl_config . gles ) ;
# else
lhs = false ;
# endif
}
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " nofixed " ) )
2017-10-31 22:52:58 +00:00
lhs = sh_config . progs_required ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " glsl " ) )
2017-10-31 22:52:58 +00:00
lhs = ( ( qrenderer = = QR_OPENGL ) & & sh_config . progs_supported ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " hlsl " ) )
2017-10-31 22:52:58 +00:00
lhs = ( ( qrenderer = = QR_DIRECT3D9 | | qrenderer = = QR_DIRECT3D11 ) & & sh_config . progs_supported ) ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " haveprogram " ) )
2017-10-31 22:52:58 +00:00
lhs = ! ! shader - > prog ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " programs " ) )
2017-10-31 22:52:58 +00:00
lhs = sh_config . progs_supported ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " diffuse " ) )
2017-10-31 22:52:58 +00:00
lhs = true ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " specular " ) )
2017-10-31 22:52:58 +00:00
lhs = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " fullbright " ) )
2017-10-31 22:52:58 +00:00
lhs = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " topoverlay " ) )
2017-10-31 22:52:58 +00:00
lhs = false ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " loweroverlay " ) )
2017-10-31 22:52:58 +00:00
lhs = false ;
2017-12-28 16:24:50 +00:00
//these are for compat/documentation purposes with qfusion/warsow
else if ( ! Q_stricmp ( token , " maxTextureSize " ) )
lhs = sh_config . texture2d_maxsize ;
else if ( ! Q_stricmp ( token , " maxTextureCubemapSize " ) )
lhs = sh_config . texturecube_maxsize ;
else if ( ! Q_stricmp ( token , " maxTextureUnits " ) )
lhs = 0 ;
else if ( ! Q_stricmp ( token , " textureCubeMap " ) )
lhs = sh_config . havecubemaps ;
// else if (!Q_stricmp(token, "GLSL"))
// lhs = 1;
else if ( ! Q_stricmp ( token , " deluxeMaps " ) | | ! Q_stricmp ( token , " deluxe " ) )
2018-07-05 16:21:44 +00:00
lhs = r_deluxemapping ;
2017-12-28 16:24:50 +00:00
else if ( ! Q_stricmp ( token , " portalMaps " ) )
lhs = false ;
//end qfusion
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
{
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 ) ;
2017-10-13 17:50:28 +00:00
lhs = 0 ;
2014-08-25 07:35:41 +00:00
}
2012-04-09 19:12:12 +00:00
}
2017-10-13 17:50:28 +00:00
}
if ( * token )
token = COM_ParseExt ( ptr , false , false ) ;
if ( * token )
{
float rhs ;
char cmp [ 4 ] ;
memcpy ( cmp , token , 4 ) ;
token = COM_ParseExt ( ptr , false , false ) ;
rhs = atof ( token ) ;
if ( ! strcmp ( cmp , " != " ) )
conditiontrue = lhs ! = rhs ;
else if ( ! strcmp ( cmp , " == " ) )
conditiontrue = lhs = = rhs ;
else if ( ! strcmp ( cmp , " < " ) )
conditiontrue = lhs < rhs ;
else if ( ! strcmp ( cmp , " <= " ) )
conditiontrue = lhs < = rhs ;
else if ( ! strcmp ( cmp , " > " ) )
conditiontrue = lhs > rhs ;
else if ( ! strcmp ( cmp , " >= " ) )
conditiontrue = lhs > = rhs ;
2010-11-10 03:32:47 +00:00
else
2017-10-13 17:50:28 +00:00
conditiontrue = false ;
}
else
{
conditiontrue = conditiontrue = = ! ! lhs ;
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 ;
}
2020-06-12 23:29:58 +00:00
static char * Shader_ParseExactString ( const char * * 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
{
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 ;
}
2020-06-12 23:29:58 +00:00
static char * Shader_ParseString ( const 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 " " ;
2017-10-31 22:52:58 +00:00
while ( * * ptr = = ' ' | | * * ptr = = ' \t ' )
* ptr + = 1 ;
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 ;
}
2020-06-12 23:29:58 +00:00
static char * Shader_ParseSensString ( const 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 ;
}
2020-06-12 23:29:58 +00:00
static float Shader_ParseFloat ( shader_t * shader , const char * * ptr , float defaultval )
2004-10-19 15:56:22 +00:00
{
2010-11-22 02:03:28 +00:00
char * token ;
if ( ! ptr | | ! ( * ptr ) )
2015-03-03 00:14:43 +00:00
return defaultval ;
2010-11-22 02:03:28 +00:00
if ( ! * * ptr | | * * ptr = = ' } ' )
2015-03-03 00:14:43 +00:00
return defaultval ;
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 , false , true ) ;
2010-11-22 02:03:28 +00:00
if ( * token = = ' $ ' )
{
2013-03-12 23:13:39 +00:00
if ( token [ 1 ] = = ' # ' )
{
2018-11-27 16:48:19 +00:00
return Shader_FloatArgument ( shader , token + 2 ) ;
2013-03-12 23:13:39 +00:00
}
else
{
cvar_t * var ;
var = Cvar_FindVar ( token + 1 ) ;
if ( var )
2015-03-03 00:14:43 +00:00
{
if ( * var - > string )
return var - > value ;
else
return defaultval ;
}
2013-03-12 23:13:39 +00:00
}
2010-11-22 02:03:28 +00:00
}
2015-03-03 00:14:43 +00:00
if ( ! * token )
return defaultval ;
2010-11-22 02:03:28 +00:00
return atof ( token ) ;
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_ParseVector ( shader_t * shader , const char * * ptr , vec3_t v )
2004-10-19 15:56:22 +00:00
{
2020-06-12 23:29:58 +00:00
const 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
2020-06-12 23:29:58 +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
2019-04-07 16:41:09 +00:00
if ( ! strncmp ( token , " 0x " , 2 ) )
{ //0xRRGGBB
unsigned int hex = strtoul ( token , NULL , 0 ) ;
v [ 0 ] = ( ( hex > > 16 ) & 255 ) / 255. ;
v [ 1 ] = ( ( hex > > 8 ) & 255 ) / 255. ;
v [ 2 ] = ( ( hex > > 0 ) & 255 ) / 255. ;
return ;
}
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
2016-07-12 00:40:13 +00:00
/*
2009-11-04 21:16:50 +00:00
if ( v [ 0 ] > 5 | | v [ 1 ] > 5 | | v [ 2 ] > 5 )
{
VectorScale ( v , 1.0f / 255 , v ) ;
}
2016-07-12 00:40:13 +00:00
*/
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 )
2017-08-29 02:29:06 +00:00
{ //FIXME: use Image_LoadCubemapTextureData to load the faces
//if possible directly use a 7th/cubemap texture instead
//this requires fixing the sky code to not do the random transforms thing though.
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 " } ,
2017-08-29 02:29:06 +00:00
// {"px", "py", "nx", "ny", "pz", "nz"},
// {"posx", "posy", "negx", "negy", "posz", "negz"},
// {"_px", "_py", "_nx", "_ny", "_pz", "_nz"},
// {"_posx", "_posy", "_negx", "_negy", "_posz", "_negz"},
2009-11-04 21:16:50 +00:00
{ " _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 ;
2017-08-29 02:29:06 +00:00
allokay = true ;
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 ] ) ;
2017-08-29 02:29:06 +00:00
images [ i ] = R_LoadHiResTexture ( path , NULL , IF_NOALPHA | IF_CLAMP | IF_LOADNOW ) ;
if ( images [ i ] - > width )
2009-11-04 21:16:50 +00:00
break ;
}
2017-08-29 02:29:06 +00:00
if ( images [ i ] - > width )
2009-11-04 21:16:50 +00:00
break ;
}
2017-08-29 02:29:06 +00:00
if ( ! images [ i ] - > width )
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
2020-06-12 23:29:58 +00:00
static void Shader_ParseFunc ( parsestate_t * ps , const char * functype , const char * * ptr , shaderfunc_t * func )
2004-10-19 15:56:22 +00:00
{
2019-12-16 17:25:59 +00:00
shader_t * shader = ps - > s ;
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 " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_SIN ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " triangle " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_TRIANGLE ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " square " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_SQUARE ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " sawtooth " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_SAWTOOTH ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " inversesawtooth " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_INVERSESAWTOOTH ;
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( token , " noise " ) )
2016-10-22 07:06:51 +00:00
func - > type = SHADER_FUNC_NOISE ;
2019-09-04 08:32:22 +00:00
else
2018-03-04 14:41:16 +00:00
{
2019-09-04 08:32:22 +00:00
if ( ! Q_stricmp ( token , " distanceramp " ) ) //QFusion
;
else
2019-12-16 17:25:59 +00:00
Con_Printf ( " %s: %s: unknown %s \" %s \" \n " , ps - > sourcename , shader - > name , functype , token ) ;
2018-03-04 14:41:16 +00:00
func - > type = SHADER_FUNC_CONSTANT ; //not supported...
Shader_ParseFloat ( shader , ptr , 0 ) ;
Shader_ParseFloat ( shader , ptr , 0 ) ;
Shader_ParseFloat ( shader , ptr , 0 ) ;
Shader_ParseFloat ( shader , ptr , 0 ) ;
Vector4Set ( func - > args , 255 , 255 , 255 , 255 ) ;
return ;
}
2004-10-19 15:56:22 +00:00
2015-03-03 00:14:43 +00:00
func - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
func - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
func - > args [ 2 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
func - > args [ 3 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2004-10-19 15:56:22 +00:00
}
//===========================================================================
2019-03-12 05:04:27 +00:00
static int Shader_SetImageFlags ( parsestate_t * parsestate , shaderpass_t * pass , char * * name , int flags )
2004-10-19 15:56:22 +00:00
{
2016-10-22 07:06:51 +00:00
//fixme: pass flags should be handled elsewhere.
2015-02-02 08:01:53 +00:00
for ( ; name ; )
2011-12-23 03:12:29 +00:00
{
2014-08-03 14:47:47 +00:00
if ( ! Q_strnicmp ( * name , " $rt: " , 4 ) )
{
* name + = 4 ;
2016-10-22 07:06:51 +00:00
flags | = IF_NOMIPMAP | IF_CLAMP | IF_RENDERTARGET ;
if ( ! ( flags & ( IF_NEAREST | IF_LINEAR ) ) )
flags | = IF_LINEAR ;
2014-08-03 14:47:47 +00:00
}
else if ( ! Q_strnicmp ( * name , " $clamp: " , 7 ) )
{
* name + = 7 ;
flags | = IF_CLAMP ;
}
2019-04-01 10:16:36 +00:00
else if ( ! Q_strnicmp ( * name , " $premul: " , 8 ) )
{ //have the engine premultiply textures for you, instead of needing to do it in an editor.
* name + = 8 ;
flags | = IF_PREMULTIPLYALPHA ;
}
2019-10-18 08:37:38 +00:00
else if ( ! Q_strnicmp ( * name , " $2d: " , 4 ) )
{
* name + = 4 ;
flags = ( flags & ~ IF_TEXTYPEMASK ) | IF_TEXTYPE_2D ;
}
else if ( ! Q_strnicmp ( * name , " $2darray: " , 9 ) )
{
* name + = 9 ;
flags = ( flags & ~ IF_TEXTYPEMASK ) | IF_TEXTYPE_2D_ARRAY ;
}
2014-08-03 14:47:47 +00:00
else if ( ! Q_strnicmp ( * name , " $3d: " , 4 ) )
2011-12-23 03:12:29 +00:00
{
* name + = 4 ;
2019-10-18 08:37:38 +00:00
flags = ( flags & ~ IF_TEXTYPEMASK ) | IF_TEXTYPE_3D ;
2013-06-23 02:17:02 +00:00
}
else if ( ! Q_strnicmp ( * name , " $cube: " , 6 ) )
{
* name + = 6 ;
2019-10-18 08:37:38 +00:00
flags = ( flags & ~ IF_TEXTYPEMASK ) | IF_TEXTYPE_CUBE ;
2011-12-23 03:12:29 +00:00
}
2019-10-18 08:37:38 +00:00
else if ( ! Q_strnicmp ( * name , " $cubearray: " , 11 ) )
2019-09-25 20:23:24 +00:00
{
2019-10-18 08:37:38 +00:00
* name + = 11 ;
flags = ( flags & ~ IF_TEXTYPEMASK ) | IF_TEXTYPE_CUBE_ARRAY ;
2019-09-25 20:23:24 +00:00
}
2019-03-12 05:04:27 +00:00
else if ( ! Q_strnicmp ( * name , " $srgb: " , 6 ) )
{
* name + = 6 ;
flags & = ~ IF_NOSRGB ;
flags | = IF_SRGB ;
}
else if ( ! Q_strnicmp ( * name , " $nosrgb: " , 8 ) )
{
* name + = 8 ;
flags & = ~ IF_SRGB ;
flags | = IF_NOSRGB ;
}
2012-09-30 05:52:03 +00:00
else if ( ! Q_strnicmp ( * name , " $nearest: " , 9 ) )
{
* name + = 9 ;
2016-10-22 07:06:51 +00:00
flags & = ~ IF_LINEAR ;
flags | = IF_NEAREST ;
2012-09-30 05:52:03 +00:00
}
2014-11-24 15:20:22 +00:00
else if ( ! Q_strnicmp ( * name , " $linear: " , 8 ) )
{
* name + = 8 ;
2016-10-22 07:06:51 +00:00
flags & = ~ IF_NEAREST ;
flags | = IF_LINEAR ;
2014-11-24 15:20:22 +00:00
}
2021-04-14 05:21:04 +00:00
else if ( ! Q_strnicmp ( * name , " $palettize: " , 11 ) )
{
* name + = 11 ;
flags | = IF_PALETTIZE ;
}
2011-12-23 03:12:29 +00:00
else
2015-02-02 08:01:53 +00:00
break ;
2011-12-23 03:12:29 +00:00
}
2009-11-04 21:16:50 +00:00
// if (shader->flags & SHADER_SKY)
// flags |= IF_SKY;
2019-03-12 05:04:27 +00:00
if ( parsestate - > s - > flags & SHADER_NOMIPMAPS )
2009-11-04 21:16:50 +00:00
flags | = IF_NOMIPMAP ;
2019-03-12 05:04:27 +00:00
if ( parsestate - > s - > flags & SHADER_NOPICMIP )
2009-11-04 21:16:50 +00:00
flags | = IF_NOPICMIP ;
2015-05-03 19:57:46 +00:00
flags | = IF_MIPCAP ;
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
if ( pass )
{
if ( flags & IF_CLAMP )
pass - > flags | = SHADER_PASS_CLAMP ;
if ( flags & IF_LINEAR )
{
pass - > flags & = ~ SHADER_PASS_NEAREST ;
pass - > flags | = SHADER_PASS_LINEAR ;
}
else if ( flags & IF_NEAREST )
{
pass - > flags & = ~ SHADER_PASS_LINEAR ;
pass - > flags | = SHADER_PASS_NEAREST ;
}
}
2004-10-19 15:56:22 +00:00
return flags ;
}
2015-02-07 22:34:22 +00:00
texid_t R_LoadColourmapImage ( void )
{
2016-07-12 00:40:13 +00:00
//FIXME: cache the result, because this is abusive
2015-04-14 23:12:17 +00:00
unsigned int w = 256 , h = VID_GRADES ;
2015-02-07 22:34:22 +00:00
unsigned int x ;
2015-04-14 23:12:17 +00:00
unsigned int data [ 256 * ( VID_GRADES ) ] ;
2015-02-07 22:34:22 +00:00
qbyte * colourmappal = ( qbyte * ) FS_LoadMallocFile ( " gfx/colormap.lmp " , NULL ) ;
2018-11-19 08:06:07 +00:00
# if defined(Q2CLIENT) && defined(IMAGEFMT_PCX)
2015-04-14 23:12:17 +00:00
if ( ! colourmappal )
{
size_t sz ;
qbyte * pcx = FS_LoadMallocFile ( " pics/colormap.pcx " , & sz ) ;
2016-11-25 08:14:54 +00:00
if ( pcx )
{
colourmappal = Z_Malloc ( 256 * VID_GRADES ) ;
ReadPCXData ( pcx , sz , 256 , VID_GRADES , colourmappal ) ;
BZ_Free ( pcx ) ;
}
2015-04-14 23:12:17 +00:00
}
2018-11-19 08:06:07 +00:00
# endif
2015-02-07 22:34:22 +00:00
if ( colourmappal )
{
for ( x = 0 ; x < sizeof ( data ) / sizeof ( data [ 0 ] ) ; x + + )
data [ x ] = d_8to24rgbtable [ colourmappal [ x ] ] ;
}
else
{ //erk
2016-11-25 08:14:54 +00:00
//fixme: generate a proper colourmap
2015-02-07 22:34:22 +00:00
for ( x = 0 ; x < sizeof ( data ) / sizeof ( data [ 0 ] ) ; x + + )
2016-11-25 08:14:54 +00:00
{
int r , g , b ;
float l = 1.0 - ( ( x / 256 ) / ( float ) VID_GRADES ) ;
r = d_8to24rgbtable [ x & 0xff ] ;
g = ( r > > 16 ) & 0xff ;
b = ( r > > 8 ) & 0xff ;
r = ( r > > 0 ) & 0xff ;
data [ x ] = d_8to24rgbtable [ GetPaletteIndex ( r * l , g * l , b * l ) ] ;
}
2015-02-07 22:34:22 +00:00
}
BZ_Free ( colourmappal ) ;
return R_LoadTexture ( " $colourmap " , w , h , TF_RGBA32 , data , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA | IF_CLAMP ) ;
}
2019-03-12 05:04:27 +00:00
static texid_t Shader_FindImage ( parsestate_t * parsestate , char * name , int flags )
2004-10-19 15:56:22 +00:00
{
2015-05-03 19:57:46 +00:00
extern texid_t missing_texture_normal ;
2019-03-12 05:04:27 +00:00
if ( parsestate - > parseflags & SPF_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 ;
2015-05-03 19:57:46 +00:00
if ( ! Q_stricmp ( name , " $blackimage " ) )
{
int wibuf [ 16 ] = { 0 } ;
return R_LoadTexture ( " $blackimage " , 4 , 4 , TF_RGBA32 , wibuf , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA ) ;
}
if ( ! Q_stricmp ( name , " $identitynormal " ) )
return missing_texture_normal ;
2015-02-07 22:34:22 +00:00
if ( ! Q_stricmp ( name , " $colourmap " ) )
return R_LoadColourmapImage ( ) ;
2011-12-05 15:23:40 +00:00
}
2014-08-03 14:47:47 +00:00
if ( flags & IF_RENDERTARGET )
2016-10-22 07:06:51 +00:00
return R2D_RT_Configure ( name , 0 , 0 , TF_INVALID , flags ) ;
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 ************************/
2020-06-12 23:29:58 +00:00
static void Shader_Cull ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
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 ;
}
}
2020-06-12 23:29:58 +00:00
static void Shader_NoMipMaps ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
shader - > flags | = ( SHADER_NOMIPMAPS | SHADER_NOPICMIP ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_Affine ( parsestate_t * ps , const char * * ptr )
2015-04-14 23:12:17 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2015-04-14 23:12:17 +00:00
shader - > flags | = SBITS_AFFINE ;
}
2020-06-12 23:29:58 +00:00
static void Shader_NoPicMip ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_NOPICMIP ;
}
2020-06-12 23:29:58 +00:00
static void Shader_DeformVertexes ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
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 ] ;
2016-07-12 00:40:13 +00:00
shader - > flags | = SHADER_NOMARKS ; //just in case...
2004-10-19 15:56:22 +00:00
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 ;
2015-03-03 00:14:43 +00:00
deformv - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2013-03-12 23:13:39 +00:00
if ( deformv - > args [ 0 ] )
2004-10-19 15:56:22 +00:00
deformv - > args [ 0 ] = 1.0f / deformv - > args [ 0 ] ;
2019-12-16 17:25:59 +00:00
Shader_ParseFunc ( ps , " deformvertexes wave " , ptr , & deformv - > func ) ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " normal " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_NORMAL ;
2015-03-03 00:14:43 +00:00
deformv - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
deformv - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " bulge " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_BULGE ;
2015-03-03 00:14:43 +00:00
Shader_ParseVector ( shader , ptr , deformv - > args ) ;
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 ) ;
2019-12-16 17:25:59 +00:00
Shader_ParseFunc ( ps , " deformvertexes move " , ptr , & deformv - > func ) ;
2013-03-12 23:13:39 +00:00
}
else if ( ! Q_stricmp ( token , " autosprite " ) )
{
2004-10-19 15:56:22 +00:00
deformv - > type = DEFORMV_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 ;
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 ;
2018-01-22 19:18:04 +00:00
else if ( ! Q_strnicmp ( token , " text " , 4 ) )
{
deformv - > type = DEFORMV_TEXT ;
deformv - > args [ 0 ] = atoi ( token + 4 ) ;
}
2013-03-12 23:13:39 +00:00
else
2004-10-19 15:56:22 +00:00
return ;
shader - > numdeforms + + ;
}
2020-06-12 23:29:58 +00:00
static void Shader_ClutterParms ( parsestate_t * ps , const char * * ptr )
2015-03-03 00:14:43 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2015-03-03 00:14:43 +00:00
struct shader_clutter_s * clut ;
char * modelname ;
modelname = Shader_ParseString ( ptr ) ;
clut = Z_Malloc ( sizeof ( * clut ) + strlen ( modelname ) ) ;
strcpy ( clut - > modelname , modelname ) ;
clut - > spacing = Shader_ParseFloat ( shader , ptr , 1000 ) ;
clut - > scalemin = Shader_ParseFloat ( shader , ptr , 1 ) ;
clut - > scalemax = Shader_ParseFloat ( shader , ptr , 1 ) ;
clut - > zofs = Shader_ParseFloat ( shader , ptr , 0 ) ;
clut - > anglemin = Shader_ParseFloat ( shader , ptr , 0 ) * M_PI * 2 / 360. ;
clut - > anglemax = Shader_ParseFloat ( shader , ptr , 360 ) * M_PI * 2 / 360. ;
clut - > next = shader - > clutter ;
shader - > clutter = clut ;
}
2004-10-19 15:56:22 +00:00
2020-06-12 23:29:58 +00:00
static void Shader_SkyParms ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
skydome_t * skydome ;
2016-02-15 06:01:17 +00:00
// 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
2016-02-15 06:01:17 +00:00
/*skyheight =*/ Shader_ParseFloat ( shader , ptr , 512 ) ;
2004-10-19 15:56:22 +00:00
2010-07-11 02:22:39 +00:00
boxname = Shader_ParseString ( ptr ) ;
2017-08-29 02:29:06 +00:00
// 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 ;
}
2020-06-12 23:29:58 +00:00
static void Shader_FogParms ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
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 ;
2015-03-03 00:14:43 +00:00
shader - > fog_dist = Shader_ParseFloat ( shader , ptr , 128 ) ;
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
}
2020-06-12 23:29:58 +00:00
static void Shader_SurfaceParm ( parsestate_t * ps , const char * * ptr )
2005-05-26 12:55:34 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2005-05-26 12:55:34 +00:00
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 " ) )
2016-07-12 00:40:13 +00:00
shader - > flags | = SHADER_NODRAW ; //an alternative so that q3map2 won't see+strip it.
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 ;
2014-10-05 20:04:11 +00:00
else if ( ! Q_stricmp ( token , " noshadows " ) )
shader - > flags | = SHADER_NOSHADOWS ;
2016-07-12 00:40:13 +00:00
else if ( ! Q_stricmp ( token , " sky " ) )
shader - > flags | = SHADER_SKY ;
else if ( ! Q_stricmp ( token , " noimpact " ) )
shader - > flags | = SHADER_NOMARKS ; //wrong, but whatever.
else if ( ! Q_stricmp ( token , " nomarks " ) )
shader - > flags | = SHADER_NOMARKS ;
2018-04-15 02:48:23 +00:00
//forceshader type things inherit certain textures from the original material
//however, that original material might not need those textures and thus won't have them loaded, which breaks replacement.
//these provide a way to override that.
else if ( ! Q_stricmp ( token , " hasdiffuse " ) )
shader - > flags | = SHADER_HASDIFFUSE ;
else if ( ! Q_stricmp ( token , " hasnormalmap " ) )
shader - > flags | = SHADER_HASNORMALMAP ;
else if ( ! Q_stricmp ( token , " hasgloss " ) )
shader - > flags | = SHADER_HASGLOSS ;
else if ( ! Q_stricmp ( token , " hasfullbright " ) )
shader - > flags | = SHADER_HASFULLBRIGHT ;
else if ( ! Q_stricmp ( token , " haspaletted " ) )
shader - > flags | = SHADER_HASPALETTED ;
else if ( ! Q_stricmp ( token , " hastop " ) | | ! Q_stricmp ( token , " hasbottom " ) | | ! Q_stricmp ( token , " hastopbottom " ) )
shader - > flags | = SHADER_HASTOPBOTTOM ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
else
Con_DLPrintf ( 2 , " Shader %s, Unknown surface parm \" %s \" \n " , ps - > s - > name , token ) ; //note that there are game-specific names used to override mod surfaceflags+contents
2005-05-26 12:55:34 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_Sort ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
char * token ;
token = Shader_ParseString ( ptr ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( r_forceprogramify . ival > = 2 )
{
Con_DPrintf ( " Shader %s, ignoring 'sort %s' \n " , ps - > s - > name , token ) ;
return ; //dp ignores 'sort' entirely.
}
else 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 ;
2017-03-27 22:57:54 +00:00
else if ( ! Q_stricmp ( token , " decal " ) | | ! Q_stricmp ( token , " litdecal " ) )
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 ;
2017-03-27 22:57:54 +00:00
else if ( ! Q_stricmp ( token , " unlitdecal " ) )
shader - > sort = SHADER_SORT_UNLITDECAL ;
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 ;
2017-10-31 22:52:58 +00:00
else if ( ! Q_stricmp ( token , " deferredlight " ) )
shader - > sort = SHADER_SORT_DEFERREDLIGHT ;
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 ) ;
}
}
2020-06-12 23:29:58 +00:00
static void Shader_Deferredlight ( parsestate_t * ps , const char * * ptr )
2011-09-03 03:49:43 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2017-10-31 22:52:58 +00:00
shader - > sort = SHADER_SORT_DEFERREDLIGHT ;
2011-09-03 03:49:43 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_Portal ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
shader - > sort = SHADER_SORT_PORTAL ;
}
2020-06-12 23:29:58 +00:00
static void Shader_PolygonOffset ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2019-04-01 10:16:36 +00:00
float m = Shader_ParseFloat ( shader , ptr , 1 ) ;
2019-03-28 04:12:47 +00:00
2019-04-01 10:16:36 +00:00
shader - > polyoffset . unit = - 25 * m ;
2009-11-04 21:16:50 +00:00
shader - > polyoffset . factor = - 0.05 ;
2016-07-12 00:40:13 +00:00
shader - > flags | = SHADER_POLYGONOFFSET ; //some backends might be lazy and only allow simple values.
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_EntityMergable ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2004-10-19 15:56:22 +00:00
shader - > flags | = SHADER_ENTITY_MERGABLE ;
}
2016-07-12 00:40:13 +00:00
# if defined(GLQUAKE) || defined(D3DQUAKE)
2020-06-12 23:29:58 +00:00
static qboolean Shader_ParseProgramCvar ( char * script , char * * cvarnames , int * cvartypes , int cvartype )
2015-08-10 18:28:23 +00:00
{
2020-06-12 23:29:58 +00:00
cvar_t * ref ;
2015-08-10 18:28:23 +00:00
char body [ MAX_QPATH ] ;
char * out ;
char * namestart ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
namestart = script ;
while ( ( * script > = ' A ' & & * script < = ' Z ' ) | | ( * script > = ' a ' & & * script < = ' z ' ) | | ( * script > = ' 0 ' & & * script < = ' 9 ' ) | | * script = = ' _ ' )
script + + ;
cvartypes [ 0 ] = cvartype ;
cvarnames [ 0 ] = Z_Malloc ( script - namestart + 1 ) ;
memcpy ( cvarnames [ 0 ] , namestart , script - namestart ) ;
cvarnames [ 0 ] [ script - namestart ] = 0 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
if ( * script = = ' = ' )
{
script + + ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
out = body ;
2015-08-20 06:12:05 +00:00
while ( out < com_token + countof ( body ) - 1 & & * script ! = ' \n ' & & ! ( script [ 0 ] = = ' / ' & & script [ 1 ] = = ' / ' ) )
* out + + = * script + + ;
* out + + = 0 ;
2020-06-12 23:29:58 +00:00
ref = Cvar_Get ( cvarnames [ 0 ] , body , 0 , " GLSL Variables " ) ;
2015-08-10 18:28:23 +00:00
}
else
2020-06-12 23:29:58 +00:00
ref = Cvar_Get ( cvarnames [ 0 ] , " " , 0 , " GLSL Variables " ) ;
if ( ! ref )
{
Z_Free ( cvarnames [ 0 ] ) ;
return false ;
}
return true ;
}
static qboolean Shader_ParseSemantic ( const char * script , const char * shadername , char * * cvarnames , int * cvartypes )
{
int s ;
const char * namestart , * nameend ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
namestart = script ;
while ( ( * script > = ' A ' & & * script < = ' Z ' ) | | ( * script > = ' a ' & & * script < = ' z ' ) | | ( * script > = ' 0 ' & & * script < = ' 9 ' ) | | * script = = ' _ ' )
script + + ;
nameend = script ;
if ( * script = = ' ' | | * script = = ' \t ' )
{
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
while ( ( * script > = ' A ' & & * script < = ' Z ' ) | | ( * script > = ' a ' & & * script < = ' z ' ) | | ( * script > = ' 0 ' & & * script < = ' 9 ' ) | | * script = = ' _ ' )
script + + ;
}
else
return false ;
cvarnames [ 0 ] = Z_Malloc ( script - namestart + 1 ) ;
memcpy ( cvarnames [ 0 ] , namestart , script - namestart ) ;
cvarnames [ 0 ] [ script - namestart ] = 0 ;
cvarnames [ 0 ] [ nameend - namestart ] = 0 ;
nameend = & cvarnames [ 0 ] [ nameend - namestart ] + 1 ;
for ( s = 0 ; shader_unif_names [ s ] . name ; s + + )
{
if ( ! strcmp ( shader_unif_names [ s ] . name , nameend ) )
{
cvartypes [ 0 ] = shader_unif_names [ s ] . ptype ;
return true ;
}
}
Con_Printf ( " %s: semantic %s not found \n " , shadername , nameend ) ;
Z_Free ( cvarnames [ 0 ] ) ;
return false ;
}
static qboolean Shader_ParseProgramConst ( char * script , char * * cvarnames , int * cvartypes , int cvartype , unsigned short * numsamplers )
{
char * namestart ;
char * nameend ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
namestart = script ;
while ( ( * script > = ' A ' & & * script < = ' Z ' ) | | ( * script > = ' a ' & & * script < = ' z ' ) | | ( * script > = ' 0 ' & & * script < = ' 9 ' ) | | * script = = ' _ ' )
script + + ;
nameend = script ;
if ( * script = = ' ' | | * script = = ' \t ' )
{
while ( * script ! = ' \n ' )
script + + ;
}
cvartypes [ 0 ] = cvartype ;
cvarnames [ 0 ] = Z_Malloc ( script - namestart + 1 ) ;
memcpy ( cvarnames [ 0 ] , namestart , script - namestart ) ;
cvarnames [ 0 ] [ script - namestart ] = 0 ;
//not a cvar. data is baked weirdly into the name.
if ( nameend < script )
{
cvarnames [ 0 ] [ nameend - namestart ] = ' = ' ;
if ( numsamplers )
{ //this is a !!constt
//make sure we know the max sampler id needed...
unsigned short s ;
nameend = & cvarnames [ 0 ] [ nameend - namestart ] + 1 ;
while ( * nameend = = ' ' | | * nameend = = ' \t ' )
nameend + + ;
s = atoi ( nameend ) + 1 ;
if ( * numsamplers < s )
* numsamplers = s ;
}
}
2015-08-10 18:28:23 +00:00
return true ;
}
2016-07-12 00:40:13 +00:00
# endif
2015-08-10 18:28:23 +00:00
2017-02-19 00:15:42 +00:00
const struct sh_defaultsamplers_s sh_defaultsamplers [ ] =
2016-07-26 11:47:59 +00:00
{
2020-11-04 10:19:30 +00:00
{ " s_shadowmap " , 1u < < S_SHADOWMAP } ,
{ " s_projectionmap " , 1u < < S_PROJECTIONMAP } ,
{ " s_diffuse " , 1u < < S_DIFFUSE } ,
{ " s_normalmap " , 1u < < S_NORMALMAP } ,
{ " s_specular " , 1u < < S_SPECULAR } ,
{ " s_upper " , 1u < < S_UPPERMAP } ,
{ " s_lower " , 1u < < S_LOWERMAP } ,
{ " s_fullbright " , 1u < < S_FULLBRIGHT } ,
{ " s_paletted " , 1u < < S_PALETTED } ,
{ " s_reflectcube " , 1u < < S_REFLECTCUBE } ,
{ " s_reflectmask " , 1u < < S_REFLECTMASK } ,
{ " s_displacement " , 1u < < S_DISPLACEMENT } ,
{ " s_occlusion " , 1u < < S_OCCLUSION } ,
{ " s_lightmap " , 1u < < S_LIGHTMAP0 } ,
{ " s_deluxemap " , 1u < < S_DELUXEMAP0 } ,
2016-07-26 11:47:59 +00:00
# if MAXRLIGHTMAPS > 1
2020-11-04 10:19:30 +00:00
{ " s_lightmap1 " , 1u < < S_LIGHTMAP1 } ,
{ " s_lightmap2 " , 1u < < S_LIGHTMAP2 } ,
{ " s_lightmap3 " , 1u < < S_LIGHTMAP3 } ,
{ " s_deluxemap1 " , 1u < < S_DELUXEMAP1 } ,
{ " s_deluxemap2 " , 1u < < S_DELUXEMAP2 } ,
{ " s_deluxemap3 " , 1u < < S_DELUXEMAP3 } ,
2017-02-19 00:15:42 +00:00
# else
{ " s_lightmap1 " , 0 } ,
{ " s_lightmap2 " , 0 } ,
{ " s_lightmap3 " , 0 } ,
2018-07-05 16:21:44 +00:00
{ " s_deluxemap1 " , 0 } ,
{ " s_deluxemap2 " , 0 } ,
{ " s_deluxemap3 " , 0 } ,
2016-07-26 11:47:59 +00:00
# endif
2017-02-19 00:15:42 +00:00
{ NULL }
2016-07-26 11:47:59 +00:00
} ;
2018-11-27 16:48:19 +00:00
static struct
{
char * name ;
unsigned int bitmask ;
} permutations [ ] =
{
{ " BUMP " , PERMUTATION_BUMPMAP } ,
{ " FULLBRIGHT " , PERMUTATION_FULLBRIGHT } ,
{ " UPPERLOWER " , PERMUTATION_UPPERLOWER } ,
{ " REFLECTCUBEMASK " , PERMUTATION_REFLECTCUBEMASK } ,
{ " SKELETAL " , PERMUTATION_SKELETAL } ,
{ " FOG " , PERMUTATION_FOG } ,
{ " FRAMEBLEND " , PERMUTATION_FRAMEBLEND } ,
{ " LIGHTSTYLED " , PERMUTATION_LIGHTSTYLES }
} ;
# define MAXMODIFIERS 64
void VARGS Q_strlcatfz ( char * dest , size_t * offset , size_t size , const char * fmt , . . . ) LIKEPRINTF ( 4 ) ;
void VARGS Q_strlcatfz ( char * dest , size_t * offset , size_t size , const char * fmt , . . . )
{
va_list argptr ;
dest + = * offset ;
size - = * offset ;
va_start ( argptr , fmt ) ;
Q_vsnprintfz ( dest , size , fmt , argptr ) ;
va_end ( argptr ) ;
* offset + = strlen ( dest ) ;
}
struct programpermu_s * Shader_LoadPermutation ( program_t * prog , unsigned int p )
{
const char * permutationdefines [ 3 ] ;
struct programpermu_s * pp ;
size_t n , pn = 0 ;
char defines [ 8192 ] ;
size_t offset ;
2019-05-23 15:11:32 +00:00
qboolean fail = false ;
2018-11-27 16:48:19 +00:00
2020-10-26 06:30:35 +00:00
extern cvar_t r_glsl_pbr , gl_specular , gl_specular_power ;
2018-11-27 16:48:19 +00:00
if ( ~ prog - > supportedpermutations & p )
return NULL ; //o.O
pp = Z_Malloc ( sizeof ( * pp ) ) ;
pp - > permutation = p ;
* defines = 0 ;
offset = 0 ;
if ( p & PERMUTATION_SKELETAL )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define MAX_GPU_BONES %i \n " , sh_config . max_gpu_bones ) ;
if ( gl_specular . value )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define SPECULAR \n #define SPECULAR_BASE_MUL %f \n #define SPECULAR_BASE_POW %f \n " , 1.0 * gl_specular . value , max ( 1 , gl_specular_power . value ) ) ;
2020-10-26 06:30:35 +00:00
if ( r_glsl_pbr . ival )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define PBR \n " ) ;
2020-02-12 12:15:56 +00:00
# ifdef RTLIGHTS
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( r_fakeshadows )
2019-11-20 04:53:22 +00:00
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define FAKESHADOWS \n %s " ,
# ifdef GLQUAKE
gl_config . arb_shadow ? " #define USE_ARB_SHADOW \n " :
# endif
" " ) ;
2020-02-12 12:15:56 +00:00
# endif
2018-11-27 16:48:19 +00:00
for ( n = 0 ; n < countof ( permutations ) ; n + + )
{
if ( p & permutations [ n ] . bitmask )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define %s \n " , permutations [ n ] . name ) ;
}
if ( p & PERMUTATION_UPPERLOWER )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define UPPER \n #define LOWER \n " ) ;
if ( p & PERMUTATION_BUMPMAP )
{
if ( r_glsl_offsetmapping . ival )
{
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define OFFSETMAPPING \n " ) ;
if ( r_glsl_offsetmapping_reliefmapping . ival & & ( p & PERMUTATION_BUMPMAP ) )
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define RELIEFMAPPING \n " ) ;
}
if ( r_deluxemapping ) //fixme: should be per-model really
Q_strlcatfz ( defines , & offset , sizeof ( defines ) , " #define DELUXE \n " ) ;
}
permutationdefines [ pn + + ] = defines ;
permutationdefines [ pn + + ] = prog - > preshade ;
permutationdefines [ pn + + ] = NULL ;
if ( ! sh_config . pCreateProgram ( prog , pp , prog - > shaderver , permutationdefines , prog - > shadertext , prog - > tess ? prog - > shadertext : NULL , prog - > tess ? prog - > shadertext : NULL , prog - > geom ? prog - > shadertext : NULL , prog - > shadertext , prog - > warned , NULL ) )
2019-05-23 15:11:32 +00:00
prog - > warned = fail = true ;
2018-11-27 16:48:19 +00:00
//extra loop to validate the programs actually linked properly.
//delaying it like this gives certain threaded drivers a chance to compile them all while we're messing around with other junk
2019-05-23 15:11:32 +00:00
if ( ! fail & & sh_config . pValidateProgram & & ! sh_config . pValidateProgram ( prog , pp , prog - > warned , NULL ) )
prog - > warned = fail = true ;
2018-11-27 16:48:19 +00:00
2019-05-23 15:11:32 +00:00
if ( ! fail & & sh_config . pProgAutoFields )
2018-11-27 16:48:19 +00:00
{
char * cvarnames [ 64 + 1 ] ;
int cvartypes [ 64 ] ;
unsigned char * cvardata = prog - > cvardata ;
size_t size = prog - > cvardatasize , i ;
for ( i = 0 ; i < countof ( cvartypes ) & & size ; i + + )
{
memcpy ( & cvartypes [ i ] , cvardata , sizeof ( int ) ) ;
cvarnames [ i ] = cvardata + sizeof ( int ) ;
size - = sizeof ( int ) + strlen ( cvarnames [ i ] ) + 1 ;
cvardata + = sizeof ( int ) + strlen ( cvarnames [ i ] ) + 1 ;
}
cvarnames [ i ] = NULL ; //no more
2020-06-12 23:29:58 +00:00
sh_config . pProgAutoFields ( prog , pp , cvarnames , cvartypes ) ;
2018-11-27 16:48:19 +00:00
}
2019-05-23 15:11:32 +00:00
if ( fail )
{
Z_Free ( pp ) ;
return NULL ;
}
2018-11-27 16:48:19 +00:00
return pp ;
}
2019-05-23 15:11:32 +00:00
qboolean Shader_PermutationEnabled ( unsigned int bit )
{
if ( bit = = PERMUTATION_REFLECTCUBEMASK )
return gl_load24bit . ival ;
if ( bit = = PERMUTATION_BUMPMAP )
return r_loadbumpmapping ;
return true ;
}
qboolean Com_PermuOrFloatArgument ( const char * shadername , char * arg , size_t arglen , float def )
{
extern cvar_t gl_specular ;
size_t p ;
//load-time-only permutations...
if ( arglen = = 8 & & ! strncmp ( " SPECULAR " , arg , arglen ) & & gl_specular . value )
return true ;
2020-02-12 12:15:56 +00:00
# ifdef RTLIGHTS
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( arglen = = 11 & & ! strncmp ( " FAKESHADOWS " , arg , arglen ) & & r_fakeshadows )
return true ;
2020-02-12 12:15:56 +00:00
# endif
2019-05-23 15:11:32 +00:00
if ( ( arglen = = 5 | | arglen = = 6 ) & & ! strncmp ( " DELUXE " , arg , arglen ) & & r_deluxemapping & & Shader_PermutationEnabled ( PERMUTATION_BUMPMAP ) )
return true ;
if ( arglen = = 13 & & ! strncmp ( " OFFSETMAPPING " , arg , arglen ) & & r_glsl_offsetmapping . ival )
return true ;
if ( arglen = = 13 & & ! strncmp ( " RELIEFMAPPING " , arg , arglen ) & & r_glsl_offsetmapping . ival & & r_glsl_offsetmapping_reliefmapping . ival )
return true ;
//real permutations
if ( arglen = = 5 & & ( ! strncmp ( " UPPER " , arg , arglen ) | | ! strncmp ( " LOWER " , arg , arglen ) ) & & Shader_PermutationEnabled ( PERMUTATION_BIT_UPPERLOWER ) )
return true ;
for ( p = 0 ; p < countof ( permutations ) ; p + + )
{
if ( arglen = = strlen ( permutations [ p ] . name ) & & ! strncmp ( permutations [ p ] . name , arg , arglen ) )
{
if ( Shader_PermutationEnabled ( permutations [ p ] . bitmask ) )
return true ;
break ;
}
}
return Com_FloatArgument ( shadername , arg , arglen , def ) ! = 0 ;
}
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
{
2016-07-12 00:40:13 +00:00
# if defined(GLQUAKE) || defined(D3DQUAKE)
2018-11-27 16:48:19 +00:00
// const char *permutationdefines[countof(permutations) + MAXMODIFIERS + 1];
2017-02-19 00:15:42 +00:00
unsigned int nopermutation = PERMUTATIONS - 1 ;
2018-11-27 16:48:19 +00:00
// int nummodifiers = 0;
int p ;
2011-01-23 03:44:49 +00:00
char * end ;
2018-11-27 16:48:19 +00:00
2011-12-23 03:12:29 +00:00
char * cvarnames [ 64 ] ;
int cvartypes [ 64 ] ;
2018-11-27 16:48:19 +00:00
size_t cvarcount = 0 , i ;
2017-10-12 12:02:25 +00:00
extern cvar_t gl_specular , gl_specular_power ;
2019-10-18 08:37:38 +00:00
qboolean cantess = false ; //not forced.
2018-11-27 16:48:19 +00:00
char prescript [ 8192 ] ;
size_t offset = 0 ;
2016-07-12 00:40:13 +00:00
# endif
2014-06-08 09:36:15 +00:00
2016-07-26 11:47:59 +00:00
# ifdef VKQUAKE
if ( qrenderer = = QR_VULKAN & & ( qrtype = = QR_VULKAN | | qrtype = = QR_OPENGL ) )
2016-08-25 00:12:14 +00:00
{ //vulkan can potentially load glsl, f it has the extensions enabled.
2016-07-26 11:47:59 +00:00
if ( qrtype = = QR_VULKAN & & VK_LoadBlob ( prog , script , name ) )
return true ;
}
else
# endif
2012-09-30 05:52:03 +00:00
if ( qrenderer ! = qrtype )
{
return false ;
}
2016-07-12 00:40:13 +00:00
# if defined(GLQUAKE) || defined(D3DQUAKE)
ver = 0 ;
2014-10-05 20:04:11 +00:00
if ( ! sh_config . pCreateProgram & & ! sh_config . pLoadBlob )
return false ;
2012-09-30 05:52:03 +00:00
2018-11-27 16:48:19 +00:00
if ( prog - > name )
return false ; //o.O
2011-04-30 17:21:10 +00:00
2018-11-27 16:48:19 +00:00
* prescript = 0 ;
offset = 0 ;
memset ( prog - > permu , 0 , sizeof ( prog - > permu ) ) ;
prog - > name = Z_StrDup ( name ) ;
prog - > geom = false ;
prog - > tess = false ;
2020-06-12 23:29:58 +00:00
prog - > calcgens = false ;
2015-03-03 00:14:43 +00:00
prog - > numsamplers = 0 ;
prog - > defaulttextures = 0 ;
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
{
2020-06-12 23:29:58 +00:00
prog - > calcgens = true ;
2014-03-30 08:55:06 +00:00
script + = 7 ;
}
2020-06-12 23:29:58 +00:00
else if ( ! strncmp ( script , " !!explicit " , 10 ) )
{
prog - > explicitsyms = true ;
script + = 10 ;
}
2015-07-01 23:15:25 +00:00
else if ( ! strncmp ( script , " !!geom " , 6 ) )
{
2018-11-27 16:48:19 +00:00
prog - > geom = true ;
2015-07-01 23:15:25 +00:00
script + = 6 ;
}
2014-03-30 08:55:06 +00:00
else if ( ! strncmp ( script , " !!tess " , 6 ) )
{
2018-11-27 16:48:19 +00:00
prog - > tess = true ;
2014-03-30 08:55:06 +00:00
script + = 6 ;
}
2016-07-26 11:47:59 +00:00
else if ( ! strncmp ( script , " !!samps " , 7 ) )
{
2018-11-27 16:48:19 +00:00
com_tokentype_t tt ;
qboolean ignore = false ;
2016-07-26 11:47:59 +00:00
script + = 7 ;
2018-11-27 16:48:19 +00:00
for ( ; ; )
2016-07-26 11:47:59 +00:00
{
2018-07-05 16:21:44 +00:00
size_t len ;
2019-07-19 02:13:19 +00:00
int i ;
2018-11-27 16:48:19 +00:00
char * type , * idx , * next ;
char * token = com_token ;
next = COM_ParseTokenOut ( script , " " , com_token , sizeof ( com_token ) , & tt ) ;
if ( tt = = TTP_LINEENDING | | tt = = TTP_EOF )
break ;
script = next ;
2016-07-26 11:47:59 +00:00
2018-11-27 16:48:19 +00:00
if ( * token = = ' = ' | | * token = = ' ! ' )
{
len = strlen ( token ) ;
2019-05-23 15:11:32 +00:00
if ( * token = = ( Com_PermuOrFloatArgument ( name , token + 1 , len - 1 , 0 ) ? ' ! ' : ' = ' ) )
2018-11-27 16:48:19 +00:00
ignore = true ;
continue ;
}
else if ( ignore )
continue ;
2019-05-23 15:11:32 +00:00
# if 1 //def HAVE_LEGACY
2018-11-27 16:48:19 +00:00
else if ( ! strncmp ( token , " deluxmap " , 8 ) )
2018-07-05 16:21:44 +00:00
{ //FIXME: remove this some time.
2019-05-23 15:11:32 +00:00
Con_DPrintf ( " Outdated texture name \" %s \" in program \" %s \" \n " , token , name ) ;
2018-11-27 16:48:19 +00:00
token = va ( " deluxemap%s " , token + 8 ) ;
2018-07-05 16:21:44 +00:00
}
# endif
2018-11-27 16:48:19 +00:00
type = strchr ( token , ' : ' ) ;
idx = strchr ( token , ' = ' ) ;
if ( type | | idx )
{ //name:type=idx
if ( type )
* type + + = 0 ;
else
2019-04-07 16:41:09 +00:00
type = " 2D " ;
2018-11-27 16:48:19 +00:00
if ( idx )
2016-07-26 11:47:59 +00:00
{
2018-11-27 16:48:19 +00:00
* idx + + = 0 ;
i = atoi ( idx ) ;
2016-07-26 11:47:59 +00:00
}
2018-11-27 16:48:19 +00:00
else
i = prog - > numsamplers ;
if ( prog - > numsamplers < i + 1 )
prog - > numsamplers = i + 1 ;
2019-07-16 02:59:12 +00:00
/*for (j = 0; sh_defaultsamplers[j].name; j++)
{
if ( ! strcmp ( token , sh_defaultsamplers [ j ] . name + 2 ) )
{
Con_Printf ( " %s: %s is an internal texture name \n " , name , token ) ;
break ;
}
} */
2018-11-27 16:48:19 +00:00
//I really want to use layout(binding = %i) here, but its specific to the glsl version (which we don't really know yet)
2019-04-07 16:41:09 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define s_%s s_t%u \n uniform %s%s s_%s; \n " , token , i , strncmp ( type , " sampler " , 7 ) ? " sampler " : " " , type , token ) ;
2016-07-26 11:47:59 +00:00
}
2018-11-27 16:48:19 +00:00
else
2016-07-26 11:47:59 +00:00
{
2018-11-27 16:48:19 +00:00
len = strlen ( token ) ;
for ( i = 0 ; sh_defaultsamplers [ i ] . name ; i + + )
{
if ( ! strcmp ( token , sh_defaultsamplers [ i ] . name + 2 ) )
{
prog - > defaulttextures | = sh_defaultsamplers [ i ] . defaulttexbits ;
break ;
}
}
if ( ! sh_defaultsamplers [ i ] . name )
{ //this path is deprecated.
i = atoi ( token ) ;
if ( i )
{
if ( qrenderer = = QR_OPENGL )
{
while ( prog - > numsamplers < i )
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " uniform sampler2D s_t%u; \n " , prog - > numsamplers + + ) ;
}
else if ( prog - > numsamplers < i )
prog - > numsamplers = i ;
}
else
2019-05-23 15:11:32 +00:00
Con_Printf ( " Unknown texture name \" %s \" in program \" %s \" \n " , token , name ) ;
2018-11-27 16:48:19 +00:00
}
2016-07-26 11:47:59 +00:00
}
}
}
2018-03-04 14:41:16 +00:00
else if ( ! strncmp ( script , " !!cvardf " , 8 ) | | ! strncmp ( script , " !!cvard3 " , 8 ) | | ! strncmp ( script , " !!cvard4 " , 8 ) | | ! strncmp ( script , " !!cvard_srgb " , 11 ) )
2013-10-08 14:28:11 +00:00
{
2018-03-04 14:41:16 +00:00
qboolean srgb = false ;
float div = 1 ;
char type = script [ 7 ] ;
script + = 8 ;
if ( type = = ' _ ' )
2013-10-08 14:28:11 +00:00
{
2018-03-04 14:41:16 +00:00
if ( * script = = ' s ' )
2015-06-29 23:46:31 +00:00
{
2018-03-04 14:41:16 +00:00
srgb = true ;
script + = 1 ;
2015-06-29 23:46:31 +00:00
}
2018-03-04 14:41:16 +00:00
if ( ! strncmp ( script , " rgba " , 4 ) )
2015-07-31 13:23:32 +00:00
{
2018-03-04 14:41:16 +00:00
type = ' 4 ' ;
script + = 4 ;
2015-07-31 13:23:32 +00:00
}
2018-03-04 14:41:16 +00:00
else if ( ! strncmp ( script , " rgb " , 3 ) )
{
type = ' 3 ' ;
script + = 3 ;
}
else if ( ! strncmp ( script , " rg " , 2 ) )
{
type = ' 2 ' ;
script + = 2 ;
}
else if ( ! strncmp ( script , " r " , 1 ) | | ! strncmp ( script , " f " , 1 ) )
{
type = ' f ' ;
script + = 1 ;
}
if ( ! strncmp ( script , " _b " , 2 ) )
{
div = 255 ;
script + = 2 ;
}
else if ( ! strncmp ( script , " _ " , 1 ) )
div = strtod ( script , & script ) ;
2015-07-31 13:23:32 +00:00
}
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
2018-11-27 16:48:19 +00:00
if ( end - script < 64 )
2015-07-31 13:23:32 +00:00
{
cvar_t * var ;
char namebuf [ 64 ] ;
char valuebuf [ 64 ] ;
memcpy ( namebuf , script , end - script ) ;
namebuf [ end - script ] = 0 ;
while ( * end = = ' ' | | * end = = ' \t ' )
end + + ;
if ( * end = = ' = ' )
{
script = + + end ;
while ( * end & & * end ! = ' \n ' & & * end ! = ' \r ' & & end < script + sizeof ( namebuf ) - 1 )
end + + ;
memcpy ( valuebuf , script , end - script ) ;
valuebuf [ end - script ] = 0 ;
}
else
strcpy ( valuebuf , " 0 " ) ;
var = Cvar_Get ( namebuf , valuebuf , CVAR_SHADERSYSTEM , " GLSL Variables " ) ;
if ( var )
2018-03-04 14:41:16 +00:00
{
2020-04-29 10:43:22 +00:00
var - > flags | = CVAR_SHADERSYSTEM ;
2018-03-04 14:41:16 +00:00
if ( srgb )
{
if ( type = = ' 4 ' )
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %s(%g,%g,%g,%g) \n " , namebuf , ( ( qrenderer = = QR_OPENGL ) ? " vec4 " : " float4 " ) , SRGBf ( var - > vec4 [ 0 ] / div ) , SRGBf ( var - > vec4 [ 1 ] / div ) , SRGBf ( var - > vec4 [ 2 ] / div ) , var - > vec4 [ 3 ] / div ) ;
2018-03-04 14:41:16 +00:00
else if ( type = = ' 3 ' )
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %s(%g,%g,%g) \n " , namebuf , ( ( qrenderer = = QR_OPENGL ) ? " vec3 " : " float3 " ) , SRGBf ( var - > vec4 [ 0 ] / div ) , SRGBf ( var - > vec4 [ 1 ] / div ) , SRGBf ( var - > vec4 [ 2 ] / div ) ) ;
2018-03-04 14:41:16 +00:00
else
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %g \n " , namebuf , SRGBf ( var - > value / div ) ) ;
2018-03-04 14:41:16 +00:00
}
else
{
if ( type = = ' 4 ' )
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %s(%g,%g,%g,%g) \n " , namebuf , ( ( qrenderer = = QR_OPENGL ) ? " vec4 " : " float4 " ) , var - > vec4 [ 0 ] / div , var - > vec4 [ 1 ] / div , var - > vec4 [ 2 ] / div , var - > vec4 [ 3 ] / div ) ;
2018-03-04 14:41:16 +00:00
else if ( type = = ' 3 ' )
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %s(%g,%g,%g) \n " , namebuf , ( ( qrenderer = = QR_OPENGL ) ? " vec3 " : " float3 " ) , var - > vec4 [ 0 ] / div , var - > vec4 [ 1 ] / div , var - > vec4 [ 2 ] / div ) ;
2018-03-04 14:41:16 +00:00
else
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define %s %g \n " , namebuf , var - > value / div ) ;
2018-03-04 14:41:16 +00:00
}
}
2015-07-31 13:23:32 +00:00
}
script = end ;
}
2020-06-12 23:29:58 +00:00
else if ( ! strncmp ( script , " !!cvarf " , 7 ) | | ! strncmp ( script , " !!cvari " , 7 ) | | ! strncmp ( script , " !!cvarv " , 7 ) | | ! strncmp ( script , " !!cvar3f " , 8 ) | | ! strncmp ( script , " !!cvar4f " , 8 ) )
2011-04-30 17:21:10 +00:00
{
2020-06-12 23:29:58 +00:00
int type ;
if ( script [ 6 ] = = ' f ' ) type = SP_CVARF ;
else if ( script [ 6 ] = = ' i ' ) type = SP_CVARI ;
else if ( script [ 6 ] = = ' v ' ) type = SP_CVAR3F ;
else if ( script [ 6 ] = = ' 3 ' ) type = SP_CVAR3F ;
else if ( script [ 6 ] = = ' 4 ' ) type = SP_CVAR4F ;
else break ;
2018-11-27 16:48:19 +00:00
if ( cvarcount ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
2020-06-12 23:29:58 +00:00
cvarcount + = Shader_ParseProgramCvar ( script + 8 , & cvarnames [ cvarcount ] , & cvartypes [ cvarcount ] , type ) ;
2011-12-23 03:12:29 +00:00
}
2020-06-12 23:29:58 +00:00
else if ( ! strncmp ( script , " !!semantic " , 10 ) )
------------------------------------------------------------------------
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
{
2018-11-27 16:48:19 +00:00
if ( cvarcount ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
2020-06-12 23:29:58 +00:00
cvarcount + = Shader_ParseSemantic ( script + 10 , name , & cvarnames [ cvarcount ] , & cvartypes [ cvarcount ] ) ;
}
else if ( ! strncmp ( script , " !!const1f " , 9 ) | |
! strncmp ( script , " !!const2f " , 9 ) | |
! strncmp ( script , " !!const3f " , 9 ) | |
! strncmp ( script , " !!const4f " , 9 ) | |
! strncmp ( script , " !!constt " , 8 ) )
{
int type ;
if ( script [ 8 ] = = ' f ' )
type = SP_CONST1F + ( script [ 7 ] - ' 1 ' ) ;
else if ( script [ 8 ] = = ' i ' )
type = SP_CONST1I + ( script [ 7 ] - ' 1 ' ) ;
else if ( script [ 7 ] = = ' t ' )
type = SP_TEXTURE ;
else
break ;
2018-11-27 16:48:19 +00:00
if ( cvarcount ! = sizeof ( cvarnames ) / sizeof ( cvarnames [ 0 ] ) )
2020-06-12 23:29:58 +00:00
cvarcount + = Shader_ParseProgramConst ( script + 9 , & cvarnames [ cvarcount ] , & cvartypes [ cvarcount ] , type , ( type = = SP_TEXTURE ) ? & prog - > numsamplers : NULL ) ;
2011-04-30 17:21:10 +00:00
}
2019-04-16 22:40:05 +00:00
else if ( ! strncmp ( script , " !!arg " , 5 ) )
{ //compat with our vulkan glsl, generate (specialisation) constants from #args
char namebuf [ MAX_QPATH ] ;
char valuebuf [ MAX_QPATH ] ;
char * out ;
char * namestart ;
char * atype ;
script + = 5 ;
if ( * script = = ' b ' )
{
atype = " bool " ;
strcpy ( valuebuf , " false " ) ;
}
else if ( * script = = ' f ' )
{
atype = " float " ;
strcpy ( valuebuf , " 0.0 " ) ;
}
else if ( * script = = ' d ' )
{
atype = " double " ;
strcpy ( valuebuf , " 0.0 " ) ;
}
else if ( * script = = ' i ' )
{
atype = " int " ;
strcpy ( valuebuf , " 0 " ) ;
}
else if ( * script = = ' u ' )
{
atype = " uint " ;
strcpy ( valuebuf , " 0 " ) ;
}
else
{
atype = " float " ; //I guess
strcpy ( valuebuf , " 0.0 " ) ;
}
while ( * script > = ' a ' & & * script < = ' z ' )
script + + ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
namestart = script ;
while ( ( * script > = ' A ' & & * script < = ' Z ' ) | | ( * script > = ' a ' & & * script < = ' z ' ) | | ( * script > = ' 0 ' & & * script < = ' 9 ' ) | | * script = = ' _ ' )
script + + ;
if ( script - namestart < countof ( namebuf ) )
{
float def = 0 ;
memcpy ( namebuf , namestart , script - namestart ) ;
namebuf [ script - namestart ] = 0 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
if ( * script = = ' = ' )
{
script + + ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
out = valuebuf ;
while ( out < com_token + countof ( valuebuf ) - 1 & & * script ! = ' \n ' & & ! ( script [ 0 ] = = ' / ' & & script [ 1 ] = = ' / ' ) )
* out + + = * script + + ;
* out + + = 0 ;
if ( ! strcmp ( valuebuf , " true " ) )
def = 1 ;
else
def = atof ( valuebuf ) ;
}
Com_FloatArgument ( name , valuebuf , sizeof ( valuebuf ) , def ) ;
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " const %s arg_%s = %s(%s); \n " , atype , namebuf , atype , valuebuf ) ;
}
}
2011-04-30 17:21:10 +00:00
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 + + ;
2017-02-19 00:15:42 +00:00
for ( p = 0 ; p < countof ( permutations ) ; p + + )
2011-01-23 03:44:49 +00:00
{
2018-11-27 16:48:19 +00:00
if ( ! strncmp ( permutations [ p ] . name , script , end - script ) & & permutations [ p ] . name [ end - script ] = = ' \0 ' )
2012-04-24 07:59:11 +00:00
{
2019-05-23 15:11:32 +00:00
if ( Shader_PermutationEnabled ( permutations [ p ] . bitmask ) )
nopermutation & = ~ permutations [ p ] . bitmask ;
2012-04-24 07:59:11 +00:00
break ;
}
2011-01-23 03:44:49 +00:00
}
2017-02-19 00:15:42 +00:00
if ( p = = countof ( permutations ) )
2015-03-03 00:14:43 +00:00
{
//we 'recognise' ones that are force-defined, despite not being actual permutations.
2017-02-11 16:14:06 +00:00
if ( end - script = = 4 & & ! strncmp ( " TESS " , script , 4 ) )
cantess = true ;
else if ( strncmp ( " SPECULAR " , script , end - script ) )
2015-05-03 19:57:46 +00:00
if ( strncmp ( " DELUXE " , script , end - script ) )
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
if ( strncmp ( " DELUX " , script , end - script ) )
2015-03-03 00:14:43 +00:00
if ( strncmp ( " OFFSETMAPPING " , script , end - script ) )
if ( strncmp ( " RELIEFMAPPING " , script , end - script ) )
2020-03-07 09:00:40 +00:00
if ( strncmp ( " FAKESHADOWS " , script , end - script ) )
2015-03-03 00:14:43 +00:00
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 ) )
{
2016-07-12 00:40:13 +00:00
int minver , maxver ;
2011-05-26 16:46:43 +00:00
script + = 5 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
end = script ;
while ( ( * end > = ' A ' & & * end < = ' Z ' ) | | ( * end > = ' a ' & & * end < = ' z ' ) | | ( * end > = ' 0 ' & & * end < = ' 9 ' ) | | * end = = ' _ ' )
end + + ;
2016-07-12 00:40:13 +00:00
minver = strtol ( script , & script , 0 ) ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
2018-11-27 16:48:19 +00:00
maxver = strtol ( script , NULL , 0 ) ;
2016-07-12 00:40:13 +00:00
if ( ! maxver )
maxver = minver ;
ver = maxver ;
if ( ver > sh_config . maxver )
ver = sh_config . maxver ;
if ( ver < minver )
ver = minver ; //some kind of error.
2011-05-26 16:46:43 +00:00
script = end ;
}
2017-11-05 13:15:08 +00:00
else if ( ! strncmp ( script , " !! " , 2 ) )
{
Con_DPrintf ( " Unknown directinve in glsl program %s \n " , name ) ;
script + = 2 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
}
2015-03-03 00:14:43 +00:00
else if ( ! strncmp ( script , " // " , 2 ) )
{
script + = 2 ;
while ( * script = = ' ' | | * script = = ' \t ' )
script + + ;
}
2011-01-23 03:44:49 +00:00
else
break ;
2015-03-03 00:14:43 +00:00
while ( * script & & * script ! = ' \n ' )
script + + ;
2020-10-26 06:30:35 +00:00
}
2018-11-27 16:48:19 +00:00
prog - > shadertext = Z_StrDup ( script ) ;
2010-08-28 17:14:38 +00:00
2017-02-11 16:14:06 +00:00
if ( qrenderer = = qrtype & & ver < 150 )
2018-11-27 16:48:19 +00:00
prog - > tess = cantess = false ; //GL_ARB_tessellation_shader requires glsl 150(gl3.2) (or glessl 3.1). nvidia complains about layouts if you try anyway
2014-03-30 08:55:06 +00:00
2018-03-04 14:41:16 +00:00
if ( ! r_fog_permutation . ival )
nopermutation | = PERMUTATION_BIT_FOG ;
2017-01-29 13:10:53 +00:00
if ( ! sh_config . max_gpu_bones )
nopermutation | = PERMUTATION_SKELETAL ;
2018-11-27 16:48:19 +00:00
//multiple lightmaps is kinda hacky. if any are set, all must be.
2019-05-23 15:11:32 +00:00
# define ALTLIGHTMAPSAMP 14
2018-11-27 16:48:19 +00:00
if ( prog - > defaulttextures & ( ( 1u < < ( ALTLIGHTMAPSAMP + 0 ) ) | ( 1u < < ( ALTLIGHTMAPSAMP + 1 ) ) | ( 1u < < ( ALTLIGHTMAPSAMP + 2 ) ) ) )
prog - > defaulttextures | = ( ( 1u < < ( ALTLIGHTMAPSAMP + 0 ) ) | ( 1u < < ( ALTLIGHTMAPSAMP + 1 ) ) | ( 1u < < ( ALTLIGHTMAPSAMP + 2 ) ) ) ;
2019-05-23 15:11:32 +00:00
# define ALTDELUXMAPSAMP 17
2018-11-27 16:48:19 +00:00
if ( prog - > defaulttextures & ( ( 1u < < ( ALTDELUXMAPSAMP + 0 ) ) | ( 1u < < ( ALTDELUXMAPSAMP + 1 ) ) | ( 1u < < ( ALTDELUXMAPSAMP + 2 ) ) ) )
prog - > defaulttextures | = ( ( 1u < < ( ALTDELUXMAPSAMP + 0 ) ) | ( 1u < < ( ALTDELUXMAPSAMP + 1 ) ) | ( 1u < < ( ALTDELUXMAPSAMP + 2 ) ) ) ;
2011-12-27 08:35:19 +00:00
for ( end = strchr ( name , ' # ' ) ; end & & * end ; )
{
2018-11-27 16:48:19 +00:00
char * start = end + 1 ;
2011-12-27 08:35:19 +00:00
end = strchr ( start , ' # ' ) ;
if ( ! end )
end = start + strlen ( start ) ;
2016-08-25 00:12:14 +00:00
if ( end - start = = 7 & & ! Q_strncasecmp ( start , " usemods " , 7 ) )
2020-06-12 23:29:58 +00:00
prog - > calcgens = true ;
2012-01-17 07:57:46 +00:00
2018-11-27 16:48:19 +00:00
if ( end - start = = 4 & & ! Q_strncasecmp ( start , " tess " , 4 ) )
prog - > tess | = cantess ;
2014-03-30 08:55:06 +00:00
2018-11-27 16:48:19 +00:00
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " #define " ) ;
while ( offset < sizeof ( prescript ) & & start < end )
2014-03-30 08:55:06 +00:00
{
2018-11-27 16:48:19 +00:00
if ( * start = = ' = ' )
2014-03-30 08:55:06 +00:00
{
2018-11-27 16:48:19 +00:00
start + + ;
prescript [ offset + + ] = ' ' ;
2014-03-30 08:55:06 +00:00
break ;
}
2018-11-27 16:48:19 +00:00
prescript [ offset + + ] = toupper ( * start + + ) ;
2014-03-30 08:55:06 +00:00
}
2018-11-27 16:48:19 +00:00
while ( offset < sizeof ( prescript ) & & start < end )
prescript [ offset + + ] = toupper ( * start + + ) ;
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " \n " ) ;
2014-03-30 08:55:06 +00:00
}
2018-11-27 16:48:19 +00:00
prog - > preshade = Z_StrDup ( prescript ) ;
prog - > supportedpermutations = ( ~ nopermutation ) & ( PERMUTATIONS - 1 ) ;
2018-12-28 00:04:36 +00:00
prog - > shaderver = ver ;
2011-02-25 04:22:14 +00:00
2018-11-27 16:48:19 +00:00
if ( cvarcount )
2014-10-05 20:04:11 +00:00
{
2018-11-27 16:48:19 +00:00
* prescript = 0 ;
offset = 0 ;
for ( i = 0 ; i < cvarcount & & offset < sizeof ( prescript ) ; i + + )
2014-10-05 20:04:11 +00:00
{
2020-06-12 23:29:58 +00:00
memcpy ( prescript + offset , & cvartypes [ i ] , sizeof ( int ) ) ;
offset + = 4 ;
Q_strlcatfz ( prescript , & offset , sizeof ( prescript ) , " %s " , cvarnames [ i ] ) ;
offset + + ;
2014-10-05 20:04:11 +00:00
}
2018-11-27 16:48:19 +00:00
prog - > cvardata = Z_Malloc ( offset ) ;
prog - > cvardatasize = offset ;
memcpy ( prog - > cvardata , prescript , prog - > cvardatasize ) ;
2014-10-05 20:04:11 +00:00
}
2015-08-10 18:28:23 +00:00
while ( cvarcount )
Z_Free ( ( char * ) cvarnames [ - - cvarcount ] ) ;
2014-03-30 08:55:06 +00:00
2018-11-27 16:48:19 +00:00
//ensure that permutation 0 works correctly as a fallback.
//FIXME: add debug mode to compile all.
prog - > permu [ 0 ] = Shader_LoadPermutation ( prog , 0 ) ;
2021-05-19 04:49:15 +00:00
if ( ! prog - > permu [ 0 ] )
return false ;
if ( r_glsl_precache . ival )
{
for ( p = prog - > supportedpermutations ; p > 0 ; )
{
if ( p ! = ( p & prog - > supportedpermutations ) )
p & = prog - > supportedpermutations ; //this permutation isn't active, skip to the next one
else
{
prog - > permu [ p ] = Shader_LoadPermutation ( prog , p ) ;
p - - ;
}
}
}
return true ;
2018-11-27 16:48:19 +00:00
# else
2012-01-16 06:22:06 +00:00
return false ;
2018-11-27 16:48:19 +00:00
# endif
2010-08-28 17:14:38 +00:00
}
2018-11-27 16:48:19 +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 )
2016-07-12 00:40:13 +00:00
sh_config . pDeleteProg ( prog ) ;
2014-03-30 08:55:06 +00:00
2018-11-27 16:48:19 +00:00
Z_Free ( prog - > name ) ;
Z_Free ( prog - > preshade ) ;
Z_Free ( prog - > shadertext ) ;
2018-11-28 05:41:39 +00:00
Z_Free ( prog - > cvardata ) ;
2018-11-27 16:48:19 +00:00
2015-08-10 18:28:23 +00:00
Z_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
2019-04-15 18:43:42 +00:00
TRACE ( ( " Loading program %s... \n " , g - > name ) ) ;
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 , ' . ' ) )
2016-07-26 11:47:59 +00:00
{ //explicit path
2012-05-11 01:57:00 +00:00
FS_LoadFile ( basicname , & file ) ;
2014-03-30 08:55:06 +00:00
* blobname = 0 ;
}
2016-08-25 00:12:14 +00:00
else if ( ruleset_allow_shaders . ival )
2016-07-26 11:47:59 +00:00
{ //renderer-specific files
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
}
2016-08-25 00:12:14 +00:00
else
{
file = NULL ;
* blobname = 0 ;
}
2014-03-30 08:55:06 +00:00
2015-08-10 18:28:23 +00:00
if ( sh_config . pDeleteProg )
{
2016-07-12 00:40:13 +00:00
sh_config . pDeleteProg ( & g - > prog ) ;
2015-08-10 18:28:23 +00:00
}
2018-11-27 16:48:19 +00:00
Z_Free ( g - > prog . name ) ;
g - > prog . name = NULL ;
Z_Free ( g - > prog . preshade ) ;
g - > prog . preshade = NULL ;
Z_Free ( g - > prog . shadertext ) ;
g - > prog . shadertext = NULL ;
2018-11-28 05:41:39 +00:00
Z_Free ( g - > prog . cvardata ) ;
g - > prog . cvardata = NULL ;
2015-08-10 18:28:23 +00:00
2011-01-23 03:44:49 +00:00
if ( file )
{
2019-04-15 18:43:42 +00:00
TRACE ( ( " Loading from disk (%s) \n " , g - > name ) ) ;
2018-07-05 16:21:44 +00:00
// Con_DPrintf("Loaded %s from disk\n", sh_config.progpath?va(sh_config.progpath, basicname):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 + + )
{
2016-08-25 00:12:14 +00:00
if ( sbuiltins [ i ] . qrtype = = qrtype & & ! 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 )
2017-11-14 14:37:04 +00:00
if ( ! ( qrenderer = = QR_OPENGL & & ver = = 110 ) )
2016-07-12 00:40:13 +00:00
continue ;
2014-03-30 08:55:06 +00:00
2019-04-15 18:43:42 +00:00
TRACE ( ( " Loading Embedded %s \n " , g - > name ) ) ;
2016-08-25 00:12:14 +00:00
g - > failed = ! Shader_LoadPermutations ( g - > name , & g - > prog , sbuiltins [ i ] . body , 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
}
}
2019-04-15 18:43:42 +00:00
TRACE ( ( " Program unloadable %s \n " , g - > name ) ) ;
2011-01-23 03:44:49 +00:00
}
2012-09-30 05:52:03 +00:00
}
2018-07-05 16:21:44 +00:00
2015-08-28 03:13:45 +00:00
program_t * Shader_FindGeneric ( char * name , int qrtype )
2012-09-30 05:52:03 +00:00
{
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 ;
2015-08-10 18:28:23 +00:00
g = BZ_Malloc ( sizeof ( * g ) + strlen ( name ) + 1 ) ;
2012-09-30 05:52:03 +00:00
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
}
2014-10-05 20:04:11 +00:00
static void Shader_ReloadGenerics ( void )
{
sgeneric_t * g ;
for ( g = sgenerics ; g ; g = g - > next )
{
2015-08-10 18:28:23 +00:00
//this happens if some cvar changed that affects the glsl itself. supposedly.
2014-10-05 20:04:11 +00:00
Shader_LoadGeneric ( g , qrenderer ) ;
}
2011-01-23 03:44:49 +00:00
2014-10-05 20:04:11 +00:00
//this shader can take a while to load due to its number of permutations.
//because this all happens on the main thread, try to avoid random stalls by pre-loading it.
if ( sh_config . progs_supported )
{
program_t * p = Shader_FindGeneric ( " defaultskin " , qrenderer ) ;
if ( p ) //generics get held on to in order to avoid so much churn. so we can just release the reference we just created and it'll be held until shutdown anyway.
p - > refs - - ;
}
}
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 [ ] =
{
2018-07-05 16:21:44 +00:00
/**/ //tagged names are available to vulkan
2011-09-03 03:49:43 +00:00
/*matricies*/
2018-07-05 16:21:44 +00:00
/**/ { " m_model " , SP_M_MODEL } , //the model matrix
{ " m_view " , SP_M_VIEW } , //the view matrix
{ " m_modelview " , SP_M_MODELVIEW } , //the combined modelview matrix
{ " m_projection " , SP_M_PROJECTION } , //projection matrix
/**/ { " m_modelviewprojection " , SP_M_MODELVIEWPROJECTION } , //fancy mvp matrix. probably has degraded precision.
2018-12-28 00:04:36 +00:00
{ " m_bones_packed " , SP_M_ENTBONES_PACKED } , //bone matrix array. should normally be read via sys/skeletal.h
{ " m_bones_mat3x4 " , SP_M_ENTBONES_MAT3X4 } , //bone matrix array. should normally be read via sys/skeletal.h
2020-06-12 23:29:58 +00:00
{ " m_bones_mat4 " , SP_M_ENTBONES_MAT4 } , //bone matrix array. should normally be read via sys/skeletal.h
2018-07-05 16:21:44 +00:00
{ " m_invviewprojection " , SP_M_INVVIEWPROJECTION } , //inverted vp matrix
{ " m_invmodelviewprojection " , SP_M_INVMODELVIEWPROJECTION } , //inverted mvp matrix.
2020-06-12 23:29:58 +00:00
{ " m_invmodelview " , SP_M_INVMODELVIEW } , //inverted mv matrix.
2018-07-05 16:21:44 +00:00
/**/ //m_modelinv
2011-09-03 03:49:43 +00:00
/*viewer properties*/
2018-07-05 16:21:44 +00:00
{ " v_eyepos " , SP_V_EYEPOS } , //eye pos in worldspace
/**/ { " w_fog " , SP_W_FOG } , //read by sys/fog.h
{ " w_user " , SP_W_USER } , //set via VF_USERDATA
2011-09-03 03:49:43 +00:00
/*ent properties*/
2018-07-05 16:21:44 +00:00
{ " e_vblend " , SP_E_VBLEND } , //v_position1+v_position2 scalers
/**/ { " e_lmscale " , SP_E_LMSCALE } , /*overbright shifting*/
{ " e_vlscale " , SP_E_VLSCALE } , /*no lightmaps, no overbrights*/
{ " e_origin " , SP_E_ORIGIN } , //the ents origin in worldspace
/**/ { " e_time " , SP_E_TIME } , //r_refdef.time - entity->time
/**/ { " e_eyepos " , SP_E_EYEPOS } , //eye pos in modelspace
{ " e_colour " , SP_E_COLOURS } , //colormod/alpha, even if colormod isn't set
/**/ { " e_colourident " , SP_E_COLOURSIDENT } , //colormod,alpha or 1,1,1,alpha if colormod isn't set
/**/ { " e_glowmod " , SP_E_GLOWMOD } , //fullbright scalers (for hdr mostly)
/**/ { " e_uppercolour " , SP_E_TOPCOLOURS } , //q1 player colours
/**/ { " e_lowercolour " , SP_E_BOTTOMCOLOURS } , //q1 player colours
/**/ { " e_light_dir " , SP_E_L_DIR } , //lightgrid light dir. dotproducts should be clamped to 0-1.
/**/ { " e_light_mul " , SP_E_L_MUL } , //lightgrid light scaler.
/**/ { " e_light_ambient " , SP_E_L_AMBIENT } , //lightgrid light value for the unlit side.
{ " s_colour " , SP_S_COLOUR } , //the rgbgen/alphagen stuff. obviously doesn't work with per-vertex ones.
2015-08-28 03:13:45 +00:00
2014-03-30 08:55:06 +00:00
/*rtlight properties, use with caution*/
2018-07-05 16:21:44 +00:00
{ " l_lightscreen " , SP_LIGHTSCREEN } , //screenspace position of the current rtlight
/**/ { " l_lightradius " , SP_LIGHTRADIUS } , //radius of the current rtlight
/**/ { " l_lightcolour " , SP_LIGHTCOLOUR } , //rgb values of the current rtlight
/**/ { " l_lightposition " , SP_LIGHTPOSITION } , //light position in modelspace
2018-07-22 11:49:37 +00:00
{ " l_lightdirection " , SP_LIGHTDIRECTION } , //light direction in modelspace (ortho lights only, instead of position)
2018-07-05 16:21:44 +00:00
/**/ { " l_lightcolourscale " , SP_LIGHTCOLOURSCALE } , //ambient/diffuse/specular scalers
/**/ { " l_cubematrix " , SP_LIGHTCUBEMATRIX } , //matrix used to control the rtlight's cubemap projection
/**/ { " l_shadowmapproj " , SP_LIGHTSHADOWMAPPROJ } , //compacted projection matrix for shadowmaps
/**/ { " l_shadowmapscale " , SP_LIGHTSHADOWMAPSCALE } , //should probably use a samplerRect instead...
{ " e_sourcesize " , SP_SOURCESIZE } , //size of VF_SOURCECOLOUR image
{ " e_rendertexturescale " , SP_RENDERTEXTURESCALE } , //scaler for $currentrender, when npot isn't supported.
2014-03-30 08:55:06 +00:00
{ NULL }
} ;
2010-08-28 17:14:38 +00:00
2020-06-12 23:29:58 +00:00
static char * Shader_ParseBody ( char * debugname , const char * * ptr )
2006-03-11 03:12:10 +00:00
{
2013-10-29 17:38:22 +00:00
char * body ;
2020-06-12 23:29:58 +00:00
const 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
2020-06-12 23:29:58 +00:00
static void Shader_SLProgramName ( shader_t * shader , shaderpass_t * pass , const char * * ptr , int qrtype )
2013-10-29 17:38:22 +00:00
{
/*accepts:
program
{
BLAH
}
where BLAH is both vertex + frag with # ifdefs
or
program fname
on one line .
*/
char * programbody ;
char * hash ;
2016-11-20 20:52:41 +00:00
program_t * newprog ;
2013-10-29 17:38:22 +00:00
programbody = Shader_ParseBody ( shader - > name , ptr ) ;
if ( programbody )
{
2016-11-20 20:52:41 +00:00
newprog = BZ_Malloc ( sizeof ( * newprog ) ) ;
memset ( newprog , 0 , sizeof ( * newprog ) ) ;
newprog - > refs = 1 ;
if ( ! Shader_LoadPermutations ( shader - > name , newprog , programbody , qrtype , 0 , NULL ) )
2013-10-29 17:38:22 +00:00
{
2016-11-20 20:52:41 +00:00
BZ_Free ( newprog ) ;
newprog = NULL ;
2009-07-05 18:45:53 +00:00
}
2013-10-29 17:38:22 +00:00
BZ_Free ( programbody ) ;
2016-11-20 20:52:41 +00:00
}
else
{
hash = strchr ( shader - > name , ' # ' ) ;
if ( hash )
{
//pass the # postfixes from the shader name onto the generic glsl to use
char newname [ 512 ] ;
Q_snprintfz ( newname , sizeof ( newname ) , " %s%s " , Shader_ParseExactString ( ptr ) , hash ) ;
newprog = Shader_FindGeneric ( newname , qrtype ) ;
}
else
newprog = Shader_FindGeneric ( Shader_ParseExactString ( ptr ) , qrtype ) ;
2009-11-04 21:16:50 +00:00
}
2010-08-28 17:14:38 +00:00
2016-11-20 20:52:41 +00:00
if ( pass )
2012-12-04 19:37:57 +00:00
{
2016-11-20 20:52:41 +00:00
if ( pass - > numMergedPasses )
{
Shader_ReleaseGeneric ( newprog ) ;
Con_DPrintf ( " shader %s: program defined after first texture map \n " , shader - > name ) ;
}
else
{
Shader_ReleaseGeneric ( pass - > prog ) ;
pass - > prog = newprog ;
}
2012-12-04 19:37:57 +00:00
}
else
2016-11-20 20:52:41 +00:00
{
Shader_ReleaseGeneric ( shader - > prog ) ;
shader - > prog = newprog ;
}
2006-03-11 03:12:10 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_GLSLProgramName ( parsestate_t * ps , const char * * ptr )
2009-11-04 21:16:50 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2009-11-04 21:16:50 +00:00
Shader_SLProgramName ( shader , pass , ptr , QR_OPENGL ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_ProgramName ( parsestate_t * ps , const char * * ptr )
2011-03-31 02:32:32 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-03-31 02:32:32 +00:00
Shader_SLProgramName ( shader , pass , ptr , qrenderer ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_HLSL9ProgramName ( parsestate_t * ps , const char * * ptr )
2009-11-04 21:16:50 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2012-09-30 05:52:03 +00:00
Shader_SLProgramName ( shader , pass , ptr , QR_DIRECT3D9 ) ;
2009-11-04 21:16:50 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_HLSL11ProgramName ( parsestate_t * ps , const char * * ptr )
2013-11-21 23:02:28 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2013-11-21 23:02:28 +00:00
Shader_SLProgramName ( shader , pass , ptr , QR_DIRECT3D11 ) ;
}
2009-11-04 21:16:50 +00:00
2020-06-12 23:29:58 +00:00
static void Shader_ReflectCube ( parsestate_t * ps , const char * * ptr )
2015-05-03 19:57:46 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-10-18 08:37:38 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , IF_TEXTYPE_CUBE ) ;
2019-03-12 05:04:27 +00:00
ps - > s - > defaulttextures - > reflectcube = Shader_FindImage ( ps , token , flags ) ;
2015-05-03 19:57:46 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_ReflectMask ( parsestate_t * ps , const char * * ptr )
2015-05-03 19:57:46 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > reflectmask = Shader_FindImage ( ps , token , flags ) ;
2015-05-03 19:57:46 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DiffuseMap ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > base = Shader_FindImage ( ps , token , flags ) ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
2019-03-12 05:04:27 +00:00
Q_strncpyz ( ps - > s - > defaulttextures - > mapname , token , sizeof ( ps - > s - > defaulttextures - > mapname ) ) ;
2011-02-25 04:22:14 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_SpecularMap ( parsestate_t * ps , const char * * ptr )
2015-02-02 08:01:53 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > specular = Shader_FindImage ( ps , token , flags ) ;
2015-02-02 08:01:53 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_NormalMap ( parsestate_t * ps , const char * * ptr )
2015-02-02 08:01:53 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , IF_TRYBUMP | IF_NOSRGB ) ;
ps - > s - > defaulttextures - > bump = Shader_FindImage ( ps , token , flags ) ;
2015-02-02 08:01:53 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_FullbrightMap ( parsestate_t * ps , const char * * ptr )
2015-02-02 08:01:53 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > fullbright = Shader_FindImage ( ps , token , flags ) ;
2015-02-02 08:01:53 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_UpperMap ( parsestate_t * ps , const char * * ptr )
2015-02-02 08:01:53 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > upperoverlay = Shader_FindImage ( ps , token , flags ) ;
2015-02-02 08:01:53 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_LowerMap ( parsestate_t * ps , const char * * ptr )
2015-02-02 08:01:53 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
ps - > s - > defaulttextures - > loweroverlay = Shader_FindImage ( ps , token , flags ) ;
2015-02-02 08:01:53 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DisplacementMap ( parsestate_t * ps , const char * * ptr )
2019-02-01 08:29:14 +00:00
{
2019-06-18 13:03:37 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2019-03-12 05:04:27 +00:00
unsigned int flags = Shader_SetImageFlags ( ps , ps - > pass , & token , IF_NOSRGB ) ;
ps - > s - > defaulttextures - > displacement = Shader_FindImage ( ps , token , flags ) ;
2019-02-01 08:29:14 +00:00
}
2015-02-02 08:01:53 +00:00
2020-06-12 23:29:58 +00:00
static void Shaderpass_QF_Material ( parsestate_t * ps , const char * * ptr )
2019-03-12 05:04:27 +00:00
{ //qf_material BASETEXTURE NORMALMAP SPECULARMAP
2017-10-31 22:52:58 +00:00
unsigned int flags ;
char * progname = " defaultwall " ;
char * token ;
2019-03-12 05:04:27 +00:00
char * hash = strchr ( ps - > s - > name , ' # ' ) ;
2017-10-31 22:52:58 +00:00
if ( hash )
{
//pass the # postfixes from the shader name onto the generic glsl to use
char newname [ 512 ] ;
Q_snprintfz ( newname , sizeof ( newname ) , " %s%s " , progname , hash ) ;
2019-03-12 05:04:27 +00:00
ps - > pass - > prog = Shader_FindGeneric ( newname , qrenderer ) ;
2017-10-31 22:52:58 +00:00
}
else
2019-03-12 05:04:27 +00:00
ps - > pass - > prog = Shader_FindGeneric ( progname , qrenderer ) ;
2017-10-31 22:52:58 +00:00
2019-06-18 13:03:37 +00:00
token = Shader_ParseSensString ( ptr ) ;
2017-10-31 22:52:58 +00:00
if ( * token & & strcmp ( token , " - " ) )
{
2019-03-12 05:04:27 +00:00
flags = Shader_SetImageFlags ( ps , ps - > pass , & token , 0 ) ;
2017-10-31 22:52:58 +00:00
if ( * token )
2019-03-12 05:04:27 +00:00
ps - > s - > defaulttextures - > base = Shader_FindImage ( ps , token , flags ) ;
2017-10-31 22:52:58 +00:00
else
{
2019-03-12 05:04:27 +00:00
token = ps - > s - > name ;
2017-10-31 22:52:58 +00:00
if ( hash )
* hash = 0 ;
2019-03-12 05:04:27 +00:00
ps - > s - > defaulttextures - > base = Shader_FindImage ( ps , token , flags ) ;
2017-10-31 22:52:58 +00:00
if ( hash )
* hash = ' # ' ;
}
}
if ( * token )
2019-06-18 13:03:37 +00:00
token = Shader_ParseSensString ( ptr ) ;
2017-10-31 22:52:58 +00:00
if ( * token & & strcmp ( token , " - " ) )
{
2019-03-12 05:04:27 +00:00
flags = Shader_SetImageFlags ( ps , NULL , & token , IF_TRYBUMP | IF_NOSRGB ) ;
ps - > s - > defaulttextures - > bump = Shader_FindImage ( ps , token , flags ) ;
2017-10-31 22:52:58 +00:00
}
if ( * token )
2019-06-18 13:03:37 +00:00
token = Shader_ParseSensString ( ptr ) ;
2017-10-31 22:52:58 +00:00
if ( * token & & strcmp ( token , " - " ) )
{
2019-03-12 05:04:27 +00:00
flags = Shader_SetImageFlags ( ps , NULL , & token , 0 ) ;
ps - > s - > defaulttextures - > specular = Shader_FindImage ( ps , token , flags ) ;
2017-10-31 22:52:58 +00:00
}
}
2019-03-12 05:04:27 +00:00
static qboolean Shaderpass_MapGen ( parsestate_t * ps , shaderpass_t * pass , char * tname ) ;
2011-02-25 04:22:14 +00:00
2020-06-12 23:29:58 +00:00
static void Shader_Translucent ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2011-02-25 04:22:14 +00:00
shader - > flags | = SHADER_BLEND ;
}
2020-06-12 23:29:58 +00:00
static void Shader_PortalFBOScale ( parsestate_t * ps , const char * * ptr )
2018-07-05 16:21:44 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2018-07-05 16:21:44 +00:00
shader - > portalfboscale = Shader_ParseFloat ( shader , ptr , 0 ) ;
shader - > portalfboscale = max ( shader - > portalfboscale , 0 ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_Camera ( parsestate_t * ps , const char * * ptr )
2012-09-30 05:52:03 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > s - > sort = SHADER_SORT_PORTAL ;
ps - > dpwatertype | = 4 ;
2012-09-30 05:52:03 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_Water ( parsestate_t * ps , const char * * ptr )
2016-08-25 00:12:14 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
ps - > parseflags | = SPF_PROGRAMIFY ;
2016-08-25 00:12:14 +00:00
2019-03-12 05:04:27 +00:00
ps - > dpwatertype | = 3 ;
ps - > reflectmin = Shader_ParseFloat ( shader , ptr , 0 ) ;
ps - > reflectmax = Shader_ParseFloat ( shader , ptr , 0 ) ;
ps - > refractfactor = Shader_ParseFloat ( shader , ptr , 0 ) ;
ps - > reflectfactor = Shader_ParseFloat ( shader , ptr , 0 ) ;
Shader_ParseVector ( shader , ptr , ps - > refractcolour ) ;
Shader_ParseVector ( shader , ptr , ps - > reflectcolour ) ;
ps - > wateralpha = Shader_ParseFloat ( shader , ptr , 0 ) ;
2016-08-25 00:12:14 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_Reflect ( parsestate_t * ps , const char * * ptr )
2016-08-25 00:12:14 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > parseflags | = SPF_PROGRAMIFY ;
2016-08-25 00:12:14 +00:00
2019-03-12 05:04:27 +00:00
ps - > dpwatertype | = 1 ;
ps - > reflectmin = 1 ;
ps - > reflectmax = 1 ;
ps - > reflectfactor = Shader_ParseFloat ( ps - > s , ptr , 0 ) ;
Shader_ParseVector ( ps - > s , ptr , ps - > reflectcolour ) ;
2016-08-25 00:12:14 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_Refract ( parsestate_t * ps , const char * * ptr )
2016-08-25 00:12:14 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > parseflags | = SPF_PROGRAMIFY ;
2016-08-25 00:12:14 +00:00
2019-03-12 05:04:27 +00:00
ps - > dpwatertype | = 2 ;
ps - > refractfactor = Shader_ParseFloat ( ps - > s , ptr , 0 ) ;
Shader_ParseVector ( ps - > s , ptr , ps - > refractcolour ) ;
2016-08-25 00:12:14 +00:00
}
2012-09-30 05:52:03 +00:00
2020-06-12 23:29:58 +00:00
static void Shader_DP_OffsetMapping ( parsestate_t * ps , const char * * ptr )
2017-08-29 02:29:06 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2017-08-29 02:29:06 +00:00
char * token = Shader_ParseString ( ptr ) ;
if ( ! strcmp ( token , " disable " ) | | ! strcmp ( token , " none " ) | | ! strcmp ( token , " off " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingmode = 0 ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " default " ) | | ! strcmp ( token , " normal " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingmode = - 1 ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " linear " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingmode = 1 ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " relief " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingmode = 2 ;
ps - > offsetmappingscale = Shader_ParseFloat ( shader , ptr , 1 ) ;
2017-08-29 02:29:06 +00:00
token = Shader_ParseString ( ptr ) ;
if ( ! strcmp ( token , " bias " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingbias = Shader_ParseFloat ( shader , ptr , 0.5 ) ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " match " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingbias = 1.0 - Shader_ParseFloat ( shader , ptr , 0.5 ) ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " match8 " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingbias = 1.0 - ( 1.0 / 255 ) * Shader_ParseFloat ( shader , ptr , 128 ) ;
2017-08-29 02:29:06 +00:00
else if ( ! strcmp ( token , " match16 " ) )
2019-03-12 05:04:27 +00:00
ps - > offsetmappingbias = 1.0 - ( 1.0 / 65535 ) * Shader_ParseFloat ( shader , ptr , 32768 ) ;
2017-08-29 02:29:06 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_GlossScale ( parsestate_t * ps , const char * * ptr )
2017-08-29 02:29:06 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > specularvalscale = Shader_ParseFloat ( ps - > s , ptr , 0 ) ;
2017-08-29 02:29:06 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_DP_GlossExponent ( parsestate_t * ps , const char * * ptr )
2017-08-29 02:29:06 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > specularexpscale = Shader_ParseFloat ( ps - > s , ptr , 0 ) ;
2017-08-29 02:29:06 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shader_FactorBase ( parsestate_t * ps , const char * * ptr )
2019-03-12 05:04:27 +00:00
{
shader_t * shader = ps - > s ;
shader - > factors [ MATERIAL_FACTOR_BASE ] [ 0 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_BASE ] [ 1 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_BASE ] [ 2 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_BASE ] [ 3 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_FactorSpec ( parsestate_t * ps , const char * * ptr )
2019-03-12 05:04:27 +00:00
{
shader_t * shader = ps - > s ;
shader - > factors [ MATERIAL_FACTOR_SPEC ] [ 0 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_SPEC ] [ 1 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_SPEC ] [ 2 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_SPEC ] [ 3 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
}
2020-06-12 23:29:58 +00:00
static void Shader_FactorEmit ( parsestate_t * ps , const char * * ptr )
2019-03-12 05:04:27 +00:00
{
shader_t * shader = ps - > s ;
shader - > factors [ MATERIAL_FACTOR_EMIT ] [ 0 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_EMIT ] [ 1 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_EMIT ] [ 2 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
shader - > factors [ MATERIAL_FACTOR_EMIT ] [ 3 ] = Shader_ParseFloat ( shader , ptr , 1 ) ;
}
2017-08-29 02:29:06 +00:00
2020-06-12 23:29:58 +00:00
static void Shader_BEMode ( parsestate_t * ps , const char * * ptr )
2013-10-29 17:38:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2017-04-18 11:12:17 +00:00
char subname [ 1024 ] ;
2013-10-29 17:38:22 +00:00
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 ;
2016-11-20 20:52:41 +00:00
else if ( ! Q_stricmp ( token , " gbuffer " ) | | ! Q_stricmp ( token , " prelight " ) )
mode = bemoverride_gbuffer ;
2013-10-29 17:38:22 +00:00
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 + + )
{
2018-01-22 19:18:04 +00:00
if ( ( mode & LSHADER_CUBE ) & & ( mode & ( LSHADER_SPOT | LSHADER_ORTHO ) ) )
continue ; //cube projections don't make sense when the light isn't projecting a cube
if ( ( mode & LSHADER_ORTHO ) & & ( mode & LSHADER_SPOT ) )
continue ; //ortho+spot are mutually exclusive.
Q_snprintfz ( subname , sizeof ( subname ) , " %s%s%s%s%s%s " , tokencopy ,
2013-10-29 17:38:22 +00:00
( mode & LSHADER_SMAP ) ? " #PCF " : " " ,
( mode & LSHADER_SPOT ) ? " #SPOT " : " " ,
2014-10-05 20:04:11 +00:00
( mode & LSHADER_CUBE ) ? " #CUBE " : " " ,
2018-01-22 19:18:04 +00:00
( mode & LSHADER_ORTHO ) ? " #ORTHO " : " " ,
2014-10-05 20:04:11 +00:00
# ifdef GLQUAKE
2018-01-22 19:18:04 +00:00
( qrenderer = = QR_OPENGL & & gl_config . arb_shadow & & ( mode & LSHADER_SMAP ) ) ? " #USE_ARB_SHADOW " : " "
2014-10-05 20:04:11 +00:00
# else
" "
# endif
2017-04-18 11:12:17 +00:00
) ;
shader - > bemoverrides [ mode ] = R_RegisterCustom ( subname , shader - > usageflags | ( embed ? SUR_FORCEFALLBACK : 0 ) , embed ? Shader_DefaultScript : NULL , embed ) ;
2013-10-29 17:38:22 +00:00
}
}
else
{
2017-04-18 11:12:17 +00:00
shader - > bemoverrides [ mode ] = R_RegisterCustom ( tokencopy , shader - > usageflags | ( embed ? SUR_FORCEFALLBACK : 0 ) , embed ? Shader_DefaultScript : NULL , embed ) ;
2013-10-29 17:38:22 +00:00
}
if ( embed )
BZ_Free ( embed ) ;
}
2004-10-19 15:56:22 +00:00
static shaderkey_t shaderkeys [ ] =
{
2017-10-31 22:52:58 +00:00
# define Q3 NULL
{ " cull " , Shader_Cull , Q3 } ,
{ " skyparms " , Shader_SkyParms , Q3 } ,
{ " fogparms " , Shader_FogParms , Q3 } ,
{ " surfaceparm " , Shader_SurfaceParm , Q3 } ,
{ " nomipmaps " , Shader_NoMipMaps , Q3 } ,
{ " nopicmip " , Shader_NoPicMip , Q3 } ,
{ " polygonoffset " , Shader_PolygonOffset , Q3 } ,
{ " sort " , Shader_Sort , Q3 } ,
{ " deformvertexes " , Shader_DeformVertexes , Q3 } ,
{ " portal " , Shader_Portal , Q3 } ,
{ " entitymergable " , Shader_EntityMergable , Q3 } ,
2009-11-04 21:16:50 +00:00
2013-10-29 17:38:22 +00:00
//fte extensions
2017-10-31 22:52:58 +00:00
{ " clutter " , Shader_ClutterParms , " fte " } ,
{ " deferredlight " , Shader_Deferredlight , " fte " } , //(sort = prelight)
// {"lpp_light", Shader_Deferredlight, "fte"}, //(sort = prelight)
{ " affine " , Shader_Affine , " fte " } , //some hardware is horribly slow, and can benefit from certain hints.
{ " bemode " , Shader_BEMode , " fte " } ,
{ " diffusemap " , Shader_DiffuseMap , " fte " } ,
{ " normalmap " , Shader_NormalMap , " fte " } ,
{ " specularmap " , Shader_SpecularMap , " fte " } ,
{ " fullbrightmap " , Shader_FullbrightMap , " fte " } ,
{ " uppermap " , Shader_UpperMap , " fte " } ,
{ " lowermap " , Shader_LowerMap , " fte " } ,
{ " reflectmask " , Shader_ReflectMask , " fte " } ,
2019-02-01 08:29:14 +00:00
{ " displacementmap " , Shader_DisplacementMap , " fte " } ,
2018-10-11 10:31:23 +00:00
2018-07-05 16:21:44 +00:00
{ " portalfboscale " , Shader_PortalFBOScale , " fte " } , //portal/mirror/refraction/reflection FBOs are resized by this scale
2019-03-12 05:04:27 +00:00
{ " basefactor " , Shader_FactorBase , " fte " } , //material scalers for glsl
{ " specularfactor " , Shader_FactorSpec , " fte " } , //material scalers for glsl
{ " fullbrightfactor " , Shader_FactorEmit , " fte " } , //material scalers for glsl
2018-10-11 10:31:23 +00:00
//TODO: PBR textures...
// {"albedomap", Shader_DiffuseMap, "fte"}, //rgb(a)
// {"loweruppermap", Shader_LowerUpperMap, "fte"}, //r=lower, g=upper (team being more important than personal colours, this allows the texture to gracefully revert to red-only)
//{"normalmap", Shader_NormalMap, "fte"}, //xy-h
2019-08-01 02:13:44 +00:00
// {"ormmap", Shader_SpecularMap, "fte"}, //r=occlusion, g=metalness, b=roughness.
2018-10-11 10:31:23 +00:00
//{"glowmap", Shader_FullbrightMap, "fte"}, //rgb
2017-10-31 22:52:58 +00:00
2018-04-06 17:21:15 +00:00
/*program stuff at the material level is an outdated practise.*/
{ " program " , Shader_ProgramName , " fte " } , //usable with any renderer that has a usable shader language...
{ " glslprogram " , Shader_GLSLProgramName , " fte " } , //for renderers that accept embedded glsl
{ " hlslprogram " , Shader_HLSL9ProgramName , " fte " } , //for d3d with embedded hlsl
{ " hlsl11program " , Shader_HLSL11ProgramName , " fte " } , //for d3d with embedded hlsl
2018-10-11 10:31:23 +00:00
// {"progblendfunc", Shader_ProgBlendFunc, "fte"}, //specifies the blend mode (actually just overrides the first subpasses' blendmode.
// {"progmap", Shader_ProgMap, "fte"}, //avoids needing extra subpasses (actually just inserts an extra pass).
2018-09-01 04:18:08 +00:00
2012-09-30 05:52:03 +00:00
//dp compat
2017-10-31 22:52:58 +00:00
{ " reflectcube " , Shader_ReflectCube , " dp " } ,
{ " camera " , Shader_DP_Camera , " dp " } ,
{ " water " , Shader_DP_Water , " dp " } ,
{ " reflect " , Shader_DP_Reflect , " dp " } ,
{ " refract " , Shader_DP_Refract , " dp " } ,
{ " offsetmapping " , Shader_DP_OffsetMapping , " dp " } ,
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
{ " shadow " , NULL , " dp " } ,
2017-10-31 22:52:58 +00:00
{ " noshadow " , NULL , " dp " } ,
{ " polygonoffset " , NULL , " dp " } ,
{ " glossintensitymod " , Shader_DP_GlossScale , " dp " } , //scales r_shadow_glossintensity(=1), aka: gl_specular
{ " glossexponentmod " , Shader_DP_GlossExponent , " dp " } , //scales r_shadow_glossexponent(=32)
2012-09-30 05:52:03 +00:00
2011-02-25 04:22:14 +00:00
/*doom3 compat*/
2017-10-31 22:52:58 +00:00
{ " diffusemap " , Shader_DiffuseMap , " doom3 " } , //macro for "{\nstage diffusemap\nmap <map>\n}"
{ " bumpmap " , Shader_NormalMap , " doom3 " } , //macro for "{\nstage bumpmap\nmap <map>\n}"
{ " discrete " , NULL , " doom3 " } ,
{ " nonsolid " , NULL , " doom3 " } ,
{ " noimpact " , NULL , " doom3 " } ,
{ " translucent " , Shader_Translucent , " doom3 " } ,
{ " noshadows " , NULL , " doom3 " } ,
{ " nooverlays " , NULL , " doom3 " } ,
{ " nofragment " , NULL , " doom3 " } ,
2018-10-11 10:31:23 +00:00
/*RTCW compat*/
2018-01-22 19:18:04 +00:00
{ " nocompress " , NULL , " rtcw " } ,
{ " allowcompress " , NULL , " rtcw " } ,
{ " nofog " , NULL , " rtcw " } ,
{ " skyfogvars " , NULL , " rtcw " } ,
{ " sunshader " , NULL , " rtcw " } ,
{ " sun " , NULL , " q3map2 " } , //provides rgb and dir
{ " sunExt " , NULL , " q3map2 " } , //treated as an alias
{ " fogParms " , NULL , " rtcw " } , //sets a cvar. *shudder*
{ " fogvars " , NULL , " rtcw " } , //sets a cvar. *shudder*
{ " waterfogvars " , NULL , " rtcw " } , //sets a cvar. *shudder*
{ " light " , NULL , " rtcw " } , //for q3map2, not us
{ " lightgridmulamb " , NULL , " rtcw " } , //urm
{ " lightgridmuldir " , NULL , " rtcw " } , //not really sure how this is useful to us
2017-10-31 22:52:58 +00:00
/*qfusion / warsow compat*/
// {"skyparms2", NULL, "qf"}, //skyparms without the underscore.
// {"skyparmssides", NULL, "qf"}, //skyparms with explicitly-named faces
// {"nocompress", NULL, "qf"}, //disables opportunistic compression (doesn't affect compressed source images, apparently)
// {"nofiltering", NULL, "qf"}, //misnomer. there is always 'filtering'. this means to use nearest filtering for min and mag, as well as no mipmaps.
// {"smallestmipmapsize", NULL, "qf"}, //mips with a size less than the specified value are dropped.
// {"stenciltest", NULL, "qf"}, //enables GL_STENCIL_TEST, which is special-case stuff that I see no reason to support
// {"offsetmappingscale", NULL, "qf"},
// {"glossexponent", NULL, "qf"},
// {"glossintensity", NULL, "qf"},
// {"template", NULL, "qf"}, //parses some other shader, with $3 etc arg expansion
{ " skip " , NULL , " qf " } , //just skips the line. acts like a comment. no idea why they can't just use a comment.
// {"softparticle", NULL, "qf"}, //uses screen depth, if possible.
// {"forceworldoutlines", NULL, "qf"}, //looks like an ugly hack to me.
2015-02-02 08:01:53 +00:00
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
// ===============================================================
2019-03-12 05:04:27 +00:00
static qboolean Shaderpass_MapGen ( parsestate_t * ps , shaderpass_t * pass , char * tname )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2014-10-25 02:16:35 +00:00
int tcgen = TC_GEN_BASE ;
2010-11-22 02:03:28 +00:00
if ( ! Q_stricmp ( tname , " $lightmap " ) )
2005-01-07 03:10:11 +00:00
{
2014-10-25 02:16:35 +00:00
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
{
2014-10-25 02:16:35 +00:00
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 ;
2015-02-02 08:01:53 +00:00
shader - > flags | = SHADER_HASDIFFUSE ;
2009-11-04 21:16:50 +00:00
}
2015-02-07 22:34:22 +00:00
else if ( ! Q_stricmp ( tname , " $paletted " ) )
{
pass - > texgen = T_GEN_PALETTED ;
shader - > flags | = SHADER_HASPALETTED ;
}
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 ;
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 ;
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 ;
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 ;
}
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 ;
}
2017-08-29 02:29:06 +00:00
else if ( ! Q_stricmp ( tname , " $reflectcube " ) )
{
2019-10-07 04:51:17 +00:00
shader - > flags | = SHADER_HASREFLECTCUBE ;
2017-08-29 02:29:06 +00:00
pass - > texgen = T_GEN_REFLECTCUBE ;
}
else if ( ! Q_stricmp ( tname , " $reflectmask " ) )
{
pass - > texgen = T_GEN_REFLECTMASK ;
}
2019-02-01 08:29:14 +00:00
else if ( ! Q_stricmp ( tname , " $displacement " ) )
{
shader - > flags | = SHADER_HASDISPLACEMENT ;
pass - > texgen = T_GEN_DISPLACEMENT ;
}
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 ;
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 ;
}
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 ;
2016-07-12 00:40:13 +00:00
shader - > flags | = SHADER_HASCURRENTRENDER ;
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 ;
}
2011-10-27 16:16:29 +00:00
else if ( ! Q_stricmp ( tname , " $sourcecube " ) )
{
pass - > texgen = T_GEN_SOURCECUBE ;
}
2011-09-03 03:49:43 +00:00
else if ( ! Q_stricmp ( tname , " $sourcedepth " ) )
{
pass - > texgen = T_GEN_SOURCEDEPTH ;
}
2017-10-31 22:52:58 +00:00
else if ( ! Q_strnicmp ( tname , " $gbuffer " , 8 ) )
{
unsigned idx = strtoul ( tname + 8 , & tname , 10 ) ;
if ( * tname | | idx > = GBUFFER_COUNT )
return false ;
pass - > texgen = T_GEN_GBUFFER0 + idx ;
}
2012-05-09 15:30:53 +00:00
else if ( ! Q_stricmp ( tname , " $reflection " ) )
{
shader - > flags | = SHADER_HASREFLECT ;
pass - > texgen = T_GEN_REFLECTION ;
}
else if ( ! Q_stricmp ( tname , " $refraction " ) )
{
shader - > flags | = SHADER_HASREFRACT ;
pass - > texgen = T_GEN_REFRACTION ;
}
2013-03-12 23:13:39 +00:00
else if ( ! Q_stricmp ( tname , " $refractiondepth " ) )
{
shader - > flags | = SHADER_HASREFRACT ;
pass - > texgen = T_GEN_REFRACTIONDEPTH ;
}
2012-05-14 01:41:08 +00:00
else if ( ! Q_stricmp ( tname , " $ripplemap " ) )
{
shader - > flags | = SHADER_HASRIPPLEMAP ;
pass - > texgen = T_GEN_RIPPLEMAP ;
}
2014-10-05 20:04:11 +00:00
else if ( ! Q_stricmp ( tname , " $null " ) )
{
pass - > flags | = SHADER_PASS_NOMIPMAP | SHADER_PASS_DETAIL ;
pass - > texgen = T_GEN_SINGLEMAP ;
}
2005-01-07 03:10:11 +00:00
else
2010-11-22 02:03:28 +00:00
return false ;
2014-10-25 02:16:35 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
pass - > tcgen = tcgen ;
2010-11-22 02:03:28 +00:00
return true ;
}
2019-03-12 05:04:27 +00:00
shaderpass_t * Shaderpass_DefineMap ( parsestate_t * ps , shaderpass_t * pass )
2016-11-20 20:52:41 +00:00
{
//'map foo' works a bit differently when there's a program in the same pass.
//instead of corrupting the previous one, it collects multiple maps so that {prog foo;map t0;map t1; map t2; blendfunc add} can work as expected
if ( pass - > prog )
{
if ( pass - > numMergedPasses = = 0 )
pass - > numMergedPasses + + ;
else
{ //FIXME: bounds check!
2019-03-12 05:04:27 +00:00
if ( ps - > s - > numpasses = = SHADER_PASS_MAX | | ps - > s - > numpasses = = SHADER_TMU_MAX )
2016-11-20 20:52:41 +00:00
{
2019-03-12 05:04:27 +00:00
Con_DPrintf ( CON_WARNING " Shader %s has too many texture passes. \n " , ps - > s - > name ) ;
ps - > droppass = true ;
2016-11-20 20:52:41 +00:00
}
// else if (shader->numpasses == be_maxpasses)
2019-03-12 05:04:27 +00:00
// ps->droppass = true;
2016-11-20 20:52:41 +00:00
else
{
pass - > numMergedPasses + + ;
2019-03-12 05:04:27 +00:00
ps - > s - > numpasses + + ;
2016-11-20 20:52:41 +00:00
}
2019-03-12 05:04:27 +00:00
pass = ps - > s - > passes + ps - > s - > numpasses - 1 ;
2016-11-20 20:52:41 +00:00
memset ( pass , 0 , sizeof ( * pass ) ) ;
}
}
else
pass - > numMergedPasses = 1 ;
return pass ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Map ( parsestate_t * ps , const char * * ptr )
2010-11-22 02:03:28 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2010-11-22 02:03:28 +00:00
int flags ;
char * token ;
2019-03-12 05:04:27 +00:00
pass = Shaderpass_DefineMap ( ps , pass ) ;
2016-11-20 20:52:41 +00:00
2010-11-22 02:03:28 +00:00
pass - > anim_frames [ 0 ] = r_nulltex ;
2019-06-18 13:03:37 +00:00
token = Shader_ParseSensString ( ptr ) ;
2015-02-02 08:01:53 +00:00
2019-03-12 05:04:27 +00:00
flags = Shader_SetImageFlags ( ps , pass , & token , 0 ) ;
if ( ! Shaderpass_MapGen ( ps , pass , token ) )
2005-01-07 03:10:11 +00:00
{
2021-05-09 13:01:15 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
2014-10-25 02:16:35 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
pass - > tcgen = TC_GEN_BASE ;
2015-05-03 19:57:46 +00:00
if ( ! * shader - > defaulttextures - > mapname & & * token ! = ' $ ' & & pass - > tcgen = = TC_GEN_BASE )
Q_strncpyz ( shader - > defaulttextures - > mapname , token , sizeof ( shader - > defaulttextures - > mapname ) ) ;
2019-03-12 05:04:27 +00:00
pass - > anim_frames [ 0 ] = Shader_FindImage ( ps , token , flags ) ;
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AnimMap_Flag ( parsestate_t * ps , const char * * ptr , unsigned int flags )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2004-10-19 15:56:22 +00:00
char * token ;
2009-11-04 21:16:50 +00:00
texid_t image ;
2015-05-03 19:57:46 +00:00
qboolean isdiffuse = false ;
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
flags | = Shader_SetImageFlags ( ps , ps - > pass , NULL , 0 ) ;
2004-10-19 15:56:22 +00:00
2014-10-25 02:16:35 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
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 ;
2015-09-07 14:34:39 +00:00
pass - > anim_fps = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 ;
}
2015-05-03 19:57:46 +00:00
if ( ! pass - > anim_numframes & & ! * shader - > defaulttextures - > mapname & & * token ! = ' $ ' & & pass - > tcgen = = TC_GEN_BASE )
{
isdiffuse = true ;
shader - > defaulttextures_fps = pass - > anim_fps ;
}
2013-06-23 02:17:02 +00:00
if ( pass - > anim_numframes < SHADER_MAX_ANIMFRAMES )
2009-11-04 21:16:50 +00:00
{
2019-03-12 05:04:27 +00:00
image = Shader_FindImage ( ps , token , flags ) ;
2004-10-19 15:56:22 +00:00
2015-05-03 19:57:46 +00:00
if ( isdiffuse )
{
if ( shader - > numdefaulttextures < pass - > anim_numframes + 1 )
{
int newmax = pass - > anim_numframes + 1 ;
shader - > defaulttextures = BZ_Realloc ( shader - > defaulttextures , sizeof ( * shader - > defaulttextures ) * ( newmax ) ) ;
memset ( shader - > defaulttextures + shader - > numdefaulttextures , 0 , sizeof ( * shader - > defaulttextures ) * ( newmax - shader - > numdefaulttextures ) ) ;
shader - > numdefaulttextures = newmax ;
}
Q_strncpyz ( shader - > defaulttextures [ pass - > anim_numframes ] . mapname , token , sizeof ( shader - > defaulttextures [ pass - > anim_numframes ] . mapname ) ) ;
}
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 ;
}
}
}
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AnimMap ( parsestate_t * ps , const char * * ptr )
2017-10-31 22:52:58 +00:00
{
2019-03-12 05:04:27 +00:00
Shaderpass_AnimMap_Flag ( ps , ptr , 0 ) ;
2017-10-31 22:52:58 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_QF_AnimClampMap ( parsestate_t * ps , const char * * ptr )
2017-10-31 22:52:58 +00:00
{
2019-03-12 05:04:27 +00:00
Shaderpass_AnimMap_Flag ( ps , ptr , IF_CLAMP ) ;
2017-10-31 22:52:58 +00:00
}
2004-10-19 15:56:22 +00:00
2020-06-12 23:29:58 +00:00
static void Shaderpass_ClampMap ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2004-10-19 15:56:22 +00:00
int flags ;
char * token ;
2019-06-18 13:03:37 +00:00
token = Shader_ParseSensString ( ptr ) ;
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
flags = Shader_SetImageFlags ( ps , pass , & token , IF_CLAMP ) ;
if ( ! Shaderpass_MapGen ( ps , pass , token ) )
2009-11-04 21:16:50 +00:00
{
2014-10-25 02:16:35 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
pass - > tcgen = TC_GEN_BASE ;
2019-03-12 05:04:27 +00:00
pass - > anim_frames [ 0 ] = Shader_FindImage ( ps , token , flags ) ;
2021-05-09 13:01:15 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
2010-11-22 02:03:28 +00:00
if ( ! TEXVALID ( pass - > anim_frames [ 0 ] ) )
{
2019-10-18 08:37:38 +00:00
if ( ( flags & IF_TEXTYPEMASK ) ! = IF_TEXTYPE_2D )
2011-12-23 03:12:29 +00:00
pass - > anim_frames [ 0 ] = r_nulltex ;
else
pass - > anim_frames [ 0 ] = missing_texture ;
2019-03-12 05:04:27 +00:00
Con_DPrintf ( CON_WARNING " Shader %s has a stage with no image: %s. \n " , ps - > s - > name , token ) ;
2010-11-22 02:03:28 +00:00
}
}
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_VideoMap ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2016-02-15 06:01:17 +00:00
char * token = Shader_ParseSensString ( ptr ) ;
2004-10-19 15:56:22 +00:00
2017-02-21 20:22:07 +00:00
# ifndef HAVE_MEDIA_DECODER
2016-02-15 06:01:17 +00:00
( void ) token ;
2009-11-04 21:16:50 +00:00
# else
2019-03-12 08:28:19 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2009-11-04 21:16:50 +00:00
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 )
2017-09-20 11:27:13 +00:00
{
2009-11-04 21:16:50 +00:00
Con_DPrintf ( CON_WARNING " (shader %s) Couldn't load video %s \n " , shader - > name , token ) ;
2017-09-20 11:27:13 +00:00
}
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
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_Map_16bit ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( ! gl_load24bit . ival ) //urm, not sure if suitable choice of cvar
2019-03-12 05:04:27 +00:00
Shaderpass_Map ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_Map_32bit ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( gl_load24bit . ival )
2019-03-12 05:04:27 +00:00
Shaderpass_Map ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_Map_s3tc ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( sh_config . texfmt [ PTI_BC3_RGBA ] & & gl_compress . ival )
2019-03-12 05:04:27 +00:00
Shaderpass_Map ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_Map_nos3tc ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( ! ( sh_config . texfmt [ PTI_BC3_RGBA ] & & gl_compress . ival ) )
2019-03-12 05:04:27 +00:00
Shaderpass_Map ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_AnimMap_s3tc ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( ( sh_config . texfmt [ PTI_BC3_RGBA ] & & gl_compress . ival ) )
2019-03-12 05:04:27 +00:00
Shaderpass_AnimMap ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RTCW_AnimMap_nos3tc ( parsestate_t * ps , const char * * ptr )
2018-01-22 19:18:04 +00:00
{
if ( ! ( sh_config . texfmt [ PTI_BC3_RGBA ] & & gl_compress . ival ) )
2019-03-12 05:04:27 +00:00
Shaderpass_AnimMap ( ps , ptr ) ;
2018-01-22 19:18:04 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_SLProgramName ( shader_t * shader , shaderpass_t * pass , const char * * ptr , int qrtype )
2016-11-20 20:52:41 +00:00
{
/*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 = BZ_Malloc ( sizeof ( * shader - > prog ) ) ;
memset ( shader - > prog , 0 , sizeof ( * shader - > prog ) ) ;
shader - > prog - > refs = 1 ;
if ( ! Shader_LoadPermutations ( shader - > name , shader - > prog , programbody , qrtype , 0 , NULL ) )
{
BZ_Free ( shader - > prog ) ;
shader - > prog = NULL ;
}
BZ_Free ( programbody ) ;
return ;
} */
hash = strchr ( shader - > name , ' # ' ) ;
if ( hash )
{
//pass the # postfixes from the shader name onto the generic glsl to use
char newname [ 512 ] ;
Q_snprintfz ( newname , sizeof ( newname ) , " %s%s " , Shader_ParseExactString ( ptr ) , hash ) ;
pass - > prog = Shader_FindGeneric ( newname , qrtype ) ;
}
else
pass - > prog = Shader_FindGeneric ( Shader_ParseExactString ( ptr ) , qrtype ) ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_ProgramName ( parsestate_t * ps , const char * * ptr )
2016-11-20 20:52:41 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2016-11-20 20:52:41 +00:00
Shaderpass_SLProgramName ( shader , pass , ptr , qrenderer ) ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_RGBGen ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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 ;
2019-12-16 17:25:59 +00:00
Shader_ParseFunc ( ps , " rgbGen wave " , 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 " ) )
2019-07-02 04:12:20 +00:00
{
2011-10-27 16:16:29 +00:00
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
2019-07-02 04:12:20 +00:00
if ( pass - > alphagen = = ALPHA_GEN_UNDEFINED ) //matches Q3, and is a perf gain, even if its inconsistent.
pass - > alphagen = ALPHA_GEN_VERTEX ;
}
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 ;
2017-12-09 21:22:46 +00:00
else if ( ! Q_stricmp ( token , " entitylighting " ) )
pass - > rgbgen = RGB_GEN_ENTITY_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
}
2018-03-04 14:41:16 +00:00
else if ( ! Q_stricmp ( token , " srgb " ) | | ! Q_stricmp ( token , " srgbconst " ) )
{
pass - > rgbgen = RGB_GEN_CONST ;
pass - > rgbgen_func . type = SHADER_FUNC_CONSTANT ;
Shader_ParseVector ( shader , ptr , pass - > rgbgen_func . args ) ;
pass - > rgbgen_func . args [ 0 ] = SRGBf ( pass - > rgbgen_func . args [ 0 ] ) ;
pass - > rgbgen_func . args [ 1 ] = SRGBf ( pass - > rgbgen_func . args [ 1 ] ) ;
pass - > rgbgen_func . args [ 2 ] = SRGBf ( pass - > rgbgen_func . args [ 2 ] ) ;
}
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
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AlphaGen ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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 ;
2015-03-03 00:14:43 +00:00
shader - > portaldist = Shader_ParseFloat ( shader , ptr , 256 ) ;
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 ;
2019-12-16 17:25:59 +00:00
Shader_ParseFunc ( ps , " alphaGen wave " , 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 ;
2015-03-03 00:14:43 +00:00
pass - > alphagen_func . args [ 0 ] = fabs ( Shader_ParseFloat ( shader , ptr , 0 ) ) ;
2004-10-19 15:56:22 +00:00
}
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AlphaShift ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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
2015-03-03 00:14:43 +00:00
speed = Shader_ParseFloat ( shader , ptr , 0 ) ;
min = Shader_ParseFloat ( shader , ptr , 0 ) ;
max = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_BlendFunc ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
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 ;
2016-07-12 00:40:13 +00:00
else if ( ! Q_stricmp ( token , " premul " ) ) //gets rid of feathering.
pass - > shaderbits | = SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA ;
2009-11-04 21:16:50 +00:00
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
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AlphaFunc ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
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
{
2016-07-12 00:40:13 +00:00
pass - > shaderbits | = SBITS_ATEST_GT0 ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " lt128 " ) )
{
2016-07-12 00:40:13 +00:00
pass - > shaderbits | = SBITS_ATEST_LT128 ;
2009-11-04 21:16:50 +00:00
}
else if ( ! Q_stricmp ( token , " ge128 " ) )
{
2016-07-12 00:40:13 +00:00
pass - > shaderbits | = SBITS_ATEST_GE128 ;
2011-03-12 13:51:40 +00:00
}
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_DepthFunc ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2004-10-19 15:56:22 +00:00
char * token ;
2018-04-27 16:40:50 +00:00
pass - > shaderbits & = ~ ( SBITS_DEPTHFUNC_BITS ) ;
2016-07-12 00:40:13 +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 , " equal " ) )
2018-04-27 16:40:50 +00:00
pass - > shaderbits | = SBITS_DEPTHFUNC_EQUAL ;
2011-03-12 13:51:40 +00:00
else if ( ! Q_stricmp ( token , " lequal " ) )
2018-04-27 16:40:50 +00:00
pass - > shaderbits | = SBITS_DEPTHFUNC_CLOSEREQUAL ; //default
2016-07-12 00:40:13 +00:00
else if ( ! Q_stricmp ( token , " less " ) )
2018-04-27 16:40:50 +00:00
pass - > shaderbits | = SBITS_DEPTHFUNC_CLOSER ;
2016-07-12 00:40:13 +00:00
else if ( ! Q_stricmp ( token , " greater " ) )
2018-04-27 16:40:50 +00:00
pass - > shaderbits | = SBITS_DEPTHFUNC_FURTHER ;
// else if (!Q_stricmp (token, "gequal"))
// pass->shaderbits |= SBITS_DEPTHFUNC_FURTHEREQUAL;
// else if (!Q_stricmp (token, "nequal"))
// pass->shaderbits |= SBITS_DEPTHFUNC_NOTEQUAL;
// else if (!Q_stricmp (token, "never"))
// pass->shaderbits |= SBITS_DEPTHFUNC_NEVER;
// else if (!Q_stricmp (token, "always"))
// pass->shaderbits |= SBITS_DEPTHFUNC_ALWAYS;
2009-11-04 21:16:50 +00:00
else
Con_DPrintf ( " Invalid depth func %s \n " , token ) ;
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_DepthWrite ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_NoDepthTest ( parsestate_t * ps , const char * * ptr )
2011-10-27 16:16:29 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-10-27 16:16:29 +00:00
shader - > flags | = SHADER_DEPTHWRITE ;
pass - > shaderbits | = SBITS_MISC_NODEPTHTEST ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_NoDepth ( parsestate_t * ps , const char * * ptr )
2011-10-27 16:16:29 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2011-10-27 16:16:29 +00:00
shader - > flags | = SHADER_DEPTHWRITE ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_TcMod ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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 " ) )
{
2015-03-03 00:14:43 +00:00
tcmod - > args [ 0 ] = - Shader_ParseFloat ( shader , ptr , 0 ) / 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 " ) )
{
2015-03-03 00:14:43 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 " ) )
{
2015-03-03 00:14:43 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 ;
2019-12-16 17:25:59 +00:00
Shader_ParseFunc ( ps , " tcmod stretch " , 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 )
2015-03-03 00:14:43 +00:00
tcmod - > args [ i ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 + + )
2015-03-03 00:14:43 +00:00
tcmod - > args [ i ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2004-10-19 15:56:22 +00:00
tcmod - > type = SHADER_TCMOD_TURB ;
2009-11-04 21:16:50 +00:00
}
2017-08-14 16:38:44 +00:00
else if ( ! Q_stricmp ( token , " page " ) )
{
for ( i = 0 ; i < 3 ; i + + )
tcmod - > args [ i ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
tcmod - > type = SHADER_TCMOD_PAGE ;
}
2018-01-22 19:18:04 +00:00
// else if (!Q_stricmp (token, "entityTranslate")) //RTCW
// else if (!Q_stricmp (token, "swap")) //RTCW
2009-11-04 21:16:50 +00:00
else
{
2018-01-22 19:18:04 +00:00
Con_DPrintf ( " Unknown tcmod %s in %s \n " , token , shader - > name ) ;
2004-10-19 15:56:22 +00:00
return ;
}
pass - > numtcmods + + ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Scale ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2006-02-27 00:42:25 +00:00
//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 " ) )
{
2015-03-03 00:14:43 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 " ) )
{
2015-03-03 00:14:43 +00:00
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 + + ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Scroll ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
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 ;
2015-03-03 00:14:43 +00:00
tcmod - > args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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 ;
2015-03-03 00:14:43 +00:00
tcmod - > args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
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
2020-06-12 23:29:58 +00:00
static void Shaderpass_TcGen ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2004-10-19 15:56:22 +00:00
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 ;
2018-01-22 19:18:04 +00:00
} else if ( ! Q_stricmp ( token , " fireriseenv " ) ) { //from RTCW
pass - > tcgen = TC_GEN_ENVIRONMENT ; //FIXME: not supported
2016-07-12 00:40:13 +00:00
} else if ( ! Q_stricmp ( token , " vector " ) )
{
pass - > tcgen = TC_GEN_VECTOR ;
Shader_ParseVector ( shader , ptr , pass - > tcgenvec [ 0 ] ) ;
Shader_ParseVector ( shader , ptr , pass - > tcgenvec [ 1 ] ) ;
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 ;
2017-08-29 02:29:06 +00:00
} else if ( ! Q_stricmp ( token , " skybox " ) ) {
pass - > tcgen = TC_GEN_SKYBOX ;
2004-10-19 15:56:22 +00:00
}
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_EnvMap ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2006-02-27 00:42:25 +00:00
pass - > tcgen = TC_GEN_ENVIRONMENT ;
}
2004-10-19 15:56:22 +00:00
2020-06-12 23:29:58 +00:00
static void Shaderpass_Detail ( parsestate_t * ps , const char * * ptr )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2004-10-19 15:56:22 +00:00
pass - > flags | = SHADER_PASS_DETAIL ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AlphaMask ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
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
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_NoLightMap ( parsestate_t * ps , const char * * ptr )
2006-02-27 00:42:25 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2006-02-27 00:42:25 +00:00
pass - > rgbgen = RGB_GEN_IDENTITY ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Red ( parsestate_t * ps , const char * * ptr )
2011-12-05 15:23:40 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-12-05 15:23:40 +00:00
pass - > rgbgen = RGB_GEN_CONST ;
2015-03-03 00:14:43 +00:00
pass - > rgbgen_func . args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2011-12-05 15:23:40 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Green ( parsestate_t * ps , const char * * ptr )
2011-12-05 15:23:40 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-12-05 15:23:40 +00:00
pass - > rgbgen = RGB_GEN_CONST ;
2015-03-03 00:14:43 +00:00
pass - > rgbgen_func . args [ 1 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2011-12-05 15:23:40 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Blue ( parsestate_t * ps , const char * * ptr )
2011-12-05 15:23:40 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-12-05 15:23:40 +00:00
pass - > rgbgen = RGB_GEN_CONST ;
2015-03-03 00:14:43 +00:00
pass - > rgbgen_func . args [ 2 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2011-12-05 15:23:40 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_Alpha ( parsestate_t * ps , const char * * ptr )
2011-12-05 15:23:40 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2011-12-05 15:23:40 +00:00
pass - > alphagen = ALPHA_GEN_CONST ;
2015-03-03 00:14:43 +00:00
pass - > alphagen_func . args [ 0 ] = Shader_ParseFloat ( shader , ptr , 0 ) ;
2011-12-05 15:23:40 +00:00
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_MaskColor ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_MASK_RED | SBITS_MASK_GREEN | SBITS_MASK_BLUE ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_MaskRed ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_MASK_RED ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_MaskGreen ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_MASK_GREEN ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_MaskBlue ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_MASK_BLUE ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_MaskAlpha ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_MASK_ALPHA ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_AlphaTest ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
shaderpass_t * pass = ps - > pass ;
2015-03-03 00:14:43 +00:00
if ( Shader_ParseFloat ( shader , ptr , 0 ) = = 0.5 )
2011-02-25 04:22:14 +00:00
pass - > shaderbits | = SBITS_ATEST_GE128 ;
else
Con_Printf ( " unsupported alphatest value \n " ) ;
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_TexGen ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-02-25 04:22:14 +00:00
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 " ) ;
}
}
2020-06-12 23:29:58 +00:00
static void Shaderpass_CubeMap ( parsestate_t * ps , const char * * ptr )
2011-02-25 04:22:14 +00:00
{
2019-03-12 05:04:27 +00:00
shaderpass_t * pass = ps - > pass ;
2011-12-23 03:12:29 +00:00
char * token = Shader_ParseString ( ptr ) ;
2017-12-28 16:24:50 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
2011-02-25 04:22:14 +00:00
pass - > tcgen = TC_GEN_SKYBOX ;
2019-10-18 08:37:38 +00:00
pass - > anim_frames [ 0 ] = Shader_FindImage ( ps , token , IF_TEXTYPE_CUBE ) ;
2021-05-09 13:01:15 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
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 [ ] =
{
2017-10-31 22:52:58 +00:00
# define Q3 NULL
{ " rgbgen " , Shaderpass_RGBGen , Q3 } ,
{ " alphagen " , Shaderpass_AlphaGen , Q3 } ,
{ " blendfunc " , Shaderpass_BlendFunc , Q3 } ,
{ " depthfunc " , Shaderpass_DepthFunc , Q3 } ,
{ " depthwrite " , Shaderpass_DepthWrite , Q3 } ,
{ " alphafunc " , Shaderpass_AlphaFunc , Q3 } ,
{ " tcmod " , Shaderpass_TcMod , Q3 } ,
{ " map " , Shaderpass_Map , Q3 } ,
{ " animmap " , Shaderpass_AnimMap , Q3 } ,
{ " clampmap " , Shaderpass_ClampMap , Q3 } ,
{ " videomap " , Shaderpass_VideoMap , Q3 } ,
{ " tcgen " , Shaderpass_TcGen , Q3 } ,
{ " texgen " , Shaderpass_TcGen , Q3 } ,
{ " detail " , Shaderpass_Detail , Q3 } ,
{ " nodepthtest " , Shaderpass_NoDepthTest , NULL } ,
{ " nodepth " , Shaderpass_NoDepth , NULL } ,
2015-03-03 00:14:43 +00:00
{ " envmap " , Shaderpass_EnvMap , " rscript " } , //for alienarena
{ " nolightmap " , Shaderpass_NoLightMap , " rscript " } , //for alienarena
{ " scale " , Shaderpass_Scale , " rscript " } , //for alienarena
{ " scroll " , Shaderpass_Scroll , " rscript " } , //for alienarena
{ " alphashift " , Shaderpass_AlphaShift , " rscript " } , //for alienarena
{ " alphamask " , Shaderpass_AlphaMask , " rscript " } , //for alienarena
2011-02-25 04:22:14 +00:00
2016-11-20 20:52:41 +00:00
{ " program " , Shaderpass_ProgramName , " fte " } ,
2017-10-31 22:52:58 +00:00
2011-02-25 04:22:14 +00:00
/*doom3 compat*/
2015-03-03 00:14:43 +00:00
{ " blend " , Shaderpass_BlendFunc , " doom3 " } ,
{ " maskcolor " , Shaderpass_MaskColor , " doom3 " } ,
{ " maskred " , Shaderpass_MaskRed , " doom3 " } ,
{ " maskgreen " , Shaderpass_MaskGreen , " doom3 " } ,
{ " maskblue " , Shaderpass_MaskBlue , " doom3 " } ,
{ " maskalpha " , Shaderpass_MaskAlpha , " doom3 " } ,
{ " alphatest " , Shaderpass_AlphaTest , " doom3 " } ,
{ " texgen " , Shaderpass_TexGen , " doom3 " } ,
{ " cubemap " , Shaderpass_CubeMap , " doom3 " } , //one of these is wrong
{ " cameracubemap " , Shaderpass_CubeMap , " doom3 " } , //one of these is wrong
{ " red " , Shaderpass_Red , " doom3 " } ,
{ " green " , Shaderpass_Green , " doom3 " } ,
{ " blue " , Shaderpass_Blue , " doom3 " } ,
{ " alpha " , Shaderpass_Alpha , " doom3 " } ,
2017-10-31 22:52:58 +00:00
2018-01-22 19:18:04 +00:00
//RTCW
//fancy map lines use the map if that mode is active.
//FIXME: actually check these to ensure there's no issues with any shaders overriding the pass's previously specified map
// (hopefully no shaders would actually do that due to the engine loading both textures, which would be wasteful)
{ " map16 " , Shaderpass_RTCW_Map_16bit , " rtcw " } ,
{ " map32 " , Shaderpass_RTCW_Map_32bit , " rtcw " } ,
{ " mapcomp " , Shaderpass_RTCW_Map_s3tc , " rtcw " } ,
{ " mapnocomp " , Shaderpass_RTCW_Map_nos3tc , " rtcw " } ,
{ " animcompmap " , Shaderpass_RTCW_AnimMap_s3tc , " rtcw " } ,
{ " animnocompmap " , Shaderpass_RTCW_AnimMap_nos3tc , " rtcw " } ,
2017-10-31 22:52:58 +00:00
//qfusion/warsow compat
{ " material " , Shaderpass_QF_Material , " qf " } ,
{ " animclampmap " , Shaderpass_QF_AnimClampMap , " qf " } ,
2017-12-28 16:24:50 +00:00
// {"cubemap", Shaderpass_QF_CubeMap, "qf"},
// {"shadecubemap",Shaderpass_QF_ShadeCubeMap, "qf"},
{ " surroundmap " , Shaderpass_CubeMap , " qf " } ,
// {"distortion", Shaderpass_QF_Distortion, "qf"},
// {"celshade", Shaderpass_QF_Celshade, "qf"},
// {"grayscale", Shaderpass_QF_Greyscale, "qf"},
// {"greyscale", Shaderpass_QF_Greyscale, "qf"},
// {"skip", Shaderpass_QF_Skip, "qf"},
2017-10-31 22:52:58 +00:00
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 )
{
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2011-06-04 16:11:35 +00:00
if ( pass - > flags & SHADER_PASS_VIDEOMAP )
{
Media_ShutdownCin ( pass - > cin ) ;
pass - > cin = NULL ;
}
# endif
2016-11-20 20:52:41 +00:00
if ( pass - > prog )
{
Shader_ReleaseGeneric ( pass - > prog ) ;
pass - > prog = NULL ;
}
2011-06-04 16:11:35 +00:00
}
2016-07-12 00:40:13 +00:00
void Shader_ReleaseGeneric ( program_t * prog )
{
if ( prog )
if ( prog - > refs - - = = 1 )
Shader_UnloadProg ( prog ) ;
}
2011-06-04 16:11:35 +00:00
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 ;
2016-07-12 00:40:13 +00:00
Shader_ReleaseGeneric ( 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 ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
shader - > skydome = NULL ;
2015-03-03 00:14:43 +00:00
while ( shader - > clutter )
{
void * t = shader - > clutter ;
shader - > clutter = shader - > clutter - > next ;
Z_Free ( t ) ;
2011-06-04 16:11:35 +00:00
}
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
2015-05-03 19:57:46 +00:00
Z_Free ( shader - > defaulttextures ) ;
shader - > defaulttextures = NULL ;
2011-06-04 16:11:35 +00:00
}
2015-02-02 08:01:53 +00:00
int QDECL Shader_InitCallback ( const char * name , qofs_t size , time_t mtime , void * param , searchpathfuncs_t * spath )
2004-10-19 15:56:22 +00:00
{
2018-04-27 16:40:50 +00:00
Shader_MakeCache ( name , SPF_DEFAULT ) ;
return true ;
}
int QDECL Shader_InitCallback_Doom3 ( const char * name , qofs_t size , time_t mtime , void * param , searchpathfuncs_t * spath )
{
Shader_MakeCache ( name , SPF_DOOM3 ) ;
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 ( ) ;
2017-01-29 13:10:53 +00:00
if ( ! sh_config . progs_supported )
sh_config . max_gpu_bones = 0 ;
else
{
extern cvar_t r_max_gpu_bones ;
if ( ! * r_max_gpu_bones . string )
{
# ifdef FTE_TARGET_WEB
sh_config . max_gpu_bones = 0 ; //webgl tends to crap out if this is too high, so 32 is a good enough value to play safe. some browsers have really shitty uniform performance too, so lets just default to pure-cpu transforms. in javascript. yes, its that bad.
# else
sh_config . max_gpu_bones = 64 ; //ATI drivers bug out and start to crash if you put this at 128.
# endif
}
else
sh_config . max_gpu_bones = bound ( 0 , r_max_gpu_bones . ival , MAX_BONES ) ;
}
2011-06-04 16:11:35 +00:00
}
2016-07-12 00:40:13 +00:00
2011-10-27 16:16:29 +00:00
if ( ! qrenderer )
r_whiteimage = r_nulltex ;
else
2019-07-16 02:59:12 +00:00
{
memset ( wibuf , 0xff , sizeof ( wibuf ) ) ;
2011-10-27 16:16:29 +00:00
r_whiteimage = R_LoadTexture ( " $whiteimage " , 4 , 4 , TF_RGBA32 , wibuf , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA ) ;
2019-07-16 02:59:12 +00:00
memset ( wibuf , 0 , sizeof ( wibuf ) ) ;
r_blackimage = R_LoadTexture ( " $blackimage " , 4 , 4 , TF_RGBA32 , wibuf , IF_NOMIPMAP | IF_NOPICMIP | IF_NEAREST | IF_NOGAMMA ) ;
}
2016-07-12 00:40:13 +00:00
Shader_NeedReload ( true ) ;
Shader_DoReload ( ) ;
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 ) ;
}
}
2018-04-27 16:40:50 +00:00
static void Shader_MakeCache ( const char * path , unsigned int parseflags )
2004-10-19 15:56:22 +00:00
{
2014-03-30 08:55:06 +00:00
unsigned int key ;
2020-06-12 23:29:58 +00:00
const char * buf , * ptr ;
char * 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 ;
2018-04-27 16:40:50 +00:00
cachefile - > parseflags = parseflags ;
2014-03-30 08:55:06 +00:00
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 ;
2018-04-27 16:40:50 +00:00
//look for meta comments.
while ( 1 )
{
//parse metas
while ( * ptr = = ' ' | | * ptr = = ' \t ' )
ptr + + ;
if ( ptr [ 0 ] = = ' \r ' & & ptr [ 1 ] = = ' \n ' )
ptr + = 2 ; //blank line with dos ending
else if ( ptr [ 0 ] = = ' \r ' | | ptr [ 0 ] = = ' \n ' )
ptr + = 1 ; //blank line with mac or unix ending
else if ( ptr [ 0 ] = = ' / ' & & ptr [ 1 ] = = ' / ' )
{
2020-06-12 23:29:58 +00:00
const char * e = strchr ( ptr , ' \n ' ) ;
2018-04-27 16:40:50 +00:00
if ( e )
e + + ;
else
e = ptr + strlen ( ptr ) ;
ptr + = 2 ;
while ( * ptr = = ' ' | | * ptr = = ' \t ' )
ptr + + ;
if ( ! strncmp ( ptr , " meta: " , 5 ) )
{
ptr + = 5 ;
token = COM_ParseExt ( & ptr , false , true ) ;
if ( ! strcmp ( token , " forceprogramify " ) )
{
cachefile - > parseflags | = SPF_PROGRAMIFY ;
token = COM_ParseExt ( & ptr , false , true ) ;
if ( * token )
Q_strncpyz ( cachefile - > forcedshadername , token , sizeof ( cachefile - > forcedshadername ) ) ;
}
else
2018-04-27 17:11:14 +00:00
Con_DPrintf ( " unknown shader meta term \" %s \" in %s \n " , token , path ) ;
2018-04-27 16:40:50 +00:00
while ( * ptr = = ' ' | | * ptr = = ' \t ' )
ptr + + ;
if ( * ptr ! = ' \r ' & & * ptr ! = ' \n ' )
{
while ( * ptr & & ( * ptr ! = ' \r ' & & * ptr ! = ' \n ' ) )
ptr + + ;
2018-04-27 17:11:14 +00:00
Con_DPrintf ( " junk after shader meta in %s \n " , path ) ;
2018-04-27 16:40:50 +00:00
}
}
ptr = e ;
}
else
break ; //the actual shader started.
}
//now scan the file looking for each individual shader.
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
{
2019-12-16 17:25:59 +00:00
ptr = Shader_Skip ( path , token , ptr ) ;
2004-10-19 15:56:22 +00:00
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 ;
2019-12-16 17:25:59 +00:00
ptr = Shader_Skip ( path , cache - > name , ptr ) ;
2004-10-19 15:56:22 +00:00
} while ( ptr ) ;
2014-03-30 08:55:06 +00:00
}
2020-06-12 23:29:58 +00:00
static qboolean Shader_LocateSource ( const char * name , const char * * buf , size_t * bufsize , size_t * offset , shadercachefile_t * * sourcefile )
2014-03-30 08:55:06 +00:00
{
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 ;
2018-04-27 16:40:50 +00:00
* sourcefile = cache - > source ;
2014-03-30 08:55:06 +00:00
}
return true ;
}
}
return false ;
2004-10-19 15:56:22 +00:00
}
2020-06-12 23:29:58 +00:00
static const char * Shader_Skip ( const char * file , const char * shadername , const 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
}
2018-03-04 14:41:16 +00:00
for ( brace_count = 1 ; brace_count > 0 ; )
2011-03-12 13:51:40 +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
tok = COM_ParseExt ( & ptr , true , true ) ;
2004-10-19 15:56:22 +00:00
if ( ! tok [ 0 ] )
2019-12-16 17:25:59 +00:00
{
2020-06-12 23:29:58 +00:00
Con_Printf ( CON_WARNING " %s: unexpected EOF parsing %s \n " , file , shadername ) ;
2004-10-19 15:56:22 +00:00
return NULL ;
2019-12-16 17:25:59 +00:00
}
2004-10-19 15:56:22 +00:00
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 )
{
2018-07-05 16:21:44 +00:00
extern cvar_t r_refractreflect_scale ;
2011-05-20 04:10:46 +00:00
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 ;
2015-05-03 19:57:46 +00:00
texnums_t * dt = s - > defaulttextures ;
int dtcount = s - > numdefaulttextures ;
float dtrate = s - > defaulttextures_fps ; //FIXME!
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 ;
2015-05-03 19:57:46 +00:00
s - > defaulttextures = NULL ;
2011-05-20 04:10:46 +00:00
Shader_Free ( s ) ;
memset ( s , 0 , sizeof ( * s ) ) ;
2018-07-05 16:21:44 +00:00
s - > portalfboscale = r_refractreflect_scale . value ; //unless otherwise specified, this cvar specifies the value.
2011-05-20 04:10:46 +00:00
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 ;
2015-05-03 19:57:46 +00:00
s - > numdefaulttextures = dtcount ;
s - > defaulttextures_fps = dtrate ;
2011-05-20 04:10:46 +00:00
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 ) ;
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
static void Shader_Regenerate ( parsestate_t * ps , const char * shortname )
{
Shader_Reset ( ps - > s ) ;
if ( ! strcmp ( shortname , " textures/common/clip " ) | | ! strcmp ( shortname , " textures/common/nodraw " ) | | ! strcmp ( shortname , " common/nodraw " ) )
Shader_DefaultScript ( ps , shortname ,
" { \n "
" surfaceparm nodraw \n "
" surfaceparm nodlight \n "
" } \n " ) ;
else
ps - > s - > generator ( ps , shortname , ps - > s - > genargs ) ;
}
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 ( ) ;
2017-08-29 02:29:06 +00:00
R_SkyShutdown ( ) ;
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
}
2018-01-22 19:18:04 +00:00
void Shader_SetBlendmode ( shaderpass_t * pass , shaderpass_t * lastpass )
2004-10-19 15:56:22 +00:00
{
2018-01-22 19:18:04 +00:00
qboolean lightmapoverbright ;
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
{
2018-01-22 19:18:04 +00:00
if ( pass - > texgen = = T_GEN_LIGHTMAP & & lastpass )
2016-07-12 00:40:13 +00:00
pass - > blendmode = PBM_OVERBRIGHT ;
else if ( ( pass - > rgbgen = = RGB_GEN_IDENTITY ) & & ( pass - > alphagen = = ALPHA_GEN_IDENTITY ) )
2009-11-04 21:16:50 +00:00
{
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 ;
}
2018-01-22 19:18:04 +00:00
lightmapoverbright = pass - > texgen = = T_GEN_LIGHTMAP | | ( lastpass & & lastpass - > texgen = = T_GEN_LIGHTMAP & & lastpass - > blendmode ! = PBM_OVERBRIGHT ) ;
2009-11-04 21:16:50 +00:00
if ( ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_ZERO | SBITS_DSTBLEND_SRC_COLOR ) ) | |
2018-01-22 19:18:04 +00:00
( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_DST_COLOR | SBITS_DSTBLEND_ZERO ) ) | |
( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_DST_COLOR | SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA ) ) )
pass - > blendmode = lightmapoverbright ? PBM_OVERBRIGHT : 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
2018-01-22 19:18:04 +00:00
pass - > blendmode = lightmapoverbright ? PBM_OVERBRIGHT : PBM_MODULATE ;
2004-10-19 15:56:22 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_FixupProgPasses ( parsestate_t * ps , shaderpass_t * pass )
2016-11-20 20:52:41 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * shader = ps - > s ;
2016-11-20 20:52:41 +00:00
int i ;
int maxpasses = SHADER_PASS_MAX - ( pass - shader - > passes ) ;
struct
{
int gen ;
unsigned int flags ;
} defaulttgen [ ] =
{
//light
2019-02-01 08:29:14 +00:00
{ T_GEN_SHADOWMAP , 0 } , //0
{ T_GEN_LIGHTCUBEMAP , 0 } , //1
2016-11-20 20:52:41 +00:00
//material
2019-02-01 08:29:14 +00:00
{ T_GEN_DIFFUSE , SHADER_HASDIFFUSE } , //2
{ T_GEN_NORMALMAP , SHADER_HASNORMALMAP } , //3
{ T_GEN_SPECULAR , SHADER_HASGLOSS } , //4
{ T_GEN_UPPEROVERLAY , SHADER_HASTOPBOTTOM } , //5
{ T_GEN_LOWEROVERLAY , SHADER_HASTOPBOTTOM } , //6
{ T_GEN_FULLBRIGHT , SHADER_HASFULLBRIGHT } , //7
{ T_GEN_PALETTED , SHADER_HASPALETTED } , //8
2019-10-07 04:51:17 +00:00
{ T_GEN_REFLECTCUBE , SHADER_HASREFLECTCUBE } , //9
2019-02-01 08:29:14 +00:00
{ T_GEN_REFLECTMASK , 0 } , //10
{ T_GEN_DISPLACEMENT , SHADER_HASDISPLACEMENT } , //11
2019-09-04 07:59:40 +00:00
{ T_GEN_OCCLUSION , 0 } , //12
2016-11-20 20:52:41 +00:00
// {T_GEN_REFLECTION, SHADER_HASREFLECT}, //
// {T_GEN_REFRACTION, SHADER_HASREFRACT}, //
// {T_GEN_REFRACTIONDEPTH, SHADER_HASREFRACTDEPTH},//
// {T_GEN_RIPPLEMAP, SHADER_HASRIPPLEMAP}, //
//batch
2019-09-04 07:59:40 +00:00
{ T_GEN_LIGHTMAP , SHADER_HASLIGHTMAP } , //13
{ T_GEN_DELUXMAP , 0 } , //14
//more lightmaps //15,16,17
//mode deluxemaps //18,19,20
2016-11-20 20:52:41 +00:00
} ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
cin_t * cin = R_ShaderGetCinematic ( shader ) ;
# endif
//if the glsl doesn't specify all samplers, just trim them.
pass - > numMergedPasses = pass - > prog - > numsamplers ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
if ( cin & & R_ShaderGetCinematic ( shader ) = = cin )
cin = NULL ;
# endif
//if the glsl has specific textures listed, be sure to provide a pass for them.
for ( i = 0 ; i < sizeof ( defaulttgen ) / sizeof ( defaulttgen [ 0 ] ) ; i + + )
{
if ( pass - > prog - > defaulttextures & ( 1u < < i ) )
{
if ( pass - > numMergedPasses > = maxpasses )
{ //panic...
2019-03-12 05:04:27 +00:00
ps - > droppass = true ;
2016-11-20 20:52:41 +00:00
break ;
}
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
pass [ pass - > numMergedPasses ] . flags | = SHADER_PASS_NOCOLORARRAY ;
2016-11-20 20:52:41 +00:00
pass [ pass - > numMergedPasses ] . flags & = ~ SHADER_PASS_DEPTHCMP ;
if ( defaulttgen [ i ] . gen = = T_GEN_SHADOWMAP )
pass [ pass - > numMergedPasses ] . flags | = SHADER_PASS_DEPTHCMP ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
if ( ! i & & cin )
{
pass [ pass - > numMergedPasses ] . texgen = T_GEN_VIDEOMAP ;
pass [ pass - > numMergedPasses ] . cin = cin ;
cin = NULL ;
}
else
# endif
{
pass [ pass - > numMergedPasses ] . texgen = defaulttgen [ i ] . gen ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
pass [ pass - > numMergedPasses ] . cin = NULL ;
# endif
}
pass - > numMergedPasses + + ;
shader - > flags | = defaulttgen [ i ] . flags ;
}
}
//must have at least one texture.
if ( ! pass - > numMergedPasses )
{
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
pass [ 0 ] . texgen = cin ? T_GEN_VIDEOMAP : T_GEN_DIFFUSE ;
pass [ 0 ] . cin = cin ;
# else
pass [ 0 ] . texgen = T_GEN_DIFFUSE ;
# endif
pass - > numMergedPasses = 1 ;
}
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2016-11-20 20:52:41 +00:00
else if ( cin )
Media_ShutdownCin ( cin ) ;
# endif
shader - > numpasses = ( pass - shader - > passes ) + pass - > numMergedPasses ;
}
2017-10-31 22:52:58 +00:00
struct scondinfo_s
{
int depth ;
int level [ 8 ] ;
# define COND_IGNORE 1
# define COND_IGNOREPARENT 2
# define COND_ALLOWELSE 4
# define COND_TAKEN 8
} ;
2020-06-12 23:29:58 +00:00
static qboolean Shader_Conditional_Read ( parsestate_t * ps , struct scondinfo_s * cond , const char * token , const char * * ptr )
2017-10-31 22:52:58 +00:00
{
2020-06-12 23:29:58 +00:00
shader_t * shader = ps - > s ;
2017-10-31 22:52:58 +00:00
if ( ! Q_stricmp ( token , " if " ) )
{
if ( cond - > depth + 1 = = countof ( cond - > level ) )
{
Con_Printf ( " if statements nest too deeply in shader %s \n " , shader - > name ) ;
* ptr + = strlen ( * ptr ) ;
return true ;
}
cond - > depth + + ;
cond - > level [ cond - > depth ] = ( Shader_EvaluateCondition ( shader , ptr ) ? 0 : COND_IGNORE ) ;
cond - > level [ cond - > depth ] | = COND_ALLOWELSE ;
if ( cond - > level [ cond - > depth - 1 ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
cond - > level [ cond - > depth ] | = COND_IGNOREPARENT ; //if ignoring the parent, ignore this one too, even if valid
if ( ! ( cond - > level [ cond - > depth ] & ( COND_IGNORE | COND_IGNOREPARENT ) ) )
cond - > level [ cond - > depth ] | = COND_TAKEN ; //if we're not ignoring the contained commands then flag it so we don't take any elifs/elses
}
else if ( ! Q_stricmp ( token , " elif " ) )
{
if ( cond - > level [ cond - > depth ] & COND_ALLOWELSE )
{
if ( cond - > level [ cond - > depth ] & COND_TAKEN )
{ //if we took the if/elif then don't take this elif either
Shader_EvaluateCondition ( shader , ptr ) ;
cond - > level [ cond - > depth ] = COND_ALLOWELSE | COND_TAKEN | COND_IGNORE ;
}
else
{
cond - > level [ cond - > depth ] = ( Shader_EvaluateCondition ( shader , ptr ) ? 0 : COND_IGNORE ) ;
cond - > level [ cond - > depth ] | = COND_ALLOWELSE ;
}
if ( cond - > level [ cond - > depth - 1 ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
cond - > level [ cond - > depth ] | = COND_IGNOREPARENT ;
if ( ! ( cond - > level [ cond - > depth ] & ( COND_IGNORE | COND_IGNOREPARENT ) ) )
cond - > level [ cond - > depth ] | = COND_TAKEN ;
}
else
{
2020-06-12 23:29:58 +00:00
Con_Printf ( CON_WARNING " unexpected elif statement in shader %s \n " , shader - > name ) ;
2017-10-31 22:52:58 +00:00
* ptr + = strlen ( * ptr ) ;
}
}
else if ( ! Q_stricmp ( token , " endif " ) )
{
if ( ! cond - > depth )
{
Con_Printf ( " endif without if in shader %s \n " , shader - > name ) ;
* ptr + = strlen ( * ptr ) ;
return true ;
}
cond - > depth - - ;
}
else if ( ! Q_stricmp ( token , " else " ) )
{
if ( cond - > level [ cond - > depth ] & COND_ALLOWELSE )
{
if ( cond - > level [ cond - > depth ] & COND_TAKEN )
cond - > level [ cond - > depth ] | = COND_IGNORE ;
else
cond - > level [ cond - > depth ] ^ = COND_IGNORE ;
cond - > level [ cond - > depth ] & = ~ COND_ALLOWELSE ;
}
else
{
2020-06-12 23:29:58 +00:00
Con_Printf ( CON_WARNING " unexpected else statement in shader %s \n " , shader - > name ) ;
2017-10-31 22:52:58 +00:00
* ptr + = strlen ( * ptr ) ;
}
}
else if ( cond - > level [ cond - > depth ] & ( COND_IGNORE | COND_IGNOREPARENT ) )
{
//eat it
while ( ptr )
{
token = COM_ParseExt ( ptr , false , true ) ;
if ( ! token [ 0 ] )
break ;
}
}
else
return false ;
return true ;
}
2018-04-27 16:40:50 +00:00
void Shader_Readpass ( parsestate_t * ps )
2004-10-19 15:56:22 +00:00
{
2018-04-27 16:40:50 +00:00
shader_t * shader = ps - > s ;
2020-06-12 23:29:58 +00:00
const char * token ;
2004-10-19 15:56:22 +00:00
shaderpass_t * pass ;
static shader_t dummy ;
2017-10-31 22:52:58 +00:00
struct scondinfo_s cond = { 0 } ;
2016-11-20 20:52:41 +00:00
unsigned int oldflags = shader - > flags ;
2004-10-19 15:56:22 +00:00
2009-11-04 21:16:50 +00:00
if ( shader - > numpasses > = SHADER_PASS_MAX )
{
2019-03-12 05:04:27 +00:00
ps - > droppass = true ;
2004-10-19 15:56:22 +00:00
shader = & dummy ;
shader - > numpasses = 1 ;
pass = shader - > passes ;
2009-11-04 21:16:50 +00:00
}
else
{
2019-03-12 05:04:27 +00:00
ps - > droppass = false ;
2004-10-19 15:56:22 +00:00
pass = & shader - > passes [ shader - > numpasses + + ] ;
}
2010-11-26 06:58:48 +00:00
2016-11-20 20:52:41 +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 ;
2019-07-02 04:12:20 +00:00
pass - > alphagen = ALPHA_GEN_UNDEFINED ;
2014-10-25 02:16:35 +00:00
pass - > tcgen = TC_GEN_UNSPECIFIED ;
2004-10-19 15:56:22 +00:00
pass - > numtcmods = 0 ;
2013-07-29 17:36:44 +00:00
pass - > stagetype = ST_AMBIENT ;
2016-11-20 20:52:41 +00:00
pass - > numMergedPasses = 0 ;
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 ;
2018-04-27 16:40:50 +00:00
ps - > pass = pass ;
while ( ps - > ptr )
2004-10-19 15:56:22 +00:00
{
2018-04-27 16:40:50 +00:00
token = COM_ParseExt ( & ps - > 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
}
2020-06-12 23:29:58 +00:00
else if ( ! Shader_Conditional_Read ( ps , & cond , token , & ps - > ptr ) )
2009-11-04 21:16:50 +00:00
{
2013-03-12 23:16:55 +00:00
if ( token [ 0 ] = = ' } ' )
break ;
2018-04-06 17:21:15 +00:00
else if ( token [ 0 ] = = ' { ' )
2020-06-12 23:29:58 +00:00
Con_Printf ( CON_WARNING " %s: unexpected indentation in %s \n " , ps - > sourcename , shader - > name ) ;
2018-04-27 16:40:50 +00:00
else if ( Shader_Parsetok ( ps , shaderpasskeys , token ) )
2013-03-12 23:16:55 +00:00
break ;
2004-10-19 15:56:22 +00:00
}
}
2019-07-02 04:12:20 +00:00
if ( pass - > alphagen = = ALPHA_GEN_UNDEFINED )
pass - > alphagen = ALPHA_GEN_IDENTITY ;
2016-11-20 20:52:41 +00:00
//if there was no texgen, then its too late now.
if ( ! pass - > numMergedPasses )
pass - > numMergedPasses = 1 ;
2017-10-31 22:52:58 +00:00
if ( cond . depth )
2013-03-12 23:16:55 +00:00
{
Con_Printf ( " if statements without endif in shader %s \n " , shader - > name ) ;
}
2014-10-25 02:16:35 +00:00
if ( pass - > tcgen = = TC_GEN_UNSPECIFIED )
pass - > tcgen = TC_GEN_BASE ;
2019-03-12 05:04:27 +00:00
if ( ! ps - > droppass )
2013-07-29 17:36:44 +00:00
{
switch ( pass - > stagetype )
{
case ST_DIFFUSEMAP :
if ( pass - > texgen = = T_GEN_SINGLEMAP )
2015-05-03 19:57:46 +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 )
2015-05-03 19:57:46 +00:00
shader - > defaulttextures - > bump = pass - > anim_frames [ 0 ] ;
2019-03-12 05:04:27 +00:00
ps - > droppass = true ; //fixme: scrolling etc may be important. but we're not doom3.
2013-07-29 17:36:44 +00:00
break ;
case ST_SPECULARMAP :
if ( pass - > texgen = = T_GEN_SINGLEMAP )
2015-05-03 19:57:46 +00:00
shader - > defaulttextures - > specular = pass - > anim_frames [ 0 ] ;
2019-03-12 05:04:27 +00:00
ps - > droppass = true ; //fixme: scrolling etc may be important. but we're not doom3.
2013-07-29 17:36:44 +00:00
break ;
}
}
2010-11-26 06:58:48 +00:00
// check some things
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
if ( ! ps - > droppass )
2016-11-20 20:52:41 +00:00
if ( ( pass - > shaderbits & SBITS_BLEND_BITS ) = = ( SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ZERO ) )
{
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
shader - > flags | = SHADER_DEPTHWRITE ;
}
2004-10-19 15:56:22 +00:00
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
*/
2016-11-20 20:52:41 +00:00
//if this pass specified a program, make sure it has all the textures that the program requires
2019-03-12 05:04:27 +00:00
if ( ! ps - > droppass & & pass - > prog )
Shader_FixupProgPasses ( ps , pass ) ;
2016-11-20 20:52:41 +00:00
2019-03-12 05:04:27 +00:00
if ( ps - > droppass )
2016-11-20 20:52:41 +00:00
{
while ( pass - > numMergedPasses > 0 )
{
Shader_FreePass ( pass + - - pass - > numMergedPasses ) ;
shader - > numpasses - - ;
}
shader - > flags = oldflags ;
}
2018-04-27 16:40:50 +00:00
ps - > pass = NULL ;
2009-11-04 21:16:50 +00:00
}
2004-10-19 15:56:22 +00:00
2018-04-27 16:40:50 +00:00
//we've read the first token, now make sense of it and any args
2020-06-12 23:29:58 +00:00
static qboolean Shader_Parsetok ( parsestate_t * ps , shaderkey_t * keys , const char * token )
2004-10-19 15:56:22 +00:00
{
2011-03-12 13:51:40 +00:00
shaderkey_t * key ;
2020-06-12 23:29:58 +00:00
const char * prefix ;
2017-08-14 16:38:44 +00:00
qboolean toolchainprefix = false ;
2015-03-03 00:14:43 +00:00
2018-04-06 17:21:15 +00:00
if ( * token = = ' _ ' )
{ //forward compat: make sure there's a way to shut stuff up if you're using future extensions in an outdated engine.
token + + ;
toolchainprefix = true ;
}
2015-03-03 00:14:43 +00:00
//handle known prefixes.
if ( ! Q_strncasecmp ( token , " fte " , 3 ) ) { prefix = token ; token + = 3 ; }
else if ( ! Q_strncasecmp ( token , " dp " , 2 ) ) { prefix = token ; token + = 2 ; }
else if ( ! Q_strncasecmp ( token , " doom3 " , 5 ) ) { prefix = token ; token + = 5 ; }
else if ( ! Q_strncasecmp ( token , " rscript " , 7 ) ) { prefix = token ; token + = 7 ; }
2017-08-14 16:38:44 +00:00
else if ( ! Q_strncasecmp ( token , " qer_ " , 4 ) ) { prefix = token ; token + = 3 ; toolchainprefix = true ; }
else if ( ! Q_strncasecmp ( token , " q3map_ " , 6 ) ) { prefix = token ; token + = 5 ; toolchainprefix = true ; }
2020-03-16 03:47:01 +00:00
else if ( ! Q_strncasecmp ( token , " vmap_ " , 6 ) ) { prefix = token ; token + = 4 ; toolchainprefix = true ; }
2015-03-03 00:14:43 +00:00
else prefix = NULL ;
if ( prefix & & * token = = ' _ ' )
token + + ;
2004-10-19 15:56:22 +00:00
for ( key = keys ; key - > keyword ! = NULL ; key + + )
{
if ( ! Q_stricmp ( token , key - > keyword ) )
{
2015-03-03 00:14:43 +00:00
if ( ! prefix | | ( prefix & & key - > prefix & & ! Q_strncasecmp ( prefix , key - > prefix , strlen ( key - > prefix ) ) ) )
{
if ( key - > func )
2019-03-12 05:04:27 +00:00
key - > func ( ps , & ps - > ptr ) ;
2004-10-19 15:56:22 +00:00
2018-04-27 16:40:50 +00:00
return ( ps - > ptr & & * ps - > ptr = = ' } ' ) ;
2015-03-03 00:14:43 +00:00
}
2004-10-19 15:56:22 +00:00
}
}
2017-08-14 16:38:44 +00:00
if ( ! toolchainprefix ) //we don't really give a damn about prefixes owned by various toolchains - they shouldn't affect us.
{
if ( prefix )
2018-04-27 16:40:50 +00:00
Con_DPrintf ( " Unknown shader directive parsing %s: \" %s \" \n " , ps - > s - > name , prefix ) ;
2017-08-14 16:38:44 +00:00
else
2018-04-27 16:40:50 +00:00
Con_DPrintf ( " Unknown shader directive parsing %s: \" %s \" \n " , ps - > s - > name , token ) ;
2017-08-14 16:38:44 +00:00
}
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
2004-10-19 15:56:22 +00:00
// Next Line
2018-04-27 16:40:50 +00:00
while ( ps - > ptr )
2004-10-19 15:56:22 +00:00
{
2018-04-27 16:40:50 +00:00
token = COM_ParseExt ( & ps - > 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 ;
}
2016-11-20 20:52:41 +00:00
//don't merge passes if they're got their own programs.
if ( pass - > prog | | pass2 - > prog )
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
2016-07-12 00:40:13 +00:00
/*don't merge passes if the hardware cannot support it*/
if ( pass - > numMergedPasses > = be_maxpasses )
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*/
2018-04-27 16:40:50 +00:00
if ( pass2 - > rgbgen = = RGB_GEN_IDENTITY_LIGHTING & & ( pass2 - > blendmode = = PBM_OVERBRIGHT | | pass2 - > blendmode = = PBM_MODULATE ) & & pass - > rgbgen = = RGB_GEN_IDENTITY )
2011-04-30 17:21:10 +00:00
{
2016-07-12 00:40:13 +00:00
if ( pass - > blendmode = = PBM_REPLACE )
pass - > blendmode = PBM_REPLACELIGHT ;
2011-04-30 17:21:10 +00:00
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 ;
2018-04-27 16:40:50 +00:00
/*if its alphatest, don't merge with anything other than lightmap (although equal stuff can be merged)*/
if ( ( pass - > shaderbits & SBITS_ATEST_BITS ) & & ( ( ( pass2 - > shaderbits & SBITS_DEPTHFUNC_BITS ) ! = SBITS_DEPTHFUNC_EQUAL ) | | pass2 - > texgen ! = T_GEN_LIGHTMAP ) )
2010-08-14 00:15:07 +00:00
return ;
2011-02-25 04:22:14 +00:00
if ( ( pass - > shaderbits & SBITS_MASK_BITS ) ! = ( pass2 - > shaderbits & SBITS_MASK_BITS ) )
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 + + ;
}
2018-01-22 19:18:04 +00:00
else if ( ( pass - > blendmode = = PBM_MODULATE | | pass - > blendmode = = PBM_OVERBRIGHT ) & & ( pass2 - > blendmode = = PBM_MODULATE | | pass2 - > blendmode = = PBM_OVERBRIGHT ) )
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
}
2018-01-22 19:18:04 +00:00
else if ( pass - > blendmode = = PBM_DECAL & & pass2 - > blendmode = = PBM_OVERBRIGHT )
pass - > numMergedPasses + + ; //HACK: allow modulating overbright passes with decal passes. overbright passes need to blend with something for their lighting to be correct, so this is a tradeoff.
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 ;
2016-07-12 00:40:13 +00:00
/*if (pass->texgen == T_GEN_LIGHTMAP && (pass->blendmode == PBM_REPLACE || pass->blendmode == PBM_REPLACELIGHT) && pass2->blendmode == PBM_MODULATE && sh_config.tex_env_combine)
2013-08-27 13:18:09 +00:00
{
2016-07-12 00:40:13 +00:00
// if (pass->rgbgen == RGB_GEN_IDENTITY)
// pass->rgbgen = RGB_GEN_IDENTITY_OVERBRIGHT; //get the light levels right
// pass2->blendmode = PBM_OVERBRIGHT;
2013-08-27 13:18:09 +00:00
}
2016-07-12 00:40:13 +00:00
if ( pass2 - > texgen = = T_GEN_LIGHTMAP & & pass2 - > blendmode = = PBM_OVERBRIGHT & & sh_config . tex_env_combine )
2013-08-27 13:18:09 +00:00
{
2016-07-12 00:40:13 +00:00
// if (pass->rgbgen == RGB_GEN_IDENTITY)
// pass->rgbgen = RGB_GEN_IDENTITY_OVERBRIGHT; //get the light levels right
// pass->blendmode = PBM_REPLACELIGHT;
// pass2->blendmode = PBM_OVERBRIGHT;
pass - > blendmode = PBM_OVERBRIGHT ;
2013-08-27 13:18:09 +00:00
}
2016-07-12 00:40:13 +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 ;
2017-08-29 02:29:06 +00:00
//cases inverted. the atest is to retain the pixel, glsl is to discard (alpha OP MASK).
2014-03-30 08:55:06 +00:00
case SBITS_ATEST_GT0 :
2017-08-29 02:29:06 +00:00
return " #MASK=0.0#MASKLT=1 " ;
2014-03-30 08:55:06 +00:00
case SBITS_ATEST_LT128 :
return " #MASK=0.5 " ;
2017-08-29 02:29:06 +00:00
case SBITS_ATEST_GE128 :
return " #MASK=0.5#MASKLT=1 " ; //ignore the eq part.
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
2019-03-12 05:04:27 +00:00
void Shader_Programify ( parsestate_t * ps )
2014-03-30 08:55:06 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
2017-08-29 02:29:06 +00:00
unsigned int reflectrefract = 0 ;
2018-04-27 16:40:50 +00:00
const char * prog = NULL ;
2014-03-30 08:55:06 +00:00
const char * mask ;
2017-08-29 02:29:06 +00:00
char args [ 1024 ] ;
2017-09-20 11:27:13 +00:00
qboolean eightbit = false ;
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 ;
2015-04-21 20:08:55 +00:00
shaderpass_t * pass , * lightmap = NULL , * modellighting = NULL , * vertexlighting = NULL ;
2014-03-30 08:55:06 +00:00
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 ] ;
2017-12-09 21:22:46 +00:00
if ( pass - > rgbgen = = RGB_GEN_LIGHTING_DIFFUSE | | pass - > rgbgen = = RGB_GEN_ENTITY_LIGHTING_DIFFUSE )
2019-09-17 19:49:39 +00:00
{
if ( s - > usageflags & SUF_LIGHTMAP )
lightmap = pass ;
else
modellighting = pass ;
}
2014-12-09 14:39:54 +00:00
else if ( pass - > rgbgen = = RGB_GEN_ENTITY )
modellighting = pass ;
2015-04-21 20:08:55 +00:00
else if ( pass - > rgbgen = = RGB_GEN_VERTEX_LIGHTING | | pass - > rgbgen = = RGB_GEN_VERTEX_EXACT )
2017-08-29 02:29:06 +00:00
{
if ( s - > usageflags & ( SUF_LIGHTMAP | SUF_2D ) )
vertexlighting = pass ;
else
modellighting = pass ; //fucking DP morons who don't know what lightmaps are.
}
2014-03-30 08:55:06 +00:00
else if ( pass - > texgen = = T_GEN_LIGHTMAP & & pass - > tcgen = = TC_GEN_LIGHTMAP )
2017-08-29 02:29:06 +00:00
{
if ( s - > usageflags & SUF_LIGHTMAP )
lightmap = pass ;
else
modellighting = pass ; //fucking DP morons who don't know what lightmaps are.
}
2015-08-28 03:13:45 +00:00
/*if (pass->numtcmods || (pass->shaderbits & SBITS_ATEST_BITS))
return ;
if ( pass - > texgen = = T_GEN_LIGHTMAP & & pass - > tcgen = = TC_GEN_LIGHTMAP )
;
else if ( pass - > texgen ! = T_GEN_LIGHTMAP & & pass - > tcgen = = TC_GEN_BASE )
;
2016-07-12 00:40:13 +00:00
else
return ; */
2004-10-19 15:56:22 +00:00
}
2019-03-12 05:04:27 +00:00
if ( ps - > forcedshader )
prog = ps - > forcedshader ;
else if ( ps - > dpwatertype )
2016-08-25 00:12:14 +00:00
{
2016-12-07 18:45:25 +00:00
prog = va ( " altwater%s#USEMODS#FRESNEL_EXP=2.0 "
2016-08-25 00:12:14 +00:00
//variable parts
" #STRENGTH_REFR=%g#STRENGTH_REFL=%g "
" #TINT_REFR=%g,%g,%g "
" #TINT_REFL=%g,%g,%g "
" #FRESNEL_MIN=%g#FRESNEL_RANGE=%g "
" #ALPHA=%g " ,
//those args
2019-03-12 05:04:27 +00:00
( ps - > dpwatertype & 1 ) ? " #REFLECT " : " " ,
ps - > refractfactor * 0.01 , ps - > reflectfactor * 0.01 ,
ps - > refractcolour [ 0 ] , ps - > refractcolour [ 1 ] , ps - > refractcolour [ 2 ] ,
ps - > reflectcolour [ 0 ] , ps - > reflectcolour [ 1 ] , ps - > reflectcolour [ 2 ] ,
ps - > reflectmin , ps - > reflectmax - ps - > reflectmin ,
ps - > wateralpha
2016-08-25 00:12:14 +00:00
) ;
//clear out blending and force regular depth.
2018-04-27 16:40:50 +00:00
s - > passes [ 0 ] . shaderbits & = ~ ( SBITS_BLEND_BITS | SBITS_MISC_NODEPTHTEST | SBITS_DEPTHFUNC_BITS ) ;
2016-08-25 00:12:14 +00:00
s - > passes [ 0 ] . shaderbits | = SBITS_MISC_DEPTHWRITE ;
2019-03-12 05:04:27 +00:00
if ( ps - > dpwatertype & 1 )
2017-08-29 02:29:06 +00:00
reflectrefract | = SHADER_HASREFLECT ;
2019-03-12 05:04:27 +00:00
if ( ps - > dpwatertype & 2 )
2017-08-29 02:29:06 +00:00
reflectrefract | = SHADER_HASREFRACT ;
2019-03-12 05:04:27 +00:00
if ( ps - > dpwatertype & 4 )
2017-08-29 02:29:06 +00:00
{
reflectrefract | = SHADER_HASREFRACT | SHADER_HASPORTAL ; //doubles up as a 'camera'
if ( s - > sort = = SHADER_SORT_PORTAL )
s - > sort = SHADER_SORT_OPAQUE ; //don't do it twice.
}
2016-08-25 00:12:14 +00:00
}
else if ( modellighting )
2009-11-04 21:16:50 +00:00
{
2017-09-20 11:27:13 +00:00
eightbit = r_softwarebanding & & ( qrenderer = = QR_OPENGL ) & & sh_config . progs_supported ;
if ( eightbit )
prog = " defaultskin#EIGHTBIT " ;
else
prog = " defaultskin " ;
2014-03-30 08:55:06 +00:00
}
else if ( lightmap )
{
2017-09-20 11:27:13 +00:00
eightbit = r_softwarebanding & & ( qrenderer = = QR_OPENGL | | qrenderer = = QR_VULKAN ) & & sh_config . progs_supported ;
if ( eightbit )
prog = " defaultwall#EIGHTBIT " ;
else
prog = " defaultwall " ;
2014-03-30 08:55:06 +00:00
}
2015-04-21 20:08:55 +00:00
else if ( vertexlighting )
{
2018-04-27 16:40:50 +00:00
if ( r_forceprogramify . ival < 0 )
prog = " defaultfill " ;
else
{
pass = vertexlighting ;
prog = " default2d " ;
}
2015-04-21 20:08:55 +00:00
}
2014-03-30 08:55:06 +00:00
else
{
2018-04-27 16:40:50 +00:00
if ( r_forceprogramify . ival < 0 )
prog = " defaultfill " ;
else
return ;
2014-03-30 08:55:06 +00:00
}
2004-10-19 15:56:22 +00:00
2017-08-29 02:29:06 +00:00
args [ 0 ] = 0 ;
2019-03-12 05:04:27 +00:00
if ( ps - > specularvalscale ! = 1 )
Q_strncatz ( args , va ( " #specmul=%g " , ps - > specularvalscale ) , sizeof ( args ) ) ;
if ( ps - > specularexpscale ! = 1 )
Q_strncatz ( args , va ( " #specexp=%g " , ps - > specularexpscale ) , sizeof ( args ) ) ;
/* switch(ps->offsetmappingmode)
2017-10-12 12:02:25 +00:00
{
case 0 : //force off.
2019-03-12 05:04:27 +00:00
Q_strncatz ( args , va ( " #NOOFFSETMAPPING " , ps - > specularexpscale ) , sizeof ( args ) ) ;
2017-10-12 12:02:25 +00:00
break ;
case 1 : //force linear
2019-03-12 05:04:27 +00:00
Q_strncatz ( args , va ( " #NORELIEFMAPPING " , ps - > specularexpscale ) , sizeof ( args ) ) ;
2017-10-12 12:02:25 +00:00
break ;
case 2 : //force relief
2019-03-12 05:04:27 +00:00
Q_strncatz ( args , va ( " #RELIEFMAPPING " , ps - > specularexpscale ) , sizeof ( args ) ) ;
2017-10-12 12:02:25 +00:00
break ;
}
2019-03-12 05:04:27 +00:00
if ( ps - > offsetmappingscale ! = 1 )
Q_strncatz ( args , va ( " #OFFSETMAPPING_SCALE=%g " , ps - > offsetmappingscale ) , sizeof ( args ) ) ;
if ( ps - > offsetmappingbias ! = 0 )
Q_strncatz ( args , va ( " #OFFSETMAPPING_BIAS=%g " , ps - > offsetmappingbias ) , sizeof ( args ) ) ;
2017-10-12 12:02:25 +00:00
*/
2017-08-29 02:29:06 +00:00
mask = strchr ( s - > name , ' # ' ) ;
if ( mask )
Q_strncatz ( args , mask , sizeof ( args ) ) ;
2014-03-30 08:55:06 +00:00
mask = Shader_AlphaMaskProgArgs ( s ) ;
2004-10-19 15:56:22 +00:00
2017-08-29 02:29:06 +00:00
s - > prog = Shader_FindGeneric ( va ( " %s%s%s " , prog , mask , args ) , qrenderer ) ;
2015-05-03 19:57:46 +00:00
if ( s - > prog )
{
s - > numpasses = 0 ;
2016-08-25 00:12:14 +00:00
if ( reflectrefract )
{
if ( s - > passes [ 0 ] . numtcmods > 0 & & s - > passes [ 0 ] . tcmods [ 0 ] . type = = SHADER_TCMOD_SCALE )
{ //crappy workaround for DP bug.
s - > passes [ 0 ] . tcmods [ 0 ] . args [ 0 ] * = 4 ;
s - > passes [ 0 ] . tcmods [ 0 ] . args [ 1 ] * = 4 ;
}
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_REFRACTION ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_REFLECTION ;
// s->passes[s->numpasses++].texgen = T_GEN_RIPPLEMAP;
// s->passes[s->numpasses++].texgen = T_GEN_REFRACTIONDEPTH;
2017-08-29 02:29:06 +00:00
s - > flags | = reflectrefract ;
2016-08-25 00:12:14 +00:00
}
else
{
2017-09-20 11:27:13 +00:00
if ( eightbit )
{
s - > passes [ s - > numpasses ] . anim_frames [ 0 ] = R_LoadColourmapImage ( ) ;
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_SINGLEMAP ;
}
else
s - > passes [ s - > numpasses + + ] . texgen = T_GEN_DIFFUSE ;
2016-08-25 00:12:14 +00:00
s - > flags | = SHADER_HASDIFFUSE ;
}
2015-05-03 19:57:46 +00:00
}
2004-10-19 15:56:22 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_Finish ( parsestate_t * ps )
2004-10-19 15:56:22 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > 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
2017-08-29 02:29:06 +00:00
#if 0
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 "
2018-03-04 14:41:16 +00:00
" rgbgen srgb $r_fastskycolour \n "
2010-12-05 02:46:07 +00:00
" } \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
}
2017-08-29 02:29:06 +00:00
# endif
2004-10-19 15:56:22 +00:00
2015-03-03 00:14:43 +00:00
if ( s - > prog & & ! s - > numpasses )
{
pass = & s - > passes [ s - > numpasses + + ] ;
pass - > tcgen = TC_GEN_BASE ;
pass - > texgen = T_GEN_DIFFUSE ;
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
pass - > rgbgen = RGB_GEN_IDENTITY ;
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numMergedPasses = 1 ;
2018-01-22 19:18:04 +00:00
Shader_SetBlendmode ( pass , NULL ) ;
2015-03-03 00:14:43 +00:00
}
if ( ! s - > numpasses & & s - > sort ! = SHADER_SORT_PORTAL & & ! ( s - > flags & ( SHADER_NODRAW | SHADER_SKY ) ) & & ! s - > fog_dist )
2005-05-26 12:55:34 +00:00
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( r_forceprogramify . ival > = 2 )
{
Con_DPrintf ( " Shader %s with no passes, forcing nodraw \n " , s - > name ) ;
s - > flags | = SHADER_NODRAW ;
}
2011-02-25 04:22:14 +00:00
else
2009-01-15 04:58:12 +00:00
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
pass = & s - > passes [ s - > numpasses + + ] ;
pass = & s - > passes [ 0 ] ;
pass - > tcgen = TC_GEN_BASE ;
if ( TEXVALID ( s - > defaulttextures - > base ) )
pass - > texgen = T_GEN_DIFFUSE ;
else
2011-02-25 04:22:14 +00:00
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
pass - > texgen = T_GEN_SINGLEMAP ;
TEXASSIGN ( pass - > anim_frames [ 0 ] , R_LoadHiResTexture ( s - > name , NULL , IF_NOALPHA ) ) ;
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 ) ;
2011-02-25 04:22:14 +00:00
}
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
pass - > shaderbits | = SBITS_MISC_DEPTHWRITE ;
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
pass - > alphagen = ALPHA_GEN_IDENTITY ;
pass - > numMergedPasses = 1 ;
Shader_SetBlendmode ( pass , NULL ) ;
2009-01-15 04:58:12 +00:00
}
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 ;
}
2016-07-12 00:40:13 +00:00
if ( ! r_vertexlight . value & & pass - > rgbgen = = RGB_GEN_IDENTITY )
{ //we found the lightmap pass. if we need a vertex-lit shader then just switch over the rgbgen+texture and hope other things work out
pass - > rgbgen = RGB_GEN_VERTEX_LIGHTING ;
pass - > flags & = ~ SHADER_PASS_LIGHTMAP ;
pass - > tcgen = T_GEN_SINGLEMAP ;
goto done ;
}
2004-10-19 15:56:22 +00:00
// 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...
2016-07-12 00:40:13 +00:00
if ( ! TEXVALID ( s - > defaulttextures - > specular ) & & ! ( s - > flags & SHADER_HASGLOSS ) )
2014-03-30 08:55:06 +00:00
{
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 )
2015-05-03 19:57:46 +00:00
s - > defaulttextures - > specular = pass - > anim_frames [ 0 ] ;
2014-03-30 08:55:06 +00:00
}
}
2016-07-12 00:40:13 +00:00
if ( ! TEXVALID ( s - > defaulttextures - > base ) & & ! ( s - > flags & SHADER_HASDIFFUSE ) & & ! s - > prog )
{ //if one of the other passes specifies $diffuse, don't try and guess one, because that means that other pass's texture gets used for BOTH passes, which isn't good.
//also, don't guess one if a program was specified.
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 ;
2019-04-01 10:16:36 +00:00
if ( pass - > texgen ! = T_GEN_ANIMMAP & & pass - > texgen ! = T_GEN_SINGLEMAP
# ifdef HAVE_MEDIA_DECODER
& & pass - > texgen ! = T_GEN_VIDEOMAP
# endif
)
2014-03-30 08:55:06 +00:00
weight + = 1000 ;
2015-02-07 22:34:22 +00:00
if ( ( pass - > texgen = = T_GEN_ANIMMAP | | pass - > texgen = = T_GEN_SINGLEMAP ) & & pass - > anim_frames [ 0 ] & & * pass - > anim_frames [ 0 ] - > ident = = ' $ ' )
weight + = 1500 ;
2014-03-30 08:55:06 +00:00
if ( weight < bestweight )
{
bestweight = weight ;
best = pass ;
}
}
if ( best )
{
if ( best - > texgen = = T_GEN_ANIMMAP | | best - > texgen = = T_GEN_SINGLEMAP )
2015-03-03 07:54:10 +00:00
{
if ( best - > anim_frames [ 0 ] & & * best - > anim_frames [ 0 ] - > ident ! = ' $ ' )
2015-05-03 19:57:46 +00:00
s - > defaulttextures - > base = best - > anim_frames [ 0 ] ;
2015-03-03 07:54:10 +00:00
}
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2014-03-30 08:55:06 +00:00
else if ( pass - > texgen = = T_GEN_VIDEOMAP & & pass - > cin )
2015-05-03 19:57:46 +00:00
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
}
2018-12-28 00:04:36 +00:00
for ( i = 0 ; i < s - > numpasses ; i + = ( pass - > prog ? pass - > numMergedPasses : 1 ) )
2009-11-04 21:16:50 +00:00
{
2018-12-28 00:04:36 +00:00
pass = s - > passes + i ;
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
{
2019-12-10 14:50:47 +00:00
if ( pass - > texgen = = T_GEN_LIGHTMAP & & r_forceprogramify . ival = = 2 )
continue ; //pretend its blended.
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 )
{
2018-01-22 19:18:04 +00:00
int maskpass ;
qboolean isopaque = false ;
2004-10-19 15:56:22 +00:00
2018-01-22 19:18:04 +00:00
maskpass = - 1 ;
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 + + )
{
2010-07-11 02:22:39 +00:00
if ( pass - > shaderbits & SBITS_ATEST_BITS )
2009-11-04 21:16:50 +00:00
{
2018-01-22 19:18:04 +00:00
maskpass = i ;
}
else if ( ( pass - > shaderbits & SBITS_MASK_BITS ) = = 0 )
{ //a few shaders use blendfunc one zero so that they're ignored when using r_vertexlight (while later alpha-masked surfs are not).
if ( /*(pass->shaderbits & (SBITS_SRCBLEND_BITS|SBITS_DSTBLEND_BITS)) == 0 ||*/
( pass - > shaderbits & ( SBITS_SRCBLEND_BITS | SBITS_DSTBLEND_BITS ) ) = = ( SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ZERO ) )
isopaque = true ;
2004-10-19 15:56:22 +00:00
}
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
2018-01-22 19:18:04 +00:00
Shader_SetBlendmode ( pass , i ? pass - 1 : NULL ) ;
2012-01-01 11:22:24 +00:00
2020-02-11 18:06:10 +00:00
if ( pass - > blendmode = = PBM_ADD & & ! s - > defaulttextures - > fullbright )
2015-05-03 19:57:46 +00:00
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 )
{
2018-01-22 19:18:04 +00:00
if ( isopaque )
s - > sort = SHADER_SORT_OPAQUE ;
else if ( maskpass = = - 1 )
{
if ( s - > numpasses & & s - > passes [ 0 ] . blendmode = = PBM_ADD )
s - > sort = SHADER_SORT_ADDITIVE ;
else
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
2018-01-22 19:18:04 +00:00
Shader_SetBlendmode ( sp , j ? sp - 1 : NULL ) ;
2004-10-19 15:56:22 +00:00
}
2009-11-04 21:16:50 +00:00
if ( ! s - > sort )
{
2018-12-29 07:43:02 +00:00
if ( i < s - > numpasses & & ( s - > passes [ i ] . 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
{
2018-12-29 07:43:02 +00:00
s - > passes - > 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 ;
2018-01-22 19:18:04 +00:00
for ( j = 1 ; j < s - > numpasses - i & & j = = pass - > numMergedPasses & & j + 1 < be_maxpasses ; j + + )
2009-11-04 21:16:50 +00:00
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 )
{
2021-05-13 10:17:27 +00:00
extern cvar_t r_refract_fbo ;
if ( ( s - > flags & SHADER_HASREFRACT ) & & ! r_refract_fbo . ival )
s - > sort = SHADER_SORT_UNDERWATER ;
else
s - > sort = SHADER_SORT_OPAQUE ;
2004-10-19 15:56:22 +00:00
}
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 ) ;
2017-02-11 16:14:06 +00:00
if ( * mask | | ( s - > prog & & s - > prog - > tess ) )
s - > bemoverrides [ bemoverride_depthonly ] = R_RegisterShader ( va ( " depthonly%s%s " , mask , ( s - > prog & & s - > prog - > tess ) ? " #TESS " : " " ) , SUF_NONE ,
2014-03-30 08:55:06 +00:00
" { \n "
" program depthonly \n "
" { \n "
" map $diffuse \n "
" depthwrite \n "
" maskcolor \n "
" } \n "
" } \n " ) ;
}
2017-02-11 16:14:06 +00:00
if ( ! s - > bemoverrides [ LSHADER_STANDARD ] & & ( s - > prog & & s - > prog - > tess ) )
{
int mode ;
for ( mode = 0 ; mode < LSHADER_MODES ; mode + + )
{
if ( ( mode & LSHADER_CUBE ) & & ( mode & LSHADER_SPOT ) )
continue ;
if ( s - > bemoverrides [ mode ] )
continue ;
s - > bemoverrides [ mode ] = R_RegisterShader ( va ( " rtlight%s%s%s%s#TESS " ,
( mode & LSHADER_SMAP ) ? " #PCF " : " " ,
( mode & LSHADER_SPOT ) ? " #SPOT " : " " ,
( mode & LSHADER_CUBE ) ? " #CUBE " : " " ,
# ifdef GLQUAKE
( qrenderer = = QR_OPENGL & & gl_config . arb_shadow & & ( mode & ( LSHADER_SMAP | LSHADER_SPOT ) ) ) ? " #USE_ARB_SHADOW " : " "
# else
" "
# endif
)
, s - > usageflags ,
" { \n "
" program rtlight \n "
" { \n "
" map $diffuse \n "
" blendfunc add \n "
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
" nodepth \n "
2017-02-11 16:14:06 +00:00
" } \n "
" } \n " ) ;
}
}
2014-03-30 08:55:06 +00:00
2019-03-12 05:04:27 +00:00
if ( ! s - > prog & & sh_config . progs_supported & & ( r_forceprogramify . ival | | ( ps - > parseflags & SPF_PROGRAMIFY ) ) )
2015-05-03 19:57:46 +00:00
{
if ( r_forceprogramify . ival > = 2 )
{
if ( s - > passes [ 0 ] . numtcmods = = 1 & & s - > passes [ 0 ] . tcmods [ 0 ] . type = = SHADER_TCMOD_SCALE )
s - > passes [ 0 ] . numtcmods = 0 ; //DP sucks and doesn't use normalized texture coords *if* there's a shader specified. so lets ignore any extra scaling that this imposes.
2016-07-12 00:40:13 +00:00
if ( s - > passes [ 0 ] . shaderbits & SBITS_ATEST_BITS ) //mimic DP's limited alphafunc support
s - > passes [ 0 ] . shaderbits = ( s - > passes [ 0 ] . shaderbits & ~ SBITS_ATEST_BITS ) | SBITS_ATEST_GE128 ;
2018-04-27 16:40:50 +00:00
s - > passes [ 0 ] . shaderbits & = ~ SBITS_DEPTHFUNC_BITS ; //DP ignores this too.
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
if ( s - > flags & SHADER_CULL_BACK ) //DP has no back-face culling
s - > flags = ( s - > flags & ~ SHADER_CULL_BACK ) | SHADER_CULL_FRONT ;
//disable rtlight stuff when blended.
if ( ( s - > passes [ 0 ] . shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_ONE & & ( s - > passes [ 0 ] . shaderbits & SBITS_DSTBLEND_BITS ) = = SBITS_DSTBLEND_ZERO )
; //replace
else if ( ( s - > passes [ 0 ] . shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_ONE & & ( s - > passes [ 0 ] . shaderbits & SBITS_DSTBLEND_BITS ) = = SBITS_DSTBLEND_ONE )
s - > flags | = SHADER_NOSHADOWS ; //add-ignore-alpha
else if ( ( s - > passes [ 0 ] . shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_SRC_ALPHA & & ( s - > passes [ 0 ] . shaderbits & SBITS_DSTBLEND_BITS ) = = SBITS_DSTBLEND_ONE )
s - > flags | = SHADER_NOSHADOWS ; //add-with-alpha
else if ( ( s - > passes [ 0 ] . shaderbits & SBITS_SRCBLEND_BITS ) = = SBITS_SRCBLEND_SRC_ALPHA & & ( s - > passes [ 0 ] . shaderbits & SBITS_DSTBLEND_BITS ) = = SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA )
s - > flags | = SHADER_NOSHADOWS ; //blended
else
s - > flags | = SHADER_NOSHADOWS | SHADER_NODLIGHT ; //erk...
if ( s - > passes [ 0 ] . numtcmods > 1 )
{ //reverse the order of tcmods (dp uses a texture matrix which it concats in reverse order)
tcmod_t tmp [ SHADER_MAX_TC_MODS ] ;
int j ;
memcpy ( tmp , s - > passes [ 0 ] . tcmods , sizeof ( * tmp ) * s - > passes [ 0 ] . numtcmods ) ;
for ( j = 0 ; j < s - > passes [ 0 ] . numtcmods ; j + + )
s - > passes [ 0 ] . tcmods [ j ] = tmp [ s - > passes [ 0 ] . numtcmods - 1 - j ] ;
}
2015-05-03 19:57:46 +00:00
}
2019-03-12 05:04:27 +00:00
Shader_Programify ( ps ) ;
2015-05-03 19:57:46 +00:00
}
2014-03-30 08:55:06 +00:00
2011-02-25 04:22:14 +00:00
if ( s - > prog )
2006-03-11 03:12:10 +00:00
{
2015-03-03 00:14:43 +00:00
struct
{
int gen ;
unsigned int flags ;
} defaulttgen [ ] =
{
2016-07-12 00:40:13 +00:00
//light
2019-02-01 08:29:14 +00:00
{ T_GEN_SHADOWMAP , 0 } , //0
{ T_GEN_LIGHTCUBEMAP , 0 } , //1
2016-07-12 00:40:13 +00:00
//material
2019-02-01 08:29:14 +00:00
{ T_GEN_DIFFUSE , SHADER_HASDIFFUSE } , //2
{ T_GEN_NORMALMAP , SHADER_HASNORMALMAP } , //3
{ T_GEN_SPECULAR , SHADER_HASGLOSS } , //4
{ T_GEN_UPPEROVERLAY , SHADER_HASTOPBOTTOM } , //5
{ T_GEN_LOWEROVERLAY , SHADER_HASTOPBOTTOM } , //6
{ T_GEN_FULLBRIGHT , SHADER_HASFULLBRIGHT } , //7
{ T_GEN_PALETTED , SHADER_HASPALETTED } , //8
2019-10-15 18:10:14 +00:00
{ T_GEN_REFLECTCUBE , SHADER_HASREFLECTCUBE } , //9
2019-02-01 08:29:14 +00:00
{ T_GEN_REFLECTMASK , 0 } , //10
{ T_GEN_DISPLACEMENT , SHADER_HASDISPLACEMENT } , //11
2019-09-04 07:59:40 +00:00
{ T_GEN_OCCLUSION , 0 } , //12
2016-07-12 00:40:13 +00:00
// {T_GEN_REFLECTION, SHADER_HASREFLECT}, //
// {T_GEN_REFRACTION, SHADER_HASREFRACT}, //
// {T_GEN_REFRACTIONDEPTH, SHADER_HASREFRACTDEPTH},//
// {T_GEN_RIPPLEMAP, SHADER_HASRIPPLEMAP}, //
//batch
2019-09-04 07:59:40 +00:00
{ T_GEN_LIGHTMAP , SHADER_HASLIGHTMAP } , //13
{ T_GEN_DELUXMAP , 0 } , //14
//more lightmaps //15,16,17
//mode deluxemaps //18,19,20
2015-03-03 00:14:43 +00:00
} ;
2015-05-03 19:57:46 +00:00
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
cin_t * cin = R_ShaderGetCinematic ( s ) ;
2015-05-03 20:15:32 +00:00
# endif
2015-05-03 19:57:46 +00:00
2015-03-03 00:14:43 +00:00
//if the glsl doesn't specify all samplers, just trim them.
s - > numpasses = s - > prog - > numsamplers ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
if ( cin & & R_ShaderGetCinematic ( s ) = = cin )
cin = NULL ;
2015-05-03 20:15:32 +00:00
# endif
2015-05-03 19:57:46 +00:00
2015-03-03 00:14:43 +00:00
//if the glsl has specific textures listed, be sure to provide a pass for them.
for ( i = 0 ; i < sizeof ( defaulttgen ) / sizeof ( defaulttgen [ 0 ] ) ; i + + )
{
if ( s - > prog - > defaulttextures & ( 1u < < i ) )
{
2015-05-03 19:57:46 +00:00
if ( s - > numpasses > = SHADER_PASS_MAX )
break ; //panic...
2015-03-03 00:14:43 +00:00
s - > passes [ s - > numpasses ] . flags & = ~ SHADER_PASS_DEPTHCMP ;
if ( defaulttgen [ i ] . gen = = T_GEN_SHADOWMAP )
s - > passes [ s - > numpasses ] . flags | = SHADER_PASS_DEPTHCMP ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
if ( ! i & & cin )
{
s - > passes [ s - > numpasses ] . texgen = T_GEN_VIDEOMAP ;
s - > passes [ s - > numpasses ] . cin = cin ;
cin = NULL ;
}
else
2015-05-03 20:15:32 +00:00
# endif
2015-05-03 19:57:46 +00:00
{
s - > passes [ s - > numpasses ] . texgen = defaulttgen [ i ] . gen ;
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
s - > passes [ s - > numpasses ] . cin = NULL ;
2015-05-03 20:15:32 +00:00
# endif
2015-05-03 19:57:46 +00:00
}
2015-03-03 00:14:43 +00:00
s - > numpasses + + ;
s - > flags | = defaulttgen [ i ] . flags ;
}
}
//must have at least one texture.
2006-03-11 03:12:10 +00:00
if ( ! s - > numpasses )
2014-03-30 08:55:06 +00:00
{
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
s - > passes [ 0 ] . texgen = cin ? T_GEN_VIDEOMAP : T_GEN_DIFFUSE ;
s - > passes [ 0 ] . cin = cin ;
2015-05-03 20:15:32 +00:00
# else
s - > passes [ 0 ] . texgen = T_GEN_DIFFUSE ;
# endif
2006-03-11 03:12:10 +00:00
s - > numpasses = 1 ;
2014-03-30 08:55:06 +00:00
}
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-05-03 19:57:46 +00:00
else if ( cin )
Media_ShutdownCin ( cin ) ;
2015-05-03 20:15:32 +00:00
# endif
2006-03-11 03:12:10 +00:00
s - > passes - > numMergedPasses = s - > numpasses ;
}
2015-09-01 04:45:15 +00:00
else if ( s - > numdeforms )
s - > flags | = SHADER_NEEDSARRAYS ;
else
{
for ( i = 0 ; i < s - > numpasses ; i + + )
{
2015-09-06 03:30:28 +00:00
pass = & s - > passes [ i ] ;
2018-05-21 13:47:53 +00:00
if ( pass - > prog )
continue ;
2015-09-06 03:30:28 +00:00
if ( pass - > numtcmods | | ( s - > passes [ i ] . tcgen ! = TC_GEN_BASE & & s - > passes [ i ] . tcgen ! = TC_GEN_LIGHTMAP ) | | ! ( s - > passes [ i ] . flags & SHADER_PASS_NOCOLORARRAY ) )
2015-09-01 04:45:15 +00:00
{
s - > flags | = SHADER_NEEDSARRAYS ;
break ;
}
2015-09-06 03:30:28 +00:00
if ( ! ( pass - > flags & SHADER_PASS_NOCOLORARRAY ) )
{
if ( ! ( ( ( pass - > rgbgen = = RGB_GEN_VERTEX_LIGHTING ) | |
( pass - > rgbgen = = RGB_GEN_VERTEX_EXACT ) | |
( pass - > rgbgen = = RGB_GEN_ONE_MINUS_VERTEX ) ) & &
( pass - > alphagen = = ALPHA_GEN_VERTEX ) ) )
{
s - > flags | = SHADER_NEEDSARRAYS ;
break ;
}
}
2015-09-01 04:45:15 +00:00
}
}
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
}
}
}
*/
2015-02-02 08:01:53 +00:00
/*
if ( * shader_diffusemapname )
{
if ( ! s - > defaulttextures . base )
s - > defaulttextures . base = Shader_FindImage ( va ( " %s.tga " , shader_diffusemapname ) , 0 ) ;
if ( ! s - > defaulttextures . bump )
s - > defaulttextures . bump = Shader_FindImage ( va ( " %s_norm.tga " , shader_diffusemapname ) , 0 ) ;
if ( ! s - > defaulttextures . fullbright )
s - > defaulttextures . fullbright = Shader_FindImage ( va ( " %s_glow.tga " , shader_diffusemapname ) , 0 ) ;
if ( ! s - > defaulttextures . specular )
s - > defaulttextures . specular = Shader_FindImage ( va ( " %s_gloss.tga " , shader_diffusemapname ) , 0 ) ;
if ( ! s - > defaulttextures . upperoverlay )
s - > defaulttextures . upperoverlay = Shader_FindImage ( va ( " %s_shirt.tga " , shader_diffusemapname ) , 0 ) ;
if ( ! s - > defaulttextures . loweroverlay )
s - > defaulttextures . loweroverlay = Shader_FindImage ( va ( " %s_pants.tga " , shader_diffusemapname ) , 0 ) ; //stupid yanks...
}
*/
2018-09-29 17:31:58 +00:00
void QDECL R_BuildDefaultTexnums ( texnums_t * src , shader_t * shader , unsigned int imageflags )
2004-10-19 15:56:22 +00:00
{
2014-02-07 08:38:40 +00:00
char * h ;
char imagename [ MAX_QPATH ] ;
2015-05-03 19:57:46 +00:00
char mapname [ MAX_QPATH ] ;
2014-10-05 20:04:11 +00:00
char * subpath = NULL ;
2015-05-03 19:57:46 +00:00
texnums_t * tex ;
unsigned int a , aframes ;
2014-02-07 08:38:40 +00:00
strcpy ( imagename , shader - > name ) ;
h = strchr ( imagename , ' # ' ) ;
if ( h )
* h = 0 ;
2015-03-03 00:14:43 +00:00
if ( * imagename = = ' / ' | | strchr ( imagename , ' : ' ) )
{ //this is not security. this is anti-spam for the verbose security in the filesystem code.
Con_Printf ( " Warning: shader has absolute path: %s \n " , shader - > name ) ;
* imagename = 0 ;
}
2014-02-07 08:38:40 +00:00
2014-10-05 20:04:11 +00:00
//skins can use an alternative path in certain cases, to work around dodgy models.
if ( shader - > generator = = Shader_DefaultSkin )
subpath = shader - > genargs ;
2015-05-03 19:57:46 +00:00
tex = shader - > defaulttextures ;
aframes = max ( 1 , shader - > numdefaulttextures ) ;
//if any were specified explicitly, replicate that into all.
//this means animmap can be used, with any explicit textures overriding all.
if ( ! shader - > numdefaulttextures & & src )
{
//only do this if there wasn't an animmap thing to break everything.
if ( ! TEXVALID ( tex - > base ) )
tex - > base = src - > base ;
if ( ! TEXVALID ( tex - > bump ) )
tex - > bump = src - > bump ;
if ( ! TEXVALID ( tex - > fullbright ) )
tex - > fullbright = src - > fullbright ;
if ( ! TEXVALID ( tex - > specular ) )
tex - > specular = src - > specular ;
if ( ! TEXVALID ( tex - > loweroverlay ) )
tex - > loweroverlay = src - > loweroverlay ;
if ( ! TEXVALID ( tex - > upperoverlay ) )
tex - > upperoverlay = src - > upperoverlay ;
if ( ! TEXVALID ( tex - > reflectmask ) )
tex - > reflectmask = src - > reflectmask ;
if ( ! TEXVALID ( tex - > reflectcube ) )
tex - > reflectcube = src - > reflectcube ;
2019-02-01 08:29:14 +00:00
if ( ! TEXVALID ( tex - > displacement ) )
tex - > displacement = src - > displacement ;
2015-05-03 19:57:46 +00:00
}
for ( a = 1 ; a < aframes ; a + + )
{
if ( ! TEXVALID ( tex [ a ] . base ) )
tex [ a ] . base = tex [ 0 ] . base ;
if ( ! TEXVALID ( tex [ a ] . bump ) )
tex [ a ] . bump = tex [ 0 ] . bump ;
if ( ! TEXVALID ( tex [ a ] . fullbright ) )
tex [ a ] . fullbright = tex [ 0 ] . fullbright ;
if ( ! TEXVALID ( tex [ a ] . specular ) )
tex [ a ] . specular = tex [ 0 ] . specular ;
if ( ! TEXVALID ( tex [ a ] . loweroverlay ) )
tex [ a ] . loweroverlay = tex [ 0 ] . loweroverlay ;
if ( ! TEXVALID ( tex [ a ] . upperoverlay ) )
tex [ a ] . upperoverlay = tex [ 0 ] . upperoverlay ;
if ( ! TEXVALID ( tex [ a ] . reflectmask ) )
tex [ a ] . reflectmask = tex [ 0 ] . reflectmask ;
if ( ! TEXVALID ( tex [ a ] . reflectcube ) )
tex [ a ] . reflectcube = tex [ 0 ] . reflectcube ;
2019-02-01 08:29:14 +00:00
if ( ! TEXVALID ( tex [ a ] . displacement ) )
tex [ a ] . displacement = tex [ 0 ] . displacement ;
2015-05-03 19:57:46 +00:00
}
for ( a = 0 ; a < aframes ; a + + , tex + + )
{
COM_StripExtension ( tex - > mapname , mapname , sizeof ( mapname ) ) ;
if ( ! TEXVALID ( tex - > base ) )
{
/*dlights/realtime lighting needs some stuff*/
if ( ! TEXVALID ( tex - > base ) & & * tex - > mapname ) // && (shader->flags & SHADER_HASDIFFUSE))
2018-09-29 17:31:58 +00:00
tex - > base = R_LoadHiResTexture ( tex - > mapname , NULL , imageflags ) ;
2016-07-12 00:40:13 +00:00
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > base ) )
2018-09-29 17:31:58 +00:00
tex - > base = R_LoadHiResTexture ( imagename , subpath , ( * imagename = = ' { ' ) ? 0 : IF_NOALPHA | imageflags ) ;
2015-05-03 19:57:46 +00:00
}
2004-10-19 15:56:22 +00:00
2016-07-12 00:40:13 +00:00
if ( ( shader - > flags & SHADER_HASPALETTED ) & & ! TEXVALID ( tex - > paletted ) )
2015-05-03 19:57:46 +00:00
{
2016-11-25 08:14:54 +00:00
if ( ! TEXVALID ( tex - > paletted ) & & * tex - > mapname )
2018-09-29 17:31:58 +00:00
tex - > paletted = R_LoadHiResTexture ( va ( " %s " , tex - > mapname ) , NULL , 0 | IF_NEAREST | IF_PALETTIZE | imageflags ) ;
2016-11-25 08:14:54 +00:00
if ( ! TEXVALID ( tex - > paletted ) )
2018-09-29 17:31:58 +00:00
tex - > paletted = R_LoadHiResTexture ( va ( " %s " , imagename ) , subpath , ( ( * imagename = = ' { ' ) ? 0 : IF_NOALPHA ) | IF_NEAREST | IF_PALETTIZE | imageflags ) ;
2015-05-03 19:57:46 +00:00
}
2015-02-07 22:34:22 +00:00
2015-05-03 19:57:46 +00:00
imageflags | = IF_LOWPRIORITY ;
2015-02-07 22:34:22 +00:00
2015-05-03 19:57:46 +00:00
COM_StripExtension ( imagename , imagename , sizeof ( imagename ) ) ;
2015-04-14 23:12:17 +00:00
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > bump ) )
2012-01-17 07:57:46 +00:00
{
2015-05-03 19:57:46 +00:00
if ( r_loadbumpmapping | | ( shader - > flags & SHADER_HASNORMALMAP ) )
{
if ( ! TEXVALID ( tex - > bump ) & & * mapname & & ( shader - > flags & SHADER_HASNORMALMAP ) )
2018-09-29 17:31:58 +00:00
tex - > bump = R_LoadHiResTexture ( va ( " %s_norm " , mapname ) , NULL , imageflags | IF_TRYBUMP | IF_NOSRGB | imageflags ) ;
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > bump ) )
2018-09-29 17:31:58 +00:00
tex - > bump = R_LoadHiResTexture ( va ( " %s_norm " , imagename ) , subpath , imageflags | IF_TRYBUMP | IF_NOSRGB | imageflags ) ;
2015-05-03 19:57:46 +00:00
}
2012-01-17 07:57:46 +00:00
}
2010-07-18 12:52:24 +00:00
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > loweroverlay ) )
2012-01-17 07:57:46 +00:00
{
2015-05-03 19:57:46 +00:00
if ( shader - > flags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tex - > loweroverlay ) & & * mapname )
tex - > loweroverlay = R_LoadHiResTexture ( va ( " %s_pants " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > loweroverlay ) )
tex - > loweroverlay = R_LoadHiResTexture ( va ( " %s_pants " , imagename ) , subpath , imageflags ) ; /*how rude*/
}
2012-01-17 07:57:46 +00:00
}
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > upperoverlay ) )
2012-01-17 07:57:46 +00:00
{
2015-05-03 19:57:46 +00:00
if ( shader - > flags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tex - > upperoverlay ) & & * mapname )
tex - > upperoverlay = R_LoadHiResTexture ( va ( " %s_shirt " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > upperoverlay ) )
tex - > upperoverlay = R_LoadHiResTexture ( va ( " %s_shirt " , imagename ) , subpath , imageflags ) ;
}
2012-01-17 07:57:46 +00:00
}
2004-10-19 15:56:22 +00:00
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > specular ) )
2012-11-27 03:23:19 +00:00
{
2015-05-03 19:57:46 +00:00
extern cvar_t gl_specular ;
if ( ( shader - > flags & SHADER_HASGLOSS ) & & gl_specular . value & & gl_load24bit . value )
{
if ( ! TEXVALID ( tex - > specular ) & & * mapname )
tex - > specular = R_LoadHiResTexture ( va ( " %s_gloss " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > specular ) )
tex - > specular = R_LoadHiResTexture ( va ( " %s_gloss " , imagename ) , subpath , imageflags ) ;
}
2012-11-27 03:23:19 +00:00
}
2014-06-22 23:44:30 +00:00
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > fullbright ) )
2014-06-22 23:44:30 +00:00
{
2015-05-03 19:57:46 +00:00
extern cvar_t r_fb_bmodels ;
if ( ( shader - > flags & SHADER_HASFULLBRIGHT ) & & r_fb_bmodels . value & & gl_load24bit . value )
{
if ( ! TEXVALID ( tex - > fullbright ) & & * mapname )
2016-08-25 00:12:14 +00:00
tex - > fullbright = R_LoadHiResTexture ( va ( " %s_luma:%s_glow " , mapname , mapname ) , NULL , imageflags ) ;
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > fullbright ) )
2016-08-25 00:12:14 +00:00
tex - > fullbright = R_LoadHiResTexture ( va ( " %s_luma:%s_glow " , imagename , imagename ) , subpath , imageflags ) ;
2015-05-03 19:57:46 +00:00
}
2014-06-22 23:44:30 +00:00
}
2018-09-23 19:35:24 +00:00
//if there's a reflectcube texture specified by the shader, make sure we have a reflectmask to go with it.
if ( tex - > reflectcube )
{
if ( ! TEXVALID ( tex - > reflectmask ) & & * mapname )
tex - > reflectmask = R_LoadHiResTexture ( va ( " %s_reflect " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > reflectmask ) )
tex - > reflectmask = R_LoadHiResTexture ( va ( " %s_reflect " , imagename ) , subpath , imageflags ) ;
}
2014-06-22 23:44:30 +00:00
}
2004-10-19 15:56:22 +00:00
}
2018-03-04 14:41:16 +00:00
#if 0 //def Q2BSPS
static qbyte * ReadRGBA8ImageFile ( const char * fname , const char * subpath , int * width , int * height )
{
qboolean hasalpha ;
qofs_t filesize ;
qbyte * img , * filedata = NULL ;
char * patterns [ ] =
{
" *overrides/%s.tga " ,
" *overrides/%s.jpg " ,
" textures/%s.tga " ,
" textures/%s.jpg " ,
} ;
char nname [ MAX_QPATH ] ;
size_t p ;
for ( p = 0 ; p < countof ( patterns ) & & ! filedata ; p + + )
{
if ( * patterns [ p ] = = ' * ' )
Q_snprintfz ( nname , sizeof ( nname ) , patterns [ p ] + 1 , COM_SkipPath ( fname ) ) ;
else
Q_snprintfz ( nname , sizeof ( nname ) , patterns [ p ] , fname ) ;
filedata = FS_MallocFile ( nname , FS_GAME , & filesize ) ;
}
img = filedata ? Read32BitImageFile ( filedata , filesize , width , height , & hasalpha , fname ) : NULL ;
BZ_Free ( filedata ) ;
return img ;
}
# endif
2015-03-03 00:14:43 +00:00
//call this with some fallback textures to directly load some textures
2020-03-07 09:00:40 +00:00
void QDECL R_BuildLegacyTexnums ( shader_t * shader , const char * fallbackname , const char * subpath , unsigned int loadflags , unsigned int imageflags , uploadfmt_t basefmt , size_t width , size_t height , qbyte * srcdata , qbyte * palette )
2015-03-03 00:14:43 +00:00
{
char * h ;
char imagename [ MAX_QPATH ] ;
2015-05-03 19:57:46 +00:00
char mapname [ MAX_QPATH ] ; //as specified by the shader.
2015-04-14 23:12:17 +00:00
//extern cvar_t gl_miptexLevel;
2015-05-03 19:57:46 +00:00
texnums_t * tex = shader - > defaulttextures ;
int a , aframes ;
2015-04-14 23:12:17 +00:00
/*else if (gl_miptexLevel.ival)
{
unsigned int miplevel = 0 , i ;
for ( i = 0 ; i < 3 & & i < gl_miptexLevel . ival & & mipdata [ i ] ; i + + )
miplevel = i ;
for ( i = 0 ; i < 3 ; i + + )
dontcrashme [ i ] = ( miplevel + i ) > 3 ? NULL : mipdata [ miplevel + i ] ;
width > > = miplevel ;
height > > = miplevel ;
mipdata = dontcrashme ;
}
*/
2015-03-03 00:14:43 +00:00
strcpy ( imagename , shader - > name ) ;
h = strchr ( imagename , ' # ' ) ;
if ( h )
* h = 0 ;
if ( * imagename = = ' / ' | | strchr ( imagename , ' : ' ) )
{ //this is not security. this is anti-spam for the verbose security in the filesystem code.
Con_Printf ( " Warning: shader has absolute path: %s \n " , shader - > name ) ;
* imagename = 0 ;
}
2015-09-18 20:30:10 +00:00
//for water texture replacements
while ( ( h = strchr ( imagename , ' * ' ) ) )
* h = ' # ' ;
2015-03-03 00:14:43 +00:00
loadflags & = shader - > flags ;
//skins can use an alternative path in certain cases, to work around dodgy models.
if ( shader - > generator = = Shader_DefaultSkin )
subpath = shader - > genargs ;
2016-12-09 09:09:12 +00:00
//optimise away any palette info if we can...
if ( ! palette | | palette = = host_basepal )
{
if ( basefmt = = TF_MIP4_8PAL24 )
basefmt = TF_MIP4_SOLID8 ;
// if (basefmt == TF_MIP4_8PAL24_T255)
// basefmt = TF_MIP4_TRANS8;
}
2015-04-14 23:12:17 +00:00
2015-03-03 00:14:43 +00:00
//make sure the noalpha thing is set properly.
2016-12-09 09:09:12 +00:00
switch ( basefmt )
{
2019-03-01 22:39:30 +00:00
case TF_MIP4_P8 :
2016-12-09 09:09:12 +00:00
case TF_MIP4_8PAL24 :
case TF_MIP4_SOLID8 :
case TF_SOLID8 :
imageflags | = IF_NOALPHA ;
2019-03-01 22:39:30 +00:00
//fallthrough
case TF_MIP4_8PAL24_T255 :
2020-03-07 09:00:40 +00:00
if ( ! srcdata )
2016-12-09 09:09:12 +00:00
basefmt = TF_SOLID8 ;
break ;
default :
break ;
}
2015-03-03 00:14:43 +00:00
imageflags | = IF_MIPCAP ;
COM_StripExtension ( imagename , imagename , sizeof ( imagename ) ) ;
2015-05-03 19:57:46 +00:00
aframes = max ( 1 , shader - > numdefaulttextures ) ;
//if any were specified explicitly, replicate that into all.
//this means animmap can be used, with any explicit textures overriding all.
for ( a = 1 ; a < aframes ; a + + )
{
if ( ! TEXVALID ( tex [ a ] . base ) )
tex [ a ] . base = tex [ 0 ] . base ;
if ( ! TEXVALID ( tex [ a ] . bump ) )
tex [ a ] . bump = tex [ 0 ] . bump ;
if ( ! TEXVALID ( tex [ a ] . fullbright ) )
tex [ a ] . fullbright = tex [ 0 ] . fullbright ;
if ( ! TEXVALID ( tex [ a ] . specular ) )
tex [ a ] . specular = tex [ 0 ] . specular ;
if ( ! TEXVALID ( tex [ a ] . loweroverlay ) )
tex [ a ] . loweroverlay = tex [ 0 ] . loweroverlay ;
if ( ! TEXVALID ( tex [ a ] . upperoverlay ) )
tex [ a ] . upperoverlay = tex [ 0 ] . upperoverlay ;
if ( ! TEXVALID ( tex [ a ] . reflectmask ) )
tex [ a ] . reflectmask = tex [ 0 ] . reflectmask ;
if ( ! TEXVALID ( tex [ a ] . reflectcube ) )
tex [ a ] . reflectcube = tex [ 0 ] . reflectcube ;
2019-02-01 08:29:14 +00:00
if ( ! TEXVALID ( tex [ a ] . displacement ) )
tex [ a ] . displacement = tex [ 0 ] . displacement ;
2015-05-03 19:57:46 +00:00
}
for ( a = 0 ; a < aframes ; a + + , tex + + )
{
COM_StripExtension ( tex - > mapname , mapname , sizeof ( mapname ) ) ;
2018-03-04 14:41:16 +00:00
#if 0 //def Q2BSPS
if ( gl_load24bit . ival = = 2 )
{
qbyte * base ;
int basewidth , baseheight ;
qbyte * norm ;
int normwidth , normheight ;
qbyte tmp ;
int x , y ;
base = ReadRGBA8ImageFile ( imagename , subpath , & basewidth , & baseheight ) ;
//base contains diffuse RGB, and height
if ( base )
{
tex - > base = Image_GetTexture ( va ( " %s_diff " , imagename ) , subpath , imageflags | IF_NOREPLACE , base , NULL , basewidth , baseheight , TF_RGBX32 ) ; //queues the texture creation.
norm = ReadRGBA8ImageFile ( va ( " %s_bump " , imagename ) , subpath , & normwidth , & normheight ) ;
if ( norm )
{
if ( normwidth ! = basewidth | | normheight ! = baseheight )
{
//sucks...
tex - > bump = Image_GetTexture ( va ( " %s_norm " , imagename ) , subpath , imageflags | IF_NOREPLACE , norm , NULL , normwidth , normheight , TF_RGBX32 ) ; //queues the texture creation.
}
else
{
//so we have a base texture, and normalmap
//we already uploaded the diffuse, so now we can just pretend that the base is the specularmap.
//we just need to swap the two alpha channels.
for ( y = 0 ; y < baseheight ; y + + )
{
for ( x = 0 ; x < basewidth ; x + + )
{
tmp = base [ ( x + y * basewidth ) * 4 + 3 ] ;
base [ ( x + y * basewidth ) * 4 + 3 ] = norm [ ( x + y * basewidth ) * 4 + 3 ] ;
norm [ ( x + y * basewidth ) * 4 + 3 ] = ( ( x + y ) & 1 ) * 255 ; //tmp;
}
}
tex - > bump = Image_GetTexture ( va ( " %s_norm " , imagename ) , subpath , imageflags | IF_NOREPLACE , norm , NULL , normwidth , normheight , TF_RGBA32 ) ; //queues the texture creation.
tex - > specular = Image_GetTexture ( va ( " %s_spec " , imagename ) , subpath , imageflags | IF_NOREPLACE , base , NULL , basewidth , baseheight , TF_RGBA32 ) ; //queues the texture creation.
}
BZ_Free ( norm ) ;
}
else
{
//generate a height8 image from the alpha channel. we can do it in place
for ( y = 0 ; y < baseheight ; y + + )
{
for ( x = 0 ; x < basewidth ; x + + )
base [ ( x + y * basewidth ) ] = base [ ( x + y * basewidth ) * 4 + 3 ] ;
}
tex - > bump = Image_GetTexture ( va ( " %s_norm " , imagename ) , subpath , imageflags | IF_NOREPLACE , base , NULL , basewidth , baseheight , TF_HEIGHT8 ) ;
}
BZ_Free ( base ) ;
}
}
# endif
2015-05-03 19:57:46 +00:00
/*dlights/realtime lighting needs some stuff*/
if ( loadflags & SHADER_HASDIFFUSE )
2015-04-14 23:12:17 +00:00
{
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > base ) & & * mapname )
tex - > base = R_LoadHiResTexture ( mapname , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > base ) & & fallbackname )
2015-04-14 23:12:17 +00:00
{
2015-05-03 19:57:46 +00:00
if ( gl_load24bit . ival )
2015-04-14 23:12:17 +00:00
{
2015-05-03 19:57:46 +00:00
tex - > base = Image_GetTexture ( imagename , subpath , imageflags | IF_NOWORKER , NULL , NULL , width , height , basefmt ) ;
if ( ! TEXLOADED ( tex - > base ) )
{
tex - > base = Image_GetTexture ( fallbackname , subpath , imageflags | IF_NOWORKER , NULL , NULL , width , height , basefmt ) ;
if ( TEXLOADED ( tex - > base ) )
Q_strncpyz ( imagename , fallbackname , sizeof ( imagename ) ) ;
}
2015-04-14 23:12:17 +00:00
}
2015-05-03 19:57:46 +00:00
if ( ! TEXLOADED ( tex - > base ) )
2020-03-07 09:00:40 +00:00
tex - > base = Image_GetTexture ( imagename , subpath , imageflags , srcdata , palette , width , height , basefmt ) ;
2015-04-14 23:12:17 +00:00
}
2015-05-03 19:57:46 +00:00
else if ( ! TEXVALID ( tex - > base ) )
2020-03-07 09:00:40 +00:00
tex - > base = Image_GetTexture ( imagename , subpath , imageflags , srcdata , palette , width , height , basefmt ) ;
2015-04-14 23:12:17 +00:00
}
2015-03-03 00:14:43 +00:00
2015-05-03 19:57:46 +00:00
if ( loadflags & SHADER_HASPALETTED )
{
if ( ! TEXVALID ( tex - > paletted ) & & * mapname )
tex - > paletted = R_LoadHiResTexture ( va ( " %s_pal " , mapname ) , NULL , imageflags | IF_NEAREST ) ;
if ( ! TEXVALID ( tex - > paletted ) )
2020-03-07 09:00:40 +00:00
tex - > paletted = Image_GetTexture ( va ( " %s_pal " , imagename ) , subpath , imageflags | IF_NEAREST | IF_NOSRGB , srcdata , palette , width , height , ( basefmt = = TF_MIP4_SOLID8 ) ? TF_MIP4_P8 : PTI_P8 ) ;
2015-05-03 19:57:46 +00:00
}
2015-03-03 00:14:43 +00:00
2015-05-03 19:57:46 +00:00
imageflags | = IF_LOWPRIORITY ;
//all the rest need/want an alpha channel in some form.
imageflags & = ~ IF_NOALPHA ;
imageflags | = IF_NOGAMMA ;
2015-03-03 00:14:43 +00:00
2016-07-12 00:40:13 +00:00
if ( loadflags & SHADER_HASNORMALMAP | | * imagename = = ' # ' )
2015-05-03 19:57:46 +00:00
{
extern cvar_t r_shadow_bumpscale_basetexture ;
if ( ! TEXVALID ( tex - > bump ) & & * mapname )
2017-07-12 08:15:27 +00:00
tex - > bump = R_LoadHiResTexture ( va ( " %s_norm " , mapname ) , NULL , imageflags | IF_TRYBUMP | IF_NOSRGB ) ;
2016-07-12 00:40:13 +00:00
if ( ! TEXVALID ( tex - > bump ) & & ( r_shadow_bumpscale_basetexture . ival | | * imagename = = ' # ' | | gl_load24bit . ival ) )
2020-03-07 09:00:40 +00:00
{
qbyte * fallbackheight ;
if ( ( r_shadow_bumpscale_basetexture . ival | | * imagename = = ' # ' ) & & ! ( basefmt & PTI_FULLMIPCHAIN ) )
fallbackheight = srcdata ; //generate normalmap from assumed heights.
else
fallbackheight = NULL ; //disabled
tex - > bump = Image_GetTexture ( va ( " %s_norm " , imagename ) , subpath , imageflags | IF_TRYBUMP | IF_NOSRGB | ( * imagename = = ' # ' ? IF_LINEAR : 0 ) , fallbackheight , palette , width , height , TF_HEIGHT8PAL ) ;
}
2015-05-03 19:57:46 +00:00
}
2015-03-03 00:14:43 +00:00
2015-05-03 19:57:46 +00:00
if ( loadflags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tex - > loweroverlay ) & & * mapname )
tex - > loweroverlay = R_LoadHiResTexture ( va ( " %s_pants " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > loweroverlay ) )
tex - > loweroverlay = Image_GetTexture ( va ( " %s_pants " , imagename ) , subpath , imageflags , NULL , palette , width , height , 0 ) ;
}
if ( loadflags & SHADER_HASTOPBOTTOM )
{
if ( ! TEXVALID ( tex - > upperoverlay ) & & * mapname )
tex - > upperoverlay = R_LoadHiResTexture ( va ( " %s_shirt " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > upperoverlay ) )
tex - > upperoverlay = Image_GetTexture ( va ( " %s_shirt " , imagename ) , subpath , imageflags , NULL , palette , width , height , 0 ) ;
}
2015-03-03 00:14:43 +00:00
2015-05-03 19:57:46 +00:00
if ( loadflags & SHADER_HASGLOSS )
{
if ( ! TEXVALID ( tex - > specular ) & & * mapname )
tex - > specular = R_LoadHiResTexture ( va ( " %s_gloss " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > specular ) )
tex - > specular = Image_GetTexture ( va ( " %s_gloss " , imagename ) , subpath , imageflags , NULL , palette , width , height , 0 ) ;
}
if ( tex - > reflectcube )
{
if ( ! TEXVALID ( tex - > reflectmask ) & & * mapname )
tex - > reflectmask = R_LoadHiResTexture ( va ( " %s_reflect " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > reflectmask ) )
tex - > reflectmask = Image_GetTexture ( va ( " %s_reflect " , imagename ) , subpath , imageflags , NULL , NULL , width , height , TF_INVALID ) ;
}
2015-03-03 00:14:43 +00:00
2015-05-03 19:57:46 +00:00
if ( loadflags & SHADER_HASFULLBRIGHT )
2015-03-03 00:14:43 +00:00
{
2015-05-03 19:57:46 +00:00
if ( ! TEXVALID ( tex - > fullbright ) & & * mapname )
tex - > fullbright = R_LoadHiResTexture ( va ( " %s_luma " , mapname ) , NULL , imageflags ) ;
if ( ! TEXVALID ( tex - > fullbright ) )
2015-03-03 00:14:43 +00:00
{
2015-05-03 19:57:46 +00:00
int s = - 1 ;
2020-03-07 09:00:40 +00:00
if ( srcdata & & ! ( basefmt & PTI_FULLMIPCHAIN ) & & ( ! palette | | palette = = host_basepal ) )
2015-10-11 11:34:58 +00:00
for ( s = width * height - 1 ; s > = 0 ; s - - )
2015-05-03 19:57:46 +00:00
{
2020-03-07 09:00:40 +00:00
if ( srcdata [ s ] > = 256 - vid . fullbright )
2015-05-03 19:57:46 +00:00
break ;
}
2020-03-07 09:00:40 +00:00
tex - > fullbright = Image_GetTexture ( va ( " %s_luma:%s_glow " , imagename , imagename ) , subpath , imageflags , ( s > = 0 ) ? srcdata : NULL , palette , width , height , TF_TRANS8_FULLBRIGHT ) ;
2015-03-03 00:14:43 +00:00
}
}
}
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultScript ( parsestate_t * ps , const char * shortname , 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 + + ;
2019-03-12 05:04:27 +00:00
Shader_ReadShader ( ps , ( void * ) f , NULL ) ;
2009-07-18 20:46:42 +00:00
}
2018-10-14 16:16:34 +00:00
}
2009-07-18 20:46:42 +00:00
2019-03-12 05:04:27 +00:00
void Shader_DefaultBSPLM ( parsestate_t * ps , const char * shortname , const void * args )
2009-11-04 21:16:50 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
2009-11-04 21:16:50 +00:00
char * builtin = NULL ;
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( ps , " defaultwall " ) )
2016-07-12 00:40:13 +00:00
return ;
2016-09-08 19:04:35 +00:00
2016-11-25 08:14:54 +00:00
if ( ! builtin & & r_softwarebanding & & ( qrenderer = = QR_OPENGL | | qrenderer = = QR_VULKAN ) & & sh_config . progs_supported )
builtin = (
" { \n "
" { \n "
" program defaultwall#EIGHTBIT \n "
" map $colourmap \n "
" } \n "
" } \n "
) ;
2016-09-08 19:04:35 +00:00
if ( ! builtin & & r_lightmap . ival )
builtin = (
" { \n "
2018-09-01 04:18:08 +00:00
" fte_program drawflat_wall#LM \n "
2016-09-08 19:04:35 +00:00
" { \n "
" map $lightmap \n "
" tcgen lightmap \n "
" } \n "
" } \n "
) ;
2012-08-04 01:35:52 +00:00
if ( ! builtin & & r_drawflat . ival )
2010-07-11 02:22:39 +00:00
builtin = (
" { \n "
2016-11-20 20:52:41 +00:00
" fte_program drawflat_wall \n "
2010-07-11 02:22:39 +00:00
" { \n "
" map $lightmap \n "
" tcgen lightmap \n "
2018-03-04 14:41:16 +00:00
" rgbgen srgb $r_floorcolour \n "
2010-07-11 02:22:39 +00:00
" } \n "
" } \n "
) ;
2012-11-27 03:23:19 +00:00
2016-11-20 20:52:41 +00:00
if ( ! builtin & & r_lightprepass )
2010-08-28 17:14:38 +00:00
{
2016-11-20 20:52:41 +00:00
builtin = (
" { \n "
" { \n "
2017-10-31 22:52:58 +00:00
" fte_program lpp_wall \n "
" map $gbuffer2 \n " //diffuse lighting info
" map $gbuffer3 \n " //specular lighting info
2016-11-20 20:52:41 +00:00
" } \n "
2017-10-31 22:52:58 +00:00
//this is drawn during the initial gbuffer pass to prepare it
2016-11-20 20:52:41 +00:00
" fte_bemode gbuffer \n "
" { \n "
2010-08-28 17:14:38 +00:00
" { \n "
2017-10-31 22:52:58 +00:00
" fte_program lpp_depthnorm \n "
// "map $normalmap\n"
2016-11-20 20:52:41 +00:00
" tcgen base \n "
2010-08-28 17:14:38 +00:00
" } \n "
2016-11-20 20:52:41 +00:00
" } \n "
" } \n "
) ;
2015-03-03 00:14:43 +00:00
}
2018-04-27 16:40:50 +00:00
//d3d has no position-invariant. this results in all sorts of glitches, so try not to use it.
if ( ! builtin & & ( ( sh_config . progs_supported & & ( qrenderer = = QR_OPENGL /*||qrenderer == QR_DIRECT3D9*/ ) ) | | sh_config . progs_required ) )
2015-03-03 00:14:43 +00:00
{
builtin = (
2010-08-28 17:14:38 +00:00
" { \n "
2016-11-20 20:52:41 +00:00
" fte_program defaultwall \n "
2011-12-23 03:12:29 +00:00
" { \n "
" map $diffuse \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
}
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 "
) ;
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname , builtin ) ;
2015-06-26 13:21:04 +00:00
2016-11-20 20:52:41 +00:00
if ( r_lightprepass )
2015-06-26 13:21:04 +00:00
s - > flags | = SHADER_HASNORMALMAP ;
2010-07-11 02:22:39 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultCinematic ( parsestate_t * ps , const char * shortname , const void * args )
2010-07-11 02:22:39 +00:00
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2010-07-11 02:22:39 +00:00
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 "
2016-07-12 00:40:13 +00:00
" blendfunc gl_one gl_one_minus_src_alpha \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_'*/
2019-03-12 05:04:27 +00:00
void Shader_DefaultSkybox ( parsestate_t * ps , const char * shortname , const void * args )
2010-07-11 02:22:39 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
2017-08-29 02:29:06 +00:00
int i ;
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2010-07-11 02:22:39 +00:00
va (
" { \n "
2017-08-29 02:29:06 +00:00
" sort sky \n "
" surfaceparm nodlight \n "
2010-07-11 02:22:39 +00:00
" skyparms %s - - \n "
" } \n "
, shortname + 7 )
) ;
2017-08-29 02:29:06 +00:00
for ( i = 0 ; i < 6 ; i + + )
{
if ( s - > skydome - > farbox_textures [ i ] = = missing_texture )
{
if ( s - > skydome )
Z_Free ( s - > skydome ) ;
s - > skydome = NULL ;
return ;
}
}
2010-07-11 02:22:39 +00:00
}
2019-03-12 05:04:27 +00:00
char * Shader_DefaultBSPWater ( parsestate_t * ps , const char * shortname , char * buffer , size_t buffersize )
2010-07-11 02:22:39 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
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 } ;
2017-06-21 01:24:25 +00:00
if ( ! strncmp ( shortname , " *portal " , 7 ) )
{
return " { \n "
" portal \n "
" } \n " ;
}
else if ( ! strncmp ( shortname , " *lava " , 5 ) )
2014-08-25 07:35:41 +00:00
type = 1 ;
else if ( ! strncmp ( shortname , " *slime " , 6 ) )
type = 2 ;
else if ( ! strncmp ( shortname , " *tele " , 5 ) )
type = 3 ;
else
type = 0 ;
2018-11-27 16:48:19 +00:00
alpha = Shader_FloatArgument ( s , " ALPHA " ) ;
2014-08-25 07:35:41 +00:00
if ( alpha )
explicitalpha = true ;
else
2016-07-12 00:40:13 +00:00
{
2020-09-30 14:54:52 +00:00
if ( cls . allow_watervis )
2016-07-12 00:40:13 +00:00
alpha = * alphavars [ type ] - > string ? alphavars [ type ] - > value : alphavars [ 0 ] - > value ;
else
alpha = 1 ;
}
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 ;
2016-07-12 00:40:13 +00:00
else if ( * stylevars [ type ] - > string )
2014-08-25 07:35:41 +00:00
wstyle = stylevars [ type ] - > ival ;
2016-07-12 00:40:13 +00:00
else if ( stylevars [ 0 ] - > ival > 0 )
2014-08-25 07:35:41 +00:00
wstyle = stylevars [ 0 ] - > ival ;
2012-07-05 19:42:36 +00:00
else
wstyle = 1 ;
2021-04-14 05:21:04 +00:00
if ( ( wstyle < 0 | | wstyle > 1 ) & & ! cls . allow_watervis )
2016-07-12 00:40:13 +00:00
wstyle = 1 ;
if ( wstyle > 1 & & ! sh_config . progs_supported )
wstyle = 1 ;
//extra silly limitations
switch ( qrenderer )
{
2013-03-12 23:09:25 +00:00
# ifdef GLQUAKE
2016-07-12 00:40:13 +00:00
case QR_OPENGL :
if ( wstyle > 2 & & ! gl_config . ext_framebuffer_objects )
wstyle = 2 ;
break ;
2013-03-12 23:09:25 +00:00
# endif
2016-07-12 00:40:13 +00:00
# ifdef VKQUAKE
case QR_VULKAN :
if ( wstyle > 3 )
wstyle = 3 ;
break ;
# endif
default : //altwater not supported with other renderers
if ( wstyle > 1 )
wstyle = 1 ;
}
2013-03-12 23:13:39 +00:00
switch ( wstyle )
{
case - 1 : //invisible
return (
" { \n "
" surfaceparm nodraw \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
2014-04-12 03:31:59 +00:00
case - 2 : //regular with r_wateralpha forced off.
return (
" { \n "
2021-04-14 05:21:04 +00:00
" fte_program defaultwarp \n "
2014-04-12 03:31:59 +00:00
" { \n "
" map $diffuse \n "
" tcmod turb 0.02 0.1 0.5 0.1 \n "
" } \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2014-04-12 03:31:59 +00:00
" } \n "
) ;
2013-03-12 23:13:39 +00:00
case 0 : //fastturb
return (
" { \n "
2012-07-05 19:42:36 +00:00
" { \n "
2020-04-29 10:43:22 +00:00
//"program defaultfill\n"
2013-03-12 23:13:39 +00:00
" map $whiteimage \n "
2018-03-04 14:41:16 +00:00
" rgbgen srgb $r_fastturbcolour \n "
2012-07-05 19:42:36 +00:00
" } \n "
2013-03-12 23:13:39 +00:00
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
default :
case 1 : //vanilla style
2018-01-06 17:38:31 +00:00
Q_snprintfz ( buffer , buffersize ,
2010-07-11 02:22:39 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" surfaceparm nodlight \n "
" surfaceparm nomarks \n "
2020-10-26 06:30:35 +00:00
" if %g < 1 \n "
" sort underwater \n "
" endif \n "
2021-04-14 05:21:04 +00:00
" fte_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 "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2014-08-15 02:20:41 +00:00
" } \n "
2020-10-26 06:30:35 +00:00
, alpha , ( explicitalpha | | alpha = = 1 ) ? " " : va ( " #ALPHA=%g " , alpha ) , alpha , alpha ) ;
2018-01-06 17:38:31 +00:00
return buffer ;
2013-03-12 23:13:39 +00:00
case 2 : //refraction of the underwater surface, with a fresnel
return (
" { \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2012-07-05 19:42:36 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" program altwater#FRESNEL=4 \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
2015-03-03 00:14:43 +00:00
" map $null \n " //$reflection
" map $null \n " //$ripplemap
" map $null \n " //$refractiondepth
2012-07-05 19:42:36 +00:00
" } \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
case 3 : //reflections
return (
" { \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2012-07-05 19:42:36 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" program altwater#REFLECT#FRESNEL=4 \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
2015-03-03 00:14:43 +00:00
" map $reflection \n "
" map $null \n " //$ripplemap
" map $null \n " //$refractiondepth
2013-03-12 23:13:39 +00:00
" } \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
case 4 : //ripples
return (
" { \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2013-03-12 23:13:39 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" program altwater#RIPPLEMAP#FRESNEL=4 \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
2015-03-03 00:14:43 +00:00
" map $null \n " //$reflection
" map $ripplemap \n "
" map $null \n " //$refractiondepth
2013-03-12 23:13:39 +00:00
" } \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
case 5 : //ripples+reflections
return (
" { \n "
" surfaceparm nodlight \n "
2016-07-12 00:40:13 +00:00
" surfaceparm nomarks \n "
2013-03-12 23:13:39 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" program altwater#REFLECT#RIPPLEMAP#FRESNEL=4 \n "
2013-03-12 23:13:39 +00:00
" map $refraction \n "
" map $reflection \n "
" map $ripplemap \n "
2015-03-03 00:14:43 +00:00
" map $null \n " //$refractiondepth
" } \n "
2018-04-15 02:48:23 +00:00
" surfaceparm hasdiffuse \n "
2013-03-12 23:13:39 +00:00
" } \n "
) ;
2012-07-05 19:42:36 +00:00
}
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultWaterShader ( parsestate_t * ps , const char * shortname , const void * args )
2013-11-21 23:02:28 +00:00
{
2018-01-06 17:38:31 +00:00
char tmpbuffer [ 2048 ] ;
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname , Shader_DefaultBSPWater ( ps , shortname , tmpbuffer , sizeof ( tmpbuffer ) ) ) ;
2013-11-21 23:02:28 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultBSPQ2 ( parsestate_t * ps , const char * shortname , const void * args )
2012-07-05 19:42:36 +00:00
{
if ( ! strncmp ( shortname , " sky/ " , 4 ) )
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2012-07-05 19:42:36 +00:00
" { \n "
2020-02-12 02:09:26 +00:00
" sort sky \n "
2012-07-05 19:42:36 +00:00
" surfaceparm nodlight \n "
" skyparms - - - \n "
" } \n "
) ;
}
2019-03-12 05:04:27 +00:00
else if ( Shader_FloatArgument ( ps - > s , " WARP " ) ) //!strncmp(shortname, "warp/", 5) || !strncmp(shortname, "warp33/", 7) || !strncmp(shortname, "warp66/", 7))
2012-07-05 19:42:36 +00:00
{
2018-01-06 17:38:31 +00:00
char tmpbuffer [ 2048 ] ;
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname , Shader_DefaultBSPWater ( ps , shortname , tmpbuffer , sizeof ( tmpbuffer ) ) ) ;
2010-07-11 02:22:39 +00:00
}
2020-02-12 03:06:48 +00:00
else if ( Shader_FloatArgument ( ps - > s , " FLOW " ) )
{
if ( Shader_FloatArgument ( ps - > s , " ALPHA " ) ) {
Shader_DefaultScript ( ps , shortname ,
" { \n "
" { \n "
" map $diffuse \n "
" alphagen const $#ALPHA \n "
" tcmod scroll -1 0 \n "
" blendfunc blend \n "
" } \n "
" } \n "
) ;
} else {
Shader_DefaultScript ( ps , shortname ,
" { \n "
" { \n "
" map $diffuse \n "
" tcmod scroll -1 0 \n "
" } \n "
" { \n "
" map $lightmap \n "
" if gl_overbright > 1 \n "
" blendfunc gl_dst_color gl_src_color \n "
" else \n "
" blendfunc gl_dst_color gl_zero \n "
" endif \n "
" depthfunc equal \n "
" } \n "
" } \n "
) ;
}
}
2019-03-12 05:04:27 +00:00
else if ( Shader_FloatArgument ( ps - > s , " ALPHA " ) ) // !strncmp(shortname, "trans/", 6))
2015-04-14 23:12:17 +00:00
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2010-07-11 02:22:39 +00:00
" { \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 "
) ;
2015-04-14 23:12:17 +00:00
}
2010-07-11 02:22:39 +00:00
else
2019-03-12 05:04:27 +00:00
Shader_DefaultBSPLM ( ps , shortname , args ) ;
2010-07-11 02:22:39 +00:00
}
2009-07-18 20:46:42 +00:00
2019-03-12 05:04:27 +00:00
void Shader_DefaultBSPQ1 ( parsestate_t * ps , const char * shortname , const void * args )
2010-07-11 02:22:39 +00:00
{
char * builtin = NULL ;
2018-01-06 17:38:31 +00:00
char tmpbuffer [ 2048 ] ;
2017-06-21 01:24:25 +00:00
if ( ! strcmp ( shortname , " mirror_portal " ) )
{
builtin = " { \n "
" portal \n "
" } \n " ;
}
else if ( r_mirroralpha . value < 1 & & ( ! strcmp ( shortname , " window02_1 " ) | | ! strncmp ( shortname , " mirror " , 6 ) ) )
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
2016-12-13 11:50:15 +00:00
if ( ! builtin & & ( * shortname = = ' * ' | | * shortname = = ' ! ' ) )
2009-07-18 20:46:42 +00:00
{
2019-03-12 05:04:27 +00:00
builtin = Shader_DefaultBSPWater ( ps , shortname , tmpbuffer , sizeof ( tmpbuffer ) ) ;
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
2017-08-29 02:29:06 +00:00
/*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 "
2018-03-04 14:41:16 +00:00
" rgbgen srgb $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 "
) ;
2017-08-29 02:29:06 +00:00
} */
/*else if (*r_skyboxname.string || *cl.skyname)
2010-12-05 02:46:07 +00:00
{
2017-08-29 02:29:06 +00:00
qboolean okay ;
Z_Free ( s - > skydome ) ;
s - > skydome = ( skydome_t * ) Z_Malloc ( sizeof ( skydome_t ) ) ;
okay = Shader_ParseSkySides ( shortname , " " , s - > skydome - > farbox_textures ) ;
s - > flags | = SHADER_SKY | SHADER_NODLIGHT ;
s - > sort = SHADER_SORT_SKY ;
if ( okay )
2010-12-05 02:46:07 +00:00
return ;
builtin = NULL ;
2017-08-29 02:29:06 +00:00
//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 ) ;
2017-08-29 02:29:06 +00:00
} */
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*/
2018-04-15 02:48:23 +00:00
if ( sh_config . progs_supported )
builtin = (
" { \n "
" fte_program defaultwall#MASK=0.666#MASKLT \n "
" } \n "
) ;
else
builtin = (
" { \n "
/* "if $deluxmap\n"
" { \n "
" map $normalmap \n "
" tcgen base \n "
" } \n "
" { \n "
" map $deluxmap \n "
" tcgen lightmap \n "
" } \n "
" endif \n " */
2009-11-04 21:16:50 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" map $diffuse \n "
2009-11-04 21:16:50 +00:00
" tcgen base \n "
2018-04-15 02:48:23 +00:00
" alphafunc ge128 \n "
2009-11-04 21:16:50 +00:00
" } \n "
2018-04-15 02:48:23 +00:00
// "if $lightmap\n"
" { \n "
" map $lightmap \n "
" if gl_overbright > 1 \n "
" blendfunc gl_dst_color gl_src_color \n " //scale it up twice. will probably still get clamped, but what can you do
" else \n "
" blendfunc gl_dst_color gl_zero \n "
" endif \n "
" depthfunc equal \n "
" } \n "
// "endif\n"
2009-11-04 21:16:50 +00:00
" { \n "
2018-04-15 02:48:23 +00:00
" map $fullbright \n "
" blendfunc add \n "
2009-11-04 21:16:50 +00:00
" depthfunc equal \n "
" } \n "
" } \n "
2018-04-15 02:48:23 +00:00
) ;
2009-11-04 21:16:50 +00:00
}
2010-07-11 02:22:39 +00:00
if ( builtin )
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname , builtin ) ;
2010-07-11 02:22:39 +00:00
else
2019-03-12 05:04:27 +00:00
Shader_DefaultBSPLM ( ps , shortname , args ) ;
2009-11-04 21:16:50 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultBSPVertex ( parsestate_t * ps , const char * shortname , const void * args )
2005-03-20 02:57:11 +00:00
{
2015-09-06 03:30:28 +00:00
char * builtin = NULL ;
2011-12-05 15:23:40 +00:00
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( ps , " defaultvertexlit " ) )
2014-03-30 08:55:06 +00:00
return ;
2015-09-06 03:30:28 +00:00
if ( ! builtin )
2011-12-05 15:23:40 +00:00
{
2015-09-06 03:30:28 +00:00
builtin = (
" { \n "
2016-07-12 00:40:13 +00:00
" program defaultwall#VERTEXLIT \n "
2015-09-06 03:30:28 +00:00
" { \n "
" map $diffuse \n "
" rgbgen vertex \n "
" alphagen vertex \n "
" } \n "
" } \n "
) ;
2005-03-20 02:57:11 +00:00
}
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname , builtin ) ;
2005-03-20 02:57:11 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultBSPFlare ( parsestate_t * ps , const char * shortname , const void * args )
2005-03-20 02:57:11 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
2005-03-20 02:57:11 +00:00
shaderpass_t * pass ;
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( ps , " defaultflare " ) )
2014-03-30 08:55:06 +00:00
return ;
2005-03-20 02:57:11 +00:00
pass = & s - > passes [ 0 ] ;
2015-06-12 14:44:50 +00:00
pass - > flags = SHADER_PASS_NOCOLORARRAY ;
2009-11-04 21:16:50 +00:00
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 ;
2018-01-22 19:18:04 +00:00
Shader_SetBlendmode ( pass , NULL ) ;
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 ;
2015-06-12 14:44:50 +00:00
s - > flags = SHADER_FLARE ;
2005-03-20 02:57:11 +00:00
s - > sort = SHADER_SORT_ADDITIVE ;
2010-11-22 02:03:28 +00:00
s - > flags | = SHADER_NODRAW ;
2005-03-20 02:57:11 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultSkin ( parsestate_t * ps , const char * shortname , const void * args )
2009-11-04 21:16:50 +00:00
{
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( ps , " defaultskin " ) )
2014-03-30 08:55:06 +00:00
return ;
2016-11-25 08:14:54 +00:00
if ( r_softwarebanding & & qrenderer = = QR_OPENGL & & sh_config . progs_supported )
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2016-11-25 08:14:54 +00:00
" { \n "
" program defaultskin#EIGHTBIT \n "
" affine \n "
" { \n "
" map $colourmap \n "
" } \n "
" } \n "
) ;
return ;
}
2017-10-31 22:52:58 +00:00
if ( r_lightprepass )
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2017-10-31 22:52:58 +00:00
" { \n "
" { \n "
" fte_program lpp_wall \n "
" map $gbuffer2 \n " //diffuse lighting info
" map $gbuffer3 \n " //specular lighting info
" } \n "
//this is drawn during the initial gbuffer pass to prepare it
" fte_bemode gbuffer \n "
" { \n "
" { \n "
" fte_program lpp_depthnorm \n "
" tcgen base \n "
" } \n "
" } \n "
" } \n "
) ;
return ;
}
2017-02-11 16:14:06 +00:00
if ( r_tessellation . ival & & sh_config . progs_supported )
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2017-02-11 16:14:06 +00:00
" { \n "
" program defaultskin#TESS \n "
" } \n "
) ;
return ;
}
2016-11-25 08:14:54 +00:00
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
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 "
2021-04-14 05:21:04 +00:00
" if #BLEND \n "
" blendfunc blend \n " //straight blend
" endif \n "
2009-11-04 21:16:50 +00:00
" } \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 "
" } \n "
) ;
}
2019-03-12 05:04:27 +00:00
void Shader_DefaultSkinShell ( parsestate_t * ps , const char * shortname , const void * args )
2005-03-20 02:57:11 +00:00
{
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( ps , " defaultskinshell " ) )
2014-03-30 08:55:06 +00:00
return ;
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2011-04-23 20:37:20 +00:00
" { \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
}
2019-03-12 05:04:27 +00:00
void Shader_Default2D ( parsestate_t * ps , const char * shortname , const void * genargs )
2005-03-20 02:57:11 +00:00
{
2019-03-12 05:04:27 +00:00
shader_t * s = ps - > s ;
if ( Shader_ParseShader ( ps , " default2d " ) )
2014-03-30 08:55:06 +00:00
return ;
2021-06-02 15:29:56 +00:00
if ( sh_config . progs_supported & & qrenderer ! = QR_DIRECT3D9
# ifdef HAVE_LEGACY
& & ! dpcompat_nopremulpics . ival
# endif
)
2015-02-02 08:01:53 +00:00
{
//hexen2 needs premultiplied alpha to avoid looking ugly
//but that results in problems where things are drawn with alpha not 0, so scale vertex colour by alpha in the fragment program
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
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 "
2015-02-02 08:01:53 +00:00
" affine \n "
" nomipmaps \n "
" program default2d#PREMUL \n "
" { \n "
2018-04-15 02:48:23 +00:00
" clampmap $diffuse \n "
2016-07-12 00:40:13 +00:00
" blendfunc gl_one gl_one_minus_src_alpha \n "
2015-02-02 08:01:53 +00:00
" } \n "
" sort additive \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 "
2015-02-02 08:01:53 +00:00
) ;
2020-05-14 15:50:26 +00:00
TEXASSIGN ( s - > defaulttextures - > base , R_LoadHiResTexture ( s - > name , genargs , IF_PREMULTIPLYALPHA | IF_UIPIC | IF_NOPICMIP | IF_NOMIPMAP | IF_CLAMP | IF_HIGHPRIORITY ) ) ;
2015-02-02 08:01:53 +00:00
}
else
{
2019-03-12 05:04:27 +00:00
Shader_DefaultScript ( ps , shortname ,
2015-02-02 08:01:53 +00:00
" { \n "
" affine \n "
" nomipmaps \n "
" { \n "
" clampmap $diffuse \n "
" rgbgen vertex \n "
" alphagen vertex \n "
" blendfunc gl_src_alpha gl_one_minus_src_alpha \n "
" } \n "
" sort additive \n "
" } \n "
) ;
2020-05-14 15:50:26 +00:00
TEXASSIGN ( s - > defaulttextures - > base , R_LoadHiResTexture ( s - > name , genargs , IF_UIPIC | IF_NOPICMIP | IF_NOMIPMAP | IF_CLAMP | IF_HIGHPRIORITY ) ) ;
2015-02-02 08:01:53 +00:00
}
2005-03-20 02:57:11 +00:00
}
2019-03-12 05:04:27 +00:00
void Shader_PolygonShader ( struct shaderparsestate_s * ps , const char * shortname , const void * args )
{
shader_t * s = ps - > s ;
Shader_DefaultScript ( ps , shortname ,
" { \n "
" if $lpp \n "
" program lpp_skin \n "
" else \n "
" program defaultskin#NONORMALS \n "
" endif \n "
" { \n "
" map $diffuse \n "
" rgbgen vertex \n "
" alphagen vertex \n "
" } \n "
" { \n "
" map $fullbright \n "
" blendfunc add \n "
" } \n "
" } \n "
) ;
if ( ! s - > defaulttextures - > base & & ( s - > flags & SHADER_HASDIFFUSE ) )
R_BuildDefaultTexnums ( NULL , s , 0 ) ;
}
2005-03-20 02:57:11 +00:00
2018-04-27 16:40:50 +00:00
static qboolean Shader_ReadShaderTerms ( parsestate_t * ps , struct scondinfo_s * cond )
2009-11-04 21:16:50 +00:00
{
char * token ;
2013-07-29 17:36:44 +00:00
2018-04-27 16:40:50 +00:00
if ( ! ps - > ptr )
2013-08-21 07:14:39 +00:00
return false ;
2018-04-27 16:40:50 +00:00
token = COM_ParseExt ( & ps - > ptr , true , true ) ;
2011-12-05 15:23:40 +00:00
2013-07-29 17:36:44 +00:00
if ( ! token [ 0 ] )
return true ;
2020-06-12 23:29:58 +00:00
else if ( ! Shader_Conditional_Read ( ps , cond , token , & ps - > ptr ) )
2013-07-29 17:36:44 +00:00
{
int i ;
for ( i = 0 ; shadermacros [ i ] . name ; i + + )
{
if ( ! Q_stricmp ( token , shadermacros [ i ] . name ) )
2009-11-04 21:16:50 +00:00
{
2019-04-07 16:41:09 +00:00
# define SHADER_MACRO_ARGS 8
2013-07-29 17:36:44 +00:00
int argn = 0 ;
2020-06-12 23:29:58 +00:00
const char * oldptr ;
2013-07-29 17:36:44 +00:00
char arg [ SHADER_MACRO_ARGS ] [ 256 ] ;
2019-04-07 16:41:09 +00:00
char tmp [ 4096 ] , * out , * in ;
2013-07-29 17:36:44 +00:00
//parse args until the end of the line
2018-04-27 16:40:50 +00:00
while ( ps - > ptr )
2009-11-04 21:16:50 +00:00
{
2018-04-27 16:40:50 +00:00
token = COM_ParseExt ( & ps - > ptr , false , true ) ;
2013-07-29 17:36:44 +00:00
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
}
2019-04-07 16:41:09 +00:00
for ( out = tmp , in = shadermacros [ i ] . body ; * in ; )
{
if ( out = = tmp + countof ( tmp ) - 1 )
break ;
if ( * in = = ' % ' & & in [ 1 ] = = ' % ' )
in + + ; //skip doubled up percents
else if ( * in = = ' % ' )
{ //expand an arg
char * e ;
int i = strtol ( in + 1 , & e , 0 ) ;
if ( e ! = in + 1 )
{
i - - ;
if ( i > = 0 & & i < countof ( arg ) )
{
for ( in = arg [ i ] ; * in ; )
{
if ( out = = tmp + countof ( tmp ) - 1 )
break ;
* out + + = * in + + ;
}
in = e ;
continue ;
}
}
}
* out + + = * in + + ;
}
* out = 0 ;
2018-04-27 17:11:14 +00:00
oldptr = ps - > ptr ;
2019-04-07 16:41:09 +00:00
ps - > ptr = tmp ;
2018-04-27 16:40:50 +00:00
Shader_ReadShaderTerms ( ps , cond ) ;
2018-04-27 17:11:14 +00:00
ps - > ptr = oldptr ;
2013-07-29 17:36:44 +00:00
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 ] = = ' { ' )
2018-04-27 16:40:50 +00:00
Shader_Readpass ( ps ) ;
else if ( Shader_Parsetok ( ps , shaderkeys , token ) )
2013-07-29 17:36:44 +00:00
return false ;
}
return true ;
}
//loads a shader string into an existing shader object, and finalises it and stuff
2020-06-12 23:29:58 +00:00
static void Shader_ReadShader ( parsestate_t * ps , const char * shadersource , shadercachefile_t * sourcefile )
2013-07-29 17:36:44 +00:00
{
2017-10-31 22:52:58 +00:00
struct scondinfo_s cond = { 0 } ;
2019-03-12 05:04:27 +00:00
char * * savebody = ps - > saveshaderbody ;
shader_t * s = ps - > s ;
2014-03-30 08:55:06 +00:00
2019-03-12 05:04:27 +00:00
memset ( ps , 0 , sizeof ( * ps ) ) ;
2018-04-27 16:40:50 +00:00
if ( sourcefile )
{
2019-03-12 05:04:27 +00:00
ps - > forcedshader = * sourcefile - > forcedshadername ? sourcefile - > forcedshadername : NULL ;
ps - > parseflags = sourcefile - > parseflags ;
2019-12-16 17:25:59 +00:00
ps - > sourcename = sourcefile - > name ;
2018-04-27 16:40:50 +00:00
}
else
2019-12-16 17:25:59 +00:00
{
2019-03-12 05:04:27 +00:00
ps - > parseflags = 0 ;
2019-12-16 17:25:59 +00:00
ps - > sourcename = " <code> " ;
}
2019-03-12 05:04:27 +00:00
ps - > specularexpscale = 1 ;
ps - > specularvalscale = 1 ;
ps - > ptr = shadersource ;
ps - > s = s ;
2013-07-29 17:36:44 +00:00
2015-07-27 08:21:34 +00:00
if ( ! s - > defaulttextures )
{
s - > defaulttextures = Z_Malloc ( sizeof ( * s - > defaulttextures ) ) ;
s - > numdefaulttextures = 0 ;
}
2013-07-29 17:36:44 +00:00
// set defaults
2015-06-12 14:44:50 +00:00
s - > flags = SHADER_CULL_FRONT ;
2013-07-29 17:36:44 +00:00
2019-03-12 05:04:27 +00:00
while ( Shader_ReadShaderTerms ( ps , & cond ) )
2013-07-29 17:36:44 +00:00
{
2013-03-12 23:16:55 +00:00
}
2017-10-31 22:52:58 +00:00
if ( cond . depth )
2013-03-12 23:16:55 +00:00
{
Con_Printf ( " if statements without endif in shader %s \n " , s - > name ) ;
2009-11-04 21:16:50 +00:00
}
2019-03-12 05:04:27 +00:00
Shader_Finish ( ps ) ;
2014-10-25 02:16:35 +00:00
//querying the shader body often requires generating the shader, which then gets parsed.
2019-03-12 05:04:27 +00:00
if ( savebody )
2014-10-25 02:16:35 +00:00
{
2019-03-12 05:04:27 +00:00
size_t l = ps - > ptr ? ps - > ptr - shadersource : 0 ;
Z_Free ( * savebody ) ;
* savebody = BZ_Malloc ( l + 1 ) ;
( * savebody ) [ l ] = 0 ;
memcpy ( * savebody , shadersource , l ) ;
2014-10-25 02:16:35 +00:00
}
2009-11-04 21:16:50 +00:00
}
2020-06-12 23:29:58 +00:00
static qboolean Shader_ParseShader ( parsestate_t * ps , const char * parsename )
2006-03-11 03:12:10 +00:00
{
2014-03-30 08:55:06 +00:00
size_t offset = 0 , length ;
2020-06-12 23:29:58 +00:00
const char * buf = NULL ;
2018-04-27 16:40:50 +00:00
shadercachefile_t * sourcefile = NULL ;
2020-06-12 23:29:58 +00:00
const char * file ;
2018-07-05 16:21:44 +00:00
const char * token ;
2018-10-11 10:31:23 +00:00
if ( ! strchr ( parsename , ' : ' ) )
2018-07-05 16:21:44 +00:00
{
2018-10-11 10:31:23 +00:00
//if the named shader is a .shader file then just directly load it.
token = COM_GetFileExtension ( parsename , NULL ) ;
2018-12-02 13:35:23 +00:00
if ( ! strcmp ( token , " .mat " ) | | ! * token )
2018-07-05 16:21:44 +00:00
{
2018-10-11 10:31:23 +00:00
char shaderfile [ MAX_QPATH ] ;
if ( ! * token )
2018-07-05 16:21:44 +00:00
{
2018-12-02 13:35:23 +00:00
Q_snprintfz ( shaderfile , sizeof ( shaderfile ) , " %s.mat " , parsename ) ;
2018-10-11 10:31:23 +00:00
file = COM_LoadTempMoreFile ( shaderfile , & length ) ;
2018-07-05 16:21:44 +00:00
}
else
2018-10-11 10:31:23 +00:00
file = COM_LoadTempMoreFile ( parsename , & length ) ;
if ( file )
{
2019-03-12 05:04:27 +00:00
Shader_Reset ( ps - > s ) ;
2018-10-11 10:31:23 +00:00
token = COM_ParseExt ( & file , true , false ) ; //we need to skip over the leading {.
if ( * token ! = ' { ' )
token = COM_ParseExt ( & file , true , false ) ; //try again, in case we found some legacy name.
if ( * token = = ' { ' )
{
2019-03-12 05:04:27 +00:00
Shader_ReadShader ( ps , file , NULL ) ;
2018-10-11 10:31:23 +00:00
return true ;
}
else
Con_Printf ( " file %s.shader does not appear to contain a shader \n " , shaderfile ) ;
}
2018-07-05 16:21:44 +00:00
}
}
2006-03-11 03:12:10 +00:00
2018-04-27 16:40:50 +00:00
if ( Shader_LocateSource ( parsename , & buf , & length , & offset , & sourcefile ) )
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 )
{
file = buf + offset ;
token = COM_ParseExt ( & file , true , true ) ;
if ( ! file | | token [ 0 ] ! = ' { ' )
{
2020-06-12 23:29:58 +00:00
FS_FreeFile ( ( char * ) buf ) ;
2014-03-30 08:55:06 +00:00
return false ;
}
2006-03-11 03:12:10 +00:00
2019-03-12 05:04:27 +00:00
Shader_Reset ( ps - > s ) ;
2006-03-11 03:12:10 +00:00
2019-03-12 05:04:27 +00:00
Shader_ReadShader ( ps , file , sourcefile ) ;
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 )
{
2016-07-12 00:40:13 +00:00
if ( ! shader )
return ;
2015-08-10 18:28:23 +00:00
if ( shader - > uses < = 0 )
{
2020-09-08 05:11:09 +00:00
Con_Printf ( " Shader double free (%p %s %i) \n " , shader , shader - > name , shader - > usageflags ) ;
2015-08-10 18:28:23 +00:00
return ;
}
2015-07-30 16:26:15 +00:00
if ( - - shader - > uses = = 0 )
2010-07-11 02:22:39 +00:00
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 ] ;
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-10-05 20:04:11 +00:00
COM_AssertMainThread ( " R_LoadShader " ) ;
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
{
2015-07-30 16:26:15 +00:00
if ( ! s - > uses )
break ;
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 ;
2019-03-12 05:04:27 +00:00
int nm ;
if ( strlen ( cleanname ) > = sizeof ( s - > name ) )
{
Sys_Error ( " R_LoadShader: Shader name too long. " ) ;
return NULL ;
}
2013-10-29 17:38:22 +00:00
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
}
2015-05-03 19:57:46 +00:00
{
2019-03-12 05:04:27 +00:00
parsestate_t ps ;
char shortname [ MAX_QPATH ] ;
char * argsstart ;
s = r_shaders [ f ] ;
if ( ! s )
{
s = r_shaders [ f ] = Z_Malloc ( sizeof ( * s ) ) ;
}
ps . saveshaderbody = NULL ;
ps . s = s ;
s - > id = f ;
if ( r_numshaders < f + 1 )
r_numshaders = f + 1 ;
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
if ( ! s - > defaulttextures )
s - > defaulttextures = Z_Malloc ( sizeof ( * s - > defaulttextures ) ) ;
else
memset ( s - > defaulttextures , 0 , sizeof ( * s - > defaulttextures ) ) ;
s - > numdefaulttextures = 0 ;
Q_strncpyz ( s - > name , cleanname , sizeof ( s - > name ) ) ;
s - > usageflags = usageflags ;
s - > generator = defaultgen ;
s - > width = 0 ;
s - > height = 0 ;
s - > uses = 1 ;
if ( genargs )
s - > genargs = strdup ( genargs ) ;
else
s - > genargs = NULL ;
2011-05-20 04:10:46 +00:00
2019-03-12 05:04:27 +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
2019-03-12 05:04:27 +00:00
if ( ruleset_allow_shaders . ival & & ! ( usageflags & SUR_FORCEFALLBACK ) )
2012-09-30 05:52:03 +00:00
{
2019-03-12 05:04:27 +00:00
if ( sh_config . shadernamefmt )
{
char drivername [ MAX_QPATH ] ;
Q_snprintfz ( drivername , sizeof ( drivername ) , sh_config . shadernamefmt , cleanname ) ;
if ( Shader_ParseShader ( & ps , drivername ) )
return s ;
}
if ( Shader_ParseShader ( & ps , cleanname ) )
2014-03-30 08:55:06 +00:00
return s ;
2019-03-12 05:04:27 +00:00
if ( strcmp ( cleanname , shortname ) )
if ( Shader_ParseShader ( & ps , shortname ) )
return s ;
2012-09-30 05:52:03 +00:00
}
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
// make a default shader
2004-10-19 15:56:22 +00:00
2019-03-12 05:04:27 +00:00
if ( s - > generator )
{
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
Shader_Regenerate ( & ps , shortname ) ;
2019-03-12 05:04:27 +00:00
return s ;
}
2011-02-25 04:22:14 +00:00
else
2019-03-12 05:04:27 +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
}
2016-07-12 00:40:13 +00:00
# ifdef _DEBUG
2017-08-29 02:29:06 +00:00
static char * Shader_DecomposePass ( char * o , shaderpass_t * p , qboolean simple )
{
if ( ! simple )
{
switch ( p - > rgbgen )
{
2018-04-27 16:40:50 +00:00
default : sprintf ( o , " RGB_GEN_? " ) ; break ;
2017-08-29 02:29:06 +00:00
case RGB_GEN_ENTITY : sprintf ( o , " RGB_GEN_ENTITY " ) ; break ;
case RGB_GEN_ONE_MINUS_ENTITY : sprintf ( o , " RGB_GEN_ONE_MINUS_ENTITY " ) ; break ;
case RGB_GEN_VERTEX_LIGHTING : sprintf ( o , " RGB_GEN_VERTEX_LIGHTING " ) ; break ;
case RGB_GEN_VERTEX_EXACT : sprintf ( o , " RGB_GEN_VERTEX_EXACT " ) ; break ;
case RGB_GEN_ONE_MINUS_VERTEX : sprintf ( o , " RGB_GEN_ONE_MINUS_VERTEX " ) ; break ;
case RGB_GEN_IDENTITY_LIGHTING : sprintf ( o , " RGB_GEN_IDENTITY_LIGHTING " ) ; break ;
case RGB_GEN_IDENTITY_OVERBRIGHT : sprintf ( o , " RGB_GEN_IDENTITY_OVERBRIGHT " ) ; break ;
case RGB_GEN_IDENTITY : sprintf ( o , " RGB_GEN_IDENTITY " ) ; break ;
case RGB_GEN_CONST : sprintf ( o , " RGB_GEN_CONST " ) ; break ;
2017-12-09 21:22:46 +00:00
case RGB_GEN_ENTITY_LIGHTING_DIFFUSE : sprintf ( o , " RGB_GEN_ENTITY_LIGHTING_DIFFUSE " ) ; break ;
2017-08-29 02:29:06 +00:00
case RGB_GEN_LIGHTING_DIFFUSE : sprintf ( o , " RGB_GEN_LIGHTING_DIFFUSE " ) ; break ;
case RGB_GEN_WAVE : sprintf ( o , " RGB_GEN_WAVE " ) ; break ;
case RGB_GEN_TOPCOLOR : sprintf ( o , " RGB_GEN_TOPCOLOR " ) ; break ;
case RGB_GEN_BOTTOMCOLOR : sprintf ( o , " RGB_GEN_BOTTOMCOLOR " ) ; break ;
2018-04-27 16:40:50 +00:00
case RGB_GEN_UNKNOWN : sprintf ( o , " RGB_GEN_UNKNOWN " ) ; break ;
2017-08-29 02:29:06 +00:00
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ; o + = strlen ( o ) ;
2018-04-27 16:40:50 +00:00
switch ( p - > alphagen )
{
default : sprintf ( o , " ALPHA_GEN_? " ) ; break ;
case ALPHA_GEN_ENTITY : sprintf ( o , " ALPHA_GEN_ENTITY " ) ; break ;
case ALPHA_GEN_WAVE : sprintf ( o , " ALPHA_GEN_WAVE " ) ; break ;
case ALPHA_GEN_PORTAL : sprintf ( o , " ALPHA_GEN_PORTAL " ) ; break ;
case ALPHA_GEN_SPECULAR : sprintf ( o , " ALPHA_GEN_SPECULAR " ) ; break ;
case ALPHA_GEN_IDENTITY : sprintf ( o , " ALPHA_GEN_IDENTITY " ) ; break ;
case ALPHA_GEN_VERTEX : sprintf ( o , " ALPHA_GEN_VERTEX " ) ; break ;
case ALPHA_GEN_CONST : sprintf ( o , " ALPHA_GEN_CONST " ) ; break ;
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ; o + = strlen ( o ) ;
}
if ( p - > prog )
{
2018-11-27 16:48:19 +00:00
sprintf ( o , " program %s \n " , p - > prog - > name ) ;
2018-04-27 16:40:50 +00:00
o + = strlen ( o ) ;
2017-08-29 02:29:06 +00:00
}
if ( p - > shaderbits & SBITS_MISC_DEPTHWRITE ) { sprintf ( o , " SBITS_MISC_DEPTHWRITE \n " ) ; o + = strlen ( o ) ; }
if ( p - > shaderbits & SBITS_MISC_NODEPTHTEST ) { sprintf ( o , " SBITS_MISC_NODEPTHTEST \n " ) ; o + = strlen ( o ) ; }
2018-04-27 16:40:50 +00:00
else switch ( p - > shaderbits & SBITS_DEPTHFUNC_BITS )
{
case SBITS_DEPTHFUNC_EQUAL : sprintf ( o , " depthfunc equal \n " ) ; break ;
case SBITS_DEPTHFUNC_CLOSER : sprintf ( o , " depthfunc less \n " ) ; break ;
case SBITS_DEPTHFUNC_CLOSEREQUAL : sprintf ( o , " depthfunc lequal \n " ) ; break ;
case SBITS_DEPTHFUNC_FURTHER : sprintf ( o , " depthfunc greater \n " ) ; break ;
}
2017-08-29 02:29:06 +00:00
if ( p - > shaderbits & SBITS_TESSELLATION ) { sprintf ( o , " SBITS_TESSELLATION \n " ) ; o + = strlen ( o ) ; }
if ( p - > shaderbits & SBITS_AFFINE ) { sprintf ( o , " SBITS_AFFINE \n " ) ; o + = strlen ( o ) ; }
if ( p - > shaderbits & SBITS_MASK_BITS ) { sprintf ( o , " SBITS_MASK_BITS \n " ) ; o + = strlen ( o ) ; }
if ( p - > shaderbits & SBITS_BLEND_BITS )
{
sprintf ( o , " blendfunc " ) ;
o + = strlen ( o ) ;
switch ( p - > shaderbits & SBITS_SRCBLEND_BITS )
{
case SBITS_SRCBLEND_NONE : sprintf ( o , " SBITS_SRCBLEND_NONE " ) ; break ;
case SBITS_SRCBLEND_ZERO : sprintf ( o , " SBITS_SRCBLEND_ZERO " ) ; break ;
case SBITS_SRCBLEND_ONE : sprintf ( o , " SBITS_SRCBLEND_ONE " ) ; break ;
case SBITS_SRCBLEND_DST_COLOR : sprintf ( o , " SBITS_SRCBLEND_DST_COLOR " ) ; break ;
case SBITS_SRCBLEND_ONE_MINUS_DST_COLOR : sprintf ( o , " SBITS_SRCBLEND_ONE_MINUS_DST_COLOR " ) ; break ;
case SBITS_SRCBLEND_SRC_ALPHA : sprintf ( o , " SBITS_SRCBLEND_SRC_ALPHA " ) ; break ;
case SBITS_SRCBLEND_ONE_MINUS_SRC_ALPHA : sprintf ( o , " SBITS_SRCBLEND_ONE_MINUS_SRC_ALPHA " ) ; break ;
case SBITS_SRCBLEND_DST_ALPHA : sprintf ( o , " SBITS_SRCBLEND_DST_ALPHA " ) ; break ;
case SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA : sprintf ( o , " SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA " ) ; break ;
case SBITS_SRCBLEND_SRC_COLOR_INVALID : sprintf ( o , " SBITS_SRCBLEND_SRC_COLOR_INVALID " ) ; break ;
case SBITS_SRCBLEND_ONE_MINUS_SRC_COLOR_INVALID : sprintf ( o , " SBITS_SRCBLEND_ONE_MINUS_SRC_COLOR_INVALID " ) ; break ;
case SBITS_SRCBLEND_ALPHA_SATURATE : sprintf ( o , " SBITS_SRCBLEND_ALPHA_SATURATE " ) ; break ;
default : sprintf ( o , " SBITS_SRCBLEND_INVALID " ) ; break ;
}
o + = strlen ( o ) ;
switch ( p - > shaderbits & SBITS_DSTBLEND_BITS )
{
case SBITS_DSTBLEND_NONE : sprintf ( o , " SBITS_DSTBLEND_NONE " ) ; break ;
case SBITS_DSTBLEND_ZERO : sprintf ( o , " SBITS_DSTBLEND_ZERO " ) ; break ;
case SBITS_DSTBLEND_ONE : sprintf ( o , " SBITS_DSTBLEND_ONE " ) ; break ;
case SBITS_DSTBLEND_DST_COLOR_INVALID : sprintf ( o , " SBITS_DSTBLEND_DST_COLOR_INVALID " ) ; break ;
case SBITS_DSTBLEND_ONE_MINUS_DST_COLOR_INVALID : sprintf ( o , " SBITS_DSTBLEND_ONE_MINUS_DST_COLOR_INVALID " ) ; break ;
case SBITS_DSTBLEND_SRC_ALPHA : sprintf ( o , " SBITS_DSTBLEND_SRC_ALPHA " ) ; break ;
case SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA : sprintf ( o , " SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA " ) ; break ;
case SBITS_DSTBLEND_DST_ALPHA : sprintf ( o , " SBITS_DSTBLEND_DST_ALPHA " ) ; break ;
case SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA : sprintf ( o , " SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA " ) ; break ;
case SBITS_DSTBLEND_SRC_COLOR : sprintf ( o , " SBITS_DSTBLEND_SRC_COLOR " ) ; break ;
case SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR : sprintf ( o , " SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR " ) ; break ;
case SBITS_DSTBLEND_ALPHA_SATURATE_INVALID : sprintf ( o , " SBITS_DSTBLEND_ALPHA_SATURATE_INVALID " ) ; break ;
default : sprintf ( o , " SBITS_DSTBLEND_INVALID " ) ; break ;
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ;
o + = strlen ( o ) ;
}
switch ( p - > shaderbits & SBITS_ATEST_BITS )
{
2018-04-27 16:40:50 +00:00
case SBITS_ATEST_NONE : break ;
2017-08-29 02:29:06 +00:00
case SBITS_ATEST_GE128 : sprintf ( o , " SBITS_ATEST_GE128 \n " ) ; break ;
case SBITS_ATEST_LT128 : sprintf ( o , " SBITS_ATEST_LT128 \n " ) ; break ;
case SBITS_ATEST_GT0 : sprintf ( o , " SBITS_ATEST_GT0 \n " ) ; break ;
}
o + = strlen ( o ) ;
2018-04-27 16:40:50 +00:00
2017-08-29 02:29:06 +00:00
return o ;
}
2019-04-01 10:16:36 +00:00
static void Shader_DecomposeSubPassMap ( char * o , shader_t * s , char * name , texid_t tex )
{
if ( tex )
{
unsigned int flags = tex - > flags ;
sprintf ( o , " %s \" %s \" %ix%i%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s " , name , tex - > ident , tex - > width , tex - > height ,
( tex - > status = = TEX_FAILED ) ? " FAILED " : " " ,
Image_FormatName ( tex - > format ) ,
( flags & IF_CLAMP ) ? " clamp " : " " ,
( flags & IF_NOMIPMAP ) ? " nomipmap " : " " ,
( flags & IF_NEAREST ) ? " nearest " : " " ,
( flags & IF_LINEAR ) ? " linear " : " " ,
( flags & IF_UIPIC ) ? " uipic " : " " ,
( flags & IF_SRGB ) ? " srgb " : " " ,
( flags & IF_NOPICMIP ) ? " nopicmip " : " " ,
( flags & IF_NOALPHA ) ? " noalpha " : " " ,
( flags & IF_NOGAMMA ) ? " noalpha " : " " ,
2019-10-18 08:37:38 +00:00
( flags & IF_TEXTYPEMASK ) ? " non-2d " : " " ,
2019-04-01 10:16:36 +00:00
( flags & IF_MIPCAP ) ? " " : " nomipcap " ,
( flags & IF_PREMULTIPLYALPHA ) ? " premultiply " : " " ,
( flags & IF_NOSRGB ) ? " nosrgb " : " " ,
( flags & IF_PALETTIZE ) ? " palettize " : " " ,
( flags & IF_NOPURGE ) ? " nopurge " : " " ,
( flags & IF_HIGHPRIORITY ) ? " highpri " : " " ,
( flags & IF_LOWPRIORITY ) ? " lowpri " : " " ,
( flags & IF_LOADNOW ) ? " loadnow " : " " ,
( flags & IF_TRYBUMP ) ? " trybump " : " " ,
( flags & IF_RENDERTARGET ) ? " rendertarget " : " " ,
( flags & IF_EXACTEXTENSION ) ? " exactext " : " " ,
( flags & IF_NOREPLACE ) ? " noreplace " : " " ,
( flags & IF_NOWORKER ) ? " noworker " : " "
) ;
}
else
sprintf ( o , " %s (%s) " , name , " UNDEFINED " ) ;
}
static char * Shader_DecomposeSubPass ( char * o , shader_t * s , shaderpass_t * p , qboolean simple )
2017-08-29 02:29:06 +00:00
{
2018-04-27 16:40:50 +00:00
int i ;
2017-08-29 02:29:06 +00:00
if ( ! simple )
{
2018-04-27 16:40:50 +00:00
switch ( p - > tcgen )
{
default : sprintf ( o , " TC_GEN_? " ) ; break ;
case TC_GEN_BASE : sprintf ( o , " TC_GEN_BASE " ) ; break ;
case TC_GEN_LIGHTMAP : sprintf ( o , " TC_GEN_LIGHTMAP " ) ; break ;
case TC_GEN_ENVIRONMENT : sprintf ( o , " TC_GEN_ENVIRONMENT " ) ; break ;
case TC_GEN_DOTPRODUCT : sprintf ( o , " TC_GEN_DOTPRODUCT " ) ; break ;
case TC_GEN_VECTOR : sprintf ( o , " TC_GEN_VECTOR " ) ; break ;
case TC_GEN_NORMAL : sprintf ( o , " TC_GEN_NORMAL " ) ; break ;
case TC_GEN_SVECTOR : sprintf ( o , " TC_GEN_SVECTOR " ) ; break ;
case TC_GEN_TVECTOR : sprintf ( o , " TC_GEN_TVECTOR " ) ; break ;
case TC_GEN_SKYBOX : sprintf ( o , " TC_GEN_SKYBOX " ) ; break ;
case TC_GEN_WOBBLESKY : sprintf ( o , " TC_GEN_WOBBLESKY " ) ; break ;
case TC_GEN_REFLECT : sprintf ( o , " TC_GEN_REFLECT " ) ; break ;
case TC_GEN_UNSPECIFIED : sprintf ( o , " TC_GEN_UNSPECIFIED " ) ; break ;
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ; o + = strlen ( o ) ;
for ( i = 0 ; i < p - > numtcmods ; i + + )
{
switch ( p - > tcmods [ i ] . type )
{
default : sprintf ( o , " TCMOD_GEN_? " ) ; break ;
case SHADER_TCMOD_NONE : sprintf ( o , " SHADER_TCMOD_NONE " ) ; break ;
case SHADER_TCMOD_SCALE : sprintf ( o , " SHADER_TCMOD_SCALE " ) ; break ;
case SHADER_TCMOD_SCROLL : sprintf ( o , " SHADER_TCMOD_SCROLL " ) ; break ;
case SHADER_TCMOD_STRETCH : sprintf ( o , " SHADER_TCMOD_STRETCH " ) ; break ;
case SHADER_TCMOD_ROTATE : sprintf ( o , " SHADER_TCMOD_ROTATE " ) ; break ;
case SHADER_TCMOD_TRANSFORM : sprintf ( o , " SHADER_TCMOD_TRANSFORM " ) ; break ;
case SHADER_TCMOD_TURB : sprintf ( o , " SHADER_TCMOD_TURB " ) ; break ;
case SHADER_TCMOD_PAGE : sprintf ( o , " SHADER_TCMOD_PAGE " ) ; break ;
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ; o + = strlen ( o ) ;
}
2017-08-29 02:29:06 +00:00
switch ( p - > blendmode )
{
2018-04-27 16:40:50 +00:00
default : sprintf ( o , " PBM_? " ) ; break ;
case PBM_MODULATE : sprintf ( o , " PBM_MODULATE " ) ; break ;
case PBM_OVERBRIGHT : sprintf ( o , " PBM_OVERBRIGHT " ) ; break ;
case PBM_DECAL : sprintf ( o , " PBM_DECAL " ) ; break ;
case PBM_ADD : sprintf ( o , " PBM_ADD " ) ; break ;
case PBM_DOTPRODUCT : sprintf ( o , " PBM_DOTPRODUCT " ) ; break ;
case PBM_REPLACE : sprintf ( o , " PBM_REPLACE " ) ; break ;
case PBM_REPLACELIGHT : sprintf ( o , " PBM_REPLACELIGHT " ) ; break ;
case PBM_MODULATE_PREV_COLOUR : sprintf ( o , " PBM_MODULATE_PREV_COLOUR " ) ; break ;
2017-08-29 02:29:06 +00:00
}
o + = strlen ( o ) ;
}
switch ( p - > texgen )
{
2018-04-27 16:40:50 +00:00
default : sprintf ( o , " T_GEN_? " ) ; break ;
2019-05-10 09:31:21 +00:00
case T_GEN_SINGLEMAP : Shader_DecomposeSubPassMap ( o , s , " map " , p - > anim_frames [ 0 ] ) ; break ;
2019-04-01 10:16:36 +00:00
case T_GEN_ANIMMAP : Shader_DecomposeSubPassMap ( o , s , " animmap " , p - > anim_frames [ 0 ] ) ; break ;
# ifdef HAVE_MEDIA_DECODER
case T_GEN_VIDEOMAP : Shader_DecomposeSubPassMap ( o , s , " videomap " , Media_UpdateForShader ( p - > cin ) ) ; break ;
# endif
2019-05-10 09:31:21 +00:00
case T_GEN_LIGHTMAP : sprintf ( o , " map $lightmap " ) ; break ;
case T_GEN_DELUXMAP : sprintf ( o , " map $deluxemap " ) ; break ;
case T_GEN_SHADOWMAP : sprintf ( o , " map $shadowmap " ) ; break ;
case T_GEN_LIGHTCUBEMAP : sprintf ( o , " map $lightcubemap " ) ; break ;
case T_GEN_DIFFUSE : Shader_DecomposeSubPassMap ( o , s , " map $diffuse " , s - > defaulttextures [ 0 ] . base ) ; break ;
case T_GEN_NORMALMAP : Shader_DecomposeSubPassMap ( o , s , " map $normalmap " , s - > defaulttextures [ 0 ] . bump ) ; break ;
case T_GEN_SPECULAR : Shader_DecomposeSubPassMap ( o , s , " map $specular " , s - > defaulttextures [ 0 ] . specular ) ; break ;
case T_GEN_UPPEROVERLAY : Shader_DecomposeSubPassMap ( o , s , " map $upper " , s - > defaulttextures [ 0 ] . upperoverlay ) ; break ;
case T_GEN_LOWEROVERLAY : Shader_DecomposeSubPassMap ( o , s , " map $lower " , s - > defaulttextures [ 0 ] . loweroverlay ) ; break ;
case T_GEN_FULLBRIGHT : Shader_DecomposeSubPassMap ( o , s , " map $fullbright " , s - > defaulttextures [ 0 ] . fullbright ) ; break ;
case T_GEN_PALETTED : Shader_DecomposeSubPassMap ( o , s , " map $paletted " , s - > defaulttextures [ 0 ] . paletted ) ; break ;
case T_GEN_REFLECTCUBE : Shader_DecomposeSubPassMap ( o , s , " map $reflectcube " , s - > defaulttextures [ 0 ] . reflectcube ) ; break ;
case T_GEN_REFLECTMASK : Shader_DecomposeSubPassMap ( o , s , " map $reflectmask " , s - > defaulttextures [ 0 ] . reflectmask ) ; break ;
case T_GEN_DISPLACEMENT : Shader_DecomposeSubPassMap ( o , s , " map $displacement " , s - > defaulttextures [ 0 ] . displacement ) ; break ;
2019-09-04 07:59:40 +00:00
case T_GEN_OCCLUSION : Shader_DecomposeSubPassMap ( o , s , " map $occlusion " , s - > defaulttextures [ 0 ] . occlusion ) ; break ;
2019-05-10 09:31:21 +00:00
case T_GEN_CURRENTRENDER : sprintf ( o , " map $currentrender " ) ; break ;
case T_GEN_SOURCECOLOUR : sprintf ( o , " map $sourcecolour " ) ; break ;
case T_GEN_SOURCEDEPTH : sprintf ( o , " map $sourcedepth " ) ; break ;
case T_GEN_REFLECTION : sprintf ( o , " map $reflection " ) ; break ;
case T_GEN_REFRACTION : sprintf ( o , " map $refraction " ) ; break ;
case T_GEN_REFRACTIONDEPTH : sprintf ( o , " map $refractiondepth " ) ; break ;
case T_GEN_RIPPLEMAP : sprintf ( o , " map $ripplemap " ) ; break ;
case T_GEN_SOURCECUBE : sprintf ( o , " map $sourcecube " ) ; break ;
case T_GEN_GBUFFERCASE : sprintf ( o , " map $gbuffer%i " , p - > texgen - T_GEN_GBUFFER0 ) ; break ;
2017-08-29 02:29:06 +00:00
}
o + = strlen ( o ) ;
sprintf ( o , " \n " ) ; o + = strlen ( o ) ;
return o ;
}
2016-07-12 00:40:13 +00:00
char * Shader_Decompose ( shader_t * s )
{
static char decomposebuf [ 32768 ] ;
char * o = decomposebuf ;
2017-08-29 02:29:06 +00:00
shaderpass_t * p ;
unsigned int i , j ;
sprintf ( o , " \n <--- \n " ) ; o + = strlen ( o ) ;
2016-07-12 00:40:13 +00:00
switch ( s - > sort )
{
2018-04-27 16:40:50 +00:00
default : sprintf ( o , " sort %i \n " , s - > sort ) ; break ;
2017-10-31 22:52:58 +00:00
case SHADER_SORT_NONE : sprintf ( o , " sort %i (SHADER_SORT_NONE) \n " , s - > sort ) ; break ;
case SHADER_SORT_RIPPLE : sprintf ( o , " sort %i (SHADER_SORT_RIPPLE) \n " , s - > sort ) ; break ;
case SHADER_SORT_DEFERREDLIGHT : sprintf ( o , " sort %i (SHADER_SORT_DEFERREDLIGHT) \n " , s - > sort ) ; break ;
case SHADER_SORT_PORTAL : sprintf ( o , " sort %i (SHADER_SORT_PORTAL) \n " , s - > sort ) ; break ;
case SHADER_SORT_SKY : sprintf ( o , " sort %i (SHADER_SORT_SKY) \n " , s - > sort ) ; break ;
case SHADER_SORT_OPAQUE : sprintf ( o , " sort %i (SHADER_SORT_OPAQUE) \n " , s - > sort ) ; break ;
case SHADER_SORT_DECAL : sprintf ( o , " sort %i (SHADER_SORT_DECAL) \n " , s - > sort ) ; break ;
case SHADER_SORT_SEETHROUGH : sprintf ( o , " sort %i (SHADER_SORT_SEETHROUGH) \n " , s - > sort ) ; break ;
case SHADER_SORT_BANNER : sprintf ( o , " sort %i (SHADER_SORT_BANNER) \n " , s - > sort ) ; break ;
case SHADER_SORT_UNDERWATER : sprintf ( o , " sort %i (SHADER_SORT_UNDERWATER) \n " , s - > sort ) ; break ;
case SHADER_SORT_BLEND : sprintf ( o , " sort %i (SHADER_SORT_BLEND) \n " , s - > sort ) ; break ;
case SHADER_SORT_ADDITIVE : sprintf ( o , " sort %i (SHADER_SORT_ADDITIVE) \n " , s - > sort ) ; break ;
case SHADER_SORT_NEAREST : sprintf ( o , " sort %i (SHADER_SORT_NEAREST) \n " , s - > sort ) ; break ;
2016-07-12 00:40:13 +00:00
}
o + = strlen ( o ) ;
if ( s - > prog )
{
2018-11-27 16:48:19 +00:00
sprintf ( o , " program %s \n " , s - > prog - > name ) ;
2016-07-12 00:40:13 +00:00
o + = strlen ( o ) ;
2017-08-29 02:29:06 +00:00
p = s - > passes ;
o = Shader_DecomposePass ( o , p , true ) ;
for ( j = 0 ; j < s - > numpasses ; j + + )
2019-04-01 10:16:36 +00:00
o = Shader_DecomposeSubPass ( o , s , p + j , true ) ;
2016-07-12 00:40:13 +00:00
}
else
{
for ( i = 0 ; i < s - > numpasses ; i + = p - > numMergedPasses )
{
p = & s - > passes [ i ] ;
sprintf ( o , " { \n " ) ; o + = strlen ( o ) ;
2017-08-29 02:29:06 +00:00
o = Shader_DecomposePass ( o , p , false ) ;
2016-07-12 00:40:13 +00:00
for ( j = 0 ; j < p - > numMergedPasses ; j + + )
2019-04-01 10:16:36 +00:00
o = Shader_DecomposeSubPass ( o , s , p + j , ! ! p - > prog ) ;
2016-07-12 00:40:13 +00:00
sprintf ( o , " } \n " ) ; o + = strlen ( o ) ;
}
}
sprintf ( o , " ---> \n " ) ; o + = strlen ( o ) ;
return decomposebuf ;
}
# endif
char * Shader_GetShaderBody ( shader_t * s , char * fname , size_t fnamesize )
2014-10-05 20:04:11 +00:00
{
2019-03-12 05:04:27 +00:00
parsestate_t ps ;
2017-08-29 02:29:06 +00:00
char * adr , * parsename = NULL , * argsstart ;
2014-10-05 20:04:11 +00:00
char cleanname [ MAX_QPATH ] ;
char shortname [ MAX_QPATH ] ;
2016-07-12 00:40:13 +00:00
char drivername [ MAX_QPATH ] ;
2014-10-05 20:04:11 +00:00
int oldsort ;
qboolean resort = false ;
2016-07-12 00:40:13 +00:00
2014-10-05 20:04:11 +00:00
if ( ! s | | ! s - > uses )
return NULL ;
2019-03-12 05:04:27 +00:00
ps . s = s ;
2014-10-05 20:04:11 +00:00
adr = Z_StrDup ( " UNKNOWN BODY " ) ;
2019-03-12 05:04:27 +00:00
ps . saveshaderbody = & adr ;
2014-10-05 20:04:11 +00:00
strcpy ( cleanname , s - > name ) ;
2017-08-29 02:29:06 +00:00
argsstart = strchr ( cleanname , ' # ' ) ;
if ( argsstart )
* argsstart = 0 ;
2014-10-05 20:04:11 +00:00
COM_StripExtension ( cleanname , shortname , sizeof ( shortname ) ) ;
2017-08-29 02:29:06 +00:00
if ( ruleset_allow_shaders . ival & & ! ( s - > usageflags & SUR_FORCEFALLBACK ) )
2014-10-05 20:04:11 +00:00
{
if ( sh_config . shadernamefmt )
{
Q_snprintfz ( drivername , sizeof ( drivername ) , sh_config . shadernamefmt , cleanname ) ;
2019-03-12 05:04:27 +00:00
if ( ! parsename & & Shader_ParseShader ( & ps , drivername ) )
2016-07-12 00:40:13 +00:00
parsename = drivername ;
2014-10-05 20:04:11 +00:00
}
2019-03-12 05:04:27 +00:00
if ( ! parsename & & Shader_ParseShader ( & ps , cleanname ) )
2016-07-12 00:40:13 +00:00
parsename = cleanname ;
2019-03-12 05:04:27 +00:00
if ( ! parsename & & Shader_ParseShader ( & ps , shortname ) )
2016-07-12 00:40:13 +00:00
parsename = shortname ;
2014-10-05 20:04:11 +00:00
}
2016-07-12 00:40:13 +00:00
if ( ! parsename & & s - > generator )
2014-10-05 20:04:11 +00:00
{
oldsort = s - > sort ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
Shader_Regenerate ( & ps , shortname ) ;
2014-10-05 20:04:11 +00:00
if ( s - > sort ! = oldsort )
resort = true ;
}
if ( resort )
{
Mod_ResortShaders ( ) ;
}
2016-07-12 00:40:13 +00:00
if ( fnamesize )
{
2018-10-23 07:09:06 +00:00
* fname = 0 ;
2016-07-12 00:40:13 +00:00
if ( parsename )
{
unsigned int key ;
shadercache_t * cache ;
key = Hash_Key ( parsename , HASH_SIZE ) ;
cache = shader_hash [ key ] ;
for ( ; cache ; cache = cache - > hash_next )
{
if ( ! Q_stricmp ( cache - > name , parsename ) )
{
char * c , * stop ;
int line = 1 ;
//okay, this is the shader we're looking for, we know where it came from too, so there's handy.
//figure out the line index now, by just counting the \ns up to the offset
for ( c = cache - > source - > data , stop = c + cache - > offset ; c < stop ; c + + )
{
if ( * c = = ' \n ' )
line + + ;
}
Q_snprintfz ( fname , fnamesize , " %s:%i " , cache - > source - > name , line ) ;
break ;
}
}
2018-11-19 06:37:25 +00:00
2018-11-10 08:26:51 +00:00
if ( ! strchr ( parsename , ' : ' ) )
2018-10-23 07:09:06 +00:00
{
2018-11-10 08:26:51 +00:00
//if the named shader is a .shader file then just directly load it.
const char * token = COM_GetFileExtension ( parsename , NULL ) ;
if ( ! strcmp ( token , " .shader " ) | | ! * token )
2018-10-23 07:09:06 +00:00
{
2018-11-10 08:26:51 +00:00
char shaderfile [ MAX_QPATH ] ;
if ( ! * token )
{
Q_snprintfz ( shaderfile , sizeof ( shaderfile ) , " %s.shader " , parsename ) ;
if ( COM_FCheckExists ( shaderfile ) )
Q_snprintfz ( fname , fnamesize , " %s:%i " , shaderfile , 1 ) ;
}
else if ( COM_FCheckExists ( parsename ) )
Q_snprintfz ( fname , fnamesize , " %s:%i " , parsename , 1 ) ;
2018-10-23 07:09:06 +00:00
}
}
}
2016-07-12 00:40:13 +00:00
}
# ifdef _DEBUG
{
char * add , * ret ;
add = Shader_Decompose ( s ) ;
if ( * add )
{
ret = Z_Malloc ( strlen ( add ) + strlen ( adr ) + 1 ) ;
strcpy ( ret , adr ) ;
strcpy ( ret + strlen ( ret ) , add ) ;
Z_Free ( adr ) ;
adr = ret ;
}
}
# endif
2018-07-05 16:21:44 +00:00
2014-10-05 20:04:11 +00:00
return adr ;
}
2014-10-25 02:16:35 +00:00
void Shader_ShowShader_f ( void )
{
char * sourcename = Cmd_Argv ( 1 ) ;
shader_t * o = R_LoadShader ( sourcename , SUF_NONE , NULL , NULL ) ;
if ( ! o )
o = R_LoadShader ( sourcename , SUF_LIGHTMAP , NULL , NULL ) ;
if ( ! o )
o = R_LoadShader ( sourcename , SUF_2D , NULL , NULL ) ;
if ( o )
{
2020-03-07 09:00:40 +00:00
char fname [ 256 ] ;
char * body = Shader_GetShaderBody ( o , fname , sizeof ( fname ) ) ;
2014-10-25 02:16:35 +00:00
if ( body )
{
2020-03-07 09:00:40 +00:00
Con_Printf ( " ^h(%s)^h \n %s \n {%s \n " , fname , o - > name , body ) ;
2014-10-25 02:16:35 +00:00
Z_Free ( body ) ;
}
else
{
Con_Printf ( " Shader \" %s \" is not in use \n " , o - > name ) ;
}
}
else
Con_Printf ( " Shader \" %s \" is not loaded \n " , sourcename ) ;
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
void Shader_TouchTextures ( void )
{
int i , j , k ;
shader_t * s ;
shaderpass_t * p ;
texnums_t * t ;
for ( i = 0 ; i < r_numshaders ; i + + )
{
s = r_shaders [ i ] ;
if ( ! s | | ! s - > uses )
continue ;
for ( j = 0 ; j < s - > numpasses ; j + + )
{
p = & s - > passes [ j ] ;
for ( k = 0 ; k < countof ( p - > anim_frames ) ; k + + )
if ( p - > anim_frames [ k ] )
p - > anim_frames [ k ] - > regsequence = r_regsequence ;
}
for ( j = 0 ; j < max ( 1 , s - > numdefaulttextures ) ; j + + )
{
t = & s - > defaulttextures [ j ] ;
if ( t - > base )
t - > base - > regsequence = r_regsequence ;
if ( t - > bump )
t - > bump - > regsequence = r_regsequence ;
if ( t - > fullbright )
t - > fullbright - > regsequence = r_regsequence ;
if ( t - > specular )
t - > specular - > regsequence = r_regsequence ;
if ( t - > upperoverlay )
t - > upperoverlay - > regsequence = r_regsequence ;
if ( t - > loweroverlay )
t - > loweroverlay - > regsequence = r_regsequence ;
}
}
}
2009-11-04 21:16:50 +00:00
void Shader_DoReload ( void )
{
shader_t * s ;
unsigned int i ;
char shortname [ MAX_QPATH ] ;
2017-08-29 02:29:06 +00:00
char cleanname [ MAX_QPATH ] , * argsstart ;
2013-03-12 23:10:44 +00:00
int oldsort ;
qboolean resort = false ;
2019-03-12 05:04:27 +00:00
parsestate_t ps ;
2009-11-04 21:16:50 +00:00
2015-07-03 02:07:41 +00:00
//don't spam shader reloads while we're connecting, as that's just wasteful.
if ( cls . state & & cls . state < ca_active )
return ;
2016-07-17 18:41:01 +00:00
if ( ! r_shaders )
return ; //err, not ready yet
2015-07-03 02:07:41 +00:00
2015-06-26 13:21:04 +00:00
if ( shader_rescan_needed )
2010-07-11 02:22:39 +00:00
{
2014-06-21 17:58:17 +00:00
Shader_FlushCache ( ) ;
2015-06-26 13:21:04 +00:00
if ( ruleset_allow_shaders . ival )
{
2018-04-27 16:40:50 +00:00
COM_EnumerateFiles ( " materials/*.mtr " , Shader_InitCallback_Doom3 , NULL ) ;
2015-06-26 13:21:04 +00:00
COM_EnumerateFiles ( " shaders/*.shader " , Shader_InitCallback , NULL ) ;
COM_EnumerateFiles ( " scripts/*.shader " , Shader_InitCallback , NULL ) ;
COM_EnumerateFiles ( " scripts/*.rscript " , Shader_InitCallback , NULL ) ;
}
2010-07-11 02:22:39 +00:00
shader_reload_needed = true ;
shader_rescan_needed = false ;
2015-06-26 13:21:04 +00:00
Con_DPrintf ( " Rescanning shaders \n " ) ;
}
else
{
if ( ! shader_reload_needed )
return ;
Con_DPrintf ( " Reloading shaders \n " ) ;
}
2009-11-04 21:16:50 +00:00
shader_reload_needed = false ;
2015-11-18 07:37:39 +00:00
R2D_ImageColours ( 1 , 1 , 1 , 1 ) ;
2019-04-15 18:43:42 +00:00
TRACE ( ( " Reloading generics \n " ) ) ;
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 ;
2019-03-12 05:04:27 +00:00
ps . s = s ;
ps . saveshaderbody = NULL ;
2009-11-04 21:16:50 +00:00
2014-10-05 20:04:11 +00:00
strcpy ( cleanname , s - > name ) ;
2017-08-29 02:29:06 +00:00
argsstart = strchr ( cleanname , ' # ' ) ;
if ( argsstart )
* argsstart = 0 ;
2014-10-05 20:04:11 +00:00
COM_StripExtension ( cleanname , shortname , sizeof ( shortname ) ) ;
2019-04-15 18:43:42 +00:00
TRACE ( ( " reparsing %s \n " , s - > name ) ) ;
2017-08-29 02:29:06 +00:00
if ( ruleset_allow_shaders . ival & & ! ( s - > usageflags & SUR_FORCEFALLBACK ) )
2009-11-04 21:16:50 +00:00
{
2014-10-05 20:04:11 +00:00
if ( sh_config . shadernamefmt )
{
char drivername [ MAX_QPATH ] ;
Q_snprintfz ( drivername , sizeof ( drivername ) , sh_config . shadernamefmt , cleanname ) ;
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( & ps , drivername ) )
2014-10-05 20:04:11 +00:00
continue ;
}
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( & ps , cleanname ) )
2014-03-30 08:55:06 +00:00
continue ;
2018-07-05 16:21:44 +00:00
if ( strcmp ( cleanname , shortname ) )
2019-03-12 05:04:27 +00:00
if ( Shader_ParseShader ( & ps , shortname ) )
2018-07-05 16:21:44 +00:00
continue ;
2009-11-04 21:16:50 +00:00
}
if ( s - > generator )
{
2013-03-12 23:10:44 +00:00
oldsort = s - > sort ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
Shader_Regenerate ( & ps , shortname ) ;
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
2019-04-15 18:43:42 +00:00
TRACE ( ( " Resorting shaders \n " ) ) ;
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 )
{
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2010-07-11 02:22:39 +00:00
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 ;
}
2015-08-24 03:54:39 +00:00
shader_t * R_ShaderFind ( const char * name )
2008-11-09 22:29:28 +00:00
{
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 ) )
2015-08-24 03:54:39 +00:00
return s ;
2008-11-09 22:29:28 +00:00
}
2013-10-29 17:38:22 +00:00
return NULL ;
2015-08-24 03:54:39 +00:00
}
cin_t * R_ShaderFindCinematic ( const char * name )
{
2017-02-21 20:22:07 +00:00
# ifdef HAVE_MEDIA_DECODER
2015-08-24 03:54:39 +00:00
return R_ShaderGetCinematic ( R_ShaderFind ( name ) ) ;
2017-02-21 20:22:07 +00:00
# else
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 ;
2019-06-21 03:59:46 +00:00
int i ;
2020-03-07 09:00:40 +00:00
size_t l ;
2014-02-13 23:54:57 +00:00
2019-06-21 03:59:46 +00:00
char cleansrcname [ MAX_QPATH ] ;
Q_strncpyz ( cleansrcname , sourcename , sizeof ( cleansrcname ) ) ;
COM_CleanUpPath ( cleansrcname ) ;
2020-03-07 09:00:40 +00:00
l = strlen ( cleansrcname ) ;
2014-02-13 23:54:57 +00:00
2019-06-21 03:59:46 +00:00
for ( i = 0 ; i < r_numshaders ; i + + )
2014-02-13 23:54:57 +00:00
{
2019-06-21 03:59:46 +00:00
o = r_shaders [ i ] ;
if ( o & & o - > uses )
2014-06-04 16:08:30 +00:00
{
2020-03-07 09:00:40 +00:00
if ( ! strncmp ( o - > name , cleansrcname , l ) & & ( ! o - > name [ l ] | | o - > name [ l ] = = ' # ' ) )
2019-06-21 03:59:46 +00:00
{
2020-03-07 09:00:40 +00:00
n = R_LoadShader ( va ( " %s%s " , destname , o - > name + l ) , o - > usageflags , NULL , NULL ) ;
2019-06-21 03:59:46 +00:00
if ( ! n )
{ //if it isn't actually available on disk then don't care about usageflags, just find ANY that's already loaded.
// check the hash first
char cleandstname [ MAX_QPATH ] ;
Q_strncpyz ( cleandstname , destname , sizeof ( cleandstname ) ) ;
COM_CleanUpPath ( cleandstname ) ;
n = Hash_Get ( & shader_active_hash , cleandstname ) ;
if ( ! n | | ! n - > uses )
n = o ;
}
o - > remapto = n ;
o - > remaptime = timeoffset ; //this just feels wrong.
}
2014-06-04 16:08:30 +00:00
}
2014-02-13 23:54:57 +00:00
}
}
void Shader_RemapShader_f ( void )
{
char * sourcename = Cmd_Argv ( 1 ) ;
char * destname = Cmd_Argv ( 2 ) ;
float timeoffset = atof ( Cmd_Argv ( 3 ) ) ;
2018-07-05 16:21:44 +00:00
if ( ! Cmd_FromGamecode ( ) & & strcmp ( InfoBuf_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-10-05 20:04:11 +00:00
//blocks
int R_GetShaderSizes ( shader_t * shader , int * width , int * height , qboolean blocktillloaded )
{
if ( ! shader )
return false ;
2015-06-12 14:44:50 +00:00
if ( ! shader - > width & & ! shader - > height )
2014-10-05 20:04:11 +00:00
{
int i ;
if ( width )
* width = 0 ;
if ( height )
* height = 0 ;
2016-07-12 00:40:13 +00:00
if ( ( shader - > flags & SHADER_HASDIFFUSE ) & & shader - > defaulttextures - > base )
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
if ( shader - > defaulttextures - > base - > status = = TEX_LOADING )
2014-10-05 20:04:11 +00:00
{
if ( ! blocktillloaded )
return - 1 ;
2016-07-12 00:40:13 +00:00
COM_WorkerPartialSync ( shader - > defaulttextures - > base , & shader - > defaulttextures - > base - > status , TEX_LOADING ) ;
}
if ( shader - > defaulttextures - > base - > status = = TEX_LOADED )
{
shader - > width = shader - > defaulttextures - > base - > width ;
shader - > height = shader - > defaulttextures - > base - > height ;
2014-10-05 20:04:11 +00:00
}
2016-07-12 00:40:13 +00:00
}
else if ( ( shader - > flags & SHADER_HASPALETTED ) & & shader - > defaulttextures - > paletted )
{
if ( shader - > defaulttextures - > paletted - > status = = TEX_LOADING )
2014-10-05 20:04:11 +00:00
{
if ( ! blocktillloaded )
return - 1 ;
2016-07-12 00:40:13 +00:00
COM_WorkerPartialSync ( shader - > defaulttextures - > paletted , & shader - > defaulttextures - > paletted - > status , TEX_LOADING ) ;
}
if ( shader - > defaulttextures - > paletted - > status = = TEX_LOADED )
{
shader - > width = shader - > defaulttextures - > paletted - > width ;
shader - > height = shader - > defaulttextures - > paletted - > height ;
2014-10-05 20:04:11 +00:00
}
}
2016-07-12 00:40:13 +00:00
else
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
for ( i = 0 ; i < shader - > numpasses ; i + + )
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
if ( shader - > passes [ i ] . texgen = = T_GEN_SINGLEMAP & & shader - > passes [ i ] . anim_frames [ 0 ] & & shader - > passes [ i ] . anim_frames [ 0 ] - > status = = TEX_LOADING )
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
if ( ! blocktillloaded )
return - 1 ;
COM_WorkerPartialSync ( shader - > passes [ i ] . anim_frames [ 0 ] , & shader - > passes [ i ] . anim_frames [ 0 ] - > status , TEX_LOADING ) ;
}
if ( shader - > passes [ i ] . texgen = = T_GEN_DIFFUSE & & ( shader - > defaulttextures - > base & & shader - > defaulttextures - > base - > status = = TEX_LOADING ) )
{
if ( ! blocktillloaded )
return - 1 ;
COM_WorkerPartialSync ( shader - > defaulttextures - > base , & shader - > defaulttextures - > base - > status , TEX_LOADING ) ;
}
if ( shader - > passes [ i ] . texgen = = T_GEN_PALETTED & & ( shader - > defaulttextures - > paletted & & shader - > defaulttextures - > paletted - > status = = TEX_LOADING ) )
{
if ( ! blocktillloaded )
return - 1 ;
COM_WorkerPartialSync ( shader - > defaulttextures - > paletted , & shader - > defaulttextures - > paletted - > status , TEX_LOADING ) ;
2014-10-05 20:04:11 +00:00
}
}
2016-07-12 00:40:13 +00:00
for ( i = 0 ; i < shader - > numpasses ; i + + )
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
if ( shader - > passes [ i ] . texgen = = T_GEN_SINGLEMAP )
2014-10-05 20:04:11 +00:00
{
2016-07-12 00:40:13 +00:00
if ( shader - > passes [ i ] . anim_frames [ 0 ] & & shader - > passes [ i ] . anim_frames [ 0 ] - > status = = TEX_LOADED )
{
shader - > width = shader - > passes [ i ] . anim_frames [ 0 ] - > width ;
shader - > height = shader - > passes [ i ] . anim_frames [ 0 ] - > height ;
}
break ;
}
if ( shader - > passes [ i ] . texgen = = T_GEN_DIFFUSE )
{
if ( shader - > defaulttextures - > base & & shader - > defaulttextures - > base - > status = = TEX_LOADED )
{
shader - > width = shader - > defaulttextures - > base - > width ;
shader - > height = shader - > defaulttextures - > base - > height ;
}
break ;
}
if ( shader - > passes [ i ] . texgen = = T_GEN_PALETTED )
{
if ( shader - > defaulttextures - > paletted & & shader - > defaulttextures - > paletted - > status = = TEX_LOADED )
{
shader - > width = shader - > defaulttextures - > paletted - > width ;
shader - > height = shader - > defaulttextures - > paletted - > height ;
}
break ;
2014-10-05 20:04:11 +00:00
}
}
2016-07-12 00:40:13 +00:00
if ( i = = shader - > numpasses )
{ //this shader has no textures from which to source a width and height
if ( ! shader - > width )
shader - > width = 64 ;
if ( ! shader - > height )
shader - > height = 64 ;
}
2014-10-11 19:39:45 +00:00
}
2014-10-05 20:04:11 +00:00
}
if ( shader - > width & & shader - > height )
{
if ( width )
* width = shader - > width ;
if ( height )
* height = shader - > height ;
return true ; //final size
}
else
{
//fill with dummy values
if ( width )
* width = 64 ;
if ( height )
* height = 64 ;
return false ;
}
}
2017-01-24 20:15:14 +00:00
shader_t * R_RegisterPic ( const char * name , const char * subdirs )
2004-10-19 15:56:22 +00:00
{
2011-12-26 15:19:13 +00:00
shader_t * shader ;
2017-01-24 20:15:14 +00:00
shader = R_LoadShader ( name , SUF_2D , Shader_Default2D , subdirs ) ;
2011-12-26 15:19:13 +00:00
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
{
2014-10-05 20:04:11 +00:00
char newsname [ MAX_QPATH ] ;
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
2014-10-05 20:04:11 +00:00
newsname [ 0 ] = 0 ;
2014-03-30 08:55:06 +00:00
if ( modname & & ! strchr ( shadername , ' / ' ) & & * shadername )
2011-07-30 14:14:56 +00:00
{
char * b = COM_SkipPath ( modname ) ;
if ( b ! = modname & & b - modname + strlen ( shadername ) + 1 < sizeof ( newsname ) )
{
2014-10-05 20:04:11 +00:00
b - - ; //no trailing /
2011-07-30 14:14:56 +00:00
memcpy ( newsname , modname , b - modname ) ;
2014-10-05 20:04:11 +00:00
newsname [ b - modname ] = 0 ;
2011-07-30 14:14:56 +00:00
}
}
2014-10-05 20:04:11 +00:00
if ( * newsname )
{
int l = strlen ( newsname ) ;
Q_strncpyz ( newsname + l , " :models " , sizeof ( newsname ) - l ) ;
}
else
Q_strncpyz ( newsname , " models " , sizeof ( newsname ) ) ;
shader = R_LoadShader ( shadername , 0 , Shader_DefaultSkin , newsname ) ;
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