Graphics: rework ubershaders to prevent duplicate shaders modules
Also rename all remaining conditions to options
This commit is contained in:
@@ -90,15 +90,6 @@ namespace Nz
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
inline void Material::EnableCondition(std::size_t conditionIndex, bool enable)
|
||||
{
|
||||
if (TestBit<UInt64>(m_enabledConditions, conditionIndex) != enable)
|
||||
{
|
||||
m_enabledConditions = ToggleBit<UInt64>(m_enabledConditions, conditionIndex);
|
||||
InvalidatePipeline();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable depth buffer for this material
|
||||
*
|
||||
@@ -189,6 +180,15 @@ namespace Nz
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
inline void Material::EnableOption(std::size_t optionIndex, bool enable)
|
||||
{
|
||||
if (TestBit<UInt64>(m_enabledOptions, optionIndex) != enable)
|
||||
{
|
||||
m_enabledOptions = ToggleBit<UInt64>(m_enabledOptions, optionIndex);
|
||||
InvalidatePipeline();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable reflection mapping for this material
|
||||
*
|
||||
@@ -515,11 +515,6 @@ namespace Nz
|
||||
return m_pipelineInfo.colorWrite;
|
||||
}
|
||||
|
||||
inline bool Material::IsConditionEnabled(std::size_t conditionIndex) const
|
||||
{
|
||||
return TestBit<UInt64>(m_enabledConditions, conditionIndex);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has depth buffer enabled
|
||||
* \return true If it is the case
|
||||
@@ -556,6 +551,11 @@ namespace Nz
|
||||
return m_pipelineInfo.faceCulling;
|
||||
}
|
||||
|
||||
inline bool Material::IsOptionEnabled(std::size_t optionIndex) const
|
||||
{
|
||||
return TestBit<UInt64>(m_enabledOptions, optionIndex);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has reflection mapping enabled
|
||||
* \return true If it is the case
|
||||
@@ -766,25 +766,6 @@ namespace Nz
|
||||
|
||||
OnMaterialInvalidated(this);
|
||||
}
|
||||
|
||||
inline void Material::UpdatePipeline() const
|
||||
{
|
||||
for (auto& shader : m_pipelineInfo.shaders)
|
||||
shader.enabledConditions = 0;
|
||||
|
||||
const auto& conditions = m_settings->GetConditions();
|
||||
for (std::size_t conditionIndex = 0; conditionIndex < conditions.size(); ++conditionIndex)
|
||||
{
|
||||
if (TestBit<UInt64>(m_enabledConditions, conditionIndex))
|
||||
{
|
||||
for (std::size_t shaderStage = 0; shaderStage < ShaderStageTypeCount; ++shaderStage)
|
||||
m_pipelineInfo.shaders[shaderStage].enabledConditions |= conditions[conditionIndex].enabledConditions[shaderStage];
|
||||
}
|
||||
}
|
||||
|
||||
m_pipeline = MaterialPipeline::Get(m_pipelineInfo);
|
||||
m_pipelineUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user