Skip to content

Commit

Permalink
Add workaround for skin shaders.
Browse files Browse the repository at this point in the history
This solves #168, which was introduced as side-effect of 4312e6f.
  • Loading branch information
Daggolin committed Apr 7, 2024
1 parent 4fb705e commit 3f59e1e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
/*
}
*/
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3f59e1e

Please sign in to comment.