17 SCL_CORE_INFO(
"Shader creation from file \"{}\" started.", ShaderProgamFilePath.string());
19 std::string shader_text =
LoadFile(ShaderProgamFilePath);
20 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgamFilePath.string(), ShaderProgamFilePath.parent_path().string(), shader_text);
22 std::vector<shader_props> Out;
23 assets_manager::shader_preprocessor::SeparateShaders(ShaderProgamFilePath.string(), shader_text, Out);
25 auto shader = shader_program::Create(Out, ShaderProgamFilePath.string());
26 shader->SingleSourceFileName = ShaderProgamFilePath.string();
31 const std::filesystem::path &PixelShaderFilePath)
33 std::stringstream file_buffer;
34 std::string shader_text;
35 std::vector<shader_props> shaders;
37 SCL_CORE_INFO(
"Shader creation from files \"{}\", \"{}\" started.", VertexShaderFilePath.string(), PixelShaderFilePath.string());
40 shader_text =
LoadFile(VertexShaderFilePath);
41 assets_manager::shader_preprocessor::ProcessIncludes(VertexShaderFilePath.string(), VertexShaderFilePath.parent_path().string(), shader_text);
42 shaders.push_back({ shader_type::VERTEX, shader_text });
45 shader_text =
LoadFile(PixelShaderFilePath);
46 assets_manager::shader_preprocessor::ProcessIncludes(PixelShaderFilePath.string(), PixelShaderFilePath.parent_path().string(), shader_text);
47 shaders.push_back({ shader_type::PIXEL, shader_text });
49 auto shader = shader_program::Create(shaders, VertexShaderFilePath.string());
50 shader->VertexShadersourceFileName = VertexShaderFilePath.string();
51 shader->PixelShadersourceFileName = PixelShaderFilePath.string();
56 const std::filesystem::path &GeomShaderFilePath,
57 const std::filesystem::path &PixelShaderFilePath)
59 std::stringstream file_buffer;
60 std::string shader_text;
61 std::vector<shader_props> shaders;
63 SCL_CORE_INFO(
"Shader creation from files \"{}\", \"{}\", \"{}\" started.", VertexShaderFilePath.string(), GeomShaderFilePath.string(), PixelShaderFilePath.string());
66 shader_text =
LoadFile(VertexShaderFilePath);
67 assets_manager::shader_preprocessor::ProcessIncludes(VertexShaderFilePath.string(), VertexShaderFilePath.parent_path().string(), shader_text);
68 shaders.push_back({ shader_type::VERTEX, shader_text });
71 shader_text =
LoadFile(GeomShaderFilePath);
72 assets_manager::shader_preprocessor::ProcessIncludes(GeomShaderFilePath.string(), GeomShaderFilePath.parent_path().string(), shader_text);
73 shaders.push_back({ shader_type::GEOMETRY, shader_text });
76 shader_text =
LoadFile(PixelShaderFilePath);
77 assets_manager::shader_preprocessor::ProcessIncludes(PixelShaderFilePath.string(), PixelShaderFilePath.parent_path().string(), shader_text);
78 shaders.push_back({ shader_type::PIXEL, shader_text });
80 auto shader = shader_program::Create(shaders, VertexShaderFilePath.string());
81 shader->VertexShadersourceFileName = VertexShaderFilePath.string();
82 shader->GeometryShadersourceFileName = GeomShaderFilePath.string();
83 shader->PixelShadersourceFileName = PixelShaderFilePath.string();
89 std::stringstream file_buffer;
90 std::string shader_text;
91 std::vector<shader_props> shaders;
93 if (ShaderProgram->SingleSourceFileName !=
"") {
94 SCL_CORE_INFO(
"Shader updation from file \"{}\" started.", ShaderProgram->SingleSourceFileName);
95 shader_text =
LoadFile(ShaderProgram->SingleSourceFileName);
96 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->SingleSourceFileName,
97 std::filesystem::path(ShaderProgram->SingleSourceFileName).parent_path().string(),
100 assets_manager::shader_preprocessor::SeparateShaders(ShaderProgram->SingleSourceFileName, shader_text, shaders);
101 ShaderProgram->Update(shaders);
102 }
else if (ShaderProgram->VertexShadersourceFileName !=
"" && ShaderProgram->PixelShadersourceFileName !=
"" &&
103 ShaderProgram->GeometryShadersourceFileName ==
"") {
104 SCL_CORE_INFO(
"Shader updation from files \"{}\", \"{}\" started.", ShaderProgram->VertexShadersourceFileName, ShaderProgram->PixelShadersourceFileName);
107 shader_text =
LoadFile(ShaderProgram->VertexShadersourceFileName);
108 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->VertexShadersourceFileName,
109 std::filesystem::path(ShaderProgram->VertexShadersourceFileName).parent_path().string(),
111 shaders.push_back({ shader_type::VERTEX, shader_text });
114 shader_text =
LoadFile(ShaderProgram->PixelShadersourceFileName);
115 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->PixelShadersourceFileName,
116 std::filesystem::path(ShaderProgram->PixelShadersourceFileName).parent_path().string(),
118 shaders.push_back({ shader_type::PIXEL, shader_text });
120 ShaderProgram->Update(shaders);
122 SCL_CORE_INFO(
"Shader creation from files \"{}\", \"{}\", \"{}\" started.", ShaderProgram->VertexShadersourceFileName, ShaderProgram->GeometryShadersourceFileName, ShaderProgram->PixelShadersourceFileName);
125 shader_text =
LoadFile(ShaderProgram->VertexShadersourceFileName);
126 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->VertexShadersourceFileName,
127 std::filesystem::path(ShaderProgram->VertexShadersourceFileName).parent_path().string(),
129 shaders.push_back({ shader_type::VERTEX, shader_text });
132 shader_text =
LoadFile(ShaderProgram->GeometryShadersourceFileName);
133 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->GeometryShadersourceFileName,
134 std::filesystem::path(ShaderProgram->GeometryShadersourceFileName).parent_path().string(),
136 shaders.push_back({ shader_type::GEOMETRY, shader_text });
139 shader_text =
LoadFile(ShaderProgram->PixelShadersourceFileName);
140 assets_manager::shader_preprocessor::ProcessIncludes(ShaderProgram->PixelShadersourceFileName,
141 std::filesystem::path(ShaderProgram->PixelShadersourceFileName).parent_path().string(),
143 shaders.push_back({ shader_type::PIXEL, shader_text });
145 ShaderProgram->Update(shaders);
#define SCL_CORE_INFO(...)
void UpdateShader(shared< shader_program > ShaderProgram)
std::string LoadFile(const std::filesystem::path &FilePath)
shared< shader_program > LoadShader(const std::filesystem::path &ShaderProgamFilePath)
std::shared_ptr< T > shared
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
Shader program interface definition module.
Assets manager shaders preprocessor class definition module.