From 3f59e1e0e6697bef43f57eaf57435b39d26771d5 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 7 Apr 2024 22:04:22 +0200 Subject: [PATCH] Add workaround for skin shaders. This solves #168, which was introduced as side-effect of 4312e6f174cb3c721277101efa77d9e2b18d10eb. --- src/renderer/tr_image.cpp | 2 +- src/renderer/tr_local.h | 3 ++- src/renderer/tr_shade.cpp | 2 +- src/renderer/tr_shader.cpp | 6 +++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/renderer/tr_image.cpp b/src/renderer/tr_image.cpp index 1343567e..d281f7f2 100644 --- a/src/renderer/tr_image.cpp +++ b/src/renderer/tr_image.cpp @@ -3027,7 +3027,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) else { */ - surf->shader = R_FindShader( token, lightmapsNone, stylesDefault, qtrue ); + surf->shader = R_FindShader( token, lightmapsNone, stylesDefault, qtrue, qfalse, qtrue ); /* } */ diff --git a/src/renderer/tr_local.h b/src/renderer/tr_local.h index cd9e7d1b..265b7b6c 100644 --- a/src/renderer/tr_local.h +++ b/src/renderer/tr_local.h @@ -493,6 +493,7 @@ Ghoul2 Insert End qboolean hasGlow; qboolean isAdvancedRemap; + qboolean isSkinShader; struct shader_s *remappedShader; // current shader this one is remapped too struct shader_s *remappedShaderAdvanced; // current shader from the advanced remaps this one is remapped to @@ -1460,7 +1461,7 @@ qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); qhandle_t RE_RegisterShaderFromImage(const char *name, int *lightmapIndex, byte *styles, image_t *image, qboolean mipRawImage); -shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage, qboolean isAdvancedRemap = qfalse ); +shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage, qboolean isAdvancedRemap = qfalse, qboolean isSkinShader = qfalse ); shader_t *R_FindAdvancedRemapShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage ); shader_t *R_GetShaderByHandle( qhandle_t hShader ); // shader_t *R_GetShaderByState( int index, int *cycleTime ); diff --git a/src/renderer/tr_shade.cpp b/src/renderer/tr_shade.cpp index caadf2fc..37113f89 100644 --- a/src/renderer/tr_shade.cpp +++ b/src/renderer/tr_shade.cpp @@ -322,7 +322,7 @@ to overflow. void RB_BeginSurface( shader_t *shader, int fogNum ) { shader_t *state = (shader->remappedShaderAdvanced ? shader->remappedShaderAdvanced : (shader->remappedShader ? shader->remappedShader : shader)); - if ( state->defaultShader ) state = tr.defaultShader; + if ( !state->isSkinShader && state->defaultShader ) state = tr.defaultShader; tess.numIndexes = 0; tess.numVertexes = 0; diff --git a/src/renderer/tr_shader.cpp b/src/renderer/tr_shader.cpp index 25c9e6d3..d3af8ecf 100644 --- a/src/renderer/tr_shader.cpp +++ b/src/renderer/tr_shader.cpp @@ -3524,7 +3524,7 @@ most world construction surfaces. =============== */ -shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage, qboolean isAdvancedRemap ) +shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage, qboolean isAdvancedRemap, qboolean isSkinShader ) { char strippedName[MAX_QPATH]; char fileName[MAX_QPATH]; @@ -3633,6 +3633,10 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte * ri.Printf( PRINT_DEVELOPER, "Couldn't find image for shader %s\n", name ); shader.defaultShader = qtrue; //return FinishShader(); + if ( isSkinShader ) { + shader.isSkinShader = qtrue; + return FinishShader(); + } image = tr.defaultImage; }