Graphics/Material: Add SetReflectionMode

This commit is contained in:
Lynix 2017-03-19 17:01:48 +01:00
parent 62fd66a159
commit 65393d98fb
3 changed files with 53 additions and 0 deletions

View File

@ -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

View File

@ -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<typename... Args> 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;

View File

@ -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
*