Skip to content

Commit

Permalink
[MULTIPLE] Add JPN ColorSpace
Browse files Browse the repository at this point in the history
- YS10 + Daybreak 1, add JPN colorspace

- Daybreak 1 -- increase stability
  • Loading branch information
marat569 committed Jan 12, 2025
1 parent 89db41d commit 500c418
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 52 deletions.
65 changes: 32 additions & 33 deletions src/games/trailsdaybreak1/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define DEBUG_LEVEL_0

// #define DEBUG_LEVEL_1 //added
// #define DEBUG_LEVEL_1 // added

#include <embed/0xAD51B4B0.h> //ui -- overworld hud

Expand Down Expand Up @@ -134,9 +134,25 @@ renodx::utils::settings::Settings settings = {
.parse = [](float value) { return value * 0.02f; },
},

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.",
.labels = {
"US Modern",
"JPN Modern",
},
},

new renodx::utils::settings::Setting{
.value_type = renodx::utils::settings::SettingValueType::TEXT,
.label = " - Please enable Native HDR in game! \r\n - Use the game's UI slider to control the UI! \r\n - This mod is still in beta, please report issues on Discord!",
.label = " - Please enable Native HDR in game! \r\n - Use the game's UI slider to control the UI! \r\n - FXAA/Anti-Aliasing High does not work, use anything else \r\n - MSAA/SGSSAA has very high VRAM usage \r\n - This mod is still in beta, please report issues on Discord!",
.section = "Instructions",
},

Expand Down Expand Up @@ -182,6 +198,8 @@ void OnPresetOff() {
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("ColorGradeColorSpace", 0.f);

// Start PostProcess effects on/off
}

Expand All @@ -190,7 +208,7 @@ void OnPresetOff() {
// NOLINTBEGIN(readability-identifier-naming)

extern "C" __declspec(dllexport) const char* NAME = "RenoDX";
extern "C" __declspec(dllexport) const char* DESCRIPTION = "RenoDX for The Legend of Heroes Trails through Daybreak";
extern "C" __declspec(dllexport) const char* DESCRIPTION = "RenoDX for The Legend of Heroes Trails through Daybreak 1";

// NOLINTEND(readability-identifier-naming)

Expand All @@ -207,45 +225,26 @@ BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) {
renodx::mods::swapchain::force_borderless = false; // needed for stability
renodx::mods::swapchain::prevent_full_screen = false; // needed for stability

// RGBA8_UNORM
// We don't really need to upgrade
// Upgrades cause artifacts; might be a to-do in the future
// Upgrades would fix FXAA

// // RGBA8_UNORM
// renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({
// .old_format = reshade::api::format::r8g8b8a8_unorm,
// .new_format = reshade::api::format::r16g16b16a16_float,
// });

// RGBA8_UNORM 512x512
// // r8g8b8a8_unorm -- new usage_include -- looks good, but game hangs
// renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({
// .old_format = reshade::api::format::r8g8b8a8_unorm,
// .new_format = reshade::api::format::r16g16b16a16_float,
// .dimensions = {512, 512},
// });
// .ignore_size = true,
// .use_resource_view_cloning = true,
// .use_resource_view_hot_swap = true,
// .usage_include = reshade::api::resource_usage::render_target | reshade::api::resource_usage::unordered_access,

// r8g8b8a8_unorm -- view upgrades
renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({
.old_format = reshade::api::format::r8g8b8a8_unorm,
.new_format = reshade::api::format::r16g16b16a16_float,
.ignore_size = true,
.use_resource_view_cloning = true,
.use_resource_view_hot_swap = true,
.usage_include = reshade::api::resource_usage::render_target | reshade::api::resource_usage::unordered_access,
});

// // r8g8b8a8_unorm -- view upgrades
// renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({.old_format = reshade::api::format::r8g8b8a8_unorm,
// .new_format = reshade::api::format::r16g16b16a16_float,
// .ignore_size = true,
// .usage_include = reshade::api::resource_usage::render_target | reshade::api::resource_usage::unordered_access,
// .view_upgrades = {
// {{reshade::api::resource_usage::shader_resource,
// reshade::api::format::r8g8b8a8_unorm},
// reshade::api::format::r16g16b16a16_float},
// {{reshade::api::resource_usage::unordered_access,
// reshade::api::format::r8g8b8a8_unorm},
// reshade::api::format::r16g16b16a16_float},
// {{reshade::api::resource_usage::render_target,
// reshade::api::format::r8g8b8a8_unorm},
// reshade::api::format::r16g16b16a16_float},
// }});
// });

// R11G11B10
// renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({.old_format = reshade::api::format::r11g11b10_float,
Expand Down
13 changes: 9 additions & 4 deletions src/games/trailsdaybreak1/final_0xAD51B4B0.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Texture2D<float4> tex : register(t0);
#define cmp -

void main(
float4 v0: SV_Position0,
float2 v1: TEXCOORD0,
out float4 o0: SV_Target0) {
float4 v0 : SV_Position0,
float2 v1 : TEXCOORD0,
out float4 o0 : SV_Target0) {
float4 r0;
uint4 bitmask, uiDest;
float4 fDest;
Expand All @@ -29,7 +29,12 @@ void main(

r0.rgb = injectedData.gamma ? renodx::math::PowSafe(r0.rgb, 2.3f) : renodx::math::PowSafe(r0.rgb, 2.2f); // The game does 2.3 gamma default

r0.rgb = applyUserTonemap(r0.rgb); // Send our color to tonemapper.hlsl to get processed!
r0.rgb = applyUserTonemap(r0.rgb); // Send our color to tonemapper.hlsl to get processed!

if (injectedData.ColorGradeColorSpace == 1.f) {
r0.rgb = renodx::color::bt709::from::BT709D93(r0.rgb);
}

r0.rgb *= injectedData.toneMapGameNits / 80.f; // paper white

o0.rgb = r0.rgb;
Expand Down
1 change: 1 addition & 0 deletions src/games/trailsdaybreak1/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct ShaderInjectData {
float colorGradeSaturation;
float gamma;
float toneMapHueCorrection;
float ColorGradeColorSpace;
};

#ifndef __cplusplus
Expand Down
28 changes: 14 additions & 14 deletions src/games/trailsdaybreak1/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ float3 applyUserTonemap(float3 untonemapped) {
}

if (injectedData.toneMapType != 0) { // UserColorGrading, pre-tonemap
outputColor.rgb = renodx::color::grade::UserColorGrading(
outputColor.rgb,
outputColor = renodx::color::grade::UserColorGrading(
outputColor,
injectedData.colorGradeExposure, // exposure
injectedData.colorGradeHighlights, // highlights
injectedData.colorGradeShadows, // shadows
Expand All @@ -38,27 +38,27 @@ float3 applyUserTonemap(float3 untonemapped) {

} else if (injectedData.toneMapType == 3.f) { // baby reinhard
float ReinhardPeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
outputColor.rgb = renodx::tonemap::ReinhardScalable(outputColor.rgb, ReinhardPeak);
outputColor = renodx::tonemap::ReinhardScalable(outputColor, ReinhardPeak);

} else if (injectedData.toneMapType == 4.f) { // Frostbite
float frostbitePeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
outputColor = renodx::tonemap::frostbite::BT709(outputColor, frostbitePeak);
}

if (injectedData.toneMapType != 0) { // UserColorGrading, post-tonemap
outputColor.rgb = renodx::color::grade::UserColorGrading(
outputColor.rgb,
1.f, // exposure
1.f, // highlights
1.f, // shadows
1.f, // contrast
injectedData.colorGradeSaturation, // saturation
0.f, // dechroma, we don't need it
injectedData.toneMapHueCorrection, // Hue Correction
renodx::tonemap::Reinhard(untonemapped));
outputColor = renodx::color::grade::UserColorGrading(
outputColor,
1.f, // exposure
1.f, // highlights
1.f, // shadows
1.f, // contrast
injectedData.colorGradeSaturation, // saturation
0.f, // dechroma, we don't need it
injectedData.toneMapHueCorrection, // Hue Correction Strength
renodx::tonemap::Reinhard(untonemapped)); // Hue Correction Type
}

outputColor = renodx::color::bt709::clamp::BT2020(outputColor); // Clamp to BT2020 to avoid negative colorsF
outputColor = renodx::color::bt709::clamp::BT2020(outputColor); // Clamp to BT2020 to avoid negative colors

return outputColor;
}
17 changes: 16 additions & 1 deletion src/games/ys10/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "../../utils/settings.hpp"
#include "./shared.h"


namespace {

renodx::mods::shader::CustomShaders custom_shaders = {
Expand Down Expand Up @@ -124,6 +123,22 @@ renodx::utils::settings::Settings settings = {
.parse = [](float value) { return value * 0.02f; },
},

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.",
.labels = {
"US Modern",
"JPN Modern",
},
},

new renodx::utils::settings::Setting{
.value_type = renodx::utils::settings::SettingValueType::TEXT,
.label = " - Please enable Native HDR in game! \r\n - Use the game's UI slider to control the UI!",
Expand Down
4 changes: 4 additions & 0 deletions src/games/ys10/final_0xAD51B4B0.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void main(
r0.rgb = applyUserTonemap(r0.rgb); // Send our color to tonemapper.hlsl to get processed!
r0.rgb *= injectedData.toneMapGameNits / 80.f; // paper white

if (injectedData.ColorGradeColorSpace == 1.f) {
r0.rgb = renodx::color::bt709::from::BT709D93(r0.rgb);
}

o0.rgb = r0.rgb;
o0.w = 1;
return;
Expand Down
1 change: 1 addition & 0 deletions src/games/ys10/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct ShaderInjectData {
float colorGradeContrast;
float colorGradeSaturation;
float gamma;
float ColorGradeColorSpace;
};

#ifndef __cplusplus
Expand Down

0 comments on commit 500c418

Please sign in to comment.