Postprocessing/FX: Expose 'viewportoffset' uniform

This commit is contained in:
Stenzek 2024-06-16 00:00:01 +10:00
parent eb80a82ce5
commit 54097fc14e
No known key found for this signature in database
2 changed files with 20 additions and 0 deletions

View File

@ -936,6 +936,18 @@ bool PostProcessing::ReShadeFXShader::GetSourceOption(const reshadefx::uniform_i
*si = SourceOptionType::ViewportHeight; *si = SourceOptionType::ViewportHeight;
return true; 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") else if (source == "viewportsize")
{ {
if (!ui.type.is_floating_point() || ui.type.components() != 2) if (!ui.type.is_floating_point() || ui.type.components() != 2)
@ -1666,6 +1678,13 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUTexture* final
} }
break; break;
case SourceOptionType::ViewportOffset:
{
const float value[2] = {static_cast<float>(final_left), static_cast<float>(final_top)};
std::memcpy(dst, &value, sizeof(value));
}
break;
case SourceOptionType::ViewportSize: case SourceOptionType::ViewportSize:
{ {
const float value[2] = {static_cast<float>(final_width), static_cast<float>(final_height)}; const float value[2] = {static_cast<float>(final_width), static_cast<float>(final_height)};

View File

@ -70,6 +70,7 @@ private:
ViewportY, ViewportY,
ViewportWidth, ViewportWidth,
ViewportHeight, ViewportHeight,
ViewportOffset,
ViewportSize, ViewportSize,
InternalPixelSize, InternalPixelSize,
InternalNormPixelSize, InternalNormPixelSize,