Graphics/Material: Add EnableVertexColor temporary

This commit is contained in:
Jérôme Leclercq 2018-06-15 14:13:18 +02:00
parent b2185f2138
commit 41e2d3e448
5 changed files with 34 additions and 1 deletions

View File

@ -83,6 +83,7 @@ namespace Nz
inline void EnableShadowCasting(bool castShadows);
inline void EnableShadowReceive(bool receiveShadows);
inline void EnableStencilTest(bool stencilTest);
inline void EnableVertexColor(bool vertexColor);
inline void EnsurePipelineUpdate() const;
@ -121,6 +122,7 @@ namespace Nz
inline bool HasHeightMap() const;
inline bool HasNormalMap() const;
inline bool HasSpecularMap() const;
inline bool HasVertexColor() const;
inline bool IsAlphaTestEnabled() const;
inline bool IsBlendingEnabled() const;

View File

@ -392,6 +392,25 @@ namespace Nz
InvalidatePipeline();
}
/*!
* \brief Enable/Disable vertex coloring on this material
*
* This is a temporary option, until the new material pipeline system is ready, allowing to enable vertex coloring.
* This option only works with meshes using vertex colors.
*
* \param vertexColor Defines if this material will use vertex color or not
*
* \remark Invalidates the pipeline
*
* \see HasVertexColor
*/
inline void Material::EnableVertexColor(bool vertexColor)
{
m_pipelineInfo.hasVertexColor = vertexColor;
InvalidatePipeline();
}
/*!
* \brief Ensures the pipeline gets updated
*
@ -756,6 +775,15 @@ namespace Nz
return m_specularMap.IsValid();
}
/*!
* \brief Checks whether this material uses vertex coloring
* \return true If it is the case
*/
inline bool Material::HasVertexColor() const
{
return m_pipelineInfo.hasVertexColor;
}
/*!
* \brief Checks whether this material has alpha test enabled
* \return true If it is the case

View File

@ -26,6 +26,7 @@ namespace Nz
bool hasHeightMap = false;
bool hasNormalMap = false;
bool hasSpecularMap = false;
bool hasVertexColor = false;
bool reflectionMapping = false;
bool shadowReceive = true;

View File

@ -71,6 +71,7 @@ namespace Nz
NazaraPipelineBoolMember(hasHeightMap);
NazaraPipelineBoolMember(hasNormalMap);
NazaraPipelineBoolMember(hasSpecularMap);
NazaraPipelineBoolMember(hasVertexColor);
NazaraPipelineBoolMember(reflectionMapping);
NazaraPipelineBoolMember(shadowReceive);
@ -127,6 +128,7 @@ namespace std
NazaraPipelineBoolMember(hasHeightMap);
NazaraPipelineBoolMember(hasNormalMap);
NazaraPipelineBoolMember(hasSpecularMap);
NazaraPipelineBoolMember(hasVertexColor);
NazaraPipelineBoolMember(reflectionMapping);
NazaraPipelineBoolMember(shadowReceive);

View File

@ -98,7 +98,7 @@ namespace Nz
list.SetParameter("FLAG_DEFERRED", static_cast<bool>((flags & ShaderFlags_Deferred) != 0));
list.SetParameter("FLAG_INSTANCING", static_cast<bool>((flags & ShaderFlags_Instancing) != 0));
list.SetParameter("FLAG_TEXTUREOVERLAY", static_cast<bool>((flags & ShaderFlags_TextureOverlay) != 0));
list.SetParameter("FLAG_VERTEXCOLOR", static_cast<bool>((flags & ShaderFlags_VertexColor) != 0));
list.SetParameter("FLAG_VERTEXCOLOR", m_pipelineInfo.hasVertexColor || static_cast<bool>((flags & ShaderFlags_VertexColor) != 0));
Instance& instance = m_instances[flags];
instance.uberInstance = m_pipelineInfo.uberShader->Get(list);