Graphics/Material: Add depth material parameter

Former-commit-id: 980888e12e5d8c8cf280c6a62592068cfab49d2e
This commit is contained in:
Lynix 2015-07-05 23:23:17 +02:00
parent 1398ed7ebc
commit c0ee9d04b5
3 changed files with 29 additions and 10 deletions

View File

@ -71,6 +71,7 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
inline float GetAlphaThreshold() const; inline float GetAlphaThreshold() const;
inline NzColor GetAmbientColor() const; inline NzColor GetAmbientColor() const;
inline nzRendererComparison GetDepthFunc() const; inline nzRendererComparison GetDepthFunc() const;
inline const NzMaterialRef& GetDepthMaterial() const;
inline NzColor GetDiffuseColor() const; inline NzColor GetDiffuseColor() const;
inline const NzTextureRef& GetDiffuseMap() const; inline const NzTextureRef& GetDiffuseMap() const;
inline NzTextureSampler& GetDiffuseSampler(); inline NzTextureSampler& GetDiffuseSampler();
@ -92,6 +93,7 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
inline nzBlendFunc GetSrcBlend() const; inline nzBlendFunc GetSrcBlend() const;
inline bool HasAlphaMap() const; inline bool HasAlphaMap() const;
inline bool HasDepthMaterial() const;
inline bool HasDiffuseMap() const; inline bool HasDiffuseMap() const;
inline bool HasEmissiveMap() const; inline bool HasEmissiveMap() const;
inline bool HasHeightMap() const; inline bool HasHeightMap() const;
@ -117,6 +119,7 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
inline void SetAlphaThreshold(float alphaThreshold); inline void SetAlphaThreshold(float alphaThreshold);
inline void SetAmbientColor(const NzColor& ambient); inline void SetAmbientColor(const NzColor& ambient);
inline void SetDepthFunc(nzRendererComparison depthFunc); inline void SetDepthFunc(nzRendererComparison depthFunc);
inline void SetDepthMaterial(NzMaterialRef depthMaterial);
inline void SetDiffuseColor(const NzColor& diffuse); inline void SetDiffuseColor(const NzColor& diffuse);
inline bool SetDiffuseMap(const NzString& textureName); inline bool SetDiffuseMap(const NzString& textureName);
inline void SetDiffuseMap(NzTextureRef diffuseMap); inline void SetDiffuseMap(NzTextureRef diffuseMap);
@ -167,6 +170,7 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
NzColor m_ambientColor; NzColor m_ambientColor;
NzColor m_diffuseColor; NzColor m_diffuseColor;
NzColor m_specularColor; NzColor m_specularColor;
NzMaterialRef m_depthMaterial; //< Materialception
NzRenderStates m_states; NzRenderStates m_states;
NzTextureSampler m_diffuseSampler; NzTextureSampler m_diffuseSampler;
NzTextureSampler m_specularSampler; NzTextureSampler m_specularSampler;

View File

@ -89,6 +89,11 @@ inline nzRendererComparison NzMaterial::GetDepthFunc() const
return m_states.depthFunc; return m_states.depthFunc;
} }
inline const NzMaterialRef& NzMaterial::GetDepthMaterial() const
{
return m_depthMaterial;
}
inline NzColor NzMaterial::GetDiffuseColor() const inline NzColor NzMaterial::GetDiffuseColor() const
{ {
return m_diffuseColor; return m_diffuseColor;
@ -193,6 +198,11 @@ inline bool NzMaterial::HasAlphaMap() const
return m_alphaMap.IsValid(); return m_alphaMap.IsValid();
} }
inline bool NzMaterial::HasDepthMaterial() const
{
return m_depthMaterial.IsValid();
}
inline bool NzMaterial::HasDiffuseMap() const inline bool NzMaterial::HasDiffuseMap() const
{ {
return m_diffuseMap.IsValid(); return m_diffuseMap.IsValid();
@ -306,6 +316,11 @@ inline void NzMaterial::SetDepthFunc(nzRendererComparison depthFunc)
m_states.depthFunc = depthFunc; m_states.depthFunc = depthFunc;
} }
inline void NzMaterial::SetDepthMaterial(NzMaterialRef depthMaterial)
{
m_depthMaterial = std::move(depthMaterial);
}
inline void NzMaterial::SetDiffuseColor(const NzColor& diffuse) inline void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
{ {
m_diffuseColor = diffuse; m_diffuseColor = diffuse;

View File

@ -125,6 +125,7 @@ void NzMaterial::Reset()
OnMaterialReset(this); OnMaterialReset(this);
m_alphaMap.Reset(); m_alphaMap.Reset();
m_depthMaterial.Reset();
m_diffuseMap.Reset(); m_diffuseMap.Reset();
m_emissiveMap.Reset(); m_emissiveMap.Reset();
m_heightMap.Reset(); m_heightMap.Reset();
@ -173,16 +174,15 @@ void NzMaterial::Copy(const NzMaterial& material)
m_states = material.m_states; m_states = material.m_states;
m_transformEnabled = material.m_transformEnabled; m_transformEnabled = material.m_transformEnabled;
// Copie des références de texture // Copying resources refs
m_alphaMap = material.m_alphaMap; m_alphaMap = material.m_alphaMap;
m_diffuseMap = material.m_diffuseMap; m_depthMaterial = material.m_depthMaterial;
m_emissiveMap = material.m_emissiveMap; m_diffuseMap = material.m_diffuseMap;
m_heightMap = material.m_heightMap; m_emissiveMap = material.m_emissiveMap;
m_normalMap = material.m_normalMap; m_heightMap = material.m_heightMap;
m_specularMap = material.m_specularMap; m_normalMap = material.m_normalMap;
m_specularMap = material.m_specularMap;
// Copie de la référence vers l'Über-Shader m_uberShader = material.m_uberShader;
m_uberShader = material.m_uberShader;
// On copie les instances de shader par la même occasion // On copie les instances de shader par la même occasion
std::memcpy(&m_shaders[0], &material.m_shaders[0], (nzShaderFlags_Max+1)*sizeof(ShaderInstance)); std::memcpy(&m_shaders[0], &material.m_shaders[0], (nzShaderFlags_Max+1)*sizeof(ShaderInstance));