summaryrefslogtreecommitdiff
path: root/mm/2s2h/Enhancements/Graphics/MotionBlur.cpp
blob: 0e3b7b492bb7e82e01dbacef6d3027d9e11783ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <libultraship/bridge/consolevariablebridge.h>
#include "2s2h/BenGui/UIWidgets.hpp"

extern "C" {
#include "variables.h"
}

const char* motionBlurOptions[] = { "Dynamic (default)", "Always Off", "Always On" };

void MotionBlur_RenderMenuOptions() {
    ImGui::SeparatorText("Motion Blur");
    UIWidgets::CVarCombobox("Motion Blur Mode", "gEnhancements.Graphics.MotionBlur.Mode", motionBlurOptions,
                            UIWidgets::ComboboxOptions().LabelPosition(UIWidgets::LabelPosition::None));

    UIWidgets::CVarCheckbox(
        "Interpolate", "gEnhancements.Graphics.MotionBlur.Interpolate",
        UIWidgets::CheckboxOptions().Tooltip(
            "Change motion blur capture to also happen on interpolated frames instead of only on game frames.\n"
            "This notably reduces the overall motion blur strength but smooths out the trails."));

    if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 0) {
        UIWidgets::Checkbox("On/Off", (bool*)&R_MOTION_BLUR_ENABLED);
        if (R_MOTION_BLUR_ENABLED) {
            int32_t motionBlurStrength = R_MOTION_BLUR_ALPHA;
            if (UIWidgets::SliderInt("Strength", &motionBlurStrength, { .min = 0, .max = 255 })) {
                R_MOTION_BLUR_ALPHA = motionBlurStrength;
            }
        }
    }
    if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 2) {
        UIWidgets::CVarSliderInt("Strength", "gEnhancements.Graphics.MotionBlur.Strength",
                                 UIWidgets::IntSliderOptions().Min(0).Max(255).DefaultValue(180));
    }
}

extern "C" void MotionBlur_Override(u8* status, s32* alpha) {
    if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 1) {
        *status = 0;
        *alpha = 0;
    } else if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 2) {
        if (*status == 0)
            *status = 2;
        *alpha = CVarGetInteger("gEnhancements.Graphics.MotionBlur.Strength", 180);
    }
}