Graphics/Material: Inline class
Former-commit-id: 7cd8b7a00c87adf087dae7d0fb8d955747cf82d1
This commit is contained in:
parent
35066a3451
commit
763701df7f
|
|
@ -53,90 +53,90 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
|
||||||
friend class NzGraphics;
|
friend class NzGraphics;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NzMaterial();
|
inline NzMaterial();
|
||||||
NzMaterial(const NzMaterial& material);
|
inline NzMaterial(const NzMaterial& material);
|
||||||
~NzMaterial();
|
inline ~NzMaterial();
|
||||||
|
|
||||||
const NzShader* Apply(nzUInt32 shaderFlags = 0, nzUInt8 textureUnit = 0, nzUInt8* lastUsedUnit = nullptr) const;
|
const NzShader* Apply(nzUInt32 shaderFlags = 0, nzUInt8 textureUnit = 0, nzUInt8* lastUsedUnit = nullptr) const;
|
||||||
|
|
||||||
void Enable(nzRendererParameter renderParameter, bool enable);
|
inline void Enable(nzRendererParameter renderParameter, bool enable);
|
||||||
void EnableAlphaTest(bool alphaTest);
|
inline void EnableAlphaTest(bool alphaTest);
|
||||||
void EnableDepthSorting(bool depthSorting);
|
inline void EnableDepthSorting(bool depthSorting);
|
||||||
void EnableLighting(bool lighting);
|
inline void EnableLighting(bool lighting);
|
||||||
void EnableTransform(bool transform);
|
inline void EnableTransform(bool transform);
|
||||||
|
|
||||||
NzTexture* GetAlphaMap() const;
|
inline NzTexture* GetAlphaMap() const;
|
||||||
float GetAlphaThreshold() const;
|
inline float GetAlphaThreshold() const;
|
||||||
NzColor GetAmbientColor() const;
|
inline NzColor GetAmbientColor() const;
|
||||||
nzRendererComparison GetDepthFunc() const;
|
inline nzRendererComparison GetDepthFunc() const;
|
||||||
NzColor GetDiffuseColor() const;
|
inline NzColor GetDiffuseColor() const;
|
||||||
NzTexture* GetDiffuseMap() const;
|
inline NzTexture* GetDiffuseMap() const;
|
||||||
NzTextureSampler& GetDiffuseSampler();
|
inline NzTextureSampler& GetDiffuseSampler();
|
||||||
const NzTextureSampler& GetDiffuseSampler() const;
|
inline const NzTextureSampler& GetDiffuseSampler() const;
|
||||||
nzBlendFunc GetDstBlend() const;
|
inline nzBlendFunc GetDstBlend() const;
|
||||||
NzTexture* GetEmissiveMap() const;
|
inline NzTexture* GetEmissiveMap() const;
|
||||||
nzFaceSide GetFaceCulling() const;
|
inline nzFaceSide GetFaceCulling() const;
|
||||||
nzFaceFilling GetFaceFilling() const;
|
inline nzFaceFilling GetFaceFilling() const;
|
||||||
NzTexture* GetHeightMap() const;
|
inline NzTexture* GetHeightMap() const;
|
||||||
NzTexture* GetNormalMap() const;
|
inline NzTexture* GetNormalMap() const;
|
||||||
const NzRenderStates& GetRenderStates() const;
|
inline const NzRenderStates& GetRenderStates() const;
|
||||||
const NzUberShader* GetShader() const;
|
inline const NzUberShader* GetShader() const;
|
||||||
const NzUberShaderInstance* GetShaderInstance(nzUInt32 flags = nzShaderFlags_None) const;
|
inline const NzUberShaderInstance* GetShaderInstance(nzUInt32 flags = nzShaderFlags_None) const;
|
||||||
float GetShininess() const;
|
inline float GetShininess() const;
|
||||||
NzColor GetSpecularColor() const;
|
inline NzColor GetSpecularColor() const;
|
||||||
NzTexture* GetSpecularMap() const;
|
inline NzTexture* GetSpecularMap() const;
|
||||||
NzTextureSampler& GetSpecularSampler();
|
inline NzTextureSampler& GetSpecularSampler();
|
||||||
const NzTextureSampler& GetSpecularSampler() const;
|
inline const NzTextureSampler& GetSpecularSampler() const;
|
||||||
nzBlendFunc GetSrcBlend() const;
|
inline nzBlendFunc GetSrcBlend() const;
|
||||||
|
|
||||||
bool HasAlphaMap() const;
|
inline bool HasAlphaMap() const;
|
||||||
bool HasDiffuseMap() const;
|
inline bool HasDiffuseMap() const;
|
||||||
bool HasEmissiveMap() const;
|
inline bool HasEmissiveMap() const;
|
||||||
bool HasHeightMap() const;
|
inline bool HasHeightMap() const;
|
||||||
bool HasNormalMap() const;
|
inline bool HasNormalMap() const;
|
||||||
bool HasSpecularMap() const;
|
inline bool HasSpecularMap() const;
|
||||||
|
|
||||||
bool IsAlphaTestEnabled() const;
|
inline bool IsAlphaTestEnabled() const;
|
||||||
bool IsDepthSortingEnabled() const;
|
inline bool IsDepthSortingEnabled() const;
|
||||||
bool IsEnabled(nzRendererParameter renderParameter) const;
|
inline bool IsEnabled(nzRendererParameter renderParameter) const;
|
||||||
bool IsLightingEnabled() const;
|
inline bool IsLightingEnabled() const;
|
||||||
bool IsTransformEnabled() const;
|
inline bool IsTransformEnabled() const;
|
||||||
|
|
||||||
bool LoadFromFile(const NzString& filePath, const NzMaterialParams& params = NzMaterialParams());
|
inline bool LoadFromFile(const NzString& filePath, const NzMaterialParams& params = NzMaterialParams());
|
||||||
bool LoadFromMemory(const void* data, std::size_t size, const NzMaterialParams& params = NzMaterialParams());
|
inline bool LoadFromMemory(const void* data, std::size_t size, const NzMaterialParams& params = NzMaterialParams());
|
||||||
bool LoadFromStream(NzInputStream& stream, const NzMaterialParams& params = NzMaterialParams());
|
inline bool LoadFromStream(NzInputStream& stream, const NzMaterialParams& params = NzMaterialParams());
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
bool SetAlphaMap(const NzString& textureName);
|
inline bool SetAlphaMap(const NzString& textureName);
|
||||||
void SetAlphaMap(NzTextureRef alphaMap);
|
inline void SetAlphaMap(NzTextureRef alphaMap);
|
||||||
void SetAlphaThreshold(float alphaThreshold);
|
inline void SetAlphaThreshold(float alphaThreshold);
|
||||||
void SetAmbientColor(const NzColor& ambient);
|
inline void SetAmbientColor(const NzColor& ambient);
|
||||||
void SetDepthFunc(nzRendererComparison depthFunc);
|
inline void SetDepthFunc(nzRendererComparison depthFunc);
|
||||||
void SetDiffuseColor(const NzColor& diffuse);
|
inline void SetDiffuseColor(const NzColor& diffuse);
|
||||||
bool SetDiffuseMap(const NzString& textureName);
|
inline bool SetDiffuseMap(const NzString& textureName);
|
||||||
void SetDiffuseMap(NzTextureRef diffuseMap);
|
inline void SetDiffuseMap(NzTextureRef diffuseMap);
|
||||||
void SetDiffuseSampler(const NzTextureSampler& sampler);
|
inline void SetDiffuseSampler(const NzTextureSampler& sampler);
|
||||||
void SetDstBlend(nzBlendFunc func);
|
inline void SetDstBlend(nzBlendFunc func);
|
||||||
bool SetEmissiveMap(const NzString& textureName);
|
inline bool SetEmissiveMap(const NzString& textureName);
|
||||||
void SetEmissiveMap(NzTextureRef textureName);
|
inline void SetEmissiveMap(NzTextureRef textureName);
|
||||||
void SetFaceCulling(nzFaceSide faceSide);
|
inline void SetFaceCulling(nzFaceSide faceSide);
|
||||||
void SetFaceFilling(nzFaceFilling filling);
|
inline void SetFaceFilling(nzFaceFilling filling);
|
||||||
bool SetHeightMap(const NzString& textureName);
|
inline bool SetHeightMap(const NzString& textureName);
|
||||||
void SetHeightMap(NzTextureRef textureName);
|
inline void SetHeightMap(NzTextureRef textureName);
|
||||||
bool SetNormalMap(const NzString& textureName);
|
inline bool SetNormalMap(const NzString& textureName);
|
||||||
void SetNormalMap(NzTextureRef textureName);
|
inline void SetNormalMap(NzTextureRef textureName);
|
||||||
void SetRenderStates(const NzRenderStates& states);
|
inline void SetRenderStates(const NzRenderStates& states);
|
||||||
void SetShader(NzUberShaderConstRef uberShader);
|
inline void SetShader(NzUberShaderConstRef uberShader);
|
||||||
bool SetShader(const NzString& uberShaderName);
|
inline bool SetShader(const NzString& uberShaderName);
|
||||||
void SetShininess(float shininess);
|
inline void SetShininess(float shininess);
|
||||||
void SetSpecularColor(const NzColor& specular);
|
inline void SetSpecularColor(const NzColor& specular);
|
||||||
bool SetSpecularMap(const NzString& textureName);
|
inline bool SetSpecularMap(const NzString& textureName);
|
||||||
void SetSpecularMap(NzTextureRef specularMap);
|
inline void SetSpecularMap(NzTextureRef specularMap);
|
||||||
void SetSpecularSampler(const NzTextureSampler& sampler);
|
inline void SetSpecularSampler(const NzTextureSampler& sampler);
|
||||||
void SetSrcBlend(nzBlendFunc func);
|
inline void SetSrcBlend(nzBlendFunc func);
|
||||||
|
|
||||||
NzMaterial& operator=(const NzMaterial& material);
|
inline NzMaterial& operator=(const NzMaterial& material);
|
||||||
|
|
||||||
static NzMaterialRef GetDefault();
|
static NzMaterialRef GetDefault();
|
||||||
template<typename... Args> static NzMaterialRef New(Args&&... args);
|
template<typename... Args> static NzMaterialRef New(Args&&... args);
|
||||||
|
|
@ -155,7 +155,7 @@ class NAZARA_GRAPHICS_API NzMaterial : public NzRefCounted, public NzResource
|
||||||
|
|
||||||
void Copy(const NzMaterial& material);
|
void Copy(const NzMaterial& material);
|
||||||
void GenerateShader(nzUInt32 flags) const;
|
void GenerateShader(nzUInt32 flags) const;
|
||||||
void InvalidateShaders();
|
inline void InvalidateShaders();
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,474 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
|
inline NzMaterial::NzMaterial()
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzMaterial::NzMaterial(const NzMaterial& material) :
|
||||||
|
NzRefCounted(),
|
||||||
|
NzResource(material)
|
||||||
|
{
|
||||||
|
Copy(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzMaterial::~NzMaterial()
|
||||||
|
{
|
||||||
|
OnMaterialRelease(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::Enable(nzRendererParameter renderParameter, bool enable)
|
||||||
|
{
|
||||||
|
NazaraAssert(parameter <= nzRendererParameter_Max, "Renderer parameter out of enum");
|
||||||
|
|
||||||
|
m_states.parameters[renderParameter] = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::EnableAlphaTest(bool alphaTest)
|
||||||
|
{
|
||||||
|
m_alphaTestEnabled = alphaTest;
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::EnableDepthSorting(bool depthSorting)
|
||||||
|
{
|
||||||
|
m_depthSortingEnabled = depthSorting;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::EnableLighting(bool lighting)
|
||||||
|
{
|
||||||
|
m_lightingEnabled = lighting;
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::EnableTransform(bool transform)
|
||||||
|
{
|
||||||
|
m_transformEnabled = transform;
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTexture* NzMaterial::GetAlphaMap() const
|
||||||
|
{
|
||||||
|
return m_alphaMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float NzMaterial::GetAlphaThreshold() const
|
||||||
|
{
|
||||||
|
return m_alphaThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzColor NzMaterial::GetAmbientColor() const
|
||||||
|
{
|
||||||
|
return m_ambientColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline nzRendererComparison NzMaterial::GetDepthFunc() const
|
||||||
|
{
|
||||||
|
return m_states.depthFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzColor NzMaterial::GetDiffuseColor() const
|
||||||
|
{
|
||||||
|
return m_diffuseColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTextureSampler& NzMaterial::GetDiffuseSampler()
|
||||||
|
{
|
||||||
|
return m_diffuseSampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const NzTextureSampler& NzMaterial::GetDiffuseSampler() const
|
||||||
|
{
|
||||||
|
return m_diffuseSampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
NzTexture* NzMaterial::GetDiffuseMap() const
|
||||||
|
{
|
||||||
|
return m_diffuseMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline nzBlendFunc NzMaterial::GetDstBlend() const
|
||||||
|
{
|
||||||
|
return m_states.dstBlend;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTexture* NzMaterial::GetEmissiveMap() const
|
||||||
|
{
|
||||||
|
return m_emissiveMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline nzFaceSide NzMaterial::GetFaceCulling() const
|
||||||
|
{
|
||||||
|
return m_states.faceCulling;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline nzFaceFilling NzMaterial::GetFaceFilling() const
|
||||||
|
{
|
||||||
|
return m_states.faceFilling;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTexture* NzMaterial::GetHeightMap() const
|
||||||
|
{
|
||||||
|
return m_heightMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTexture* NzMaterial::GetNormalMap() const
|
||||||
|
{
|
||||||
|
return m_normalMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const NzRenderStates& NzMaterial::GetRenderStates() const
|
||||||
|
{
|
||||||
|
return m_states;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const NzUberShader* NzMaterial::GetShader() const
|
||||||
|
{
|
||||||
|
return m_uberShader;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const NzUberShaderInstance* NzMaterial::GetShaderInstance(nzUInt32 flags) const
|
||||||
|
{
|
||||||
|
const ShaderInstance& instance = m_shaders[flags];
|
||||||
|
if (!instance.uberInstance)
|
||||||
|
GenerateShader(flags);
|
||||||
|
|
||||||
|
return instance.uberInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float NzMaterial::GetShininess() const
|
||||||
|
{
|
||||||
|
return m_shininess;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzColor NzMaterial::GetSpecularColor() const
|
||||||
|
{
|
||||||
|
return m_specularColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTexture* NzMaterial::GetSpecularMap() const
|
||||||
|
{
|
||||||
|
return m_specularMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzTextureSampler& NzMaterial::GetSpecularSampler()
|
||||||
|
{
|
||||||
|
return m_specularSampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const NzTextureSampler& NzMaterial::GetSpecularSampler() const
|
||||||
|
{
|
||||||
|
return m_specularSampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline nzBlendFunc NzMaterial::GetSrcBlend() const
|
||||||
|
{
|
||||||
|
return m_states.srcBlend;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasAlphaMap() const
|
||||||
|
{
|
||||||
|
return m_alphaMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasDiffuseMap() const
|
||||||
|
{
|
||||||
|
return m_diffuseMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasEmissiveMap() const
|
||||||
|
{
|
||||||
|
return m_emissiveMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasHeightMap() const
|
||||||
|
{
|
||||||
|
return m_heightMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasNormalMap() const
|
||||||
|
{
|
||||||
|
return m_normalMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::HasSpecularMap() const
|
||||||
|
{
|
||||||
|
return m_specularMap.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::IsAlphaTestEnabled() const
|
||||||
|
{
|
||||||
|
return m_alphaTestEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::IsDepthSortingEnabled() const
|
||||||
|
{
|
||||||
|
return m_depthSortingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::IsEnabled(nzRendererParameter parameter) const
|
||||||
|
{
|
||||||
|
NazaraAssert(parameter <= nzRendererParameter_Max, "Renderer parameter out of enum");
|
||||||
|
|
||||||
|
return m_states.parameters[parameter];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::IsLightingEnabled() const
|
||||||
|
{
|
||||||
|
return m_lightingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::IsTransformEnabled() const
|
||||||
|
{
|
||||||
|
return m_transformEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::LoadFromFile(const NzString& filePath, const NzMaterialParams& params)
|
||||||
|
{
|
||||||
|
return NzMaterialLoader::LoadFromFile(this, filePath, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::LoadFromMemory(const void* data, std::size_t size, const NzMaterialParams& params)
|
||||||
|
{
|
||||||
|
return NzMaterialLoader::LoadFromMemory(this, data, size, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::LoadFromStream(NzInputStream& stream, const NzMaterialParams& params)
|
||||||
|
{
|
||||||
|
return NzMaterialLoader::LoadFromStream(this, stream, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetAlphaMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAlphaMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetAlphaMap(NzTextureRef alphaMap)
|
||||||
|
{
|
||||||
|
m_alphaMap = std::move(alphaMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetAlphaThreshold(float alphaThreshold)
|
||||||
|
{
|
||||||
|
m_alphaThreshold = alphaThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetAmbientColor(const NzColor& ambient)
|
||||||
|
{
|
||||||
|
m_ambientColor = ambient;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetDepthFunc(nzRendererComparison depthFunc)
|
||||||
|
{
|
||||||
|
m_states.depthFunc = depthFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
|
||||||
|
{
|
||||||
|
m_diffuseColor = diffuse;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetDiffuseMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDiffuseMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetDiffuseMap(NzTextureRef diffuseMap)
|
||||||
|
{
|
||||||
|
m_diffuseMap = std::move(diffuseMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetDiffuseSampler(const NzTextureSampler& sampler)
|
||||||
|
{
|
||||||
|
m_diffuseSampler = sampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetDstBlend(nzBlendFunc func)
|
||||||
|
{
|
||||||
|
m_states.dstBlend = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetEmissiveMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetEmissiveMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetEmissiveMap(NzTextureRef emissiveMap)
|
||||||
|
{
|
||||||
|
m_emissiveMap = std::move(emissiveMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetFaceCulling(nzFaceSide faceSide)
|
||||||
|
{
|
||||||
|
m_states.faceCulling = faceSide;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetFaceFilling(nzFaceFilling filling)
|
||||||
|
{
|
||||||
|
m_states.faceFilling = filling;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetHeightMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetHeightMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetHeightMap(NzTextureRef heightMap)
|
||||||
|
{
|
||||||
|
m_heightMap = std::move(heightMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetNormalMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetNormalMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetNormalMap(NzTextureRef normalMap)
|
||||||
|
{
|
||||||
|
m_normalMap = std::move(normalMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetRenderStates(const NzRenderStates& states)
|
||||||
|
{
|
||||||
|
m_states = states;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetShader(NzUberShaderConstRef uberShader)
|
||||||
|
{
|
||||||
|
m_uberShader = std::move(uberShader);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetShader(const NzString& uberShaderName)
|
||||||
|
{
|
||||||
|
NzUberShaderConstRef uberShader = NzUberShaderLibrary::Get(uberShaderName);
|
||||||
|
if (!uberShader)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SetShader(std::move(uberShader));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetShininess(float shininess)
|
||||||
|
{
|
||||||
|
m_shininess = shininess;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetSpecularColor(const NzColor& specular)
|
||||||
|
{
|
||||||
|
m_specularColor = specular;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool NzMaterial::SetSpecularMap(const NzString& textureName)
|
||||||
|
{
|
||||||
|
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
texture = NzTextureManager::Get(textureName);
|
||||||
|
if (!texture)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSpecularMap(std::move(texture));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetSpecularMap(NzTextureRef specularMap)
|
||||||
|
{
|
||||||
|
m_specularMap = std::move(specularMap);
|
||||||
|
|
||||||
|
InvalidateShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetSpecularSampler(const NzTextureSampler& sampler)
|
||||||
|
{
|
||||||
|
m_specularSampler = sampler;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::SetSrcBlend(nzBlendFunc func)
|
||||||
|
{
|
||||||
|
m_states.srcBlend = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzMaterial& NzMaterial::operator=(const NzMaterial& material)
|
||||||
|
{
|
||||||
|
NzResource::operator=(material);
|
||||||
|
|
||||||
|
Copy(material);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline NzMaterialRef NzMaterial::GetDefault()
|
||||||
|
{
|
||||||
|
return s_defaultMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NzMaterial::InvalidateShaders()
|
||||||
|
{
|
||||||
|
for (ShaderInstance& instance : m_shaders)
|
||||||
|
instance.uberInstance = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
NzMaterialRef NzMaterial::New(Args&&... args)
|
NzMaterialRef NzMaterial::New(Args&&... args)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,23 +41,6 @@ bool NzMaterialParams::IsValid() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMaterial::NzMaterial()
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
NzMaterial::NzMaterial(const NzMaterial& material) :
|
|
||||||
NzRefCounted(),
|
|
||||||
NzResource(material)
|
|
||||||
{
|
|
||||||
Copy(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
NzMaterial::~NzMaterial()
|
|
||||||
{
|
|
||||||
OnMaterialRelease(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzShader* NzMaterial::Apply(nzUInt32 shaderFlags, nzUInt8 textureUnit, nzUInt8* lastUsedUnit) const
|
const NzShader* NzMaterial::Apply(nzUInt32 shaderFlags, nzUInt8 textureUnit, nzUInt8* lastUsedUnit) const
|
||||||
{
|
{
|
||||||
const ShaderInstance& instance = m_shaders[shaderFlags];
|
const ShaderInstance& instance = m_shaders[shaderFlags];
|
||||||
|
|
@ -137,242 +120,6 @@ const NzShader* NzMaterial::Apply(nzUInt32 shaderFlags, nzUInt8 textureUnit, nzU
|
||||||
return instance.shader;
|
return instance.shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::Enable(nzRendererParameter renderParameter, bool enable)
|
|
||||||
{
|
|
||||||
#ifdef NAZARA_DEBUG
|
|
||||||
if (renderParameter > nzRendererParameter_Max)
|
|
||||||
{
|
|
||||||
NazaraError("Renderer parameter out of enum");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_states.parameters[renderParameter] = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::EnableAlphaTest(bool alphaTest)
|
|
||||||
{
|
|
||||||
m_alphaTestEnabled = alphaTest;
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::EnableDepthSorting(bool depthSorting)
|
|
||||||
{
|
|
||||||
m_depthSortingEnabled = depthSorting;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::EnableLighting(bool lighting)
|
|
||||||
{
|
|
||||||
m_lightingEnabled = lighting;
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::EnableTransform(bool transform)
|
|
||||||
{
|
|
||||||
m_transformEnabled = transform;
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetAlphaMap() const
|
|
||||||
{
|
|
||||||
return m_alphaMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
float NzMaterial::GetAlphaThreshold() const
|
|
||||||
{
|
|
||||||
return m_alphaThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzColor NzMaterial::GetAmbientColor() const
|
|
||||||
{
|
|
||||||
return m_ambientColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzRendererComparison NzMaterial::GetDepthFunc() const
|
|
||||||
{
|
|
||||||
return m_states.depthFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzColor NzMaterial::GetDiffuseColor() const
|
|
||||||
{
|
|
||||||
return m_diffuseColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTextureSampler& NzMaterial::GetDiffuseSampler()
|
|
||||||
{
|
|
||||||
return m_diffuseSampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzTextureSampler& NzMaterial::GetDiffuseSampler() const
|
|
||||||
{
|
|
||||||
return m_diffuseSampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetDiffuseMap() const
|
|
||||||
{
|
|
||||||
return m_diffuseMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzBlendFunc NzMaterial::GetDstBlend() const
|
|
||||||
{
|
|
||||||
return m_states.dstBlend;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetEmissiveMap() const
|
|
||||||
{
|
|
||||||
return m_emissiveMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzFaceSide NzMaterial::GetFaceCulling() const
|
|
||||||
{
|
|
||||||
return m_states.faceCulling;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzFaceFilling NzMaterial::GetFaceFilling() const
|
|
||||||
{
|
|
||||||
return m_states.faceFilling;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetHeightMap() const
|
|
||||||
{
|
|
||||||
return m_heightMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetNormalMap() const
|
|
||||||
{
|
|
||||||
return m_normalMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzRenderStates& NzMaterial::GetRenderStates() const
|
|
||||||
{
|
|
||||||
return m_states;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzUberShader* NzMaterial::GetShader() const
|
|
||||||
{
|
|
||||||
return m_uberShader;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzUberShaderInstance* NzMaterial::GetShaderInstance(nzUInt32 flags) const
|
|
||||||
{
|
|
||||||
const ShaderInstance& instance = m_shaders[flags];
|
|
||||||
if (!instance.uberInstance)
|
|
||||||
GenerateShader(flags);
|
|
||||||
|
|
||||||
return instance.uberInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
float NzMaterial::GetShininess() const
|
|
||||||
{
|
|
||||||
return m_shininess;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzColor NzMaterial::GetSpecularColor() const
|
|
||||||
{
|
|
||||||
return m_specularColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTexture* NzMaterial::GetSpecularMap() const
|
|
||||||
{
|
|
||||||
return m_specularMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzTextureSampler& NzMaterial::GetSpecularSampler()
|
|
||||||
{
|
|
||||||
return m_specularSampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzTextureSampler& NzMaterial::GetSpecularSampler() const
|
|
||||||
{
|
|
||||||
return m_specularSampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzBlendFunc NzMaterial::GetSrcBlend() const
|
|
||||||
{
|
|
||||||
return m_states.srcBlend;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasAlphaMap() const
|
|
||||||
{
|
|
||||||
return m_alphaMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasDiffuseMap() const
|
|
||||||
{
|
|
||||||
return m_diffuseMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasEmissiveMap() const
|
|
||||||
{
|
|
||||||
return m_emissiveMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasHeightMap() const
|
|
||||||
{
|
|
||||||
return m_heightMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasNormalMap() const
|
|
||||||
{
|
|
||||||
return m_normalMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::HasSpecularMap() const
|
|
||||||
{
|
|
||||||
return m_specularMap.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::IsAlphaTestEnabled() const
|
|
||||||
{
|
|
||||||
return m_alphaTestEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::IsDepthSortingEnabled() const
|
|
||||||
{
|
|
||||||
return m_depthSortingEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::IsEnabled(nzRendererParameter parameter) const
|
|
||||||
{
|
|
||||||
#ifdef NAZARA_DEBUG
|
|
||||||
if (parameter > nzRendererParameter_Max)
|
|
||||||
{
|
|
||||||
NazaraError("Renderer parameter out of enum");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_states.parameters[parameter];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::IsLightingEnabled() const
|
|
||||||
{
|
|
||||||
return m_lightingEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::IsTransformEnabled() const
|
|
||||||
{
|
|
||||||
return m_transformEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::LoadFromFile(const NzString& filePath, const NzMaterialParams& params)
|
|
||||||
{
|
|
||||||
return NzMaterialLoader::LoadFromFile(this, filePath, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::LoadFromMemory(const void* data, std::size_t size, const NzMaterialParams& params)
|
|
||||||
{
|
|
||||||
return NzMaterialLoader::LoadFromMemory(this, data, size, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::LoadFromStream(NzInputStream& stream, const NzMaterialParams& params)
|
|
||||||
{
|
|
||||||
return NzMaterialLoader::LoadFromStream(this, stream, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::Reset()
|
void NzMaterial::Reset()
|
||||||
{
|
{
|
||||||
OnMaterialReset(this);
|
OnMaterialReset(this);
|
||||||
|
|
@ -406,227 +153,6 @@ void NzMaterial::Reset()
|
||||||
SetShader("Basic");
|
SetShader("Basic");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzMaterial::SetAlphaMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAlphaMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetAlphaMap(NzTextureRef alphaMap)
|
|
||||||
{
|
|
||||||
m_alphaMap = std::move(alphaMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetAlphaThreshold(float alphaThreshold)
|
|
||||||
{
|
|
||||||
m_alphaThreshold = alphaThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetAmbientColor(const NzColor& ambient)
|
|
||||||
{
|
|
||||||
m_ambientColor = ambient;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetDepthFunc(nzRendererComparison depthFunc)
|
|
||||||
{
|
|
||||||
m_states.depthFunc = depthFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
|
|
||||||
{
|
|
||||||
m_diffuseColor = diffuse;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetDiffuseMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDiffuseMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseMap(NzTextureRef diffuseMap)
|
|
||||||
{
|
|
||||||
m_diffuseMap = std::move(diffuseMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseSampler(const NzTextureSampler& sampler)
|
|
||||||
{
|
|
||||||
m_diffuseSampler = sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetDstBlend(nzBlendFunc func)
|
|
||||||
{
|
|
||||||
m_states.dstBlend = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetEmissiveMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetEmissiveMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetEmissiveMap(NzTextureRef emissiveMap)
|
|
||||||
{
|
|
||||||
m_emissiveMap = std::move(emissiveMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetFaceCulling(nzFaceSide faceSide)
|
|
||||||
{
|
|
||||||
m_states.faceCulling = faceSide;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetFaceFilling(nzFaceFilling filling)
|
|
||||||
{
|
|
||||||
m_states.faceFilling = filling;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetHeightMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetHeightMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetHeightMap(NzTextureRef heightMap)
|
|
||||||
{
|
|
||||||
m_heightMap = std::move(heightMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetNormalMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetNormalMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetNormalMap(NzTextureRef normalMap)
|
|
||||||
{
|
|
||||||
m_normalMap = std::move(normalMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetRenderStates(const NzRenderStates& states)
|
|
||||||
{
|
|
||||||
m_states = states;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetShader(NzUberShaderConstRef uberShader)
|
|
||||||
{
|
|
||||||
m_uberShader = std::move(uberShader);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetShader(const NzString& uberShaderName)
|
|
||||||
{
|
|
||||||
NzUberShaderConstRef uberShader = NzUberShaderLibrary::Get(uberShaderName);
|
|
||||||
if (!uberShader)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SetShader(std::move(uberShader));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetShininess(float shininess)
|
|
||||||
{
|
|
||||||
m_shininess = shininess;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetSpecularColor(const NzColor& specular)
|
|
||||||
{
|
|
||||||
m_specularColor = specular;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::SetSpecularMap(const NzString& textureName)
|
|
||||||
{
|
|
||||||
NzTextureRef texture = NzTextureLibrary::Query(textureName);
|
|
||||||
if (!texture)
|
|
||||||
{
|
|
||||||
texture = NzTextureManager::Get(textureName);
|
|
||||||
if (!texture)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetSpecularMap(std::move(texture));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetSpecularMap(NzTextureRef specularMap)
|
|
||||||
{
|
|
||||||
m_specularMap = std::move(specularMap);
|
|
||||||
|
|
||||||
InvalidateShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetSpecularSampler(const NzTextureSampler& sampler)
|
|
||||||
{
|
|
||||||
m_specularSampler = sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::SetSrcBlend(nzBlendFunc func)
|
|
||||||
{
|
|
||||||
m_states.srcBlend = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzMaterial& NzMaterial::operator=(const NzMaterial& material)
|
|
||||||
{
|
|
||||||
NzResource::operator=(material);
|
|
||||||
|
|
||||||
Copy(material);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzMaterialRef NzMaterial::GetDefault()
|
|
||||||
{
|
|
||||||
return s_defaultMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::Copy(const NzMaterial& material)
|
void NzMaterial::Copy(const NzMaterial& material)
|
||||||
{
|
{
|
||||||
// Copie des états de base
|
// Copie des états de base
|
||||||
|
|
@ -702,12 +228,6 @@ void NzMaterial::GenerateShader(nzUInt32 flags) const
|
||||||
#undef CacheUniform
|
#undef CacheUniform
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::InvalidateShaders()
|
|
||||||
{
|
|
||||||
for (ShaderInstance& instance : m_shaders)
|
|
||||||
instance.uberInstance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzMaterial::Initialize()
|
bool NzMaterial::Initialize()
|
||||||
{
|
{
|
||||||
if (!NzMaterialLibrary::Initialize())
|
if (!NzMaterialLibrary::Initialize())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue