diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 87f6ed615..2d09c2f35 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -63,6 +63,8 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource inline void EnableAlphaTest(bool alphaTest); inline void EnableDepthSorting(bool depthSorting); inline void EnableLighting(bool lighting); + inline void EnableShadowCasting(bool castShadows); + inline void EnableShadowReceive(bool receiveShadows); inline void EnableTransform(bool transform); inline NzTexture* GetAlphaMap() const; @@ -100,6 +102,8 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource inline bool IsDepthSortingEnabled() const; inline bool IsEnabled(nzRendererParameter renderParameter) const; inline bool IsLightingEnabled() const; + inline bool IsShadowCastingEnabled() const; + inline bool IsShadowReceiveEnabled() const; inline bool IsTransformEnabled() const; inline bool LoadFromFile(const NzString& filePath, const NzMaterialParams& params = NzMaterialParams()); @@ -177,6 +181,8 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource bool m_alphaTestEnabled; bool m_depthSortingEnabled; bool m_lightingEnabled; + bool m_shadowCastingEnabled; + bool m_shadowReceiveEnabled; bool m_transformEnabled; float m_alphaThreshold; float m_shininess; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index aed3f2ceb..93cca4bb0 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -38,6 +38,7 @@ inline void NzMaterial::EnableAlphaTest(bool alphaTest) inline void NzMaterial::EnableDepthSorting(bool depthSorting) { + // Has no influence on shaders m_depthSortingEnabled = depthSorting; } @@ -48,6 +49,19 @@ inline void NzMaterial::EnableLighting(bool lighting) InvalidateShaders(); } +inline void NzMaterial::EnableShadowCasting(bool castShadows) +{ + // Has no influence on shaders + m_shadowCastingEnabled = castShadows; +} + +inline void NzMaterial::EnableShadowReceive(bool receiveShadows) +{ + m_shadowReceiveEnabled = receiveShadows; + + InvalidateShaders(); +} + inline void NzMaterial::EnableTransform(bool transform) { m_transformEnabled = transform; @@ -226,6 +240,16 @@ inline bool NzMaterial::IsLightingEnabled() const return m_lightingEnabled; } +inline bool NzMaterial::IsShadowCastingEnabled() const +{ + return m_shadowCastingEnabled; +} + +inline bool NzMaterial::IsShadowReceiveEnabled() const +{ + return m_shadowReceiveEnabled; +} + inline bool NzMaterial::IsTransformEnabled() const { return m_transformEnabled; diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 382cf4d2c..e6cd9ff1b 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -195,6 +195,7 @@ void NzMaterial::GenerateShader(nzUInt32 flags) const list.SetParameter("LIGHTING", m_lightingEnabled); list.SetParameter("NORMAL_MAPPING", m_normalMap.IsValid()); list.SetParameter("PARALLAX_MAPPING", m_heightMap.IsValid()); + list.SetParameter("SHADOW_MAPPING", m_shadowReceiveEnabled); list.SetParameter("SPECULAR_MAPPING", m_specularMap.IsValid()); list.SetParameter("TEXTURE_MAPPING", m_alphaMap.IsValid() || m_diffuseMap.IsValid() || m_emissiveMap.IsValid() || m_normalMap.IsValid() || m_heightMap.IsValid() || m_specularMap.IsValid() ||