Skip to content

Commit

Permalink
#5532: Parser support for storing the render map dimensions (width/he…
Browse files Browse the repository at this point in the history
…ight) of remoteRenderMap and mirrorRenderMap stages
  • Loading branch information
codereader committed Feb 26, 2021
1 parent 70d7154 commit 610aeac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/ShaderLayer.h
Expand Up @@ -93,6 +93,7 @@ class ShaderLayer
TEXGEN_REFLECT = 1 << 1,
TEXGEN_SKYBOX = 1 << 2,
TEXGEN_WOBBLESKY = 1 << 3,
TEXGEN_SCREEN = 1 << 4, // screen aligned, for mirrorRenders and screen space temporaries
};

/**
Expand Down Expand Up @@ -212,6 +213,12 @@ class ShaderLayer
*/
virtual CubeMapMode getCubeMapMode() const = 0;

/**
* Returns the dimensions specifying the map size for
* stages using the "mirrorRenderMap", "remoteRenderMap" keywords.
*/
virtual const Vector2& getRenderMapSize() = 0;

/**
* Returns the value of the scale expressions of this stage.
*/
Expand Down
10 changes: 10 additions & 0 deletions radiantcore/shaders/Doom3ShaderLayer.cpp
Expand Up @@ -226,6 +226,16 @@ void Doom3ShaderLayer::setMapType(MapType type)
_mapType = type;
}

const Vector2& Doom3ShaderLayer::getRenderMapSize()
{
return _renderMapSize;
}

void Doom3ShaderLayer::setRenderMapSize(const Vector2& size)
{
_renderMapSize = size;
}

bool Doom3ShaderLayer::hasAlphaTest() const
{
return _alphaTest != REG_ZERO;
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/shaders/Doom3ShaderLayer.h
Expand Up @@ -113,6 +113,8 @@ class Doom3ShaderLayer
// Stage-specific polygon offset, is 0 if not used
float _privatePolygonOffset;

Vector2 _renderMapSize;

public:

// Constructor
Expand All @@ -130,6 +132,9 @@ class Doom3ShaderLayer
MapType getMapType() const override;
void setMapType(MapType type);

const Vector2& getRenderMapSize() override;
void setRenderMapSize(const Vector2& size);

bool hasAlphaTest() const override;
float getAlphaTest() const override;

Expand Down
11 changes: 7 additions & 4 deletions radiantcore/shaders/ShaderTemplate.cpp
Expand Up @@ -615,8 +615,9 @@ bool ShaderTemplate::parseBlendMaps(parser::DefTokeniser& tokeniser, const std::

try
{
std::stoi(tokeniser.nextToken());
std::stoi(tokeniser.nextToken());
auto width = std::stoi(tokeniser.nextToken());
auto height = std::stoi(tokeniser.nextToken());
_currentLayer->setRenderMapSize(Vector2(width, height));
}
catch (std::logic_error& e)
{
Expand All @@ -627,11 +628,13 @@ bool ShaderTemplate::parseBlendMaps(parser::DefTokeniser& tokeniser, const std::
else if (token == "mirrorrendermap")
{
_currentLayer->setMapType(ShaderLayer::MapType::MirrorRenderMap);
_currentLayer->setTexGenType(ShaderLayer::TexGenType::TEXGEN_SCREEN);

try
{
std::stoi(tokeniser.nextToken());
std::stoi(tokeniser.nextToken());
auto width = std::stoi(tokeniser.nextToken());
auto height = std::stoi(tokeniser.nextToken());
_currentLayer->setRenderMapSize(Vector2(width, height));
}
catch (std::invalid_argument& e)
{
Expand Down

0 comments on commit 610aeac

Please sign in to comment.