Skip to content

Commit 1ee1342

Browse files
committed
tr_shader: reuse common code in dpoffsetmapping
1 parent d634467 commit 1ee1342

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/engine/renderer/tr_shader.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,28 +4397,26 @@ static bool ParseShader( const char *_text )
43974397
}
43984398

43994399
// dpoffsetmapping - 2 match8 65
4400-
float off;
4401-
float div;
4400+
reliefBias_t reliefBias = { 0.0f, 1.0f, 0.0f };
44024401

44034402
if ( !Q_stricmp( token, "bias" ) )
44044403
{
4405-
off = 0.0f;
4406-
div = 1.0f;
4404+
// Use default values.
44074405
}
44084406
else if ( !Q_stricmp( token, "match" ) )
44094407
{
4410-
off = 1.0f;
4411-
div = 1.0f;
4408+
reliefBias.origin = 1.0f;
4409+
reliefBias.divisor = 1.0f;
44124410
}
44134411
else if ( !Q_stricmp( token, "match8" ) )
44144412
{
4415-
off = 1.0f;
4416-
div = 255.0f;
4413+
reliefBias.origin = 1.0f;
4414+
reliefBias.divisor = 255.0f;
44174415
}
44184416
else if ( !Q_stricmp( token, "match16" ) )
44194417
{
4420-
off = 1.0f;
4421-
div = 65535.0f;
4418+
reliefBias.origin = 1.0f;
4419+
reliefBias.divisor = 65535.0f;
44224420
}
44234421
else
44244422
{
@@ -4435,8 +4433,8 @@ static bool ParseShader( const char *_text )
44354433
continue;
44364434
}
44374435

4438-
float bias = atof( token );
4439-
shader.reliefOffsetBias = off - bias / div;
4436+
reliefBias.offset = atof( token );
4437+
shader.reliefOffsetBias = reliefBias.origin - reliefBias.offset / reliefBias.divisor;
44404438
continue;
44414439
}
44424440
// entityMergable, allowing sprite surfaces from multiple entities

0 commit comments

Comments
 (0)