From e5da172a85368551954332836e52d2c98b37edec Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 25 Jan 2023 21:55:31 -0800 Subject: Finish basic PBR shading TaSTT shader now uses physically based rendering (PBR). Users can pick smoothness, metallic, and emissive. This implementation borrows heavily from catlikecoding.com's excellent tutorials, which are released under MIT No Attribution (MIT-0). https://catlikecoding.com/unity/tutorials/license/ To retain what little clarity remains in the shader, I have chosen not to attribute the code in the source itself. --- GUI/GUI/GUI/PythonWrapper.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index cad9395..60437d2 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -179,7 +179,9 @@ bool PythonWrapper::GenerateAnimator( std::string generate_menu_path = "Resources/Scripts/generate_menu.py"; std::string generate_shader_path = "Resources/Scripts/generate_shader.py"; std::string shader_template_path = "Resources/Shaders/TaSTT_template.shader"; + std::string shader_lighting_template_path = "Resources/Shaders/TaSTT_lighting_template.cginc"; std::string shader_path = "Resources/Shaders/TaSTT.shader"; + std::string shader_lighting_path = "Resources/Shaders/TaSTT_lighting.cginc"; // Generated directory locations std::filesystem::path tastt_generated_dir_path = @@ -211,7 +213,7 @@ bool PythonWrapper::GenerateAnimator( tastt_generated_dir_path / unity_animator_generated_name; { - Log(out, "Generating shader for {}x{} board...", config.rows, config.cols); + Log(out, "Generating shader for {}x{} board (pass 0)...", config.rows, config.cols); std::string py_stdout, py_stderr; if (InvokeWithArgs({ generate_shader_path, @@ -237,6 +239,33 @@ bool PythonWrapper::GenerateAnimator( return false; } } + { + Log(out, "Generating shader for {}x{} board (pass 1)...", config.rows, config.cols); + + std::string py_stdout, py_stderr; + if (InvokeWithArgs({ generate_shader_path, + "--bytes_per_char", std::to_string(config.bytes_per_char), + "--rows", std::to_string(config.rows), + "--cols", std::to_string(config.cols), + "--shader_template", shader_lighting_template_path, + "--shader_path", shader_lighting_path }, + &py_stdout, &py_stderr)) { + Log(out, "success!\n"); + Log(out, py_stdout.c_str()); + if (!py_stdout.empty()) { + Log(out, "\n"); + } + Log(out, py_stderr.c_str()); + if (!py_stderr.empty()) { + Log(out, "\n"); + } + } + else { + wxLogError("Failed to generate shader: %s", py_stderr.c_str()); + Log(out, "failed!\n"); + return false; + } + } { Log(out, "Creating {}\n", tastt_generated_dir_path.string()); std::filesystem::create_directories(tastt_generated_dir_path); -- cgit v1.2.3