Add shader getter to IMaterial interface
This commit is contained in:
@@ -48,6 +48,11 @@ const MaterialInfo& Material::GetInfo() const
|
|||||||
return EmptyInfo;
|
return EmptyInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* Material::GetShader() const
|
||||||
|
{
|
||||||
|
return _materialShader ? _materialShader->GetShader() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Material::IsReady() const
|
bool Material::IsReady() const
|
||||||
{
|
{
|
||||||
return _materialShader && _materialShader->IsReady();
|
return _materialShader && _materialShader->IsReady();
|
||||||
@@ -431,7 +436,7 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options)
|
|||||||
options.Macros.Add({ "USE_GBUFFER_CUSTOM_DATA", Numbers[useCustomData ? 1 : 0] });
|
options.Macros.Add({ "USE_GBUFFER_CUSTOM_DATA", Numbers[useCustomData ? 1 : 0] });
|
||||||
options.Macros.Add({ "USE_REFLECTIONS", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections ? 0 : 1] });
|
options.Macros.Add({ "USE_REFLECTIONS", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections ? 0 : 1] });
|
||||||
if (!(info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && info.FeaturesFlags & MaterialFeaturesFlags::ScreenSpaceReflections)
|
if (!(info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && info.FeaturesFlags & MaterialFeaturesFlags::ScreenSpaceReflections)
|
||||||
options.Macros.Add({ "MATERIAL_REFLECTIONS", Numbers[1]});
|
options.Macros.Add({ "MATERIAL_REFLECTIONS", Numbers[1] });
|
||||||
options.Macros.Add({ "USE_FOG", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableFog ? 0 : 1] });
|
options.Macros.Add({ "USE_FOG", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableFog ? 0 : 1] });
|
||||||
if (useForward)
|
if (useForward)
|
||||||
options.Macros.Add({ "USE_PIXEL_NORMAL_OFFSET_REFRACTION", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::PixelNormalOffsetRefraction ? 1 : 0] });
|
options.Macros.Add({ "USE_PIXEL_NORMAL_OFFSET_REFRACTION", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::PixelNormalOffsetRefraction ? 1 : 0] });
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
bool CanUseLightmap() const override;
|
bool CanUseLightmap() const override;
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ const MaterialInfo& MaterialInstance::GetInfo() const
|
|||||||
return EmptyInfo;
|
return EmptyInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* MaterialInstance::GetShader() const
|
||||||
|
{
|
||||||
|
return _baseMaterial ? _baseMaterial->GetShader() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool MaterialInstance::IsReady() const
|
bool MaterialInstance::IsReady() const
|
||||||
{
|
{
|
||||||
return IsLoaded() && _baseMaterial && _baseMaterial->IsReady();
|
return IsLoaded() && _baseMaterial && _baseMaterial->IsReady();
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
bool CanUseLightmap() const override;
|
bool CanUseLightmap() const override;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "MaterialInfo.h"
|
#include "MaterialInfo.h"
|
||||||
|
|
||||||
struct MaterialParamsLink;
|
struct MaterialParamsLink;
|
||||||
|
class GPUShader;
|
||||||
class GPUContext;
|
class GPUContext;
|
||||||
class GPUTextureView;
|
class GPUTextureView;
|
||||||
class RenderBuffers;
|
class RenderBuffers;
|
||||||
@@ -26,6 +27,12 @@ public:
|
|||||||
/// <returns>The constant reference to the material descriptor.</returns>
|
/// <returns>The constant reference to the material descriptor.</returns>
|
||||||
virtual const MaterialInfo& GetInfo() const = 0;
|
virtual const MaterialInfo& GetInfo() const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the shader resource.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The material shader resource.</returns>
|
||||||
|
virtual GPUShader* GetShader() const = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether material is a surface shader.
|
/// Determines whether material is a surface shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -98,8 +98,6 @@ public:
|
|||||||
/// <returns>The created and loaded material or null if failed.</returns>
|
/// <returns>The created and loaded material or null if failed.</returns>
|
||||||
static MaterialShader* CreateDummy(MemoryReadStream& shaderCacheStream, const MaterialInfo& info);
|
static MaterialShader* CreateDummy(MemoryReadStream& shaderCacheStream, const MaterialInfo& info);
|
||||||
|
|
||||||
GPUShader* GetShader() const;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears the loaded data.
|
/// Clears the loaded data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -114,5 +112,6 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ const MaterialInfo& LODPreviewMaterialShader::GetInfo() const
|
|||||||
return _material->GetInfo();
|
return _material->GetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* LODPreviewMaterialShader::GetShader() const
|
||||||
|
{
|
||||||
|
return _material->GetShader();
|
||||||
|
}
|
||||||
|
|
||||||
bool LODPreviewMaterialShader::IsReady() const
|
bool LODPreviewMaterialShader::IsReady() const
|
||||||
{
|
{
|
||||||
return _material && _material->IsReady();
|
return _material && _material->IsReady();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
bool CanUseInstancing(InstancingHandler& handler) const override;
|
bool CanUseInstancing(InstancingHandler& handler) const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ const MaterialInfo& LightmapUVsDensityMaterialShader::GetInfo() const
|
|||||||
return _info;
|
return _info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* LightmapUVsDensityMaterialShader::GetShader() const
|
||||||
|
{
|
||||||
|
return _shader->GetShader();
|
||||||
|
}
|
||||||
|
|
||||||
bool LightmapUVsDensityMaterialShader::IsReady() const
|
bool LightmapUVsDensityMaterialShader::IsReady() const
|
||||||
{
|
{
|
||||||
return _shader && _shader->IsLoaded();
|
return _shader && _shader->IsLoaded();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
void Bind(BindParameters& params) override;
|
void Bind(BindParameters& params) override;
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ const MaterialInfo& MaterialComplexityMaterialShader::WrapperShader::GetInfo() c
|
|||||||
return Info;
|
return Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* MaterialComplexityMaterialShader::WrapperShader::GetShader() const
|
||||||
|
{
|
||||||
|
return MaterialAsset->GetShader();
|
||||||
|
}
|
||||||
|
|
||||||
bool MaterialComplexityMaterialShader::WrapperShader::IsReady() const
|
bool MaterialComplexityMaterialShader::WrapperShader::IsReady() const
|
||||||
{
|
{
|
||||||
return MaterialAsset && MaterialAsset->IsReady();
|
return MaterialAsset && MaterialAsset->IsReady();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ private:
|
|||||||
MaterialDomain Domain;
|
MaterialDomain Domain;
|
||||||
AssetReference<Material> MaterialAsset;
|
AssetReference<Material> MaterialAsset;
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
bool CanUseInstancing(InstancingHandler& handler) const override;
|
bool CanUseInstancing(InstancingHandler& handler) const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ const MaterialInfo& VertexColorsMaterialShader::GetInfo() const
|
|||||||
return _info;
|
return _info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUShader* VertexColorsMaterialShader::GetShader() const
|
||||||
|
{
|
||||||
|
return _shader->GetShader();
|
||||||
|
}
|
||||||
|
|
||||||
bool VertexColorsMaterialShader::IsReady() const
|
bool VertexColorsMaterialShader::IsReady() const
|
||||||
{
|
{
|
||||||
return _shader && _shader->IsLoaded();
|
return _shader && _shader->IsLoaded();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
// [IMaterial]
|
// [IMaterial]
|
||||||
const MaterialInfo& GetInfo() const override;
|
const MaterialInfo& GetInfo() const override;
|
||||||
|
GPUShader* GetShader() const override;
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
DrawPass GetDrawModes() const override;
|
DrawPass GetDrawModes() const override;
|
||||||
void Bind(BindParameters& params) override;
|
void Bind(BindParameters& params) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user