parsing the q3map_sun[Ext] shader directives

This commit is contained in:
myT 2024-03-29 04:05:35 +01:00
parent c737a2833f
commit a01c88707d
3 changed files with 43 additions and 0 deletions

View file

@ -1499,6 +1499,7 @@ static void R_LoadFogs( const lump_t* l, const lump_t* brushesLump, const lump_t
// get information from the shader for fog parameters
shader_t* shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, FINDSHADER_MIPRAWIMAGE_BIT );
shader->isFog = qtrue;
out->parms = shader->fogParms;

View file

@ -415,6 +415,12 @@ struct shader_t {
float dfInvDist;
float dfBias;
// Radiant sun information from the sky shader
qbool isSunDataValid;
vec3_t sunColor;
float sunAzimuth;
float sunInclination;
qbool greyscaleCTF;
// extra info for /shaderinfo
@ -429,6 +435,7 @@ struct shader_t {
qbool isAlphaTestedOpaque; // no alpha blending, first stage is alpha tested
qbool isDynamic; // at least one vertex attribute must be generated on the fly
qbool hasLightmapStage;
qbool isFog;
pipeline_t pipelines[MAX_SHADER_STAGES];
int numPipelines;

View file

@ -1314,6 +1314,37 @@ static void ParseSurfaceParm( const char** text )
}
static qbool ParseFloat( float* out, const char** text, const char* commandName, int argIndex )
{
const char* const token = COM_ParseExt( text, qfalse );
if ( token[0] == '\0' || sscanf( token, "%f", out ) != 1 ) {
ParserWarning( "invalid/missing %s argument #%d", commandName, argIndex );
return qfalse;
}
return qtrue;
}
// q3map_sun R G B intensity azimuth elevation
// q3map_sunExt R G B intensity azimuth elevation shadow_degrees samples
static void ParseSun( const char** text )
{
float v[6];
for ( int i = 0; i < ARRAY_LEN( v ); i++ ) {
if ( !ParseFloat( &v[i], text, "q3map_sun", i + 1 ) ) {
return;
}
}
shader.isSunDataValid = qtrue;
VectorSet( shader.sunColor, v[0], v[1], v[2] );
shader.sunAzimuth = v[4];
shader.sunInclination = 90.0f - v[5];
}
// q3map_cnq3_depthFade <scale> <bias>
static void ParseDepthFade( const char** text )
@ -1407,6 +1438,10 @@ static qbool ParseShader( const char** text )
ParseDepthFade( text );
continue;
}
else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
ParseSun( text );
SkipRestOfLine( text );
}
// skip stuff that only the q3map needs
else if ( !Q_stricmpn( token, "q3map", 5 ) ) {
SkipRestOfLine( text );