Skip to content

Commit

Permalink
#6052: Don't write the default blend func pair gl_one, gl_zero into t…
Browse files Browse the repository at this point in the history
…he stage
  • Loading branch information
codereader committed Aug 5, 2022
1 parent 847218f commit fbf84b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libs/materials/ParseLib.h
Expand Up @@ -6,6 +6,7 @@
#include "ishaderlayer.h"
#include "gamelib.h"
#include "os/path.h"
#include "string/case_conv.h"
#include "xmlutil/MissingXMLNodeException.h"

namespace shaders
Expand Down Expand Up @@ -294,6 +295,12 @@ constexpr std::pair<const char*, std::pair<const char*, const char*>> BlendTypeS
{ "none", { "gl_zero", "gl_one" } },
};

inline bool isDefaultBlendFunc(const std::pair<std::string, std::string>& blendFuncStrings)
{
return string::to_lower_copy(blendFuncStrings.first) == "gl_one" &&
string::to_lower_copy(blendFuncStrings.second) == "gl_zero";
}

constexpr std::pair<const char*, IShaderLayer::TexGenType> TexGenTypeNames[]
{
{ "normal", IShaderLayer::TEXGEN_NORMAL },
Expand Down
4 changes: 2 additions & 2 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -295,12 +295,12 @@ namespace

}

void writeBlendMap(std::ostream& stream, Doom3ShaderLayer& layer)
void writeBlendMap(std::ostream& stream, const Doom3ShaderLayer& layer)
{
// Blend types
const auto& blendFunc = layer.getBlendFuncStrings();

if (!blendFunc.first.empty())
if (!blendFunc.first.empty() && !isDefaultBlendFunc(blendFunc))
{
stream << "\t\tblend " << blendFunc.first;

Expand Down

0 comments on commit fbf84b7

Please sign in to comment.