Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reshade configuration #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions src/effect_reshade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ namespace vkBasalt
break;
}

std::string filePath = pConfig->getOption<std::string>("reshadeTexturePath") + "/" + source->value.string_data;
std::string filePath = pConfig->getOption<std::string>("reshadeTexturePath",
pConfig->getOption<std::string>("reshadePath") + "/Textures") +
"/" + source->value.string_data;
stbi_uc* pixels;
std::vector<stbi_uc> resizedPixels;
uint32_t size;
Expand Down Expand Up @@ -566,33 +568,34 @@ namespace vkBasalt
{
if (!opt.name.empty())
{
std::string val = pConfig->getOption<std::string>(opt.name);
std::string opt_name = effectName + "_" + opt.name;
std::string val = pConfig->getOption<std::string>(opt_name);
if (!val.empty())
{
std::variant<int32_t, uint32_t, float> convertedValue;
offset = static_cast<uint32_t>(specData.size());
switch (opt.type.base)
{
case reshadefx::type::t_bool:
convertedValue = (int32_t) pConfig->getOption<bool>(opt.name);
convertedValue = (int32_t) pConfig->getOption<bool>(opt_name);
specData.resize(offset + sizeof(VkBool32));
std::memcpy(specData.data() + offset, &convertedValue, sizeof(VkBool32));
specMapEntrys.push_back({specId, offset, sizeof(VkBool32)});
break;
case reshadefx::type::t_int:
convertedValue = pConfig->getOption<int32_t>(opt.name);
convertedValue = pConfig->getOption<int32_t>(opt_name);
specData.resize(offset + sizeof(int32_t));
std::memcpy(specData.data() + offset, &convertedValue, sizeof(int32_t));
specMapEntrys.push_back({specId, offset, sizeof(int32_t)});
break;
case reshadefx::type::t_uint:
convertedValue = (uint32_t) pConfig->getOption<int32_t>(opt.name);
convertedValue = (uint32_t) pConfig->getOption<int32_t>(opt_name);
specData.resize(offset + sizeof(uint32_t));
std::memcpy(specData.data() + offset, &convertedValue, sizeof(uint32_t));
specMapEntrys.push_back({specId, offset, sizeof(uint32_t)});
break;
case reshadefx::type::t_float:
convertedValue = pConfig->getOption<float>(opt.name);
convertedValue = pConfig->getOption<float>(opt_name);
specData.resize(offset + sizeof(float));
std::memcpy(specData.data() + offset, &convertedValue, sizeof(float));
specMapEntrys.push_back({specId, offset, sizeof(float)});
Expand Down Expand Up @@ -1132,10 +1135,21 @@ namespace vkBasalt
preprocessor.add_macro_definition("BUFFER_RCP_WIDTH", "(1.0 / BUFFER_WIDTH)");
preprocessor.add_macro_definition("BUFFER_RCP_HEIGHT", "(1.0 / BUFFER_HEIGHT)");
preprocessor.add_macro_definition("BUFFER_COLOR_DEPTH", (inputOutputFormatUNORM == VK_FORMAT_A2R10G10B10_UNORM_PACK32) ? "10" : "8");
preprocessor.add_include_path(pConfig->getOption<std::string>("reshadeIncludePath"));
if (!preprocessor.append_file(pConfig->getOption<std::string>(effectName)))

std::string includePath = pConfig->getOption<std::string>("reshadeShaderPath",
pConfig->getOption<std::string>("reshadeIncludePath",
pConfig->getOption<std::string>("reshadePath") + "/Shaders"));
std::string effectPath = pConfig->getOption<std::string>(effectName, effectName);

if (effectPath[0] != '/')
{
effectPath = includePath + "/" + effectPath;
}

preprocessor.add_include_path(includePath);
if (!preprocessor.append_file(effectPath) && !preprocessor.append_file(effectPath + ".fx"))
{
Logger::err("failed to load shader file: " + pConfig->getOption<std::string>(effectName));
Logger::err("failed to load shader file: " + effectPath);
Logger::err("Does the filepath exist and does it not include spaces?");
}

Expand Down