Skip to content

Commit

Permalink
tr_shader: reuse common code in dpoffsetmapping
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Sep 7, 2024
1 parent e399780 commit 7f00631
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4397,28 +4397,26 @@ static bool ParseShader( const char *_text )
}

// dpoffsetmapping - 2 match8 65
float off;
float div;
reliefBias_t reliefBias = { 0.0f, 1.0f, 0.0f };

if ( !Q_stricmp( token, "bias" ) )
{
off = 0.0f;
div = 1.0f;
// Use default values.
}
else if ( !Q_stricmp( token, "match" ) )
{
off = 1.0f;
div = 1.0f;
reliefBias.origin = 1.0f;
reliefBias.divisor = 1.0f;
}
else if ( !Q_stricmp( token, "match8" ) )
{
off = 1.0f;
div = 255.0f;
reliefBias.origin = 1.0f;
reliefBias.divisor = 255.0f;
}
else if ( !Q_stricmp( token, "match16" ) )
{
off = 1.0f;
div = 65535.0f;
reliefBias.origin = 1.0f;
reliefBias.divisor = 65535.0f;
}
else
{
Expand All @@ -4435,8 +4433,8 @@ static bool ParseShader( const char *_text )
continue;
}

float bias = atof( token );
shader.reliefOffsetBias = off - bias / div;
reliefBias.offset = atof( token );
shader.reliefOffsetBias = reliefBias.origin - reliefBias.offset / reliefBias.divisor;
continue;
}
// entityMergable, allowing sprite surfaces from multiple entities
Expand Down

0 comments on commit 7f00631

Please sign in to comment.