Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public class HDRModConfig implements ConfigData {

@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("general")
public float uiBrightness = -1.0f;
public float uiBrightness = System.getProperty("os.name").startsWith("Windows") ? 203.f : -1.0f; //TODO: GLFW auto get fix on Windows
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("general")
public float customGamePaperWhiteBrightness = -1.0f;
public float customGamePaperWhiteBrightness = System.getProperty("os.name").startsWith("Windows") ? 203.f : -1.0f; //TODO: GLFW auto get fix on Windows
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("general")
public float customGamePeakBrightness = 1000.0f;
public float customGamePeakBrightness = 1000.0f; //TODO: GLFW auto get
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("general")
public float customGameMinimumBrightness = 0.0f;
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("general")
public float customEotfEmulate = System.getProperty("os.name").startsWith("Windows") ? -1.0f : 0.0f;
public float customEotfEmulate = System.getProperty("os.name").startsWith("Windows") ? 203.f : 0.0f; //TODO: GLFW auto get fix on Windows

@ConfigEntry.Gui.Tooltip
@ConfigEntry.Category("advanced")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,40 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xyz.rrtt217.HDRMod.HDRMod;
import xyz.rrtt217.HDRMod.util.GLFWColorManagement;
import xyz.rrtt217.HDRMod.config.HDRModConfig;


@Mixin(IrisExclusiveUniforms.class)
public class MixinIrisExclusiveUniforms {
private static float GlwfCached_Min = 0;
private static float GlwfCached_Peak = 0;
private static float GlwfCached_Paper = 0;

@Inject(method = "addIrisExclusiveUniforms", at = @At("RETURN"))
private static void addHDRModExclusiveUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier, CallbackInfo ci){
private static void addHDRModExclusiveUniforms(UniformHolder uniforms, FrameUpdateNotifier updateNotifier, CallbackInfo ci) {
//GLFW
{
//TODO: This only runs on shaderpack compile. This will miss multimonitor switching. (but this means other GLWF must be fixed first)
//get
var handle = Minecraft.getInstance().getWindow().handle();
GlwfCached_Min = GLFWColorManagement.glfwGetWindowMinLuminance(handle);
GlwfCached_Peak = GLFWColorManagement.glfwGetWindowMaxLuminance(handle);
GlwfCached_Paper = GLFWColorManagement.glfwGetWindowSdrWhiteLevel(handle);

//log
HDRMod.LOGGER.info("GLFW Reported Min: " + GlwfCached_Min);
HDRMod.LOGGER.info("GLFW Reported Peak: " + GlwfCached_Peak);
HDRMod.LOGGER.info("GLFW Reported Paper: " + GlwfCached_Paper);
}

//add uniforms
HDRModConfig config = AutoConfig.getConfigHolder(HDRModConfig.class).getConfig();
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME,"HdrGameMinimumBrightness",() -> config.customGameMinimumBrightness < 0 ? GLFWColorManagement.glfwGetWindowMinLuminance(Minecraft.getInstance().getWindow().handle()) : config.customGameMinimumBrightness );
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME,"HdrGamePeakBrightness",() -> config.customGamePeakBrightness < 0 ? GLFWColorManagement.glfwGetWindowMaxLuminance(Minecraft.getInstance().getWindow().handle()) : config.customGamePeakBrightness );
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME,"HdrGamePaperWhiteBrightness", () -> config.customGamePaperWhiteBrightness < 0 ? GLFWColorManagement.glfwGetWindowSdrWhiteLevel(Minecraft.getInstance().getWindow().handle()) : config.customGamePaperWhiteBrightness);
uniforms.uniform1f(UniformUpdateFrequency.PER_FRAME,"HdrUIBrightness", () -> config.uiBrightness < 0 ? GLFWColorManagement.glfwGetWindowSdrWhiteLevel(Minecraft.getInstance().getWindow().handle()) : config.uiBrightness);
//TODO: even slower than UniformUpdateFrequency.PER_TICK
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK,"HdrGameMinimumBrightness",() -> config.customGameMinimumBrightness < 0 ? GlwfCached_Min : config.customGameMinimumBrightness );
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK,"HdrGamePeakBrightness",() -> config.customGamePeakBrightness < 0 ? GlwfCached_Peak : config.customGamePeakBrightness );
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK,"HdrGamePaperWhiteBrightness", () -> config.customGamePaperWhiteBrightness < 0 ? GlwfCached_Paper : config.customGamePaperWhiteBrightness);
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK,"HdrUIBrightness", () -> config.uiBrightness < 0 ? GlwfCached_Paper : config.uiBrightness);
}
}
24 changes: 12 additions & 12 deletions common/src/main/resources/assets/hdr_mod/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"text.autoconfig.hdr_mod.option.enableHDR": "Enable HDR",
"text.autoconfig.hdr_mod.option.uiBrightness": "Custom UI Brightness",
"text.autoconfig.hdr_mod.option.customGamePaperWhiteBrightness": "Custom Game Paper White Brightness",
"text.autoconfig.hdr_mod.option.customGameMinimumBrightness": "Custom Game Minimum Brightness",
"text.autoconfig.hdr_mod.option.customGamePeakBrightness": "Custom Game Peak Brightness",
"text.autoconfig.hdr_mod.option.uiBrightness": "UI Brightness",
"text.autoconfig.hdr_mod.option.customGamePaperWhiteBrightness": "Game Paper White Brightness",
"text.autoconfig.hdr_mod.option.customGameMinimumBrightness": "Game Minimum Brightness",
"text.autoconfig.hdr_mod.option.customGamePeakBrightness": "Game Peak Brightness",
"text.autoconfig.hdr_mod.option.customEotfEmulate": "EOTF / Gamma Correction 2.2 Threshold",
"text.autoconfig.hdr_mod.option.enableHDR.@Tooltip": "Enable HDR (Restart the game to take effect).",
"text.autoconfig.hdr_mod.option.uiBrightness.@Tooltip": "In nits, the paper white of UI elements and vanilla game (i.e without shaders). Set it negative to use display reported SDR paper white.",
"text.autoconfig.hdr_mod.option.customGamePaperWhiteBrightness.@Tooltip": "In nits, the paper white of the game/scene. Set it negative to use display reported value.",
"text.autoconfig.hdr_mod.option.customGameMinimumBrightness.@Tooltip": "In nits, the minimum the display can output. Set it negative to use display reported value. Leave 0 if unsure.",
"text.autoconfig.hdr_mod.option.customGamePeakBrightness.@Tooltip": "In nits, the maximum the display can output. Set it negative to use display reported value.",
"text.autoconfig.hdr_mod.option.customEotfEmulate.@Tooltip": "Correct raised shadows to match SDR. Use if OS or display doesn't do so already. Set it negative to use display reported SDR paper white.",
"text.autoconfig.hdr_mod.option.enableHDR.@Tooltip": "Enable HDR (Requires Client Restart).",
"text.autoconfig.hdr_mod.option.uiBrightness.@Tooltip": "In nits, the paper white of UI elements and vanilla game (i.e without shaders).\n(Linux) Set it negative to use display reported SDR paper white.",
"text.autoconfig.hdr_mod.option.customGamePaperWhiteBrightness.@Tooltip": "In nits, the paper white of the game/scene.\n(Linux) Set it negative to use display reported value.",
"text.autoconfig.hdr_mod.option.customGameMinimumBrightness.@Tooltip": "In nits, the minimum the display can output.\n(Linux) Set it negative to use display reported value. Leave 0 if unsure.",
"text.autoconfig.hdr_mod.option.customGamePeakBrightness.@Tooltip": "In nits, the maximum the display can output.\n(Linux) Set it negative to use display reported value.",
"text.autoconfig.hdr_mod.option.customEotfEmulate.@Tooltip": "Correct raised shadows to match SDR.\nUse if OS or display doesn't do so already.\n(Linux) Set it negative to use display reported SDR paper white.",

"text.autoconfig.hdr_mod.option.onlyUpgradeNecessaryTexture": "Only Upgrade Necessary Texture",
"text.autoconfig.hdr_mod.option.onlyUpgradeNecessaryTexture.@Tooltip": "Only upgrade necessary texture from RGBA8 to RGBA16F. When enabled, only color texture of a render target or the BEFORE_BLIT ping-pong texture will be upgraded. When disabled, all color textures created by vanilla will be upgraded.",
"text.autoconfig.hdr_mod.option.onlyUpgradeNecessaryTexture.@Tooltip": "Only upgrade necessary texture from RGBA8 to RGBA16F.\nWhen enabled, only color texture of a render target or the BEFORE_BLIT ping-pong texture will be upgraded.\nWhen disabled, all color textures created by vanilla will be upgraded.",
"text.autoconfig.hdr_mod.option.writeBeforeBlitToMainTarget": "Write BEFORE_BLIT Render Target To Main Render Target",
"text.autoconfig.hdr_mod.option.writeBeforeBlitToMainTarget.@Tooltip": "If on, ingame screenshot and ReplayMod/Flashback will be severely broken.\n If off, some mods that rewrite blitToScreen may break the game. Keep 'off' if unsure.",
"text.autoconfig.hdr_mod.option.useRGBA16UNORM": "Use RGBA16 UNORM For BEFORE_BLIT Render Target",
"text.autoconfig.hdr_mod.option.useRGBA16UNORM.@Tooltip": "Improve precision when using BT.2100 PQ transfer function, but completely breaks scRGB linear. Keep default if unsure.",
"text.autoconfig.hdr_mod.option.useRGBA16UNORM.@Tooltip": "Improve precision when using BT.2100 PQ transfer function, but completely breaks scRGB linear.\nKeep default if unsure.",

"text.autoconfig.hdr_mod.option.autoSetPrimaries": "Auto Set Primaries",
"text.autoconfig.hdr_mod.option.customPrimaries": "Custom Primaries ",
Expand Down