Improve fade config, add localization, and add fading to the quality presets

This commit is contained in:
James Seibel
2024-10-03 17:10:51 -05:00
parent 38f3b46f8a
commit ea4d4bf955
5 changed files with 116 additions and 29 deletions
@@ -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 <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.api.enums.config;
/**
* Handles how Minecraft's rendering
* is faded out to smooth the transition
* between MC and DH rendering. <br><br>
*
* NONE, <br>
* NON_COLLIDING, <br>
*
* @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. <br>
* Fastest.
*/
NONE,
/**
* Fading only runs after the translucent render pass. <br>
* 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;
}
@@ -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);
}
}
}
@@ -255,19 +255,14 @@ public class Config
.addListener(ReloadLodsConfigEventHandler.INSTANCE)
.build();
public static ConfigEntry<Boolean> fadeOutVanillaRendering = new ConfigEntry.Builder<Boolean>()
.set(true)
public static ConfigEntry<EDhApiMcRenderingFadeMode> vanillaFadeMode = new ConfigEntry.Builder<EDhApiMcRenderingFadeMode>()
.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<Boolean> twoPassVanillaFade = new ConfigEntry.Builder<Boolean>()
.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<Boolean> ditherDhFade = new ConfigEntry.Builder<Boolean>()
.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();
@@ -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<EDhApiQualityPreset, EDhApiMcRenderingFadeMode> vanillaFade = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.vanillaFadeMode,
new HashMap<EDhApiQualityPreset, EDhApiMcRenderingFadeMode>()
{{
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<EDhApiQualityPreset, Boolean> dhDither = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.ditherDhFade,
new HashMap<EDhApiQualityPreset, Boolean>()
{{
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<EDhApiQualityPreset, ?> config : this.configList)
@@ -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":