diff --git a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiAmbientOcclusionConfig.java b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiAmbientOcclusionConfig.java new file mode 100644 index 000000000..d20bac76e --- /dev/null +++ b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiAmbientOcclusionConfig.java @@ -0,0 +1,68 @@ +/* + * 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.interfaces.config.client; + +import com.seibel.distanthorizons.api.enums.rendering.EFogColorMode; +import com.seibel.distanthorizons.api.enums.rendering.EFogDistance; +import com.seibel.distanthorizons.api.enums.rendering.EFogDrawMode; +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup; +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue; + +/** + * Distant Horizons' fog configuration.

+ * + * @author James Seibel + * @version 2022-9-6 + * @since API 1.0.0 + */ +public interface IDhApiAmbientOcclusionConfig extends IDhApiConfigGroup +{ + /** Determines if Ambient Occlusion is rendered */ + IDhApiConfigValue enabled(); + + /** + * Determines how many points in space are sampled for the occlusion test. + * Higher numbers will improve quality and reduce banding, but will increase GPU load. + */ + IDhApiConfigValue sampleCount(); + + /** Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks. */ + IDhApiConfigValue radius(); + + /** Determines how dark the Screen Space Ambient Occlusion effect will be. */ + IDhApiConfigValue strength(); + + /** Increasing the value can reduce banding at the cost of reducing the strength of the effect. */ + IDhApiConfigValue bias(); + + /** + * Determines how dark the occlusion shadows can be.
+ * 0 = totally black at the corners
+ * 1 = no shadow + */ + IDhApiConfigValue minLight(); + + /** + * The radius, measured in pixels, that blurring is calculated.
+ * Higher numbers will reduce banding at the cost of GPU performance. + */ + IDhApiConfigValue blurRadius(); + +} diff --git a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiGraphicsConfig.java b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiGraphicsConfig.java index b083c4eb8..d09fed095 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiGraphicsConfig.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/client/IDhApiGraphicsConfig.java @@ -40,6 +40,7 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup //===============// IDhApiFogConfig fog(); + IDhApiAmbientOcclusionConfig ambientOcclusion(); IDhApiNoiseTextureConfig noiseTexture(); @@ -84,20 +85,6 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup /** Modifies the quadratic function fake chunks use for horizontal quality drop-off. */ IDhApiConfigValue horizontalQuality(); - IDhApiConfigValue ambientOcclusion(); - - IDhApiConfigValue ambientOcclusion_SampleCount(); - - IDhApiConfigValue ambientOcclusion_Radius(); - - IDhApiConfigValue ambientOcclusion_Strength(); - - IDhApiConfigValue ambientOcclusion_Bias(); - - IDhApiConfigValue ambientOcclusion_MinLight(); - - IDhApiConfigValue ambientOcclusion_BlurRadius(); - IDhApiConfigValue transparency(); /** Defines what blocks won't be rendered as LODs. */ diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiAmbientOcclusionConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiAmbientOcclusionConfig.java new file mode 100644 index 000000000..4afc661f8 --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiAmbientOcclusionConfig.java @@ -0,0 +1,64 @@ +/* + * 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.core.api.external.methods.config.client; + +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue; +import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiAmbientOcclusionConfig; +import com.seibel.distanthorizons.api.objects.config.DhApiConfigValue; +import com.seibel.distanthorizons.core.config.Config; + +public class DhApiAmbientOcclusionConfig implements IDhApiAmbientOcclusionConfig +{ + public static DhApiAmbientOcclusionConfig INSTANCE = new DhApiAmbientOcclusionConfig(); + + private DhApiAmbientOcclusionConfig() { } + + + + + @Override + public IDhApiConfigValue enabled() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.enabled); } + + @Override + public IDhApiConfigValue sampleCount() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.sampleCount); } + + @Override + public IDhApiConfigValue radius() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.radius); } + + @Override + public IDhApiConfigValue strength() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.strength); } + + @Override + public IDhApiConfigValue bias() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.bias); } + + @Override + public IDhApiConfigValue minLight() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.minLight); } + + @Override + public IDhApiConfigValue blurRadius() + { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Ssao.blurRadius); } + +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java index 3e7943751..df8f8d280 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java @@ -22,6 +22,7 @@ package com.seibel.distanthorizons.core.api.external.methods.config.client; import com.seibel.distanthorizons.api.enums.config.*; import com.seibel.distanthorizons.api.enums.rendering.ETransparency; import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue; +import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiAmbientOcclusionConfig; import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiFogConfig; import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiGraphicsConfig; import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiNoiseTextureConfig; @@ -42,6 +43,7 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig //==============// public IDhApiFogConfig fog() { return DhApiFogConfig.INSTANCE; } + public IDhApiAmbientOcclusionConfig ambientOcclusion() { return DhApiAmbientOcclusionConfig.INSTANCE; } public IDhApiNoiseTextureConfig noiseTexture() { return DhApiNoiseTextureConfig.INSTANCE; } @@ -80,34 +82,6 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig public IDhApiConfigValue horizontalQuality() { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.horizontalQuality); } - @Override - public IDhApiConfigValue ambientOcclusion() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssao); } - - @Override - public IDhApiConfigValue ambientOcclusion_SampleCount() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoSampleCount); } - - @Override - public IDhApiConfigValue ambientOcclusion_Radius() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoRadius); } - - @Override - public IDhApiConfigValue ambientOcclusion_Strength() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoStrength); } - - @Override - public IDhApiConfigValue ambientOcclusion_Bias() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoBias); } - - @Override - public IDhApiConfigValue ambientOcclusion_MinLight() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoMinLight); } - - @Override - public IDhApiConfigValue ambientOcclusion_BlurRadius() - { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.ssaoBlurRadius); } - @Override public IDhApiConfigValue transparency() { return new DhApiConfigValue(Config.Client.Advanced.Graphics.Quality.transparency); } 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 6d6ddece6..4cc2a1d77 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 @@ -132,6 +132,7 @@ public class Config { public static ConfigCategory quality = new ConfigCategory.Builder().set(Quality.class).build(); public static ConfigCategory fog = new ConfigCategory.Builder().set(Fog.class).build(); + public static ConfigCategory ssao = new ConfigCategory.Builder().set(Ssao.class).build(); public static ConfigCategory noiseTextureSettings = new ConfigCategory.Builder().set(NoiseTextureSettings.class).build(); public static ConfigCategory advancedGraphics = new ConfigCategory.Builder().set(AdvancedGraphics.class).build(); @@ -174,41 +175,6 @@ public class Config .setPerformance(EConfigEntryPerformance.VERY_HIGH) .build(); - public static ConfigEntry ssao = new ConfigEntry.Builder() - .set(true) - .comment("Enable Screen Space Ambient Occlusion") - .build(); - - public static ConfigEntry ssaoSampleCount = new ConfigEntry.Builder() - .set(6) - .comment("Number of samples to use for Screen Space Ambient Occlusion") - .build(); - - public static ConfigEntry ssaoRadius = new ConfigEntry.Builder() - .set(4.0) - .comment("Radius of Screen Space Ambient Occlusion effect in blocks") - .build(); - - public static ConfigEntry ssaoStrength = new ConfigEntry.Builder() - .set(0.2) - .comment("Strength of Screen Space Ambient Occlusion effect") - .build(); - - public static ConfigEntry ssaoBias = new ConfigEntry.Builder() - .set(0.02) - .comment("Bias of Screen Space Ambient Occlusion effect") - .build(); - - public static ConfigEntry ssaoMinLight = new ConfigEntry.Builder() - .set(0.25) - .comment("Minimum brightness of Screen Space Ambient Occlusion effect") - .build(); - - public static ConfigEntry ssaoBlurRadius = new ConfigEntry.Builder() - .set(2) - .comment("Radius in pixels of Screen Space Ambient Occlusion blurring") - .build(); - public static ConfigEntry horizontalQuality = new ConfigEntry.Builder() .set(EHorizontalQuality.MEDIUM) .comment("" @@ -473,6 +439,68 @@ public class Config } + public static class Ssao + { + public static ConfigEntry enabled = new ConfigEntry.Builder() + .set(true) + .comment("Enable Screen Space Ambient Occlusion") + .setPerformance(EConfigEntryPerformance.MEDIUM) + .build(); + + public static ConfigEntry sampleCount = new ConfigEntry.Builder() + .set(6) + .comment("" + + "Determines how many points in space are sampled for the occlusion test. \n" + + "Higher numbers will improve quality and reduce banding, but will increase GPU load." + + "") + .setPerformance(EConfigEntryPerformance.MEDIUM) + .build(); + + public static ConfigEntry radius = new ConfigEntry.Builder() + .set(4.0) + .comment("" + + "Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks." + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .build(); + + public static ConfigEntry strength = new ConfigEntry.Builder() + .set(0.2) + .comment("" + + "Determines how dark the Screen Space Ambient Occlusion effect will be." + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .build(); + + public static ConfigEntry bias = new ConfigEntry.Builder() + .set(0.02) + .comment("" + + "Increasing the value can reduce banding at the cost of reducing the strength of the effect." + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .build(); + + public static ConfigEntry minLight = new ConfigEntry.Builder() + .set(0.25) + .comment("" + + "Determines how dark the occlusion shadows can be. \n" + + "0 = totally black at the corners \n" + + "1 = no shadow" + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .build(); + + public static ConfigEntry blurRadius = new ConfigEntry.Builder() + .set(2) + .comment("" + + "The radius, measured in pixels, that blurring is calculated for the SSAO. \n" + + "Higher numbers will reduce banding at the cost of GPU performance." + + "") + .setPerformance(EConfigEntryPerformance.HIGH) + .build(); + + } + public static class NoiseTextureSettings { public static ConfigEntry noiseEnabled = new ConfigEntry.Builder() @@ -549,6 +577,7 @@ public class Config .setPerformance(EConfigEntryPerformance.NONE) .build(); + // move into "shader compatibility" public static ConfigEntry brightnessMultiplier = new ConfigEntry.Builder() // TODO: Make this a float (the ClassicConfigGUI doesnt support floats) .set(1.0) .comment("" 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 bc8808689..3ac0f6f78 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 @@ -76,7 +76,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE this.put(EQualityPreset.HIGH, ETransparency.COMPLETE); this.put(EQualityPreset.EXTREME, ETransparency.COMPLETE); }}); - private final ConfigEntryWithPresetOptions ssao = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.ssao, + private final ConfigEntryWithPresetOptions ssaoEnabled = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Ssao.enabled, new HashMap() {{ this.put(EQualityPreset.MINIMUM, false); @@ -100,7 +100,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE this.configList.add(this.verticalQuality); this.configList.add(this.horizontalQuality); this.configList.add(this.transparency); - this.configList.add(this.ssao); + this.configList.add(this.ssaoEnabled); for (ConfigEntryWithPresetOptions config : this.configList) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java index 00b2cc1c7..5c201dcd1 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java @@ -44,7 +44,6 @@ import com.seibel.distanthorizons.coreapi.util.math.Mat4f; import com.seibel.distanthorizons.coreapi.util.math.Vec3d; import com.seibel.distanthorizons.coreapi.util.math.Vec3f; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL32; import java.awt.*; @@ -283,7 +282,7 @@ public class LodRenderer // TODO: Directional culling this.bufferHandler.renderOpaque(this); - if (Config.Client.Advanced.Graphics.Quality.ssao.get()) + if (Config.Client.Advanced.Graphics.Ssao.enabled.get()) { profiler.popPush("LOD SSAO"); SSAORenderer.INSTANCE.render(partialTicks); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/SSAORenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/SSAORenderer.java index 926a2e8b1..364b3ba78 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/SSAORenderer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/shaders/SSAORenderer.java @@ -212,12 +212,12 @@ public class SSAORenderer Mat4f invertedPerspective = new Mat4f(perspective); invertedPerspective.invert(); - int sampleCount = Config.Client.Advanced.Graphics.Quality.ssaoSampleCount.get(); - int blurRadius = Config.Client.Advanced.Graphics.Quality.ssaoBlurRadius.get(); - float radius = Config.Client.Advanced.Graphics.Quality.ssaoRadius.get().floatValue(); - float strength = Config.Client.Advanced.Graphics.Quality.ssaoStrength.get().floatValue(); - float minLight = Config.Client.Advanced.Graphics.Quality.ssaoMinLight.get().floatValue(); - float bias = Config.Client.Advanced.Graphics.Quality.ssaoBias.get().floatValue(); + int sampleCount = Config.Client.Advanced.Graphics.Ssao.sampleCount.get(); + int blurRadius = Config.Client.Advanced.Graphics.Ssao.blurRadius.get(); + float radius = Config.Client.Advanced.Graphics.Ssao.radius.get().floatValue(); + float strength = Config.Client.Advanced.Graphics.Ssao.strength.get().floatValue(); + float minLight = Config.Client.Advanced.Graphics.Ssao.minLight.get().floatValue(); + float bias = Config.Client.Advanced.Graphics.Ssao.bias.get().floatValue(); this.ssaoShader.bind(); this.ssaoShader.setUniform(this.ssaoShaderUniforms.gProjUniform, perspective); 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 a0f378a23..dbcfd896a 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -94,22 +94,6 @@ "Horizontal Scale", "distanthorizons.config.client.advanced.graphics.quality.horizontalScale.@tooltip": "How quickly LODs drop off in quality.\n\nLarger numbers will improve how distant terrain looks\nbut will increase memory and GPU usage.", - "distanthorizons.config.client.advanced.graphics.quality.ssao": - "SSAO", - "distanthorizons.config.client.advanced.graphics.quality.ssao.@tooltip": - "Screen Space Ambient Occlusion adds depth to the lighting of blocks.", - "distanthorizons.config.client.advanced.graphics.quality.ssaoSampleCount": - "SSAO Sample Count", - "distanthorizons.config.client.advanced.graphics.quality.ssaoRadius": - "SSAO Radius", - "distanthorizons.config.client.advanced.graphics.quality.ssaoStrength": - "SSAO Strength", - "distanthorizons.config.client.advanced.graphics.quality.ssaoMinLight": - "SSAO Min Light", - "distanthorizons.config.client.advanced.graphics.quality.ssaoBias": - "SSAO Bias", - "distanthorizons.config.client.advanced.graphics.quality.ssaoBlurRadius": - "SSAO Blur Radius", "distanthorizons.config.client.advanced.graphics.quality.horizontalQuality": "Horizontal Quality", "distanthorizons.config.client.advanced.graphics.quality.horizontalQuality.@tooltip": @@ -175,6 +159,39 @@ "Far Fog Density", "distanthorizons.config.client.advanced.graphics.fog.advancedFog.farFogDensity.@tooltip": "What is the fog density? ", + + + "distanthorizons.config.client.advanced.graphics.ssao": + "Ambient Occlusion", + + "distanthorizons.config.client.advanced.graphics.ssao.enabled": + "Enable Ambient Occlusion", + "distanthorizons.config.client.advanced.graphics.ssao.enabled.@tooltip": + "Ambient Occlusion adds depth to the lighting of blocks.", + "distanthorizons.config.client.advanced.graphics.ssao.sampleCount": + "Sample Count", + "distanthorizons.config.client.advanced.graphics.ssao.sampleCount.@tooltip": + "Determines how many points in space are sampled for the occlusion test. \nHigher numbers will improve quality and reduce banding, but will increase GPU load.", + "distanthorizons.config.client.advanced.graphics.ssao.radius": + "Radius", + "distanthorizons.config.client.advanced.graphics.ssao.radius.@tooltip": + "Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks.", + "distanthorizons.config.client.advanced.graphics.ssao.strength": + "Strength", + "distanthorizons.config.client.advanced.graphics.ssao.strength.@tooltip": + "Determines how dark the Screen Space Ambient Occlusion effect will be.", + "distanthorizons.config.client.advanced.graphics.ssao.bias": + "Bias", + "distanthorizons.config.client.advanced.graphics.ssao.bias.@tooltip": + "Increasing the value can reduce banding at the cost of reducing the strength of the effect.", + "distanthorizons.config.client.advanced.graphics.ssao.minLight": + "Min Light", + "distanthorizons.config.client.advanced.graphics.ssao.minLight.@tooltip": + "Determines how dark the occlusion shadows can be. \n0 = totally black at the corners \n1 = no shadow", + "distanthorizons.config.client.advanced.graphics.ssao.blurRadius": + "Blur Radius", + "distanthorizons.config.client.advanced.graphics.ssao.blurRadius.@tooltip": + "The radius, measured in pixels, that blurring is calculated for the SSAO. \nHigher numbers will reduce banding at the cost of GPU performance.", "distanthorizons.config.client.advanced.graphics.fog.advancedFog.heightFog":