Reorganize SSAO config

This commit is contained in:
James Seibel
2023-09-06 21:25:13 -05:00
parent ea05ef3d3d
commit 36fc6aaea3
9 changed files with 241 additions and 103 deletions
@@ -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 <https://www.gnu.org/licenses/>.
*/
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. <br><br>
*
* @author James Seibel
* @version 2022-9-6
* @since API 1.0.0
*/
public interface IDhApiAmbientOcclusionConfig extends IDhApiConfigGroup
{
/** Determines if Ambient Occlusion is rendered */
IDhApiConfigValue<Boolean> 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<Integer> sampleCount();
/** Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks. */
IDhApiConfigValue<Double> radius();
/** Determines how dark the Screen Space Ambient Occlusion effect will be. */
IDhApiConfigValue<Double> strength();
/** Increasing the value can reduce banding at the cost of reducing the strength of the effect. */
IDhApiConfigValue<Double> bias();
/**
* Determines how dark the occlusion shadows can be. <br>
* 0 = totally black at the corners <br>
* 1 = no shadow
*/
IDhApiConfigValue<Double> minLight();
/**
* The radius, measured in pixels, that blurring is calculated. <br>
* Higher numbers will reduce banding at the cost of GPU performance.
*/
IDhApiConfigValue<Integer> blurRadius();
}
@@ -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<EHorizontalQuality> horizontalQuality();
IDhApiConfigValue<Boolean> ambientOcclusion();
IDhApiConfigValue<Integer> ambientOcclusion_SampleCount();
IDhApiConfigValue<Double> ambientOcclusion_Radius();
IDhApiConfigValue<Double> ambientOcclusion_Strength();
IDhApiConfigValue<Double> ambientOcclusion_Bias();
IDhApiConfigValue<Double> ambientOcclusion_MinLight();
IDhApiConfigValue<Integer> ambientOcclusion_BlurRadius();
IDhApiConfigValue<ETransparency> transparency();
/** Defines what blocks won't be rendered as LODs. */
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<Boolean> enabled()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.Ssao.enabled); }
@Override
public IDhApiConfigValue<Integer> sampleCount()
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Ssao.sampleCount); }
@Override
public IDhApiConfigValue<Double> radius()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.radius); }
@Override
public IDhApiConfigValue<Double> strength()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.strength); }
@Override
public IDhApiConfigValue<Double> bias()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.bias); }
@Override
public IDhApiConfigValue<Double> minLight()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.minLight); }
@Override
public IDhApiConfigValue<Integer> blurRadius()
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Ssao.blurRadius); }
}
@@ -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<EHorizontalQuality> horizontalQuality()
{ return new DhApiConfigValue<EHorizontalQuality, EHorizontalQuality>(Config.Client.Advanced.Graphics.Quality.horizontalQuality); }
@Override
public IDhApiConfigValue<Boolean> ambientOcclusion()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.Quality.ssao); }
@Override
public IDhApiConfigValue<Integer> ambientOcclusion_SampleCount()
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Quality.ssaoSampleCount); }
@Override
public IDhApiConfigValue<Double> ambientOcclusion_Radius()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Quality.ssaoRadius); }
@Override
public IDhApiConfigValue<Double> ambientOcclusion_Strength()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Quality.ssaoStrength); }
@Override
public IDhApiConfigValue<Double> ambientOcclusion_Bias()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Quality.ssaoBias); }
@Override
public IDhApiConfigValue<Double> ambientOcclusion_MinLight()
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Quality.ssaoMinLight); }
@Override
public IDhApiConfigValue<Integer> ambientOcclusion_BlurRadius()
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Quality.ssaoBlurRadius); }
@Override
public IDhApiConfigValue<ETransparency> transparency()
{ return new DhApiConfigValue<ETransparency, ETransparency>(Config.Client.Advanced.Graphics.Quality.transparency); }
@@ -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<Boolean> ssao = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment("Enable Screen Space Ambient Occlusion")
.build();
public static ConfigEntry<Integer> ssaoSampleCount = new ConfigEntry.Builder<Integer>()
.set(6)
.comment("Number of samples to use for Screen Space Ambient Occlusion")
.build();
public static ConfigEntry<Double> ssaoRadius = new ConfigEntry.Builder<Double>()
.set(4.0)
.comment("Radius of Screen Space Ambient Occlusion effect in blocks")
.build();
public static ConfigEntry<Double> ssaoStrength = new ConfigEntry.Builder<Double>()
.set(0.2)
.comment("Strength of Screen Space Ambient Occlusion effect")
.build();
public static ConfigEntry<Double> ssaoBias = new ConfigEntry.Builder<Double>()
.set(0.02)
.comment("Bias of Screen Space Ambient Occlusion effect")
.build();
public static ConfigEntry<Double> ssaoMinLight = new ConfigEntry.Builder<Double>()
.set(0.25)
.comment("Minimum brightness of Screen Space Ambient Occlusion effect")
.build();
public static ConfigEntry<Integer> ssaoBlurRadius = new ConfigEntry.Builder<Integer>()
.set(2)
.comment("Radius in pixels of Screen Space Ambient Occlusion blurring")
.build();
public static ConfigEntry<EHorizontalQuality> horizontalQuality = new ConfigEntry.Builder<EHorizontalQuality>()
.set(EHorizontalQuality.MEDIUM)
.comment(""
@@ -473,6 +439,68 @@ public class Config
}
public static class Ssao
{
public static ConfigEntry<Boolean> enabled = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment("Enable Screen Space Ambient Occlusion")
.setPerformance(EConfigEntryPerformance.MEDIUM)
.build();
public static ConfigEntry<Integer> sampleCount = new ConfigEntry.Builder<Integer>()
.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<Double> radius = new ConfigEntry.Builder<Double>()
.set(4.0)
.comment("" +
"Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks." +
"")
.setPerformance(EConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<Double> strength = new ConfigEntry.Builder<Double>()
.set(0.2)
.comment("" +
"Determines how dark the Screen Space Ambient Occlusion effect will be." +
"")
.setPerformance(EConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<Double> bias = new ConfigEntry.Builder<Double>()
.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<Double> minLight = new ConfigEntry.Builder<Double>()
.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<Integer> blurRadius = new ConfigEntry.Builder<Integer>()
.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<Boolean> noiseEnabled = new ConfigEntry.Builder<Boolean>()
@@ -549,6 +577,7 @@ public class Config
.setPerformance(EConfigEntryPerformance.NONE)
.build();
// move into "shader compatibility"
public static ConfigEntry<Double> brightnessMultiplier = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI doesnt support floats)
.set(1.0)
.comment(""
@@ -76,7 +76,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
this.put(EQualityPreset.HIGH, ETransparency.COMPLETE);
this.put(EQualityPreset.EXTREME, ETransparency.COMPLETE);
}});
private final ConfigEntryWithPresetOptions<EQualityPreset, Boolean> ssao = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.ssao,
private final ConfigEntryWithPresetOptions<EQualityPreset, Boolean> ssaoEnabled = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Ssao.enabled,
new HashMap<EQualityPreset, Boolean>()
{{
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<EQualityPreset, ?> config : this.configList)
@@ -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);
@@ -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);
@@ -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":