mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
Postprocesing/FX: Add BUFFER_COLOR_BIT_DEPTH and random source
This commit is contained in:
parent
4ef465cea4
commit
8f1d724f4c
|
@ -329,6 +329,7 @@ bool PostProcessing::ReShadeFXShader::CreateModule(s32 buffer_width, s32 buffer_
|
||||||
pp.add_macro_definition("BUFFER_HEIGHT", std::to_string(buffer_height));
|
pp.add_macro_definition("BUFFER_HEIGHT", std::to_string(buffer_height));
|
||||||
pp.add_macro_definition("BUFFER_RCP_WIDTH", std::to_string(1.0f / static_cast<float>(buffer_width)));
|
pp.add_macro_definition("BUFFER_RCP_WIDTH", std::to_string(1.0f / static_cast<float>(buffer_width)));
|
||||||
pp.add_macro_definition("BUFFER_RCP_HEIGHT", std::to_string(1.0f / static_cast<float>(buffer_height)));
|
pp.add_macro_definition("BUFFER_RCP_HEIGHT", std::to_string(1.0f / static_cast<float>(buffer_height)));
|
||||||
|
pp.add_macro_definition("BUFFER_COLOR_BIT_DEPTH", "32");
|
||||||
|
|
||||||
switch (GetRenderAPI())
|
switch (GetRenderAPI())
|
||||||
{
|
{
|
||||||
|
@ -683,6 +684,19 @@ bool PostProcessing::ReShadeFXShader::GetSourceOption(const reshadefx::uniform_i
|
||||||
*si = SourceOptionType::MousePoint;
|
*si = SourceOptionType::MousePoint;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (source == "random")
|
||||||
|
{
|
||||||
|
if ((!ui.type.is_floating_point() && !ui.type.is_integral()) || ui.type.components() != 1)
|
||||||
|
{
|
||||||
|
Error::SetString(error, fmt::format("Unexpected type '{}' ({} components) for random source in uniform '{}'",
|
||||||
|
ui.type.description(), ui.type.components(), ui.name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This is missing min/max handling.
|
||||||
|
*si = (ui.type.base == reshadefx::type::t_float) ? SourceOptionType::RandomF : SourceOptionType::Random;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (source == "overlay_active" || source == "has_depth")
|
else if (source == "overlay_active" || source == "has_depth")
|
||||||
{
|
{
|
||||||
*si = SourceOptionType::Zero;
|
*si = SourceOptionType::Zero;
|
||||||
|
@ -1241,6 +1255,19 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SourceOptionType::Random:
|
||||||
|
{
|
||||||
|
const s32 rv = m_random() % 32767; // reshade uses rand(), which on some platforms has a 0x7fff maximum.
|
||||||
|
std::memcpy(dst, &rv, sizeof(rv));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SourceOptionType::RandomF:
|
||||||
|
{
|
||||||
|
const float rv = (m_random() - m_random.min()) / static_cast<float>(m_random.max() - m_random.min());
|
||||||
|
std::memcpy(dst, &rv, sizeof(rv));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SourceOptionType::BufferWidth:
|
case SourceOptionType::BufferWidth:
|
||||||
case SourceOptionType::BufferHeight:
|
case SourceOptionType::BufferHeight:
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
// reshadefx
|
// reshadefx
|
||||||
#include "effect_module.hpp"
|
#include "effect_module.hpp"
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
class Error;
|
class Error;
|
||||||
|
|
||||||
namespace PostProcessing {
|
namespace PostProcessing {
|
||||||
|
@ -46,6 +48,8 @@ private:
|
||||||
FrameCountF,
|
FrameCountF,
|
||||||
PingPong,
|
PingPong,
|
||||||
MousePoint,
|
MousePoint,
|
||||||
|
Random,
|
||||||
|
RandomF,
|
||||||
BufferWidth,
|
BufferWidth,
|
||||||
BufferHeight,
|
BufferHeight,
|
||||||
BufferWidthF,
|
BufferWidthF,
|
||||||
|
@ -117,6 +121,9 @@ private:
|
||||||
|
|
||||||
Common::Timer m_frame_timer;
|
Common::Timer m_frame_timer;
|
||||||
u32 m_frame_count = 0;
|
u32 m_frame_count = 0;
|
||||||
|
|
||||||
|
// Specifically using a fixed seed, so that it's consistent from run-to-run.
|
||||||
|
std::mt19937 m_random{0x1337};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace PostProcessing
|
} // namespace PostProcessing
|
Loading…
Reference in a new issue