diff --git a/Source/Engine/Content/Assets/Material.cpp b/Source/Engine/Content/Assets/Material.cpp
index 2b715da0c..baef3adce 100644
--- a/Source/Engine/Content/Assets/Material.cpp
+++ b/Source/Engine/Content/Assets/Material.cpp
@@ -48,6 +48,11 @@ const MaterialInfo& Material::GetInfo() const
return EmptyInfo;
}
+GPUShader* Material::GetShader() const
+{
+ return _materialShader ? _materialShader->GetShader() : nullptr;
+}
+
bool Material::IsReady() const
{
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_REFLECTIONS", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections ? 0 : 1] });
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] });
if (useForward)
options.Macros.Add({ "USE_PIXEL_NORMAL_OFFSET_REFRACTION", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::PixelNormalOffsetRefraction ? 1 : 0] });
diff --git a/Source/Engine/Content/Assets/Material.h b/Source/Engine/Content/Assets/Material.h
index a8bf9a629..676680968 100644
--- a/Source/Engine/Content/Assets/Material.h
+++ b/Source/Engine/Content/Assets/Material.h
@@ -45,6 +45,7 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
DrawPass GetDrawModes() const override;
bool CanUseLightmap() const override;
diff --git a/Source/Engine/Content/Assets/MaterialInstance.cpp b/Source/Engine/Content/Assets/MaterialInstance.cpp
index e0e57c6cb..9d94aeed4 100644
--- a/Source/Engine/Content/Assets/MaterialInstance.cpp
+++ b/Source/Engine/Content/Assets/MaterialInstance.cpp
@@ -143,6 +143,11 @@ const MaterialInfo& MaterialInstance::GetInfo() const
return EmptyInfo;
}
+GPUShader* MaterialInstance::GetShader() const
+{
+ return _baseMaterial ? _baseMaterial->GetShader() : nullptr;
+}
+
bool MaterialInstance::IsReady() const
{
return IsLoaded() && _baseMaterial && _baseMaterial->IsReady();
diff --git a/Source/Engine/Content/Assets/MaterialInstance.h b/Source/Engine/Content/Assets/MaterialInstance.h
index f5143aadd..d5df025be 100644
--- a/Source/Engine/Content/Assets/MaterialInstance.h
+++ b/Source/Engine/Content/Assets/MaterialInstance.h
@@ -59,6 +59,7 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
DrawPass GetDrawModes() const override;
bool CanUseLightmap() const override;
diff --git a/Source/Engine/Graphics/Materials/IMaterial.h b/Source/Engine/Graphics/Materials/IMaterial.h
index f22feda91..c59aebb58 100644
--- a/Source/Engine/Graphics/Materials/IMaterial.h
+++ b/Source/Engine/Graphics/Materials/IMaterial.h
@@ -5,6 +5,7 @@
#include "MaterialInfo.h"
struct MaterialParamsLink;
+class GPUShader;
class GPUContext;
class GPUTextureView;
class RenderBuffers;
@@ -26,6 +27,12 @@ public:
/// The constant reference to the material descriptor.
virtual const MaterialInfo& GetInfo() const = 0;
+ ///
+ /// Gets the shader resource.
+ ///
+ /// The material shader resource.
+ virtual GPUShader* GetShader() const = 0;
+
///
/// Determines whether material is a surface shader.
///
diff --git a/Source/Engine/Graphics/Materials/MaterialShader.h b/Source/Engine/Graphics/Materials/MaterialShader.h
index 4c789b2ea..8257147c8 100644
--- a/Source/Engine/Graphics/Materials/MaterialShader.h
+++ b/Source/Engine/Graphics/Materials/MaterialShader.h
@@ -98,8 +98,6 @@ public:
/// The created and loaded material or null if failed.
static MaterialShader* CreateDummy(MemoryReadStream& shaderCacheStream, const MaterialInfo& info);
- GPUShader* GetShader() const;
-
///
/// Clears the loaded data.
///
@@ -114,5 +112,6 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
};
diff --git a/Source/Engine/Renderer/Editor/LODPreview.cpp b/Source/Engine/Renderer/Editor/LODPreview.cpp
index 57b79083d..612de21a8 100644
--- a/Source/Engine/Renderer/Editor/LODPreview.cpp
+++ b/Source/Engine/Renderer/Editor/LODPreview.cpp
@@ -22,6 +22,11 @@ const MaterialInfo& LODPreviewMaterialShader::GetInfo() const
return _material->GetInfo();
}
+GPUShader* LODPreviewMaterialShader::GetShader() const
+{
+ return _material->GetShader();
+}
+
bool LODPreviewMaterialShader::IsReady() const
{
return _material && _material->IsReady();
diff --git a/Source/Engine/Renderer/Editor/LODPreview.h b/Source/Engine/Renderer/Editor/LODPreview.h
index c8df9cadd..8de84a7cf 100644
--- a/Source/Engine/Renderer/Editor/LODPreview.h
+++ b/Source/Engine/Renderer/Editor/LODPreview.h
@@ -30,6 +30,7 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
bool CanUseInstancing(InstancingHandler& handler) const override;
DrawPass GetDrawModes() const override;
diff --git a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp
index 6b7ac9b5f..d5a6d11e8 100644
--- a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp
+++ b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp
@@ -53,6 +53,11 @@ const MaterialInfo& LightmapUVsDensityMaterialShader::GetInfo() const
return _info;
}
+GPUShader* LightmapUVsDensityMaterialShader::GetShader() const
+{
+ return _shader->GetShader();
+}
+
bool LightmapUVsDensityMaterialShader::IsReady() const
{
return _shader && _shader->IsLoaded();
diff --git a/Source/Engine/Renderer/Editor/LightmapUVsDensity.h b/Source/Engine/Renderer/Editor/LightmapUVsDensity.h
index a8905094a..9c293ca57 100644
--- a/Source/Engine/Renderer/Editor/LightmapUVsDensity.h
+++ b/Source/Engine/Renderer/Editor/LightmapUVsDensity.h
@@ -40,6 +40,7 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
DrawPass GetDrawModes() const override;
void Bind(BindParameters& params) override;
diff --git a/Source/Engine/Renderer/Editor/MaterialComplexity.cpp b/Source/Engine/Renderer/Editor/MaterialComplexity.cpp
index 81c125d43..e8e1feb97 100644
--- a/Source/Engine/Renderer/Editor/MaterialComplexity.cpp
+++ b/Source/Engine/Renderer/Editor/MaterialComplexity.cpp
@@ -29,6 +29,11 @@ const MaterialInfo& MaterialComplexityMaterialShader::WrapperShader::GetInfo() c
return Info;
}
+GPUShader* MaterialComplexityMaterialShader::WrapperShader::GetShader() const
+{
+ return MaterialAsset->GetShader();
+}
+
bool MaterialComplexityMaterialShader::WrapperShader::IsReady() const
{
return MaterialAsset && MaterialAsset->IsReady();
diff --git a/Source/Engine/Renderer/Editor/MaterialComplexity.h b/Source/Engine/Renderer/Editor/MaterialComplexity.h
index 292f736a5..716964f0d 100644
--- a/Source/Engine/Renderer/Editor/MaterialComplexity.h
+++ b/Source/Engine/Renderer/Editor/MaterialComplexity.h
@@ -25,6 +25,7 @@ private:
MaterialDomain Domain;
AssetReference MaterialAsset;
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
bool CanUseInstancing(InstancingHandler& handler) const override;
DrawPass GetDrawModes() const override;
diff --git a/Source/Engine/Renderer/Editor/VertexColors.cpp b/Source/Engine/Renderer/Editor/VertexColors.cpp
index 965ba3fd9..4b4a8fc3c 100644
--- a/Source/Engine/Renderer/Editor/VertexColors.cpp
+++ b/Source/Engine/Renderer/Editor/VertexColors.cpp
@@ -41,6 +41,11 @@ const MaterialInfo& VertexColorsMaterialShader::GetInfo() const
return _info;
}
+GPUShader* VertexColorsMaterialShader::GetShader() const
+{
+ return _shader->GetShader();
+}
+
bool VertexColorsMaterialShader::IsReady() const
{
return _shader && _shader->IsLoaded();
diff --git a/Source/Engine/Renderer/Editor/VertexColors.h b/Source/Engine/Renderer/Editor/VertexColors.h
index ffeca3245..79ea22ae0 100644
--- a/Source/Engine/Renderer/Editor/VertexColors.h
+++ b/Source/Engine/Renderer/Editor/VertexColors.h
@@ -38,6 +38,7 @@ public:
// [IMaterial]
const MaterialInfo& GetInfo() const override;
+ GPUShader* GetShader() const override;
bool IsReady() const override;
DrawPass GetDrawModes() const override;
void Bind(BindParameters& params) override;