2008-07-25 07:31:37 +00:00
|
|
|
/* -------------------------------------------------------------------------------
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant 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.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
----------------------------------------------------------------------------------
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This code has been altered significantly from its original form, to support
|
|
|
|
several games based on the Quake III Arena engine, in the form of "Q3Map2."
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
------------------------------------------------------------------------------- */
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* marker */
|
|
|
|
#define SHADERS_C
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* dependencies */
|
|
|
|
#include "q3map2.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
ColorMod()
|
|
|
|
routines for dealing with vertex color/alpha modification
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ColorMod( colorMod_t *cm, int numVerts, bspDrawVert_t *drawVerts ){
|
|
|
|
int i, j, k;
|
|
|
|
float c;
|
|
|
|
vec4_t mult, add;
|
|
|
|
bspDrawVert_t *dv;
|
|
|
|
colorMod_t *cm2;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( cm == NULL || numVerts < 1 || drawVerts == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* walk vertex list */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numVerts; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get vertex */
|
|
|
|
dv = &drawVerts[ i ];
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* walk colorMod list */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( cm2 = cm; cm2 != NULL; cm2 = cm2->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2008-07-25 07:31:37 +00:00
|
|
|
/* default */
|
|
|
|
VectorSet( mult, 1.0f, 1.0f, 1.0f );
|
|
|
|
mult[ 3 ] = 1.0f;
|
|
|
|
VectorSet( add, 0.0f, 0.0f, 0.0f );
|
|
|
|
mult[ 3 ] = 0.0f;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* switch on type */
|
2012-03-17 20:01:54 +00:00
|
|
|
switch ( cm2->type )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
case CM_COLOR_SET:
|
|
|
|
VectorClear( mult );
|
|
|
|
VectorScale( cm2->data, 255.0f, add );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_ALPHA_SET:
|
|
|
|
mult[ 3 ] = 0.0f;
|
|
|
|
add[ 3 ] = cm2->data[ 0 ] * 255.0f;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_COLOR_SCALE:
|
|
|
|
VectorCopy( cm2->data, mult );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_ALPHA_SCALE:
|
|
|
|
mult[ 3 ] = cm2->data[ 0 ];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_COLOR_DOT_PRODUCT:
|
|
|
|
c = DotProduct( dv->normal, cm2->data );
|
|
|
|
VectorSet( mult, c, c, c );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_ALPHA_DOT_PRODUCT:
|
|
|
|
mult[ 3 ] = DotProduct( dv->normal, cm2->data );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_COLOR_DOT_PRODUCT_2:
|
|
|
|
c = DotProduct( dv->normal, cm2->data );
|
|
|
|
c *= c;
|
|
|
|
VectorSet( mult, c, c, c );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CM_ALPHA_DOT_PRODUCT_2:
|
|
|
|
mult[ 3 ] = DotProduct( dv->normal, cm2->data );
|
|
|
|
mult[ 3 ] *= mult[ 3 ];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* apply mod */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < MAX_LIGHTMAPS; j++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( k = 0; k < 4; k++ )
|
2008-07-25 07:31:37 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
c = ( mult[ k ] * dv->color[ j ][ k ] ) + add[ k ];
|
|
|
|
if ( c < 0 ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
c = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( c > 255 ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
c = 255;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2008-07-25 07:31:37 +00:00
|
|
|
dv->color[ j ][ k ] = c;
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
TCMod*()
|
|
|
|
routines for dealing with a 3x3 texture mod matrix
|
|
|
|
*/
|
|
|
|
|
|
|
|
void TCMod( tcMod_t mod, float st[ 2 ] ){
|
|
|
|
float old[ 2 ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
old[ 0 ] = st[ 0 ];
|
|
|
|
old[ 1 ] = st[ 1 ];
|
2012-03-17 20:01:54 +00:00
|
|
|
st[ 0 ] = ( mod[ 0 ][ 0 ] * old[ 0 ] ) + ( mod[ 0 ][ 1 ] * old[ 1 ] ) + mod[ 0 ][ 2 ];
|
|
|
|
st[ 1 ] = ( mod[ 1 ][ 0 ] * old[ 0 ] ) + ( mod[ 1 ][ 1 ] * old[ 1 ] ) + mod[ 1 ][ 2 ];
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TCModIdentity( tcMod_t mod ){
|
|
|
|
mod[ 0 ][ 0 ] = 1.0f; mod[ 0 ][ 1 ] = 0.0f; mod[ 0 ][ 2 ] = 0.0f;
|
|
|
|
mod[ 1 ][ 0 ] = 0.0f; mod[ 1 ][ 1 ] = 1.0f; mod[ 1 ][ 2 ] = 0.0f;
|
|
|
|
mod[ 2 ][ 0 ] = 0.0f; mod[ 2 ][ 1 ] = 0.0f; mod[ 2 ][ 2 ] = 1.0f; /* this row is only used for multiples, not transformation */
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TCModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ){
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < 3; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
out[ i ][ 0 ] = ( a[ i ][ 0 ] * b[ 0 ][ 0 ] ) + ( a[ i ][ 1 ] * b[ 1 ][ 0 ] ) + ( a[ i ][ 2 ] * b[ 2 ][ 0 ] );
|
|
|
|
out[ i ][ 1 ] = ( a[ i ][ 0 ] * b[ 0 ][ 1 ] ) + ( a[ i ][ 1 ] * b[ 1 ][ 1 ] ) + ( a[ i ][ 2 ] * b[ 2 ][ 1 ] );
|
|
|
|
out[ i ][ 2 ] = ( a[ i ][ 0 ] * b[ 0 ][ 2 ] ) + ( a[ i ][ 1 ] * b[ 1 ][ 2 ] ) + ( a[ i ][ 2 ] * b[ 2 ][ 2 ] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TCModTranslate( tcMod_t mod, float s, float t ){
|
2007-11-04 03:34:51 +00:00
|
|
|
mod[ 0 ][ 2 ] += s;
|
|
|
|
mod[ 1 ][ 2 ] += t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TCModScale( tcMod_t mod, float s, float t ){
|
2007-11-04 03:34:51 +00:00
|
|
|
mod[ 0 ][ 0 ] *= s;
|
|
|
|
mod[ 1 ][ 1 ] *= t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void TCModRotate( tcMod_t mod, float euler ){
|
|
|
|
tcMod_t old, temp;
|
|
|
|
float radians, sinv, cosv;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
memcpy( old, mod, sizeof( tcMod_t ) );
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModIdentity( temp );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
radians = euler / 180 * Q_PI;
|
|
|
|
sinv = sin( radians );
|
|
|
|
cosv = cos( radians );
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
temp[ 0 ][ 0 ] = cosv; temp[ 0 ][ 1 ] = -sinv;
|
|
|
|
temp[ 1 ][ 0 ] = sinv; temp[ 1 ][ 1 ] = cosv;
|
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModMultiply( old, temp, mod );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
ApplySurfaceParm() - ydnar
|
|
|
|
applies a named surfaceparm to the supplied flags
|
|
|
|
*/
|
|
|
|
|
|
|
|
qboolean ApplySurfaceParm( char *name, int *contentFlags, int *surfaceFlags, int *compileFlags ){
|
|
|
|
int i, fake;
|
|
|
|
surfaceParm_t *sp;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( name == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
name = "";
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( contentFlags == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
contentFlags = &fake;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( surfaceFlags == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
surfaceFlags = &fake;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( compileFlags == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
compileFlags = &fake;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* walk the current game's surfaceparms */
|
|
|
|
sp = game->surfaceParms;
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( sp->name != NULL )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* match? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( name, sp->name ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* clear and set flags */
|
2012-03-17 20:01:54 +00:00
|
|
|
*contentFlags &= ~( sp->contentFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*contentFlags |= sp->contentFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
*surfaceFlags &= ~( sp->surfaceFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*surfaceFlags |= sp->surfaceFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
*compileFlags &= ~( sp->compileFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*compileFlags |= sp->compileFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return ok */
|
|
|
|
return qtrue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* next */
|
|
|
|
sp++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* check custom info parms */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numCustSurfaceParms; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get surfaceparm */
|
|
|
|
sp = &custSurfaceParms[ i ];
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* match? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( name, sp->name ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* clear and set flags */
|
2012-03-17 20:01:54 +00:00
|
|
|
*contentFlags &= ~( sp->contentFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*contentFlags |= sp->contentFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
*surfaceFlags &= ~( sp->surfaceFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*surfaceFlags |= sp->surfaceFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
*compileFlags &= ~( sp->compileFlagsClear );
|
2007-11-04 03:34:51 +00:00
|
|
|
*compileFlags |= sp->compileFlags;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return ok */
|
|
|
|
return qtrue;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* no matching surfaceparm found */
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
BeginMapShaderFile() - ydnar
|
|
|
|
erases and starts a new map shader script
|
|
|
|
*/
|
|
|
|
|
|
|
|
void BeginMapShaderFile( const char *mapFile ){
|
|
|
|
char base[ 1024 ];
|
|
|
|
int len;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* dummy check */
|
|
|
|
mapName[ 0 ] = '\0';
|
|
|
|
mapShaderFile[ 0 ] = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( mapFile == NULL || mapFile[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* copy map name */
|
|
|
|
strcpy( base, mapFile );
|
|
|
|
StripExtension( base );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* extract map name */
|
|
|
|
len = strlen( base ) - 1;
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( len > 0 && base[ len ] != '/' && base[ len ] != '\\' )
|
2007-11-04 03:34:51 +00:00
|
|
|
len--;
|
|
|
|
strcpy( mapName, &base[ len + 1 ] );
|
|
|
|
base[ len ] = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( len <= 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* append ../scripts/q3map2_<mapname>.shader */
|
|
|
|
sprintf( mapShaderFile, "%s/../%s/q3map2_%s.shader", base, game->shaderPath, mapName );
|
|
|
|
Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* remove it */
|
|
|
|
remove( mapShaderFile );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* stop making warnings about missing images */
|
|
|
|
warnImage = qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
WriteMapShaderFile() - ydnar
|
|
|
|
writes a shader to the map shader script
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WriteMapShaderFile( void ){
|
|
|
|
FILE *file;
|
|
|
|
shaderInfo_t *si;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( mapShaderFile[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* are there any custom shaders? */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0, num = 0; i < numShaderInfo; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( shaderInfo[ i ].custom ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( i == numShaderInfo ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* note it */
|
2012-03-17 20:01:54 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "--- WriteMapShaderFile ---\n" );
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "Writing %s", mapShaderFile );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* open shader file */
|
|
|
|
file = fopen( mapShaderFile, "w" );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( file == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Unable to open map shader file %s for writing\n", mapShaderFile );
|
|
|
|
return;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* print header */
|
|
|
|
fprintf( file,
|
2012-03-17 20:01:54 +00:00
|
|
|
"// Custom shader file for %s.bsp\n"
|
|
|
|
"// Generated by Q3Map2 (ydnar)\n"
|
|
|
|
"// Do not edit! This file is overwritten on recompiles.\n\n",
|
|
|
|
mapName );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* walk the shader list */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0, num = 0; i < numShaderInfo; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get the shader and print it */
|
|
|
|
si = &shaderInfo[ i ];
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->custom == qfalse || si->shaderText == NULL || si->shaderText[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
num++;
|
|
|
|
|
|
|
|
/* print it to the file */
|
|
|
|
fprintf( file, "%s%s\n", si->shader, si->shaderText );
|
2008-08-24 03:20:51 +00:00
|
|
|
//Sys_Printf( "%s%s\n", si->shader, si->shaderText ); /* FIXME: remove debugging code */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "." );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* close the shader */
|
2008-08-24 03:20:51 +00:00
|
|
|
fflush( file );
|
2007-11-04 03:34:51 +00:00
|
|
|
fclose( file );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "\n" );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* print some stats */
|
|
|
|
Sys_Printf( "%9d custom shaders emitted\n", num );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
CustomShader() - ydnar
|
|
|
|
sets up a custom map shader
|
|
|
|
*/
|
|
|
|
|
|
|
|
shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
|
|
|
|
shaderInfo_t *csi;
|
|
|
|
char shader[ MAX_QPATH ];
|
|
|
|
char *s;
|
|
|
|
int loc;
|
|
|
|
md5_state_t mh;
|
|
|
|
byte digest[ 16 ];
|
|
|
|
char *srcShaderText, temp[ 8192 ], shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return ShaderInfoForShader( "default" );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* default shader text source */
|
|
|
|
srcShaderText = si->shaderText;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* et: implicitMap */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->implicitMap == IM_OPAQUE ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
srcShaderText = temp;
|
|
|
|
sprintf( temp, "\n"
|
2012-03-17 20:01:54 +00:00
|
|
|
"{ // Q3Map2 defaulted (implicitMap)\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap $lightmap\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\tq3map_styleMarker\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap %s\n"
|
|
|
|
"\t\tblendFunc GL_DST_COLOR GL_ZERO\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t}\n"
|
|
|
|
"}\n",
|
|
|
|
si->implicitImagePath );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* et: implicitMask */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( si->implicitMap == IM_MASKED ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
srcShaderText = temp;
|
|
|
|
sprintf( temp, "\n"
|
2012-03-17 20:01:54 +00:00
|
|
|
"{ // Q3Map2 defaulted (implicitMask)\n"
|
|
|
|
"\tcull none\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap %s\n"
|
|
|
|
"\t\talphaFunc GE128\n"
|
|
|
|
"\t\tdepthWrite\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap $lightmap\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t\tdepthFunc equal\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\tq3map_styleMarker\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap %s\n"
|
|
|
|
"\t\tblendFunc GL_DST_COLOR GL_ZERO\n"
|
|
|
|
"\t\tdepthFunc equal\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t}\n"
|
|
|
|
"}\n",
|
|
|
|
si->implicitImagePath,
|
|
|
|
si->implicitImagePath );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* et: implicitBlend */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( si->implicitMap == IM_BLEND ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
srcShaderText = temp;
|
|
|
|
sprintf( temp, "\n"
|
2012-03-17 20:01:54 +00:00
|
|
|
"{ // Q3Map2 defaulted (implicitBlend)\n"
|
|
|
|
"\tcull none\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap %s\n"
|
|
|
|
"\t\tblendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap $lightmap\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t\tblendFunc GL_DST_COLOR GL_ZERO\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\tq3map_styleMarker\n"
|
|
|
|
"}\n",
|
|
|
|
si->implicitImagePath );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* default shader text */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( srcShaderText == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
srcShaderText = temp;
|
|
|
|
sprintf( temp, "\n"
|
2012-03-17 20:01:54 +00:00
|
|
|
"{ // Q3Map2 defaulted\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap $lightmap\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t}\n"
|
|
|
|
"\tq3map_styleMarker\n"
|
|
|
|
"\t{\n"
|
|
|
|
"\t\tmap %s.tga\n"
|
|
|
|
"\t\tblendFunc GL_DST_COLOR GL_ZERO\n"
|
|
|
|
"\t\trgbGen identity\n"
|
|
|
|
"\t}\n"
|
|
|
|
"}\n",
|
|
|
|
si->shader );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* error check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( strlen( mapName ) + 1 + 32 ) > MAX_QPATH ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Custom shader name length (%d) exceeded. Shorten your map name.\n", MAX_QPATH );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* do some bad find-replace */
|
|
|
|
s = strstr( srcShaderText, find );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( s == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
//% strcpy( shaderText, srcShaderText );
|
2012-03-17 20:01:54 +00:00
|
|
|
return si; /* testing just using the existing shader if this fails */
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* substitute 'find' with 'replace' */
|
|
|
|
loc = s - srcShaderText;
|
|
|
|
strcpy( shaderText, srcShaderText );
|
|
|
|
shaderText[ loc ] = '\0';
|
|
|
|
strcat( shaderText, replace );
|
|
|
|
strcat( shaderText, &srcShaderText[ loc + strlen( find ) ] );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* make md5 hash of the shader text */
|
2010-11-26 05:59:17 +00:00
|
|
|
md5_init( &mh );
|
|
|
|
md5_append( &mh, shaderText, strlen( shaderText ) );
|
|
|
|
md5_finish( &mh, digest );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* mangle hash into a shader name */
|
|
|
|
sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName,
|
2012-03-17 20:01:54 +00:00
|
|
|
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
|
|
|
|
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get shader */
|
|
|
|
csi = ShaderInfoForShader( shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* might be a preexisting shader */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( csi->custom ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return csi;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* clone the existing shader and rename */
|
|
|
|
memcpy( csi, si, sizeof( shaderInfo_t ) );
|
|
|
|
strcpy( csi->shader, shader );
|
|
|
|
csi->custom = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* store new shader text */
|
|
|
|
csi->shaderText = safe_malloc( strlen( shaderText ) + 1 );
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( csi->shaderText, shaderText ); /* LEAK! */
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return it */
|
|
|
|
return csi;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
EmitVertexRemapShader()
|
|
|
|
adds a vertexremapshader key/value pair to worldspawn
|
|
|
|
*/
|
|
|
|
|
|
|
|
void EmitVertexRemapShader( char *from, char *to ){
|
|
|
|
md5_state_t mh;
|
|
|
|
byte digest[ 16 ];
|
|
|
|
char key[ 64 ], value[ 256 ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( from == NULL || from[ 0 ] == '\0' ||
|
|
|
|
to == NULL || to[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* build value */
|
|
|
|
sprintf( value, "%s;%s", from, to );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* make md5 hash */
|
2010-11-26 05:59:17 +00:00
|
|
|
md5_init( &mh );
|
|
|
|
md5_append( &mh, value, strlen( value ) );
|
|
|
|
md5_finish( &mh, digest );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
/* make key (this is annoying, as vertexremapshader is precisely 17 characters,
|
|
|
|
which is one too long, so we leave off the last byte of the md5 digest) */
|
|
|
|
sprintf( key, "vertexremapshader%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
2012-03-17 20:01:54 +00:00
|
|
|
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
|
|
|
|
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ] ); /* no: digest[ 15 ] */
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add key/value pair to worldspawn */
|
|
|
|
SetKeyValue( &entities[ 0 ], key, value );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
AllocShaderInfo()
|
|
|
|
allocates and initializes a new shader
|
|
|
|
*/
|
|
|
|
|
|
|
|
static shaderInfo_t *AllocShaderInfo( void ){
|
|
|
|
shaderInfo_t *si;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( shaderInfo == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
shaderInfo = safe_malloc( sizeof( shaderInfo_t ) * MAX_SHADER_INFO );
|
|
|
|
numShaderInfo = 0;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* bounds check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numShaderInfo == MAX_SHADER_INFO ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "MAX_SHADER_INFO exceeded. Remove some PK3 files or shader scripts from shaderlist.txt and try again." );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
si = &shaderInfo[ numShaderInfo ];
|
|
|
|
numShaderInfo++;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: clear to 0 first */
|
|
|
|
memset( si, 0, sizeof( shaderInfo_t ) );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set defaults */
|
|
|
|
ApplySurfaceParm( "default", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
si->backsplashFraction = DEF_BACKSPLASH_FRACTION;
|
|
|
|
si->backsplashDistance = DEF_BACKSPLASH_DISTANCE;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
si->bounceScale = DEF_RADIOSITY_BOUNCE;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
si->lightStyle = LS_NORMAL;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
si->polygonOffset = qfalse;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shadeAngleDegrees = 0.0f;
|
|
|
|
si->lightmapSampleSize = 0;
|
|
|
|
si->lightmapSampleOffset = DEFAULT_LIGHTMAP_SAMPLE_OFFSET;
|
|
|
|
si->patchShadows = qfalse;
|
2012-03-17 20:01:54 +00:00
|
|
|
si->vertexShadows = qtrue; /* ydnar: changed default behavior */
|
2007-11-04 03:34:51 +00:00
|
|
|
si->forceSunlight = qfalse;
|
|
|
|
si->vertexScale = 1.0;
|
|
|
|
si->notjunc = qfalse;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: set texture coordinate transform matrix to identity */
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModIdentity( si->mod );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar: lightmaps can now be > 128x128 in certain games or an externally generated tga */
|
|
|
|
si->lmCustomWidth = lmCustomSize;
|
|
|
|
si->lmCustomHeight = lmCustomSize;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return to sender */
|
|
|
|
return si;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
FinishShader() - ydnar
|
|
|
|
sets a shader's width and height among other things
|
|
|
|
*/
|
|
|
|
|
|
|
|
void FinishShader( shaderInfo_t *si ){
|
|
|
|
int x, y;
|
|
|
|
float st[ 2 ], o[ 2 ], dist, bestDist;
|
|
|
|
vec4_t color, bestColor, delta;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* don't double-dip */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->finished ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* if they're explicitly set, copy from image size */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->shaderWidth == 0 && si->shaderHeight == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderWidth = si->shaderImage->width;
|
|
|
|
si->shaderHeight = si->shaderImage->height;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* legacy terrain has explicit image-sized texture projection */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->legacyTerrain && si->tcGen == qfalse ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set xy texture projection */
|
|
|
|
si->tcGen = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
VectorSet( si->vecs[ 0 ], ( 1.0f / ( si->shaderWidth * 0.5f ) ), 0, 0 );
|
|
|
|
VectorSet( si->vecs[ 1 ], 0, ( 1.0f / ( si->shaderHeight * 0.5f ) ), 0 );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* find pixel coordinates best matching the average color of the image */
|
|
|
|
bestDist = 99999999;
|
|
|
|
o[ 0 ] = 1.0f / si->shaderImage->width;
|
|
|
|
o[ 1 ] = 1.0f / si->shaderImage->height;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( y = 0, st[ 1 ] = 0.0f; y < si->shaderImage->height; y++, st[ 1 ] += o[ 1 ] )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( x = 0, st[ 0 ] = 0.0f; x < si->shaderImage->width; x++, st[ 0 ] += o[ 0 ] )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* sample the shader image */
|
|
|
|
RadSampleImage( si->shaderImage->pixels, si->shaderImage->width, si->shaderImage->height, st, color );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* determine error squared */
|
|
|
|
VectorSubtract( color, si->averageColor, delta );
|
|
|
|
delta[ 3 ] = color[ 3 ] - si->averageColor[ 3 ];
|
|
|
|
dist = delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ] + delta[ 2 ] * delta[ 2 ] + delta[ 3 ] * delta[ 3 ];
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( dist < bestDist ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorCopy( color, bestColor );
|
|
|
|
bestColor[ 3 ] = color[ 3 ];
|
|
|
|
si->stFlat[ 0 ] = st[ 0 ];
|
|
|
|
si->stFlat[ 1 ] = st[ 1 ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set to finished */
|
|
|
|
si->finished = qtrue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
LoadShaderImages()
|
|
|
|
loads a shader's images
|
|
|
|
ydnar: image.c made this a bit simpler
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void LoadShaderImages( shaderInfo_t *si ){
|
|
|
|
int i, count;
|
|
|
|
float color[ 4 ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* nodraw shaders don't need images */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->compileFlags & C_NODRAW ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderImage = ImageLoad( DEFAULT_IMAGE );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* try to load editor image first */
|
|
|
|
si->shaderImage = ImageLoad( si->editorImagePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* then try shadername */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->shaderImage == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderImage = ImageLoad( si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* then try implicit image path (note: new behavior!) */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->shaderImage == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderImage = ImageLoad( si->implicitImagePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* then try lightimage (note: new behavior!) */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->shaderImage == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderImage = ImageLoad( si->lightImagePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* otherwise, use default image */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->shaderImage == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->shaderImage = ImageLoad( DEFAULT_IMAGE );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( warnImage && strcmp( si->shader, "noshader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Couldn't find image for shader %s\n", si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load light image */
|
|
|
|
si->lightImage = ImageLoad( si->lightImagePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load normalmap image (ok if this is NULL) */
|
|
|
|
si->normalImage = ImageLoad( si->normalImagePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->normalImage != NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_FPrintf( SYS_VRB, "Shader %s has\n"
|
|
|
|
" NM %s\n", si->shader, si->normalImagePath );
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* if no light image, use shader image */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->lightImage == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->lightImage = ImageLoad( si->shaderImage->name );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* create default and average colors */
|
|
|
|
count = si->lightImage->width * si->lightImage->height;
|
|
|
|
VectorClear( color );
|
|
|
|
color[ 3 ] = 0.0f;
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < count; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
color[ 0 ] += si->lightImage->pixels[ i * 4 + 0 ];
|
|
|
|
color[ 1 ] += si->lightImage->pixels[ i * 4 + 1 ];
|
|
|
|
color[ 2 ] += si->lightImage->pixels[ i * 4 + 2 ];
|
|
|
|
color[ 3 ] += si->lightImage->pixels[ i * 4 + 3 ];
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
if ( VectorLength( si->color ) <= 0.0f ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ColorNormalize( color, si->color );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
VectorScale( color, ( 1.0f / count ), si->averageColor );
|
2013-11-01 00:24:58 +00:00
|
|
|
si->averageColor[ 3 ] = color[ 3 ] / count;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
ShaderInfoForShader()
|
|
|
|
finds a shaderinfo for a named shader
|
|
|
|
*/
|
|
|
|
|
|
|
|
shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
|
|
|
|
int i;
|
|
|
|
shaderInfo_t *si;
|
|
|
|
char shader[ MAX_QPATH ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( shaderName == NULL || shaderName[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Null or empty shader name\n" );
|
|
|
|
shaderName = "missing";
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* strip off extension */
|
|
|
|
strcpy( shader, shaderName );
|
|
|
|
StripExtension( shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* search for it */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numShaderInfo; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
si = &shaderInfo[ i ];
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( shader, si->shader ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load image if necessary */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->finished == qfalse ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
LoadShaderImages( si );
|
|
|
|
FinishShader( si );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return it */
|
|
|
|
return si;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate a default shader */
|
|
|
|
si = AllocShaderInfo();
|
|
|
|
strcpy( si->shader, shader );
|
|
|
|
LoadShaderImages( si );
|
|
|
|
FinishShader( si );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return it */
|
|
|
|
return si;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
GetTokenAppend() - ydnar
|
|
|
|
gets a token and appends its text to the specified buffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int oldScriptLine = 0;
|
|
|
|
static int tabDepth = 0;
|
|
|
|
|
|
|
|
qboolean GetTokenAppend( char *buffer, qboolean crossline ){
|
|
|
|
qboolean r;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get the token */
|
|
|
|
r = GetToken( crossline );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( r == qfalse || buffer == NULL || token[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return r;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* pre-tabstops */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] == '}' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tabDepth--;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* append? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( oldScriptLine != scriptline ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcat( buffer, "\n" );
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < tabDepth; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
strcat( buffer, "\t" );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
strcat( buffer, " " );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
oldScriptLine = scriptline;
|
|
|
|
strcat( buffer, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* post-tabstops */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] == '{' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
tabDepth++;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* return */
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, "(" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Parse1DMatrixAppend(): line %d: ( not found!", scriptline );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
for ( i = 0; i < x; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetTokenAppend( buffer, qfalse ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Parse1DMatrixAppend(): line %d: Number not found!", scriptline );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
m[ i ] = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, ")" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Parse1DMatrixAppend(): line %d: ) not found!", scriptline );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
ParseShaderFile()
|
|
|
|
parses a shader file into discrete shaderInfo_t
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void ParseShaderFile( const char *filename ){
|
|
|
|
int i, val;
|
|
|
|
shaderInfo_t *si;
|
|
|
|
char *suffix, temp[ 1024 ];
|
|
|
|
char shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* init */
|
|
|
|
si = NULL;
|
|
|
|
shaderText[ 0 ] = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load the shader */
|
|
|
|
LoadScriptFile( filename, 0 );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* tokenize it */
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( 1 )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* copy shader text to the shaderinfo */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si != NULL && shaderText[ 0 ] != '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcat( shaderText, "\n" );
|
|
|
|
si->shaderText = safe_malloc( strlen( shaderText ) + 1 );
|
|
|
|
strcpy( si->shaderText, shaderText );
|
|
|
|
//% if( VectorLength( si->vecs[ 0 ] ) )
|
|
|
|
//% Sys_Printf( "%s\n", shaderText );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: clear shader text buffer */
|
|
|
|
shaderText[ 0 ] = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* test for end of file */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetToken( qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* shader name is initial token */
|
|
|
|
si = AllocShaderInfo();
|
|
|
|
strcpy( si->shader, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ignore ":q3map" suffix */
|
|
|
|
suffix = strstr( si->shader, ":q3map" );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( suffix != NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
*suffix = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* handle { } section */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetTokenAppend( shaderText, qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( strcmp( token, "{" ) ) {
|
|
|
|
if ( si != NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s",
|
2012-03-17 20:01:54 +00:00
|
|
|
filename, scriptline, token, si->shader );
|
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s",
|
2012-03-17 20:01:54 +00:00
|
|
|
filename, scriptline, token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
while ( 1 )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* get the next token */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetTokenAppend( shaderText, qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( !strcmp( token, "}" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
shader stages (passes)
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse stage directives */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( token, "{" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->hasPasses = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( 1 )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetTokenAppend( shaderText, qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( !strcmp( token, "}" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* only care about images if we don't have a editor/light image */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->editorImagePath[ 0 ] == '\0' && si->lightImagePath[ 0 ] == '\0' && si->implicitImagePath[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* digest any images */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "map" ) ||
|
|
|
|
!Q_stricmp( token, "clampMap" ) ||
|
|
|
|
!Q_stricmp( token, "animMap" ) ||
|
|
|
|
!Q_stricmp( token, "clampAnimMap" ) ||
|
|
|
|
!Q_stricmp( token, "clampMap" ) ||
|
|
|
|
!Q_stricmp( token, "mapComp" ) ||
|
|
|
|
!Q_stricmp( token, "mapNoComp" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* skip one token for animated stages */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "animMap" ) || !Q_stricmp( token, "clampAnimMap" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get an image */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( si->lightImagePath, token );
|
|
|
|
DefaultExtension( si->lightImagePath, ".tga" );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* debug code */
|
|
|
|
//% Sys_FPrintf( SYS_VRB, "Deduced shader image: %s\n", si->lightImagePath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
surfaceparm * directives
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* match surfaceparm */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "surfaceparm" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ApplySurfaceParm( token, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Unknown surfaceparm: \"%s\"\n", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
game-related shader directives
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: fogparms (for determining fog volumes) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "fogparms" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->fogParms = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: polygonoffset (for no culling) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "polygonoffset" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->polygonOffset = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* tesssize is used to force liquid surfaces to subdivide */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "tessSize" ) || !Q_stricmp( token, "q3map_tessSize" ) /* sof2 */ ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->subdivisions = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* cull none will set twoSided (ydnar: added disable too) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "cull" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "none" ) || !Q_stricmp( token, "disable" ) || !Q_stricmp( token, "twosided" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->twoSided = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* deformVertexes autosprite[ 2 ]
|
|
|
|
we catch this so autosprited surfaces become point
|
|
|
|
lights instead of area lights */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "deformVertexes" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* deformVertexes autosprite(2) */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_strncasecmp( token, "autosprite", 10 ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set it as autosprite and detail */
|
|
|
|
si->autosprite = qtrue;
|
|
|
|
ApplySurfaceParm( "detail", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: added these useful things */
|
|
|
|
si->noClip = qtrue;
|
|
|
|
si->notjunc = qtrue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* deformVertexes move <x> <y> <z> <func> <base> <amplitude> <phase> <freq> (ydnar: for particle studio support) */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "move" ) ) {
|
|
|
|
vec3_t amt, mins, maxs;
|
|
|
|
float base, amp;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get move amount */
|
2012-03-17 20:01:54 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse ); amt[ 0 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse ); amt[ 1 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse ); amt[ 2 ] = atof( token );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* skip func */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get base and amplitude */
|
2012-03-17 20:01:54 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse ); base = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse ); amp = atof( token );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* calculate */
|
|
|
|
VectorScale( amt, base, mins );
|
|
|
|
VectorMA( mins, amp, amt, maxs );
|
|
|
|
VectorAdd( si->mins, mins, si->mins );
|
|
|
|
VectorAdd( si->maxs, maxs, si->maxs );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* light <value> (old-style flare specification) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "light" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2008-07-25 07:31:37 +00:00
|
|
|
si->flareShader = game->flareShader;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: damageShader <shader> <health> (sof2 mods) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "damageShader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->damageShader = safe_malloc( strlen( token ) + 1 );
|
|
|
|
strcpy( si->damageShader, token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: enemy territory implicit shaders */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "implicitMap" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->implicitMap = IM_OPAQUE;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( si->implicitImagePath, "%s.tga", si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( si->implicitImagePath, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "implicitMask" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->implicitMap = IM_MASKED;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( si->implicitImagePath, "%s.tga", si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( si->implicitImagePath, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "implicitBlend" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->implicitMap = IM_MASKED;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( si->implicitImagePath, "%s.tga", si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( si->implicitImagePath, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
image directives
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* qer_editorimage <image> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "qer_editorImage" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
strcpy( si->editorImagePath, token );
|
|
|
|
DefaultExtension( si->editorImagePath, ".tga" );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_normalimage <image> (bumpmapping normal map) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_normalImage" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
strcpy( si->normalImagePath, token );
|
|
|
|
DefaultExtension( si->normalImagePath, ".tga" );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_lightimage <image> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightImage" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
strcpy( si->lightImagePath, token );
|
|
|
|
DefaultExtension( si->lightImagePath, ".tga" );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: skyparms <outer image> <cloud height> <inner image> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "skyParms" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get image base */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ignore bogus paths */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( si->skyParmsImageBase, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* use top image as sky light image */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->lightImagePath[ 0 ] == '\0' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* skip rest of line */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
q3map_* directives
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_sun <red> <green> <blue> <intensity> <degrees> <elevation>
|
|
|
|
color will be normalized, so it doesn't matter what range you use
|
|
|
|
intensity falls off with angle but not distance 100 is a fairly bright sun
|
|
|
|
degree of 0 = from the east, 90 = north, etc. altitude of 0 = sunrise/set, 90 = noon
|
|
|
|
ydnar: sof2map has bareword 'sun' token, so we support that as well */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "sun" ) /* sof2 */ || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
|
|
|
|
float a, b;
|
|
|
|
sun_t *sun;
|
|
|
|
qboolean ext;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: extended sun directive? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "q3map_sunext" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ext = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate sun */
|
|
|
|
sun = safe_malloc( sizeof( *sun ) );
|
|
|
|
memset( sun, 0, sizeof( *sun ) );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* set style */
|
|
|
|
sun->style = si->lightStyle;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get color */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->color[ 0 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->color[ 1 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->color[ 2 ] = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* normalize it */
|
|
|
|
VectorNormalize( sun->color, sun->color );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* scale color by brightness */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->photons = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get sun angle/elevation */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
a = atof( token );
|
|
|
|
a = a / 180.0f * Q_PI;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
b = atof( token );
|
|
|
|
b = b / 180.0f * Q_PI;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
sun->direction[ 0 ] = cos( a ) * cos( b );
|
|
|
|
sun->direction[ 1 ] = sin( a ) * cos( b );
|
|
|
|
sun->direction[ 2 ] = sin( b );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get filter radius from shader */
|
|
|
|
sun->filterRadius = si->lightFilterRadius;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: get sun angular deviance/samples */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ext && TokenAvailable() ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->deviance = atof( token );
|
|
|
|
sun->deviance = sun->deviance / 180.0f * Q_PI;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sun->numSamples = atoi( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* store sun */
|
|
|
|
sun->next = si->sun;
|
|
|
|
si->sun = sun;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* apply sky surfaceparm */
|
|
|
|
ApplySurfaceParm( "sky", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* don't process any more tokens on this line */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match q3map_ */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_strncasecmp( token, "q3map_", 6 ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_baseShader <shader> (inherit this shader's parameters) */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "q3map_baseShader" ) ) {
|
|
|
|
shaderInfo_t *si2;
|
|
|
|
qboolean oldWarnImage;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get shader */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
//% Sys_FPrintf( SYS_VRB, "Shader %s has base shader %s\n", si->shader, token );
|
|
|
|
oldWarnImage = warnImage;
|
|
|
|
warnImage = qfalse;
|
|
|
|
si2 = ShaderInfoForShader( token );
|
|
|
|
warnImage = oldWarnImage;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* subclass it */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si2 != NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* preserve name */
|
|
|
|
strcpy( temp, si->shader );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* copy shader */
|
|
|
|
memcpy( si, si2, sizeof( *si ) );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* restore name and set to unfinished */
|
|
|
|
strcpy( si->shader, temp );
|
2008-07-25 07:31:37 +00:00
|
|
|
si->shaderWidth = 0;
|
|
|
|
si->shaderHeight = 0;
|
2007-11-04 03:34:51 +00:00
|
|
|
si->finished = qfalse;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_surfacemodel <path to model> <density> <min scale> <max scale> <min angle> <max angle> <oriented (0 or 1)> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_surfacemodel" ) ) {
|
|
|
|
surfaceModel_t *model;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate new model and attach it */
|
|
|
|
model = safe_malloc( sizeof( *model ) );
|
|
|
|
memset( model, 0, sizeof( *model ) );
|
|
|
|
model->next = si->surfaceModel;
|
|
|
|
si->surfaceModel = model;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get parameters */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
strcpy( model->model, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->density = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->odds = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->minScale = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->maxScale = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->minAngle = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
model->maxAngle = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
model->oriented = ( token[ 0 ] == '1' ? qtrue : qfalse );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar/sd: q3map_foliage <path to model> <scale> <density> <odds> <invert alpha (1 or 0)> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_foliage" ) ) {
|
|
|
|
foliage_t *foliage;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* allocate new foliage struct and attach it */
|
|
|
|
foliage = safe_malloc( sizeof( *foliage ) );
|
|
|
|
memset( foliage, 0, sizeof( *foliage ) );
|
|
|
|
foliage->next = si->foliage;
|
|
|
|
si->foliage = foliage;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get parameters */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
strcpy( foliage->model, token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
foliage->scale = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
foliage->density = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
foliage->odds = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
foliage->inverseAlpha = atoi( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_bounce <value> (fraction of light to re-emit during radiosity passes) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_bounce" ) || !Q_stricmp( token, "q3map_bounceScale" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->bounceScale = atof( token );
|
|
|
|
}
|
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar/splashdamage: q3map_skyLight <value> <iterations> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_skyLight" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->skyLightValue = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->skyLightIterations = atoi( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* clamp */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->skyLightValue < 0.0f ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->skyLightValue = 0.0f;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( si->skyLightIterations < 2 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->skyLightIterations = 2;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_surfacelight <value> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_surfacelight" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->value = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_lightStyle (sof2/jk2 lightstyle) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightStyle" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
val = atoi( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( val < 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
val = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( val > LS_NONE ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
val = LS_NONE;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
si->lightStyle = val;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* wolf: q3map_lightRGB <red> <green> <blue> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightRGB" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorClear( si->color );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->color[ 0 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->color[ 1 ] = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->color[ 2 ] = atof( token );
|
|
|
|
ColorNormalize( si->color, si->color );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_lightSubdivide <value> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightSubdivide" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lightSubdivide = atoi( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_backsplash <percent> <distance> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_backsplash" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->backsplashFraction = atof( token ) * 0.01f;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->backsplashDistance = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_lightmapSampleSize <value> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapSampleSize" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lightmapSampleSize = atoi( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_lightmapSampleSffset <value> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapSampleOffset" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lightmapSampleOffset = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_lightmapFilterRadius <self> <other> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapFilterRadius" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lmFilterRadius = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lightFilterRadius = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_lightmapAxis [xyz] */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapAxis" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "x" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorSet( si->lightmapAxis, 1, 0, 0 );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !Q_stricmp( token, "y" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorSet( si->lightmapAxis, 0, 1, 0 );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !Q_stricmp( token, "z" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
VectorSet( si->lightmapAxis, 0, 0, 1 );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Sys_Printf( "WARNING: Unknown value for lightmap axis: %s\n", token );
|
|
|
|
VectorClear( si->lightmapAxis );
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_lightmapSize <width> <height> (for autogenerated shaders + external tga lightmaps) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapSize" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lmCustomWidth = atoi( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->lmCustomHeight = atoi( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* must be a power of 2 */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( ( si->lmCustomWidth - 1 ) & si->lmCustomWidth ) ||
|
|
|
|
( ( si->lmCustomHeight - 1 ) & si->lmCustomHeight ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Non power-of-two lightmap size specified (%d, %d)\n",
|
2012-03-17 20:01:54 +00:00
|
|
|
si->lmCustomWidth, si->lmCustomHeight );
|
2008-07-25 07:31:37 +00:00
|
|
|
si->lmCustomWidth = lmCustomSize;
|
|
|
|
si->lmCustomHeight = lmCustomSize;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar: q3map_lightmapBrightness N (for autogenerated shaders + external tga lightmaps) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapBrightness" ) || !Q_stricmp( token, "q3map_lightmapGamma" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2008-07-25 07:31:37 +00:00
|
|
|
si->lmBrightness = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->lmBrightness < 0 ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->lmBrightness = 1.0;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_vertexScale (scale vertex lighting by this fraction) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_vertexScale" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->vertexScale = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* q3map_noVertexLight */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_noVertexLight" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->noVertexLight = qtrue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* q3map_flare[Shader] <shader> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_flare" ) || !Q_stricmp( token, "q3map_flareShader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->flareShader = safe_malloc( strlen( token ) + 1 );
|
|
|
|
strcpy( si->flareShader, token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_backShader <shader> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_backShader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->backShader = safe_malloc( strlen( token ) + 1 );
|
|
|
|
strcpy( si->backShader, token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar: q3map_cloneShader <shader> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_cloneShader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->cloneShader = safe_malloc( strlen( token ) + 1 );
|
|
|
|
strcpy( si->cloneShader, token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* q3map_remapShader <shader> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_remapShader" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( token[ 0 ] != '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->remapShader = safe_malloc( strlen( token ) + 1 );
|
|
|
|
strcpy( si->remapShader, token );
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar: q3map_offset <value> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_offset" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2008-07-25 07:31:37 +00:00
|
|
|
si->offset = atof( token );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_textureSize <width> <height> (substitute for q3map_lightimage derivation for terrain) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_fur" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->furNumLayers = atoi( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->furOffset = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->furFade = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: legacy support for terrain/terrain2 shaders */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_terrain" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* team arena terrain is assumed to be nonplanar, with full normal averaging,
|
|
|
|
passed through the metatriangle surface pipeline, with a lightmap axis on z */
|
|
|
|
si->legacyTerrain = qtrue;
|
|
|
|
si->noClip = qtrue;
|
|
|
|
si->notjunc = qtrue;
|
|
|
|
si->indexed = qtrue;
|
|
|
|
si->nonplanar = qtrue;
|
|
|
|
si->forceMeta = qtrue;
|
|
|
|
si->shadeAngleDegrees = 179.0f;
|
|
|
|
//% VectorSet( si->lightmapAxis, 0, 0, 1 ); /* ydnar 2002-09-21: turning this off for better lightmapping of cliff faces */
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: picomodel: q3map_forceMeta (forces brush faces and/or triangle models to go through the metasurface pipeline) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_forceMeta" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->forceMeta = qtrue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_shadeAngle <degrees> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_shadeAngle" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->shadeAngleDegrees = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_textureSize <width> <height> (substitute for q3map_lightimage derivation for terrain) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_textureSize" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->shaderWidth = atoi( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
si->shaderHeight = atoi( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_tcGen <style> <parameters> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_tcGen" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->tcGen = qtrue;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_tcGen vector <s vector> <t vector> */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "vector" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Parse1DMatrixAppend( shaderText, 3, si->vecs[ 0 ] );
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, si->vecs[ 1 ] );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_tcGen ivector <1.0/s vector> <1.0/t vector> (inverse vector, easier for mappers to understand) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "ivector" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Parse1DMatrixAppend( shaderText, 3, si->vecs[ 0 ] );
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, si->vecs[ 1 ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < 3; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
si->vecs[ 0 ][ i ] = si->vecs[ 0 ][ i ] ? 1.0 / si->vecs[ 0 ][ i ] : 0;
|
|
|
|
si->vecs[ 1 ][ i ] = si->vecs[ 1 ][ i ] ? 1.0 / si->vecs[ 1 ][ i ] : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Sys_Printf( "WARNING: Unknown q3map_tcGen method: %s\n", token );
|
|
|
|
VectorClear( si->vecs[ 0 ] );
|
|
|
|
VectorClear( si->vecs[ 1 ] );
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* ydnar: gs mods: q3map_[color|rgb|alpha][Gen|Mod] <style> <parameters> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_colorGen" ) || !Q_stricmp( token, "q3map_colorMod" ) ||
|
|
|
|
!Q_stricmp( token, "q3map_rgbGen" ) || !Q_stricmp( token, "q3map_rgbMod" ) ||
|
|
|
|
!Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) {
|
|
|
|
colorMod_t *cm, *cm2;
|
|
|
|
int alpha;
|
|
|
|
|
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* alphamods are colormod + 1 */
|
2012-03-17 20:01:54 +00:00
|
|
|
alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
|
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* allocate new colormod */
|
|
|
|
cm = safe_malloc( sizeof( *cm ) );
|
|
|
|
memset( cm, 0, sizeof( *cm ) );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* attach to shader */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( si->colorMod == NULL ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
si->colorMod = cm;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
else
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( cm2 = si->colorMod; cm2 != NULL; cm2 = cm2->next )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( cm2->next == NULL ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm2->next = cm;
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get type */
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* alpha set|const A */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( alpha && ( !Q_stricmp( token, "set" ) || !Q_stricmp( token, "const" ) ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_ALPHA_SET;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
cm->data[ 0 ] = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* color|rgb set|const ( X Y Z ) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "set" ) || !Q_stricmp( token, "const" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_COLOR_SET;
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* alpha scale A */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( alpha && !Q_stricmp( token, "scale" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_ALPHA_SCALE;
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
cm->data[ 0 ] = atof( token );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* color|rgb scale ( X Y Z ) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "scale" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_COLOR_SCALE;
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* dotProduct ( X Y Z ) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "dotProduct" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_COLOR_DOT_PRODUCT + alpha;
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* dotProduct2 ( X Y Z ) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "dotProduct2" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
cm->type = CM_COLOR_DOT_PRODUCT_2 + alpha;
|
|
|
|
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* volume */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "volume" ) ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
/* special stub mode for flagging volume brushes */
|
|
|
|
cm->type = CM_VOLUME;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* unknown */
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
2008-07-25 07:31:37 +00:00
|
|
|
Sys_Printf( "WARNING: Unknown colorMod method: %s\n", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_tcMod <style> <parameters> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_tcMod" ) ) {
|
|
|
|
float a, b;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_tcMod [translate | shift | offset] <s> <t> */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( token, "translate" ) || !Q_stricmp( token, "shift" ) || !Q_stricmp( token, "offset" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
a = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
b = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModTranslate( si->mod, a, b );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* q3map_tcMod scale <s> <t> */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "scale" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
a = atof( token );
|
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
b = atof( token );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModScale( si->mod, a, b );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_tcMod rotate <s> <t> (fixme: make this communitive) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "rotate" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
a = atof( token );
|
2008-07-25 07:31:37 +00:00
|
|
|
TCModRotate( si->mod, a );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Unknown q3map_tcMod method: %s\n", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_fogDir (direction a fog shader fades from transparent to opaque) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_fogDir" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Parse1DMatrixAppend( shaderText, 3, si->fogDir );
|
|
|
|
VectorNormalize( si->fogDir, si->fogDir );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_globaltexture */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_globaltexture" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->globalTexture = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_nonplanar (make it a nonplanar merge candidate for meta surfaces) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_nonplanar" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->nonplanar = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_noclip (preserve original face winding, don't clip by bsp tree) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_noclip" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->noClip = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_notjunc */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_notjunc" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->notjunc = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_nofog */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_nofog" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->noFog = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_indexed (for explicit terrain-style indexed mapping) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_indexed" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->indexed = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_invert (inverts a drawsurface's facing) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_invert" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->invert = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: gs mods: q3map_lightmapMergable (ok to merge non-planar */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_lightmapMergable" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->lmMergable = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_nofast */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_noFast" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->noFast = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_patchshadows */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_patchShadows" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->patchShadows = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_vertexshadows */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_vertexShadows" ) ) {
|
|
|
|
si->vertexShadows = qtrue; /* ydnar */
|
|
|
|
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_novertexshadows */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_noVertexShadows" ) ) {
|
|
|
|
si->vertexShadows = qfalse; /* ydnar */
|
|
|
|
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_splotchfix (filter dark lightmap luxels on lightmapped models) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_splotchfix" ) ) {
|
|
|
|
si->splotchFix = qtrue; /* ydnar */
|
|
|
|
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_forcesunlight */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_forceSunlight" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->forceSunlight = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_onlyvertexlighting (sof2) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_onlyVertexLighting" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ApplySurfaceParm( "pointlight", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* q3map_material (sof2) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_material" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
GetTokenAppend( shaderText, qfalse );
|
|
|
|
sprintf( temp, "*mat_%s", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Unknown material \"%s\"\n", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_clipmodel (autogenerate clip brushes for model triangles using this shader) */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_clipmodel" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->clipModel = qtrue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: q3map_styleMarker[2] */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !Q_stricmp( token, "q3map_styleMarker" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
si->styleMarker = 1;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !Q_stricmp( token, "q3map_styleMarker2" ) ) { /* uses depthFunc equal */
|
2007-11-04 03:34:51 +00:00
|
|
|
si->styleMarker = 2;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ydnar: default to searching for q3map_<surfaceparm> */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//% Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
|
|
|
|
; //% Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
skip
|
|
|
|
----------------------------------------------------------------- */
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* ignore all other tokens on the line */
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( TokenAvailable() && GetTokenAppend( shaderText, qfalse ) ) ;
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
ParseCustomInfoParms() - rr2do2
|
|
|
|
loads custom info parms file for mods
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void ParseCustomInfoParms( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
qboolean parsedContent, parsedSurface;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* file exists? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( vfsGetFileCount( "scripts/custinfoparms.txt" ) == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load it */
|
|
|
|
LoadScriptFile( "scripts/custinfoparms.txt", 0 );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* clear the array */
|
|
|
|
memset( custSurfaceParms, 0, sizeof( custSurfaceParms ) );
|
|
|
|
numCustSurfaceParms = 0;
|
|
|
|
parsedContent = parsedSurface = qfalse;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse custom contentflags */
|
|
|
|
MatchToken( "{" );
|
|
|
|
while ( 1 )
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetToken( qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
if ( !strcmp( token, "}" ) ) {
|
|
|
|
parsedContent = qtrue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
custSurfaceParms[ numCustSurfaceParms ].name = safe_malloc( MAX_OS_PATH );
|
|
|
|
strcpy( custSurfaceParms[ numCustSurfaceParms ].name, token );
|
|
|
|
GetToken( qfalse );
|
|
|
|
sscanf( token, "%x", &custSurfaceParms[ numCustSurfaceParms ].contentFlags );
|
|
|
|
numCustSurfaceParms++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* any content? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !parsedContent ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Couldn't find valid custom contentsflag section\n" );
|
|
|
|
return;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse custom surfaceflags */
|
|
|
|
MatchToken( "{" );
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( 1 )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !GetToken( qtrue ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( token, "}" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
parsedSurface = qtrue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
custSurfaceParms[ numCustSurfaceParms ].name = safe_malloc( MAX_OS_PATH );
|
|
|
|
strcpy( custSurfaceParms[ numCustSurfaceParms ].name, token );
|
|
|
|
GetToken( qfalse );
|
|
|
|
sscanf( token, "%x", &custSurfaceParms[ numCustSurfaceParms ].surfaceFlags );
|
|
|
|
numCustSurfaceParms++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* any content? */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !parsedContent ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "WARNING: Couldn't find valid custom surfaceflag section\n" );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
LoadShaderInfo()
|
|
|
|
the shaders are parsed out of shaderlist.txt from a main directory
|
|
|
|
that is, if using -fs_game we ignore the shader scripts that might be in baseq3/
|
|
|
|
on linux there's an additional twist, we actually merge the stuff from ~/.q3a/ and from the base dir
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_SHADER_FILES 1024
|
|
|
|
|
|
|
|
void LoadShaderInfo( void ){
|
|
|
|
int i, j, numShaderFiles, count;
|
|
|
|
char filename[ 1024 ];
|
|
|
|
char *shaderFiles[ MAX_SHADER_FILES ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* rr2do2: parse custom infoparms first */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( useCustomInfoParms ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
ParseCustomInfoParms();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* start with zero */
|
|
|
|
numShaderFiles = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* we can pile up several shader files, the one in baseq3 and ones in the mod dir or other spots */
|
|
|
|
sprintf( filename, "%s/shaderlist.txt", game->shaderPath );
|
|
|
|
count = vfsGetFileCount( filename );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* load them all */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < count; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* load shader list */
|
|
|
|
sprintf( filename, "%s/shaderlist.txt", game->shaderPath );
|
|
|
|
LoadScriptFile( filename, i );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse it */
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( GetToken( qtrue ) )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* check for duplicate entries */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < numShaderFiles; j++ )
|
|
|
|
if ( !strcmp( shaderFiles[ j ], token ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* test limit */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( j >= MAX_SHADER_FILES ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "MAX_SHADER_FILES (%d) reached, trim your shaderlist.txt!", (int) MAX_SHADER_FILES );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* new shader file */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( j == numShaderFiles ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
shaderFiles[ numShaderFiles ] = safe_malloc( MAX_OS_PATH );
|
|
|
|
strcpy( shaderFiles[ numShaderFiles ], token );
|
|
|
|
numShaderFiles++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse the shader files */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numShaderFiles; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
sprintf( filename, "%s/%s.shader", game->shaderPath, shaderFiles[ i ] );
|
|
|
|
ParseShaderFile( filename );
|
|
|
|
free( shaderFiles[ i ] );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* emit some statistics */
|
|
|
|
Sys_FPrintf( SYS_VRB, "%9d shaderInfo\n", numShaderInfo );
|
|
|
|
}
|