Skip to content

Commit

Permalink
tr_shader: implement fitScreen shader keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 13, 2024
1 parent c27ab6d commit d23c90c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };

int deformIndex;
bool overrideNoPicMip; // for images that must always be full resolution
bool overrideFitScreen;
bool overrideFilterType; // for console fonts, 2D elements, etc.
filterType_t filterType;
bool overrideWrapType;
Expand Down Expand Up @@ -1285,6 +1286,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
float polygonOffsetValue;

bool noPicMip; // for images that must always be full resolution
bool fitScreen;
int imageMinDimension; // for images that must not be loaded with smaller size
int imageMaxDimension; // for images that must not be loaded with larger size
filterType_t filterType; // for console fonts, 2D elements, etc.
Expand Down
31 changes: 31 additions & 0 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,11 @@ static bool LoadMap( shaderStage_t *stage, const char *buffer, stageType_t type,
imageParams.bits |= IF_NOPICMIP;
}

if ( stage->overrideFitScreen || shader.fitScreen )
{
imageParams.bits |= IF_FITSCREEN;
}

switch ( type )
{
case stageType_t::ST_NORMALMAP:
Expand Down Expand Up @@ -2172,6 +2177,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
imageBits |= IF_NOPICMIP;
}

if ( stage->overrideFitScreen || shader.fitScreen )
{
imageBits |= IF_FITSCREEN;
}

if ( stage->overrideFilterType )
{
filterType = stage->filterType;
Expand Down Expand Up @@ -2293,6 +2303,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
imageBits |= IF_NOPICMIP;
}

if ( stage->overrideFitScreen || shader.fitScreen )
{
imageBits |= IF_FITSCREEN;
}

if ( stage->overrideFilterType )
{
filterType = stage->filterType;
Expand Down Expand Up @@ -2385,6 +2400,10 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
{
stage->overrideNoPicMip = true;
}
else if ( !Q_stricmp( token, "fitScreen" ) )
{
stage->overrideFitScreen = true;
}
// clamp, edgeClamp etc.
else if ( ParseClampType( token, &stage->wrapType ) )
{
Expand Down Expand Up @@ -4177,6 +4196,12 @@ static bool ParseShader( const char *_text )
shader.noPicMip = true;
continue;
}
// fit screen adjustment
else if ( !Q_stricmp( token, "fitscreen" ) )
{
shader.fitScreen = true;
continue;
}
// imageMinDimension enforcement
else if ( !Q_stricmp( token, "imageMinDimension" ) )
{
Expand Down Expand Up @@ -6328,6 +6353,12 @@ shader_t *R_FindShader( const char *name, shaderType_t type,
shader.noPicMip = true;
}

if ( flags & RSF_FITSCREEN )
{
bits |= IF_FITSCREEN;
shader.fitScreen = true;
}

if ( flags & RSF_NOLIGHTSCALE )
{
bits |= IF_NOLIGHTSCALE;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/renderer/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ using glIndex_t = unsigned int;
enum RegisterShaderFlags_t {
RSF_DEFAULT = 0x00,
RSF_NOMIP = 0x01,
RSF_LIGHT_ATTENUATION = 0x02,
RSF_FITSCREEN = 0x02,
RSF_LIGHT_ATTENUATION = 0x03,
RSF_NOLIGHTSCALE = 0x04,
RSF_SPRITE = 0x08
};
Expand Down

0 comments on commit d23c90c

Please sign in to comment.