Add Fog Config API methods

This commit is contained in:
James Seibel
2022-06-30 22:16:37 -05:00
parent 00118ea885
commit 9299e2d53f
16 changed files with 403 additions and 54 deletions
@@ -0,0 +1,39 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.api.external.apiObjects.enums;
/**
* NEAR, <br>
* FAR, <br>
* NEAR_AND_FAR <br>
*
* @author James Seibel
* @version 2022-6-2
*/
public enum EDhApiFogDistance
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NEAR,
FAR,
NEAR_AND_FAR
}
@@ -0,0 +1,46 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.api.external.apiObjects.enums;
/**
* USE_OPTIFINE_FOG_SETTING, <br>
* FOG_ENABLED, <br>
* FOG_DISABLED <br>
*
* @author James Seibel
* @version 2022-6-2
*/
public enum EDhApiFogDrawMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Use whatever Fog setting optifine is using.
* If optifine isn't installed this defaults to FOG_ENABLED.
*/
USE_OPTIFINE_SETTING,
FOG_ENABLED,
FOG_DISABLED;
}
@@ -0,0 +1,21 @@
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* LINEAR, <br>
* EXPONENTIAL, <br>
* EXPONENTIAL_SQUARED <br>
*
* @author Leetom
* @version 2022-6-30
*/
public enum EDhApiFogFalloff
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
LINEAR,
EXPONENTIAL,
EXPONENTIAL_SQUARED,
}
@@ -0,0 +1,49 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.api.external.apiObjects.enums;
/**
* BASIC <br>
* IGNORE_HEIGHT <br>
* ADDITION <br>
* MAX <br>
* MULTIPLY <br>
* INVERSE_MULTIPLY <br>
* LIMITED_ADDITION <br>
* MULTIPLY_ADDITION <br>
* INVERSE_MULTIPLY_ADDITION <br>
* AVERAGE <br>
*
* @author Leetom
* @version 2022-4-14
*/
public enum EDhApiHeightFogMixMode
{
BASIC,
IGNORE_HEIGHT,
ADDITION,
MAX,
MULTIPLY,
INVERSE_MULTIPLY,
LIMITED_ADDITION,
MULTIPLY_ADDITION,
INVERSE_MULTIPLY_ADDITION,
AVERAGE,
}
@@ -0,0 +1,57 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.api.external.apiObjects.enums;
/**
* ABOVE_CAMERA, <br>
* BELOW_CAMERA, <br>
* ABOVE_AND_BELOW_CAMERA, <br>
* ABOVE_SET_HEIGHT, <br>
* BELOW_SET_HEIGHT, <br>
* ABOVE_AND_BELOW_SET_HEIGHT, <br>
*
* @author Leetom
* @version 6-30-2022
*/
public enum EDhApiHeightFogMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
ABOVE_CAMERA(true, true, false),
BELOW_CAMERA(true, false, true),
ABOVE_AND_BELOW_CAMERA(true, true, true),
ABOVE_SET_HEIGHT(false, true, false),
BELOW_SET_HEIGHT(false, false, true),
ABOVE_AND_BELOW_SET_HEIGHT(false, true, true);
public final boolean basedOnCamera;
public final boolean above;
public final boolean below;
EDhApiHeightFogMode(boolean basedOnCamera, boolean above, boolean below)
{
this.basedOnCamera = basedOnCamera;
this.above = above;
this.below = below;
}
}
@@ -20,6 +20,10 @@
package com.seibel.lod.core.api.external.apiObjects.enums;
/**
* LOW, <br>
* MEDIUM, <br>
* HIGH, <br>
* ULTRA <br>
*
* @author Leonardo Amato
* @version 2022-6-9
@@ -1,36 +1,140 @@
package com.seibel.lod.core.api.external.config.client.graphics;
import com.seibel.lod.core.api.external.apiObjects.enums.*;
import com.seibel.lod.core.api.external.apiObjects.wrapperInterfaces.IDhApiConfig;
import com.seibel.lod.core.api.implementation.objects.GenericEnumConverter;
import com.seibel.lod.core.api.implementation.wrappers.DhApiConfig;
import com.seibel.lod.core.enums.rendering.EFogColorMode;
import com.seibel.lod.core.enums.rendering.EFogDistance;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.config.Config.Client.Graphics.FogQuality;
import com.seibel.lod.core.enums.rendering.EFogDrawMode;
/**
* Any graphics settings related to fog.
* Any graphics settings related to fog. <br>
*
* @author James Seibel
* @version 2022-6-13
*/
public class DhApiGraphicsFog
{
//====================//
// basic fog settings //
//====================//
/** Returns the config related to when fog is rendered. */
public static IDhApiConfig<EFogDistance> getFogDistanceConfig()
{ return new DhApiConfig<>(FogQuality.fogDistance); }
public static IDhApiConfig<EDhApiFogDistance> getFogDistanceConfig()
{ return new DhApiConfig<>(FogQuality.fogDistance, new GenericEnumConverter<>(EFogDistance.class, EDhApiFogDistance.class)); }
/** Returns the config related to when fog is rendered. */
public static IDhApiConfig<EFogDrawMode> getFogRenderConfig()
{ return new DhApiConfig<>(FogQuality.fogDrawMode); }
public static IDhApiConfig<EDhApiFogDrawMode> getFogRenderConfig()
{ return new DhApiConfig<>(FogQuality.fogDrawMode, new GenericEnumConverter<>(EFogDrawMode.class, EDhApiFogDrawMode.class)); }
/** Returns the config related to the fog draw type. */
public static IDhApiConfig<EFogColorMode> getFogColorConfig()
{ return new DhApiConfig<>(FogQuality.fogColorMode); }
public static IDhApiConfig<EDhApiFogColorMode> getFogColorConfig()
{ return new DhApiConfig<>(FogQuality.fogColorMode, new GenericEnumConverter<>(EFogColorMode.class, EDhApiFogColorMode.class)); }
/** Returns the config related to disabling vanilla fog. */
public static IDhApiConfig<Boolean> getDisableVanillaFogConfig()
{ return new DhApiConfig<>(FogQuality.disableVanillaFog); }
//=======================//
// advanced fog settings //
//=======================//
/** Returns the config related to the fog starting distance. */
public static IDhApiConfig<Double> getFogStartDistanceConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogStart); }
/** Returns the config related to the fog ending distance. */
public static IDhApiConfig<Double> getFogEndDistanceConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogEnd); }
/**
* Returns the config related to the fog minimum thickness
* (aka how opaque the fog's is at its thinnest point).
*/
public static IDhApiConfig<Double> getFogMinThicknessConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogMin); }
/**
* Returns the config related to the fog maximum thickness
* (aka how opaque the fog's is at its thickest point).
*/
public static IDhApiConfig<Double> getFogMaxThicknessConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogMax); }
/**
* Returns the config related to how the fog increases/decreases
* in thickness over the given start and end distance.
*/
public static IDhApiConfig<EDhApiFogFalloff> getFogFalloffConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogType, new GenericEnumConverter<>(EFogFalloff.class, EDhApiFogFalloff.class)); }
/** Returns the config related to the fog density. */
public static IDhApiConfig<Double> getFogDensityFunctionConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.farFogDensity); }
//=====================//
// height fog settings //
//=====================//
/** Returns the config related to how the height fog mixes. */
public static IDhApiConfig<EDhApiHeightFogMixMode> getHeightFogMixModeConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogMixMode, new GenericEnumConverter<>(EHeightFogMixMode.class, EDhApiHeightFogMixMode.class)); }
/**
* Returns the config related to how the height fog
* is drawn relative to the camera or world.
*/
public static IDhApiConfig<EDhApiHeightFogMode> getHeightFogModeConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogMode, new GenericEnumConverter<>(EHeightFogMode.class, EDhApiHeightFogMode.class)); }
/**
* Returns the config related to the height fog's base height.
* (This defines the height used by EDhApiHeightFogMode if
* it is set up to use a specific height)
*/
public static IDhApiConfig<Double> getHeightFogBaseHeightConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogHeight); }
/**
* Returns the config related to the height fog's
* starting height as a percent of the world height.
*/
public static IDhApiConfig<Double> getHeightFogStartingHeightPercentConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogStart); }
/**
* Returns the config related to the height fog's
* ending height as a percent of the world height.
*/
public static IDhApiConfig<Double> getHeightFogEndingHeightPercentConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogEnd); }
/**
* Returns the config related to the height fog's minimum thickness
* (aka how opaque the height fog is at its thinnest point).
*/
public static IDhApiConfig<Double> getHeightFogMinThicknessConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogMin); }
/**
* Returns the config related to the height fog's maximum thickness
* (aka how opaque the height fog is at its thickest point).
*/
public static IDhApiConfig<Double> getHeightFogMaxThicknessConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogMax); }
/**
* Returns the config related to how the height fog increases/decreases
* in thickness over the given start and end height.
*/
public static IDhApiConfig<EDhApiFogFalloff> getHeightFogFalloffConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogType, new GenericEnumConverter<>(EFogFalloff.class, EDhApiFogFalloff.class)); }
/** Returns the config related to the height fog's density. */
public static IDhApiConfig<Double> getHeightFogDensityConfig()
{ return new DhApiConfig<>(FogQuality.AdvancedFog.HeightFog.heightFogDensity); }
}
@@ -257,14 +257,14 @@ public class Config
+ " '1.0': Fully fog color.")
.build();
public static ConfigEntry<EFogSetting.FogType> farFogType = new ConfigEntry.Builder<EFogSetting.FogType>()
.set(EFogSetting.FogType.EXPONENTIAL_SQUARED)
public static ConfigEntry<EFogFalloff> farFogType = new ConfigEntry.Builder<EFogFalloff>()
.set(EFogFalloff.EXPONENTIAL_SQUARED)
.comment(""
+ "How the fog thickness should be calculated from distance? \n"
+ "How should the fog thickness should be calculated? \n"
+ "\n"
+ EFogSetting.FogType.LINEAR + ": Linear based on distance (will ignore 'density')\n"
+ EFogSetting.FogType.EXPONENTIAL + ": 1/(e^(distance*density)) \n"
+ EFogSetting.FogType.EXPONENTIAL_SQUARED + ": 1/(e^((distance*density)^2)")
+ EFogFalloff.LINEAR + ": Linear based on distance (will ignore 'density')\n"
+ EFogFalloff.EXPONENTIAL + ": 1/(e^(distance*density)) \n"
+ EFogFalloff.EXPONENTIAL_SQUARED + ": 1/(e^((distance*density)^2)")
.build();
public static ConfigEntry<Double> farFogDensity = new ConfigEntry.Builder<Double>()
@@ -349,14 +349,14 @@ public class Config
+ " '1.0': Fully fog color.")
.build();
public static ConfigEntry<EFogSetting.FogType> heightFogType = new ConfigEntry.Builder<EFogSetting.FogType>()
.set(EFogSetting.FogType.EXPONENTIAL_SQUARED)
public static ConfigEntry<EFogFalloff> heightFogType = new ConfigEntry.Builder<EFogFalloff>()
.set(EFogFalloff.EXPONENTIAL_SQUARED)
.comment(""
+ "How the fog thickness should be calculated from height? \n"
+ "\n"
+ EFogSetting.FogType.LINEAR + ": Linear based on height (will ignore 'density')\n"
+ EFogSetting.FogType.EXPONENTIAL + ": 1/(e^(height*density)) \n"
+ EFogSetting.FogType.EXPONENTIAL_SQUARED + ": 1/(e^((height*density)^2)")
+ EFogFalloff.LINEAR + ": Linear based on height (will ignore 'density')\n"
+ EFogFalloff.EXPONENTIAL + ": 1/(e^(height*density)) \n"
+ EFogFalloff.EXPONENTIAL_SQUARED + ": 1/(e^((height*density)^2)")
.build();
public static ConfigEntry<Double> heightFogDensity = new ConfigEntry.Builder<Double>()
@@ -35,7 +35,7 @@ public enum EFogDrawMode
/**
* Use whatever Fog setting optifine is using.
* If optifine isn't installed this defaults to ALWAYS_DRAW_FOG.
* If optifine isn't installed this defaults to FOG_ENABLED.
*/
USE_OPTIFINE_SETTING,
@@ -0,0 +1,22 @@
package com.seibel.lod.core.enums.rendering;
/**
* LINEAR, <br>
* EXPONENTIAL, <br>
* EXPONENTIAL_SQUARED <br>
*
* @author Leetom
* @version 2022-6-30
*/
public enum EFogFalloff
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
LINEAR,
EXPONENTIAL,
EXPONENTIAL_SQUARED,
// TEXTURE_BASED, // TODO: Impl this
}
@@ -29,7 +29,7 @@ import java.util.Objects;
public class EFogSetting
{
/** a FogSetting object with 0 for every value */
public static final EFogSetting EMPTY = new EFogSetting(0, 0, 0, 0,0, EFogSetting.FogType.LINEAR);
public static final EFogSetting EMPTY = new EFogSetting(0, 0, 0, 0,0, EFogFalloff.LINEAR);
public final double start;
@@ -37,9 +37,9 @@ public class EFogSetting
public final double min;
public final double max;
public final double density;
public final FogType fogType;
public final EFogFalloff fogType;
public EFogSetting(double start, double end, double min, double max, double density, FogType fogType)
public EFogSetting(double start, double end, double min, double max, double density, EFogFalloff fogType)
{
this.start = start;
this.end = end;
@@ -66,13 +66,5 @@ public class EFogSetting
return Objects.hash(start, end, min, max, density, fogType);
}
public enum FogType
{
LINEAR,
EXPONENTIAL,
EXPONENTIAL_SQUARED,
// TEXTURE_BASED, // TODO: Impl this
}
}
@@ -20,16 +20,16 @@
package com.seibel.lod.core.enums.rendering;
/**
* basic <br>
* Ignore_Height <br>
* Addition <br>
* Max <br>
* Multiply <br>
* Inverse_Multiply <br>
* Limited_Addition <br>
* Multiply_Addition <br>
* Inverse_Multiply_Addition <br>
* Average <br>
* BASIC <br>
* IGNORE_HEIGHT <br>
* ADDITION <br>
* MAX <br>
* MULTIPLY <br>
* INVERSE_MULTIPLY <br>
* LIMITED_ADDITION <br>
* MULTIPLY_ADDITION <br>
* INVERSE_MULTIPLY_ADDITION <br>
* AVERAGE <br>
*
* @author Leetom
* @version 2022-4-14
@@ -19,8 +19,24 @@
package com.seibel.lod.core.enums.rendering;
/**
* ABOVE_CAMERA, <br>
* BELOW_CAMERA, <br>
* ABOVE_AND_BELOW_CAMERA, <br>
* ABOVE_SET_HEIGHT, <br>
* BELOW_SET_HEIGHT, <br>
* ABOVE_AND_BELOW_SET_HEIGHT, <br>
*
* @author Leetom
* @version 6-30-2022
*/
public enum EHeightFogMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
ABOVE_CAMERA(true, true, false),
BELOW_CAMERA(true, false, true),
ABOVE_AND_BELOW_CAMERA(true, true, true),
@@ -260,7 +260,7 @@ public class LodFogConfig
return str;
}
private static String getFarFogMethod(EFogSetting.FogType fogType)
private static String getFarFogMethod(EFogFalloff fogType)
{
switch (fogType)
{
@@ -308,7 +308,7 @@ public class LodFogConfig
* Example: <br>
* <code>" return linearFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange);"</code>
*/
private static String getHeightFogMethod(EFogSetting.FogType fogType)
private static String getHeightFogMethod(EFogFalloff fogType)
{
switch (fogType)
{
@@ -20,7 +20,6 @@
package com.seibel.lod.core.wrapperInterfaces.config;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.config.types.ConfigCategory;
import com.seibel.lod.core.enums.rendering.EFogDrawMode;
import com.seibel.lod.core.enums.rendering.EFogColorMode;
import com.seibel.lod.core.enums.rendering.EFogDistance;
@@ -122,8 +121,8 @@ public interface ILodConfigWrapperSingleton extends IBindable
double getFarFogMax();
void setFarFogMax(double newFarFogMax);
EFogSetting.FogType getFarFogType();
void setFarFogType(EFogSetting.FogType newFarFogType);
EFogFalloff getFarFogType();
void setFarFogType(EFogFalloff newFarFogType);
double getFarFogDensity();
void setFarFogDensity(double newFarFogDensity);
@@ -152,8 +151,8 @@ public interface ILodConfigWrapperSingleton extends IBindable
double getHeightFogMax();
void setHeightFogMax(double newHeightFogMax);
EFogSetting.FogType getHeightFogType();
void setHeightFogType(EFogSetting.FogType newFarFogType);
EFogFalloff getHeightFogType();
void setHeightFogType(EFogFalloff newFarFogType);
double getHeightFogDensity();
void setHeightFogDensity(double newHeightFogDensity);
@@ -287,7 +287,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax.get();
}
@Override
public EFogSetting.FogType getFarFogType() {
public EFogFalloff getFarFogType() {
return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType.get();
}
@Override
@@ -312,7 +312,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax.set(newFarFogMax);
}
@Override
public void setFarFogType(EFogSetting.FogType newFarFogType) {
public void setFarFogType(EFogFalloff newFarFogType) {
Config.Client.Graphics.FogQuality.AdvancedFog.farFogType.set(newFarFogType);
}
@Override
@@ -356,7 +356,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMax.get();
}
@Override
public EFogSetting.FogType getHeightFogType() {
public EFogFalloff getHeightFogType() {
return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogType.get();
}
@Override
@@ -393,7 +393,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMax.set(newHeightFogMax);
}
@Override
public void setHeightFogType(EFogSetting.FogType newHeightFogType) {
public void setHeightFogType(EFogFalloff newHeightFogType) {
Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogType.set(newHeightFogType);
}
@Override