Graphics: Use module name to retrieve material shaders

This commit is contained in:
Jérôme Leclercq
2022-03-15 13:14:43 +01:00
parent 0f55779a8a
commit 0e92ef823d
9 changed files with 42 additions and 95 deletions

View File

@@ -9,35 +9,9 @@
namespace Nz
{
namespace
{
const UInt8 r_depthMaterialShader[] = {
#include <Nazara/Graphics/Resources/Shaders/depth_material.nzsl.h>
};
}
std::vector<std::shared_ptr<UberShader>> DepthMaterial::BuildShaders()
{
ShaderAst::ModulePtr shaderModule;
#ifdef NAZARA_DEBUG
std::filesystem::path shaderPath = "../../src/Nazara/Graphics/Resources/Shaders/depth_material.nzsl";
if (std::filesystem::exists(shaderPath))
{
try
{
shaderModule = ShaderLang::ParseFromFile(shaderPath);
}
catch (const std::exception& e)
{
NazaraError(std::string("failed to load shader from engine folder: ") + e.what());
}
}
#endif
if (!shaderModule)
shaderModule = ShaderLang::Parse(std::string_view(reinterpret_cast<const char*>(r_depthMaterialShader), sizeof(r_depthMaterialShader)));
ShaderAst::ModulePtr shaderModule = Graphics::Instance()->GetShaderModuleResolver()->Resolve("DepthMaterial");
auto shader = std::make_shared<UberShader>(ShaderStageType::Fragment | ShaderStageType::Vertex, std::move(shaderModule));
return { std::move(shader) };