Graphics: Move LightData to a shader module and add hotreload in debug

This commit is contained in:
Jérôme Leclercq
2022-03-12 16:53:36 +01:00
parent b92a9f8a1c
commit 2f26a1d9c7
6 changed files with 90 additions and 24 deletions

View File

@@ -18,7 +18,26 @@ namespace Nz
std::vector<std::shared_ptr<UberShader>> DepthMaterial::BuildShaders()
{
ShaderAst::ModulePtr shaderModule = ShaderLang::Parse(std::string_view(reinterpret_cast<const char*>(r_shader), sizeof(r_shader)));
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_shader), sizeof(r_shader)));
auto shader = std::make_shared<UberShader>(ShaderStageType::Fragment | ShaderStageType::Vertex, std::move(shaderModule));
return { std::move(shader) };