From ea4d4bf955794263a4d23214a706da528426ebad Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 3 Oct 2024 17:10:51 -0500 Subject: [PATCH] Improve fade config, add localization, and add fading to the quality presets --- .../config/EDhApiMcRenderingFadeMode.java | 57 +++++++++++++++++++ .../core/api/internal/ClientApi.java | 22 ++++--- .../distanthorizons/core/config/Config.java | 23 ++++---- ...RenderQualityPresetConfigEventHandler.java | 21 +++++++ .../assets/distanthorizons/lang/en_us.json | 22 ++++--- 5 files changed, 116 insertions(+), 29 deletions(-) create mode 100644 api/src/main/java/com/seibel/distanthorizons/api/enums/config/EDhApiMcRenderingFadeMode.java diff --git a/api/src/main/java/com/seibel/distanthorizons/api/enums/config/EDhApiMcRenderingFadeMode.java b/api/src/main/java/com/seibel/distanthorizons/api/enums/config/EDhApiMcRenderingFadeMode.java new file mode 100644 index 000000000..b1b02560d --- /dev/null +++ b/api/src/main/java/com/seibel/distanthorizons/api/enums/config/EDhApiMcRenderingFadeMode.java @@ -0,0 +1,57 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020-2023 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.api.enums.config; + +/** + * Handles how Minecraft's rendering + * is faded out to smooth the transition + * between MC and DH rendering.

+ * + * NONE,
+ * NON_COLLIDING,
+ * + * @since API 4.0.0 + * @version 2024-10-3 + */ +public enum EDhApiMcRenderingFadeMode +{ + // Reminder: + // when adding items up the API minor version + // when removing items up the API major version + + /** + * No fading is done, there will be a pronounced border between + * Minecraft and Distant Horizons.
+ * Fastest. + */ + NONE, + /** + * Fading only runs after the translucent render pass.
+ * Looks good for the tops of oceans and rivers, but + * doesn't fade the opaque blocks underwater. + */ + SINGLE_PASS, + /** + * Fading runs after both opaque and translucent render passes. + * Slowest, but oceans and rivers look better. + */ + DOUBLE_PASS; + +} \ No newline at end of file diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java index 33f6c346e..f77e78e87 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java @@ -20,11 +20,11 @@ package com.seibel.distanthorizons.core.api.internal; import com.seibel.distanthorizons.api.DhApi; +import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode; import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass; import com.seibel.distanthorizons.api.methods.events.abstractEvents.*; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam; import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure; -import com.seibel.distanthorizons.core.level.DhClientLevel; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.render.DhApiRenderProxy; import com.seibel.distanthorizons.core.render.renderer.FadeRenderer; @@ -555,20 +555,26 @@ public class ClientApi /** should be called after DH and MC finish rendering so we can smooth the transition between the two */ public void renderFadeOpaque(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IClientLevelWrapper level) { - if (Config.Client.Advanced.Graphics.Quality.fadeOutVanillaRendering.get() - && Config.Client.Advanced.Graphics.Quality.twoPassVanillaFade.get() - && Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT) + // only fade when DH is rendering + if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT) { - FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level); + if (Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() == EDhApiMcRenderingFadeMode.DOUBLE_PASS) + { + FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level); + } } } /** should be called after DH and MC finish rendering so we can smooth the transition between the two */ public void renderFade(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IClientLevelWrapper level) { - if (Config.Client.Advanced.Graphics.Quality.fadeOutVanillaRendering.get() - && Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT) + // only fade when DH is rendering + if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT) { - FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level); + // fade if any level fading is active + if (Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() != EDhApiMcRenderingFadeMode.NONE) + { + FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level); + } } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index f53156349..8a517a8fb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -255,19 +255,14 @@ public class Config .addListener(ReloadLodsConfigEventHandler.INSTANCE) .build(); - public static ConfigEntry fadeOutVanillaRendering = new ConfigEntry.Builder() - .set(true) + public static ConfigEntry vanillaFadeMode = new ConfigEntry.Builder() + .set(EDhApiMcRenderingFadeMode.DOUBLE_PASS) .comment("" - + "If true vanilla chunks will fade out the further away they are \n" - + "smoothing the transition between Distant Horizons and vanilla rendering. \n" - + "") - .setPerformance(EConfigEntryPerformance.LOW) - .build(); - - public static ConfigEntry twoPassVanillaFade = new ConfigEntry.Builder() - .set(true) - .comment("" - + "TODO \n" + + "How should vanilla Minecraft fade into Distant Horizons LODs? \n" + + "\n" + + EDhApiMcRenderingFadeMode.NONE + ": Fastest, there will be a pronounced border between DH and MC rendering. \n" + + EDhApiMcRenderingFadeMode.SINGLE_PASS + ": Fades after MC's transparent pass, opaque blocks underwater won't be faded. \n" + + EDhApiMcRenderingFadeMode.DOUBLE_PASS + ": Slowest, fades after both MC's opaque and transparent passes, provides the smoothest transition. \n" + "") .setPerformance(EConfigEntryPerformance.LOW) .build(); @@ -275,7 +270,9 @@ public class Config public static ConfigEntry ditherDhFade = new ConfigEntry.Builder() .set(true) .comment("" - + "TODO \n" + + "If true LODs will fade away as you get closer to them. \n" + + "If false LODs will cut off abruptly at a set distance from the camera. \n" + + "This setting is affected by the vanilla overdraw prevention config. \n" + "") .setPerformance(EConfigEntryPerformance.LOW) .build(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/RenderQualityPresetConfigEventHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/RenderQualityPresetConfigEventHandler.java index b6fc1cb81..124d464d4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/RenderQualityPresetConfigEventHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/RenderQualityPresetConfigEventHandler.java @@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.config.eventHandlers.presets; import com.seibel.distanthorizons.api.enums.config.EDhApiHorizontalQuality; import com.seibel.distanthorizons.api.enums.config.EDhApiMaxHorizontalResolution; +import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode; import com.seibel.distanthorizons.api.enums.config.EDhApiVerticalQuality; import com.seibel.distanthorizons.api.enums.config.quickOptions.EDhApiQualityPreset; import com.seibel.distanthorizons.api.enums.rendering.EDhApiTransparency; @@ -86,6 +87,24 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE this.put(EDhApiQualityPreset.HIGH, true); this.put(EDhApiQualityPreset.EXTREME, true); }}); + private final ConfigEntryWithPresetOptions vanillaFade = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.vanillaFadeMode, + new HashMap() + {{ + this.put(EDhApiQualityPreset.MINIMUM, EDhApiMcRenderingFadeMode.NONE); + this.put(EDhApiQualityPreset.LOW, EDhApiMcRenderingFadeMode.SINGLE_PASS); + this.put(EDhApiQualityPreset.MEDIUM, EDhApiMcRenderingFadeMode.DOUBLE_PASS); + this.put(EDhApiQualityPreset.HIGH, EDhApiMcRenderingFadeMode.DOUBLE_PASS); + this.put(EDhApiQualityPreset.EXTREME, EDhApiMcRenderingFadeMode.DOUBLE_PASS); + }}); + private final ConfigEntryWithPresetOptions dhDither = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.ditherDhFade, + new HashMap() + {{ + this.put(EDhApiQualityPreset.MINIMUM, false); + this.put(EDhApiQualityPreset.LOW, true); + this.put(EDhApiQualityPreset.MEDIUM, true); + this.put(EDhApiQualityPreset.HIGH, true); + this.put(EDhApiQualityPreset.EXTREME, true); + }}); @@ -102,6 +121,8 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE this.configList.add(this.horizontalQuality); this.configList.add(this.transparency); this.configList.add(this.ssaoEnabled); + this.configList.add(this.vanillaFade); + this.configList.add(this.dhDither); for (ConfigEntryWithPresetOptions config : this.configList) diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index bae2b07fc..7e5f9bede 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -114,15 +114,14 @@ "Tint With Avoided Blocks", "distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks.@tooltip": "§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them", - "distanthorizons.config.client.advanced.graphics.quality.fadeOutVanillaRendering": - "Fade Out Vanilla Rendering", - "distanthorizons.config.client.advanced.graphics.quality.fadeOutVanillaRendering.@tooltip": - "If true vanilla chunks will fade out the further away they are\nsmoothing the transition between Distant Horizons and vanilla rendering.", - - "distanthorizons.config.client.advanced.graphics.quality.twoPassVanillaFade": - "Two Pass Vanilla Fade", + "distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode": + "Vanilla Fade Mode", + "distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode.@tooltip": + "How should vanilla Minecraft fade into Distant Horizons LODs? \n\nNONE: Fastest, there will be a pronounced border between DH and MC rendering. \nSINGLE_PASS: Fades after MC's transparent pass, opaque blocks underwater won't be faded. \nDOUBLE_PASS: Slowest, fades after both MC's opaque and transparent passes, provides the smoothest transition.", "distanthorizons.config.client.advanced.graphics.quality.ditherDhFade": - "Dither DH Near Rendering", + "Fade Nearby DH LODs", + "distanthorizons.config.client.advanced.graphics.quality.ditherDhFade.@tooltip": + "If true LODs will fade away as you get closer to them. \nIf false LODs will cut off abruptly at a set distance from the camera. \nThis setting is affected by the vanilla overdraw prevention config.", "distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending": "Biome Blending", @@ -736,6 +735,13 @@ "distanthorizons.config.enum.EDhApiMaxHorizontalResolution.CHUNK": "Chunk", + "distanthorizons.config.enum.EDhApiMcRenderingFadeMode.NONE": + "None", + "distanthorizons.config.enum.EDhApiMcRenderingFadeMode.SINGLE_PASS": + "Single Pass", + "distanthorizons.config.enum.EDhApiMcRenderingFadeMode.DOUBLE_PASS": + "Double Pass", + "distanthorizons.config.enum.EDhApiVerticalQuality.HEIGHT_MAP": "1. Height Map", "distanthorizons.config.enum.EDhApiVerticalQuality.LOW":