-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(crisiscoreff7reunion): first commit
- Loading branch information
1 parent
ad39e0f
commit 7b9d74b
Showing
10 changed files
with
5,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,296 @@ | ||
/* | ||
* Copyright (C) 2023 Carlos Lopez | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define ImTextureID ImU64 | ||
|
||
#define DEBUG_LEVEL_0 | ||
|
||
#include <deps/imgui/imgui.h> | ||
#include <embed/shaders.h> | ||
#include <include/reshade.hpp> | ||
|
||
#include "../../mods/shader.hpp" | ||
#include "../../mods/swapchain.hpp" | ||
#include "../../utils/settings.hpp" | ||
#include "./shared.h" | ||
|
||
namespace { | ||
|
||
renodx::mods::shader::CustomShaders custom_shaders = { | ||
CustomSwapchainShader(0xAC791084), | ||
CustomShaderEntry(0xC1BCC6B5), | ||
CustomShaderEntry(0x61C2EA30), | ||
CustomShaderEntry(0xE6EB2840), | ||
CustomShaderEntry(0xBBA0606A), | ||
}; | ||
|
||
ShaderInjectData shader_injection; | ||
|
||
renodx::utils::settings::Settings settings = { | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapType", | ||
.binding = &shader_injection.toneMapType, | ||
.value_type = renodx::utils::settings::SettingValueType::INTEGER, | ||
.default_value = 3.f, | ||
.can_reset = false, | ||
.label = "Tone Mapper", | ||
.section = "Tone Mapping", | ||
.tooltip = "Sets the tone mapper type", | ||
.labels = {"Vanilla", "None", "ACES", "RenoDRT"}, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapPeakNits", | ||
.binding = &shader_injection.toneMapPeakNits, | ||
.default_value = 1000.f, | ||
.can_reset = false, | ||
.label = "Peak Brightness", | ||
.section = "Tone Mapping", | ||
.tooltip = "Sets the value of peak white in nits", | ||
.min = 48.f, | ||
.max = 4000.f, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapGameNits", | ||
.binding = &shader_injection.toneMapGameNits, | ||
.default_value = 203.f, | ||
.label = "Game Brightness", | ||
.section = "Tone Mapping", | ||
.tooltip = "Sets the value of 100% white in nits", | ||
.min = 48.f, | ||
.max = 500.f, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapUINits", | ||
.binding = &shader_injection.toneMapUINits, | ||
.default_value = 203.f, | ||
.label = "UI Brightness", | ||
.section = "Tone Mapping", | ||
.tooltip = "Sets the brightness of UI and HUD elements in nits", | ||
.min = 48.f, | ||
.max = 500.f, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapGammaCorrection", | ||
.binding = &shader_injection.toneMapGammaCorrection, | ||
.value_type = renodx::utils::settings::SettingValueType::INTEGER, | ||
.default_value = 2.f, | ||
.label = "Gamma Correction", | ||
.section = "Tone Mapping", | ||
.tooltip = "Emulates a display EOTF." | ||
"\nLCD for 2.2 Gamma." | ||
"\nCRT for 2.4/BT.1886 Gamma." | ||
"\nDefault: CRT with HDR", | ||
.labels = {"Off", "LCD", "CRT"}, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapHueCorrectionMethod", | ||
.binding = &shader_injection.toneMapHueCorrectionMethod, | ||
.value_type = renodx::utils::settings::SettingValueType::INTEGER, | ||
.default_value = 3.f, | ||
.label = "Hue Correction Method", | ||
.section = "Tone Mapping", | ||
.tooltip = "Applies hue shift emulation before tonemapping", | ||
.labels = {"None", "SDR Clip", "Filmic", "RenoDRT"}, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "toneMapHueCorrection", | ||
.binding = &shader_injection.toneMapHueCorrection, | ||
.default_value = 100.f, | ||
.label = "Hue Correction", | ||
.section = "Tone Mapping", | ||
.tooltip = "Emulates Vanilla hue shifts.", | ||
.min = 0.f, | ||
.max = 100.f, | ||
.is_enabled = []() { return shader_injection.toneMapHueCorrectionMethod != 0; }, | ||
.parse = [](float value) { return value * 0.01f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeExposure", | ||
.binding = &shader_injection.colorGradeExposure, | ||
.default_value = 1.f, | ||
.label = "Exposure", | ||
.section = "Color Grading", | ||
.max = 10.f, | ||
.format = "%.2f", | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeHighlights", | ||
.binding = &shader_injection.colorGradeHighlights, | ||
.default_value = 50.f, | ||
.label = "Highlights", | ||
.section = "Color Grading", | ||
.max = 100.f, | ||
.parse = [](float value) { return value * 0.02f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeShadows", | ||
.binding = &shader_injection.colorGradeShadows, | ||
.default_value = 50.f, | ||
.label = "Shadows", | ||
.section = "Color Grading", | ||
.max = 100.f, | ||
.parse = [](float value) { return value * 0.02f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeContrast", | ||
.binding = &shader_injection.colorGradeContrast, | ||
.default_value = 50.f, | ||
.label = "Contrast", | ||
.section = "Color Grading", | ||
.max = 100.f, | ||
.parse = [](float value) { return value * 0.02f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeSaturation", | ||
.binding = &shader_injection.colorGradeSaturation, | ||
.default_value = 50.f, | ||
.label = "Saturation", | ||
.section = "Color Grading", | ||
.max = 100.f, | ||
.parse = [](float value) { return value * 0.02f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeBlowout", | ||
.binding = &shader_injection.colorGradeBlowout, | ||
.default_value = 50.f, | ||
.label = "Blowout", | ||
.section = "Color Grading", | ||
.tooltip = "Controls highlight desaturation due to overexposure.", | ||
.max = 100.f, | ||
.parse = [](float value) { return value * 0.01f; }, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.key = "colorGradeColorSpace", | ||
.binding = &shader_injection.colorGradeColorSpace, | ||
.value_type = renodx::utils::settings::SettingValueType::INTEGER, | ||
.default_value = 0.f, | ||
.label = "Color Space", | ||
.section = "Color Grading", | ||
.tooltip = "Selects output color space" | ||
"\nUS Modern for BT.709 D65." | ||
"\nJPN Modern for BT.709 D93." | ||
"\nUS CRT for BT.601 (NTSC-U)." | ||
"\nJPN CRT for BT.601 ARIB-TR-B09 D93 (NTSC-J)." | ||
"\nDefault: US CRT", | ||
.labels = { | ||
"US Modern", | ||
"JPN Modern", | ||
"US CRT", | ||
"JPN CRT", | ||
}, | ||
|
||
}, | ||
new renodx::utils::settings::Setting{ | ||
.value_type = renodx::utils::settings::SettingValueType::BUTTON, | ||
.label = "Discord", | ||
.section = "Links", | ||
.group = "button-line-1", | ||
.tint = 0x5865F2, | ||
.on_change = []() { | ||
ShellExecute(0, "open", "https://discord.gg/5WZXDpmbpP", 0, 0, SW_SHOW); | ||
}, | ||
}, | ||
new renodx::utils::settings::Setting{ | ||
.value_type = renodx::utils::settings::SettingValueType::BUTTON, | ||
.label = "Github", | ||
.section = "Links", | ||
.group = "button-line-1", | ||
.on_change = []() { | ||
ShellExecute(0, "open", "https://github.com/clshortfuse/renodx", 0, 0, SW_SHOW); | ||
}, | ||
}, | ||
}; | ||
|
||
void OnPresetOff() { | ||
renodx::utils::settings::UpdateSetting("toneMapType", 0.f); | ||
renodx::utils::settings::UpdateSetting("toneMapPeakNits", 203.f); | ||
renodx::utils::settings::UpdateSetting("toneMapGameNits", 203.f); | ||
renodx::utils::settings::UpdateSetting("toneMapUINits", 203.f); | ||
renodx::utils::settings::UpdateSetting("toneMapGammaCorrection", 0.f); | ||
renodx::utils::settings::UpdateSetting("toneMapHueCorrection", 0.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeExposure", 1.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeHighlights", 50.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeShadows", 50.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeContrast", 50.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeSaturation", 50.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeBlowout", 0.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeLUTStrength", 100.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeLUTScaling", 0.f); | ||
renodx::utils::settings::UpdateSetting("colorGradeColorSpace", 0.f); | ||
} | ||
|
||
bool fired_on_init_swapchain = false; | ||
|
||
void OnInitSwapchain(reshade::api::swapchain* swapchain) { | ||
if (fired_on_init_swapchain) return; | ||
fired_on_init_swapchain = true; | ||
auto peak = renodx::utils::swapchain::GetPeakNits(swapchain); | ||
if (peak.has_value()) { | ||
settings[1]->default_value = peak.value(); | ||
settings[1]->can_reset = true; | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
extern "C" __declspec(dllexport) constexpr const char* NAME = "RenoDX"; | ||
extern "C" __declspec(dllexport) constexpr const char* DESCRIPTION = "RenoDX for Crisis Core - Final Fantasy VII Reunion"; | ||
|
||
BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) { | ||
switch (fdw_reason) { | ||
case DLL_PROCESS_ATTACH: | ||
if (!reshade::register_addon(h_module)) return FALSE; | ||
|
||
renodx::mods::swapchain::use_resource_cloning = true; | ||
renodx::mods::swapchain::swap_chain_proxy_vertex_shader = { | ||
_swap_chain_proxy_vertex_shader, | ||
_swap_chain_proxy_vertex_shader + sizeof(_swap_chain_proxy_vertex_shader), | ||
}; | ||
renodx::mods::swapchain::swap_chain_proxy_pixel_shader = { | ||
_swap_chain_proxy_pixel_shader, | ||
_swap_chain_proxy_pixel_shader + sizeof(_swap_chain_proxy_pixel_shader), | ||
}; | ||
|
||
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ | ||
.old_format = reshade::api::format::r8g8b8a8_typeless, | ||
.new_format = reshade::api::format::r16g16b16a16_typeless, | ||
}); | ||
|
||
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ | ||
.old_format = reshade::api::format::r8g8b8a8_unorm, | ||
.new_format = reshade::api::format::r16g16b16a16_float, | ||
}); | ||
|
||
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ | ||
.old_format = reshade::api::format::b8g8r8a8_unorm, | ||
.new_format = reshade::api::format::r16g16b16a16_float, | ||
}); | ||
|
||
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ | ||
.old_format = reshade::api::format::b8g8r8a8_typeless, | ||
.new_format = reshade::api::format::r16g16b16a16_typeless, | ||
}); | ||
|
||
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ | ||
.old_format = reshade::api::format::r10g10b10a2_unorm, | ||
.new_format = reshade::api::format::r16g16b16a16_float, | ||
.dimensions = {.width = 32, .height = 32, .depth = 32}, | ||
}); | ||
|
||
reshade::register_event<reshade::addon_event::init_swapchain>(OnInitSwapchain); | ||
|
||
break; | ||
case DLL_PROCESS_DETACH: | ||
reshade::unregister_event<reshade::addon_event::init_swapchain>(OnInitSwapchain); | ||
reshade::unregister_addon(h_module); | ||
break; | ||
} | ||
|
||
renodx::utils::settings::Use(fdw_reason, &settings, &OnPresetOff); | ||
renodx::mods::shader::Use(fdw_reason, custom_shaders, &shader_injection); | ||
renodx::mods::swapchain::Use(fdw_reason, &shader_injection); | ||
|
||
return TRUE; | ||
} |
Oops, something went wrong.