From 26cfa070e41d8b1d2405f1903f502fc3065c767f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 9 Jan 2020 06:25:08 +0100 Subject: [PATCH] renderer: better comments and debug messages --- src/engine/renderer/tr_bsp.cpp | 2 +- src/engine/renderer/tr_shader.cpp | 59 +++++++++++++++---------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index 9119d63b29..55e392494a 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -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 ); diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index 575b65e484..96b4832a66 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -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, }, }; /* @@ -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 { @@ -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 } ``` @@ -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 ) ); @@ -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; @@ -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 @@ -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 ) ) @@ -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) ) { @@ -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(); } @@ -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 ] )