Skip to content

Commit

Permalink
renderer: better comments and debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jan 15, 2020
1 parent 8191a6c commit 26cfa07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_bsp.cpp
Expand Up @@ -3628,7 +3628,7 @@ static void R_LoadShaders( lump_t *l )

for ( i = 0; i < count; i++ )
{
Log::Debug("shader: '%s'", out[ i ].shader );
Log::Debug("loading shader: '%s'", out[ i ].shader );

out[ i ].surfaceFlags = LittleLong( out[ i ].surfaceFlags );
out[ i ].contentFlags = LittleLong( out[ i ].contentFlags );
Expand Down
59 changes: 29 additions & 30 deletions src/engine/renderer/tr_shader.cpp
Expand Up @@ -1677,11 +1677,13 @@ struct extraMapParser_t

static const extraMapParser_t dpExtraMapParsers[] =
{
{ "_norm", "normal map", ParseNormalMap, TB_NORMALMAP, },
{ "_bump", "height map", ParseHeightMap, TB_HEIGHTMAP, },
{ "_gloss", "specular map", ParseSpecularMap, TB_SPECULARMAP, },
{ "_glow", "glow map", ParseGlowMap, TB_GLOWMAP, },
{ "_luma", "glow map", ParseGlowMap, TB_GLOWMAP, },
{ "_norm", "DarkPlaces normal map", ParseNormalMap, TB_NORMALMAP, },
{ "_bump", "DarkPlaces height map", ParseHeightMap, TB_HEIGHTMAP, },
{ "_gloss", "DarkPlaces specular map", ParseSpecularMap, TB_SPECULARMAP, },
{ "_glow", "DarkPlaces glow map", ParseGlowMap, TB_GLOWMAP, },
// DarkPlaces implemented _luma for Tenebrae compatibility, the
// probability of finding this suffix with Xonotic maps is very low.
{ "_luma", "Tenebrae glow map", ParseGlowMap, TB_GLOWMAP, },
};

/*
Expand Down Expand Up @@ -1719,16 +1721,15 @@ void LoadExtraMaps( shaderStage_t *stage, const char *colorMapName )
surfaceparm trans
surfaceparm water
surfaceparm nolightmap
cull none
q3map_globaltexture
tessSize 256
cull none
{
map textures/map_solarium/water4/water4.tga
tcmod scale 0.3 0.4
tcmod scale 0.3 0.4
tcMod scroll 0.05 0.05
blendfunc add
alphaGen vertex
alphaGen vertex
}
dpreflectcube cubemaps/default/sky
{
Expand All @@ -1745,32 +1746,26 @@ void LoadExtraMaps( shaderStage_t *stage, const char *colorMapName )
```
textures/map_solarium/water4
{
qer_editorimage textures/map_solarium/water4/water4.tga
qer_editorimage textures/map_solarium/water4/water4
qer_trans 20
surfaceparm nomarks
surfaceparm trans
surfaceparm water
surfaceparm nolightmap
cull none
q3map_globaltexture
tessSize 256
normalMap textures/map_solarium/water4/water4_norm
specularMap textures/map_solarium/water4/water4_gloss
cull none
{
stage diffuseMap
map textures/map_solarium/water4/water4.tga
tcmod scale 0.3 0.4
diffuseMap textures/map_solarium/water4/water4
normalMap textures/map_solarium/water4/water4_norm
specularMap textures/map_solarium/water4/water4_gloss
normalScale 1 -1 1
tcmod scale 0.3 0.4
tcMod scroll 0.05 0.05
blendfunc add
alphaGen vertex
alphaGen vertex
}
dpreflectcube cubemaps/default/sky
{
map $lightmap
blendfunc add
tcGen lightmap
}
dp_water 0.1 1.2 1.4 0.7 1 1 1 1 1 1 0.1
}
```
Expand All @@ -1791,7 +1786,7 @@ void LoadExtraMaps( shaderStage_t *stage, const char *colorMapName )
char colorMapBaseName[ MAX_QPATH ];
bool foundExtraMap = false;

Log::Debug( "looking for extra maps for color map: '%s'", colorMapName );
Log::Debug( "looking for DarkPlaces extra maps for color map: '%s'", colorMapName );

COM_StripExtension3( colorMapName, colorMapBaseName, sizeof( colorMapBaseName ) );

Expand Down Expand Up @@ -4423,8 +4418,8 @@ static void CollapseStages()
{
if ( stages[ i ].dpMaterial )
{
// DarkPlaces only supports one kind of lightmap blend
// which is the default one
// DarkPlaces only supports one kind of lightmap blend:
// https://gitlab.com/xonotic/darkplaces/blob/324a5329d33ef90df59e6488abce6433d90ac04c/model_shared.c#L1886-1887
Log::Debug("found custom lightmap stage in DarkPlaces '%s' shader, disable it and enable implicit one instead", shader.name);
stages[ i ].implicitLightmap = true;
stages[ lightStage ].active = false;
Expand Down Expand Up @@ -4795,7 +4790,9 @@ static shader_t *FinishShader()
stages[ 0 ].overrideWrapType = true;
stages[ 0 ].wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;

LoadMap( &stages[ 0 ], "lights/squarelight1a.tga" );
const char *squarelight1a = "lights/squarelight1a";
Log::Debug( "loading '%s' image as shader", squarelight1a );
LoadMap( &stages[ 0 ], squarelight1a );
}

// force following shader stages to be xy attenuation stages
Expand Down Expand Up @@ -5359,7 +5356,7 @@ shader_t *R_FindShader( const char *name, shaderType_t type,
// of all explicit shaders
if ( r_printShaders->integer )
{
Log::Notice("...loading explicit shader '%s'", strippedName );
Log::Notice("loading explicit shader '%s'", strippedName );
}

if ( !ParseShader( shaderText ) )
Expand Down Expand Up @@ -5399,6 +5396,8 @@ shader_t *R_FindShader( const char *name, shaderType_t type,
if( flags & RSF_NOLIGHTSCALE )
bits |= IF_NOLIGHTSCALE;

Log::Debug( "loading '%s' image as shader", fileName );

// choosing filter based on the NOMIP flag seems strange,
// maybe it should be changed to type == SHADER_2D
if( !(bits & RSF_NOMIP) ) {
Expand All @@ -5413,7 +5412,7 @@ shader_t *R_FindShader( const char *name, shaderType_t type,

if ( !image )
{
Log::Warn("Couldn't find image file for shader %s", name );
Log::Warn("Couldn't find image file '%s'", name );
shader.defaultShader = true;
return FinishShader();
}
Expand Down Expand Up @@ -5885,7 +5884,7 @@ static void ScanAndLoadShaderFiles()
{
Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[ i ] );

Log::Debug("...loading '%s'", filename );
Log::Debug("loading '%s' shader file", filename );
summand = ri.FS_ReadFile( filename, ( void ** ) &buffers[ i ] );

if ( !buffers[ i ] )
Expand Down

0 comments on commit 26cfa07

Please sign in to comment.