diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index 68a8ed95e..83f46dc22 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -122,6 +122,15 @@ namespace Nz RenderTechniqueType_Max = RenderTechniqueType_User }; + enum ReflectionMode + { + ReflectionMode_RealTime, + ReflectionMode_Probe, + ReflectionMode_Skybox, + + ReflectionMode_Max = ReflectionMode_Skybox + }; + enum SceneNodeType { SceneNodeType_Light, // Light diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 73f37091a..13a9476ea 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -106,6 +106,7 @@ namespace Nz inline const MaterialPipeline* GetPipeline() const; inline const MaterialPipelineInfo& GetPipelineInfo() const; inline float GetPointSize() const; + inline ReflectionMode GetReflectionMode() const; inline const UberShader* GetShader() const; inline float GetShininess() const; inline Color GetSpecularColor() const; @@ -164,6 +165,7 @@ namespace Nz inline bool SetNormalMap(const String& textureName); inline void SetNormalMap(TextureRef textureName); inline void SetPointSize(float pointSize); + inline void SetReflectionMode(ReflectionMode reflectionMode); inline void SetShader(UberShaderConstRef uberShader); inline bool SetShader(const String& uberShaderName); inline void SetShininess(float shininess); @@ -180,6 +182,7 @@ namespace Nz template static MaterialRef New(Args&&... args); // Signals: + NazaraSignal(OnMaterialReflectionChange, const Material* /*material*/, ReflectionMode /*newReflectionMode*/); NazaraSignal(OnMaterialRelease, const Material* /*material*/); NazaraSignal(OnMaterialReset, const Material* /*material*/); @@ -197,6 +200,7 @@ namespace Nz MaterialRef m_depthMaterial; //< Materialception mutable const MaterialPipeline* m_pipeline; MaterialPipelineInfo m_pipelineInfo; + ReflectionMode m_reflectionMode; TextureSampler m_diffuseSampler; TextureSampler m_specularSampler; TextureRef m_alphaMap; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 6c4e8880b..b19a1bc19 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -618,6 +618,18 @@ namespace Nz return m_pipelineInfo.pointSize; } + /*! + * \brief Gets the reflection mode of the material + * + * \return Current reflection mode + * + * \see SetReflectionMode + */ + inline ReflectionMode Material::GetReflectionMode() const + { + return m_reflectionMode; + } + /*! * \brief Gets the über-shader used by this material * \return Constant pointer to the über-shader used @@ -1243,6 +1255,34 @@ namespace Nz InvalidatePipeline(); } + /*! + * \brief Changes reflection mode of the material + * + * When reflections are enable, the material will render reflections from the object environment according to the reflection mode. + * This function does change the reflection mode used by the material. + * + * Skyboxes reflections are the cheapest but are static and thus can't reflect other objects. + * Probes reflections are cheap, depending on probes reflection mode, but require regular probe finding from objects using it. + * Real-time reflections are expensive but provide the most accurate reflection map (and can reflect other objects around). + * + * \param reflectionMode The new reflection mode this material should use + * + * \remark May invalidates the pipeline + * + * \see EnableReflectionMapping + * \see IsReflectionMappingEnabled + * \see SetReflectionSize + */ + inline void Material::SetReflectionMode(ReflectionMode reflectionMode) + { + if (m_reflectionMode != reflectionMode) + { + OnMaterialReflectionChange(this, reflectionMode); + + m_reflectionMode = reflectionMode; + } + } + /*! * \brief Sets the shader with a constant reference to a ubershader *