From 54097fc14eda861931215862002d5ea567c3cd69 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 16 Jun 2024 00:00:01 +1000 Subject: [PATCH] Postprocessing/FX: Expose 'viewportoffset' uniform --- src/util/postprocessing_shader_fx.cpp | 19 +++++++++++++++++++ src/util/postprocessing_shader_fx.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/util/postprocessing_shader_fx.cpp b/src/util/postprocessing_shader_fx.cpp index 1b1b6b433..961497764 100644 --- a/src/util/postprocessing_shader_fx.cpp +++ b/src/util/postprocessing_shader_fx.cpp @@ -936,6 +936,18 @@ bool PostProcessing::ReShadeFXShader::GetSourceOption(const reshadefx::uniform_i *si = SourceOptionType::ViewportHeight; return true; } + else if (source == "viewportoffset") + { + if (!ui.type.is_floating_point() || ui.type.components() != 2) + { + Error::SetString(error, fmt::format("Unexpected type '{}' for {} source in uniform '{}'", ui.type.description(), + source, ui.name)); + return false; + } + + *si = SourceOptionType::ViewportOffset; + return true; + } else if (source == "viewportsize") { if (!ui.type.is_floating_point() || ui.type.components() != 2) @@ -1666,6 +1678,13 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUTexture* final } break; + case SourceOptionType::ViewportOffset: + { + const float value[2] = {static_cast(final_left), static_cast(final_top)}; + std::memcpy(dst, &value, sizeof(value)); + } + break; + case SourceOptionType::ViewportSize: { const float value[2] = {static_cast(final_width), static_cast(final_height)}; diff --git a/src/util/postprocessing_shader_fx.h b/src/util/postprocessing_shader_fx.h index 2be747e1c..d28fdd83d 100644 --- a/src/util/postprocessing_shader_fx.h +++ b/src/util/postprocessing_shader_fx.h @@ -70,6 +70,7 @@ private: ViewportY, ViewportWidth, ViewportHeight, + ViewportOffset, ViewportSize, InternalPixelSize, InternalNormPixelSize,