Merge remote-tracking branch 'upstream-core/main'

This commit is contained in:
Steveplays28
2023-08-18 15:12:11 +02:00
92 changed files with 389 additions and 228 deletions
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverri
*
* @author James Seibel
* @version 2023-6-29
* @since API 1.0.0
*/
public class DhApi
{
@@ -38,25 +39,35 @@ public class DhApi
* Bind a custom {@link DhApiAfterDhInitEvent DhApiAfterDhInitEvent}
* to {@link DhApi#events ApiCoreInjectors.events} in order to be notified when this class can
* be safely used.
*
* @since API 1.0.0
*/
public static class Delayed
{
/** Used to interact with Distant Horizons' Configs. */
/**
* Used to interact with Distant Horizons' Configs.
* @since API 1.0.0
*/
public static IDhApiConfig configs = null;
/**
* Used to interact with Distant Horizons' terrain data.
* Designed to be used in conjunction with {@link DhApi.Delayed#worldProxy}.
* @since API 1.0.0
*/
public static IDhApiTerrainDataRepo terrainRepo = null;
/**
* Used to interact with Distant Horizons' currently loaded world.
* Designed to be used in conjunction with {@link DhApi.Delayed#terrainRepo}.
* @since API 1.0.0
*/
public static IDhApiWorldProxy worldProxy = null;
/** Used to interact with Distant Horizons' rendering system. */
/**
* Used to interact with Distant Horizons' rendering system.
* @since API 1.0.0
*/
public static IDhApiRenderProxy renderProxy = null;
}
@@ -64,33 +75,58 @@ public class DhApi
// always available //
/** Used to bind/unbind Distant Horizons Api events. */
/**
* Used to bind/unbind Distant Horizons Api events.
* @since API 1.0.0
*/
public static final IDhApiEventInjector events = ApiEventInjector.INSTANCE;
/** Used to bind/unbind Distant Horizons Api events. */
/**
* Used to bind/unbind Distant Horizons Api events.
* @since API 1.0.0
*/
public static final IDhApiWorldGeneratorOverrideRegister worldGenOverrides = DhApiWorldGeneratorOverrideRegister.INSTANCE;
/** Used to bind overrides to change Distant Horizons' core behavior. */
/**
* Used to bind overrides to change Distant Horizons' core behavior.
* @since API 1.0.0
*/
public static final IOverrideInjector<IDhApiOverrideable> overrides = OverrideInjector.INSTANCE;
/** This version should only be updated when breaking changes are introduced to the Distant Horizons API. */
/**
* This version should only be updated when breaking changes are introduced to the Distant Horizons API.
* @since API 1.0.0
*/
public static int getApiMajorVersion() { return ModInfo.API_MAJOR_VERSION; }
/** This version should be updated whenever new methods are added to the Distant Horizons API. */
/**
* This version should be updated whenever new methods are added to the Distant Horizons API.
* @since API 1.0.0
*/
public static int getApiMinorVersion() { return ModInfo.API_MINOR_VERSION; }
/** This version should be updated whenever non-breaking fixes are added to the Distant Horizons API. */
/**
* This version should be updated whenever non-breaking fixes are added to the Distant Horizons API.
* @since API 1.0.0
*/
public static int getApiPatchVersion() { return ModInfo.API_PATH_VERSION; }
/**
* Returns the mod's semantic version number in the format: Major.Minor.Patch
* with optional extensions "-a" for alpha, "-b" for beta, and -dev for unstable development builds. <br>
* Examples: "1.6.9-a", "1.7.0-a-dev", "2.1.0-b", "3.0.0", "3.1.4-dev"
* @since API 1.0.0
*/
public static String getModVersion() { return ModInfo.VERSION; }
/** Returns true if the mod is a development version, false if it is a release version. */
/**
* Returns true if the mod is a development version, false if it is a release version.
* @since API 1.0.0
*/
public static boolean getIsDevVersion() { return ModInfo.IS_DEV_BUILD; }
/** Returns the network protocol version. */
/**
* Returns the network protocol version.
* @since API 1.0.0
*/
public static int getNetworkProtocolVersion() { return ModInfo.PROTOCOL_VERSION; }
}
@@ -16,6 +16,7 @@ package com.seibel.distanthorizons.api.enums;
*
* @author James Seibel
* @version 2022-12-5
* @since API 1.0.0
*/
public enum EDhApiDetailLevel
{
@@ -22,6 +22,8 @@ package com.seibel.distanthorizons.api.enums.config;
/**
* NONE, <br>
* NON_COLLIDING, <br>
*
* @since API 1.0.0
*/
public enum EBlocksToAvoid
{
@@ -29,6 +29,7 @@ package com.seibel.distanthorizons.api.enums.config;
* @author Leetom
* @author James Seibel
* @version 2022-7-2
* @since API 1.0.0
*/
public enum EGpuUploadMethod
{
@@ -25,6 +25,8 @@ package com.seibel.distanthorizons.api.enums.config;
* MEDIUM <br>
* HIGH <br>
* UNLIMITED <br>
*
* @since API 1.0.0
*/
public enum EHorizontalQuality
{
@@ -25,6 +25,7 @@ package com.seibel.distanthorizons.api.enums.config;
*
* @author Leetom
* @version 2023-6-7
* @since API 1.0.0
*/
public enum ELightGenerationMode
{
@@ -23,6 +23,8 @@ package com.seibel.distanthorizons.api.enums.config;
* MINECRAFT <br>
* OLD_LIGHTING <br>
* NONE <br>
*
* @since API 1.0.0
*/
public enum ELodShading
{
@@ -21,6 +21,9 @@ package com.seibel.distanthorizons.api.enums.config;
import org.apache.logging.log4j.Level;
/**
* @since API 1.0.0
*/
public enum ELoggerMode
{
DISABLED(Level.OFF, Level.OFF),
@@ -34,6 +34,7 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
* @author James Seibel
* @author Leonardo Amato
* @version 2023-6-14
* @since API 1.0.0
*/
public enum EMaxHorizontalResolution
{
@@ -23,7 +23,9 @@ package com.seibel.distanthorizons.api.enums.config;
* NONE <br>
* LIGHT <br>
* MEDIUM <br>
* HEAVY <br> <br>
* HEAVY <br>
*
* @since API 1.0.0
*/
public enum EOverdrawPrevention
{
@@ -30,6 +30,7 @@ package com.seibel.distanthorizons.api.enums.config;
*
* @author James Seibel
* @version 2022-7-1
* @since API 1.0.0
*/
public enum EServerFolderNameMode
{
@@ -30,6 +30,7 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
*
* @author Leonardo Amato
* @version 2023-2-5
* @since API 1.0.0
*/
public enum EVerticalQuality
{
@@ -29,6 +29,8 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
* MEDIUM, <br>
* HIGH, <br>
* EXTREME, <br>
*
* @since API 1.0.0
*/
public enum EQualityPreset
{
@@ -28,7 +28,8 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
* LOW_IMPACT, <br>
* BALANCED, <br>
* AGGRESSIVE, <br>
* I_PAID_FOR_THE_WHOLE_CPU, <br>
*
* @since API 1.0.0
*/
public enum EThreadPreset
{
@@ -29,6 +29,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
* @author Leetom
* @author James Seibel
* @version 2023-6-7
* @since API 1.0.0
*/
public enum EDebugRendering
{
@@ -25,6 +25,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author James Seibel
* @version 2022-6-9
* @since API 1.0.0
*/
public enum EFogColorMode
{
@@ -20,10 +20,13 @@
package com.seibel.distanthorizons.api.enums.rendering;
/**
* NEAR, FAR, or NEAR_AND_FAR.
* NEAR, <br>
* FAR, <br>
* NEAR_AND_FAR <br>
*
* @author James Seibel
* @version 2022-6-2
* @since API 1.0.0
*/
public enum EFogDistance
{
@@ -26,6 +26,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author James Seibel
* @version 2022-6-2
* @since API 1.0.0
*/
public enum EFogDrawMode
{
@@ -7,6 +7,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author Leetom
* @version 2022-6-30
* @since API 1.0.0
*/
public enum EFogFalloff
{
@@ -33,6 +33,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author Leetom
* @version 2022-4-14
* @since API 1.0.0
*/
public enum EHeightFogMixMode
{
@@ -29,6 +29,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author Leetom
* @version 6-30-2022
* @since API 1.0.0
*/
public enum EHeightFogMode
{
@@ -20,11 +20,12 @@
package com.seibel.distanthorizons.api.enums.rendering;
/**
* Default
* Debug
* Disabled
* Default <br>
* Debug <br>
* Disabled <br>
*
* @version 2022-6-2
* @since API 1.0.0
*/
public enum ERendererMode
{
@@ -23,6 +23,8 @@ package com.seibel.distanthorizons.api.enums.rendering;
* DISABLED, <br>
* FAKE, <br>
* COMPLETE, <br>
*
* @since API 1.0.0
*/
public enum ETransparency
{
@@ -32,6 +32,7 @@ package com.seibel.distanthorizons.api.enums.worldGeneration;
* @author James Seibel
* @author Leonardo Amato
* @version 2022-12-10
* @since API 1.0.0
*/
public enum EDhApiDistantGeneratorMode
{
@@ -7,6 +7,7 @@ package com.seibel.distanthorizons.api.enums.worldGeneration;
*
* @author James Seibel
* @version 2022-7-13
* @since API 1.0.0
*/
public enum EDhApiLevelType
{
@@ -1,32 +0,0 @@
package com.seibel.distanthorizons.api.enums.worldGeneration;
/**
* MULTI_THREADED, <br>
* SINGLE_THREADED, <br>
* SERVER_THREAD, <br>
*
* @author James Seibel
* @version 7-14-2022
*/
@Deprecated // not currently in use, if the config this enum represents is re-implemented, the deprecated flag can be removed
public enum EDhApiWorldGenThreadMode
{
/**
* This world generator can be run on an unlimited number
* of concurrent threads.
*/
MULTI_THREADED,
/**
* This world generator can only be run on one thread at
* a time, however that thread can run concurrently
* to Minecraft's server thread.
*/
SINGLE_THREADED,
/**
* This world generator can only be run on Minecraft's
* server thread.
*/
SERVER_THREAD,
}
@@ -14,6 +14,7 @@ package com.seibel.distanthorizons.api.enums.worldGeneration;
*
* @author James Seibel
* @version 2023-4-20
* @since API 1.0.0
*/
public enum EDhApiWorldGenerationStep
{
@@ -6,6 +6,7 @@ package com.seibel.distanthorizons.api.interfaces;
*
* @author James Seibel
* @version 2023-6-17
* @since API 1.0.0
*/
public interface IDhApiUnsafeWrapper
{
@@ -26,6 +26,7 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
*
* @author James Seibel
* @version 3-5-2022
* @since API 1.0.0
*/
public interface IDhApiBiomeWrapper extends IDhApiUnsafeWrapper
{
@@ -7,6 +7,7 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
*
* @author James Seibel
* @version 2023-6-11
* @since API 1.0.0
*/
public interface IDhApiBlockStateWrapper extends IDhApiUnsafeWrapper
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.api.interfaces.config.client.*;
*
* @author James Seibel
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiConfig
{
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
*
* @author James Seibel
* @version 9-15-2022
* @since API 1.0.0
*/
public interface IDhApiConfigGroup extends IBindable
{
@@ -6,6 +6,7 @@ package com.seibel.distanthorizons.api.interfaces.config;
* @param <T> The data type of this config.
* @author James Seibel
* @version 2022-9-15
* @since API 1.0.0
*/
public interface IDhApiConfigValue<T>
{
@@ -31,6 +31,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2022-9-15
* @since API 1.0.0
*/
public interface IDhApiWorldGenerationConfig extends IDhApiConfigGroup
{
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2022-9-15
* @since API 1.0.0
*/
public interface IDhApiDebuggingConfig extends IDhApiConfigGroup
{
@@ -33,6 +33,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
*
* @author James Seibel
* @version 2022-6-14
* @since API 1.0.0
*/
public interface IDhApiFarFogConfig extends IDhApiConfigGroup
{
@@ -35,6 +35,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
*
* @author James Seibel
* @version 2022-6-14
* @since API 1.0.0
*/
public interface IDhApiFogConfig extends IDhApiConfigGroup
{
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
*
* @author James Seibel
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiGpuBuffersConfig extends IDhApiConfigGroup
{
@@ -31,6 +31,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
{
@@ -34,6 +34,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
*
* @author James Seibel
* @version 2022-6-14
* @since API 1.0.0
*/
public interface IDhApiHeightFogConfig extends IDhApiConfigGroup
{
@@ -26,6 +26,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2022-6-14
* @since API 1.0.0
*/
public interface IDhApiLoggingConfig extends IDhApiConfigGroup
{
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiMultiThreadingConfig extends IDhApiConfigGroup
{
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
*
* @author James Seibel
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiMultiplayerConfig extends IDhApiConfigGroup
{
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
*
* @author James Seibel
* @version 2022-6-14
* @since API 1.0.0
*/
public interface IDhApiNoiseTextureConfig extends IDhApiConfigGroup
{
@@ -12,6 +12,7 @@ import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
*
* @author James Seibel
* @version 2023-6-22
* @since API 1.0.0
*/
public interface IDhApiTerrainDataRepo
{
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IDepend
*
* @author James Seibel
* @version 2022-9-13
* @since API 1.0.0
*/
public interface IDhApiEventInjector extends IDependencyInjector<IDhApiEvent>
{
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverri
*
* @author James Seibel
* @version 2022-9-5
* @since API 1.0.0
*/
public interface IDhApiOverrideable extends IBindable
{
@@ -13,6 +13,7 @@ import java.util.function.Consumer;
/**
* @author James Seibel
* @version 2023-6-22
* @since API 1.0.0
*/
public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDhApiOverrideable, IDhApiWorldGenerator
{
@@ -12,6 +12,7 @@ import java.util.function.Consumer;
/**
* @author James Seibel
* @version 2023-6-22
* @since API 1.0.0
*/
public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
{
@@ -19,12 +20,6 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
// parameters //
//============//
/*
* Returns which thread chunk generation requests will be run on. <br>
* TODO: only {@link EDhApiWorldGenThreadMode#MULTI_THREADED} is implemented
*/
//EDhApiWorldGenThreadMode getThreadingMode();
/**
* Defines the smallest datapoint size that can be generated at a time. <br>
* Minimum detail level is 0 (1 block) <br>
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.api.objects.DhApiResult;
*
* @author James Seibel
* @version 2022-12-10
* @since API 1.0.0
*/
public interface IDhApiWorldGeneratorOverrideRegister
{
@@ -26,6 +26,7 @@ import com.seibel.distanthorizons.api.objects.DhApiResult;
*
* @author James Seibel
* @version 2023-2-8
* @since API 1.0.0
*/
public interface IDhApiRenderProxy
{
@@ -24,6 +24,7 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
/**
* @author James Seibel
* @version 2022-7-14
* @since API 1.0.0
*/
public interface IDhApiDimensionTypeWrapper extends IDhApiUnsafeWrapper
{
@@ -28,6 +28,7 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
*
* @author James Seibel
* @version 2022-7-14
* @since API 1.0.0
*/
public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
{
@@ -25,6 +25,7 @@ package com.seibel.distanthorizons.api.interfaces.world;
*
* @author James Seibel
* @version 2022-11-20
* @since API 1.0.0
*/
public interface IDhApiWorldProxy
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
*
* @author James Seibel
* @version 2022-9-16
* @since API 1.0.0
*/
public class DhApiEventRegister
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public abstract class DhApiAfterDhInitEvent implements IDhApiEvent<Void>, IDhApiOneTimeEvent<Void>
{
@@ -12,6 +12,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
* @author James Seibel
* @version 2023-6-23
* @see DhApiRenderParam
* @since API 1.0.0
*/
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRenderEvent.EventParam>
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public abstract class DhApiBeforeDhInitEvent implements IDhApiEvent<Void>
{
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public abstract class DhApiBeforeRenderEvent implements IDhApiCancelableEvent<DhApiBeforeRenderEvent.EventParam>
{
@@ -14,6 +14,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
* @author James Seibel
* @version 2023-6-23
* @see IDhApiTerrainDataRepo
* @since API 1.0.0
*/
public abstract class DhApiChunkModifiedEvent implements IDhApiEvent<DhApiChunkModifiedEvent.EventParam>
{
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public abstract class DhApiLevelLoadEvent implements IDhApiEvent<DhApiLevelLoadEvent.EventParam>
{
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public abstract class DhApiLevelUnloadEvent implements IDhApiEvent<DhApiLevelUnloadEvent.EventParam>
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public interface IDhApiCancelableEvent<T> extends IDhApiEvent<T>
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
* @param <T> This is the datatype that will be passed into the event handler's method.
* @author James Seibel
* @version 2023-6-23
* @since API 1.0.0
*/
public interface IDhApiEvent<T> extends IBindable
{
@@ -5,6 +5,8 @@ package com.seibel.distanthorizons.api.methods.events.interfaces;
* An example of this would be initial setup methods, DH won't run its initial setup more than once. <br><br>
*
* If a handler is bound to a one time event after the event has been fired, the handler will immediately fire.
*
* @since API 1.0.0
*/
public interface IDhApiOneTimeEvent<T> extends IDhApiEvent<T>
{
@@ -1,6 +1,10 @@
package com.seibel.distanthorizons.api.methods.events.sharedParameterObjects;
/** Extension of {@link DhApiEventParam} that allows the event to be canceled. */
/**
* Extension of {@link DhApiEventParam} that allows the event to be canceled.
*
* @since API 1.0.0
*/
public class DhApiCancelableEventParam<T> extends DhApiEventParam<T>
{
public DhApiCancelableEventParam(T value) { super(value); }
@@ -2,7 +2,11 @@ package com.seibel.distanthorizons.api.methods.events.sharedParameterObjects;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
/** Wraps the event parameter to allow for additional control over the event */
/**
* Wraps the event parameter to allow for additional control over the event
*
* @since API 1.0.0
*/
public class DhApiEventParam<T>
{
/** Depending on the {@link IDhApiEvent} this can be null. */
@@ -7,6 +7,7 @@ import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
*
* @author James Seibel
* @version 2022-9-5
* @since API 1.0.0
*/
public class DhApiRenderParam
{
@@ -11,6 +11,7 @@ import com.seibel.distanthorizons.coreapi.DependencyInjection.WorldGeneratorInje
*
* @author James Seibel
* @version 2022-12-10
* @since API 1.0.0
*/
public class DhApiWorldGeneratorOverrideRegister implements IDhApiWorldGeneratorOverrideRegister
{
@@ -6,6 +6,7 @@ package com.seibel.distanthorizons.api.objects;
* @param <T> The payload type this result contains, can be Void if the result is just used to notify success/failure.
* @author James Seibel
* @version 2022-11-24
* @since API 1.0.0
*/
public class DhApiResult<T>
{
@@ -16,6 +16,7 @@ import com.seibel.distanthorizons.coreapi.util.converters.DefaultConverter;
* @param <coreType> The datatype Distant Horizons uses in the background; implementing developers can ignore this.
* @author James Seibel
* @version 2022-6-30
* @since API 1.0.0
*/
public class DhApiConfigValue<coreType, apiType> implements IDhApiConfigValue<apiType>
{
@@ -9,6 +9,7 @@ import com.seibel.distanthorizons.coreapi.util.math.Vec3i;
*
* @author James Seibel
* @version 2022-11-19
* @since API 1.0.0
*/
public class DhApiRaycastResult
{
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
*
* @author James Seibel
* @version 2022-11-13
* @since API 1.0.0
*/
public class DhApiTerrainDataPoint
{
@@ -25,6 +25,7 @@ package com.seibel.distanthorizons.api.objects.math;
*
* @author James Seibel
* @version 2022-11-19
* @since API 1.0.0
*/
public class DhApiVec3i
{
@@ -2,6 +2,8 @@ package com.seibel.distanthorizons.core.config.eventHandlers.presets;
import com.seibel.distanthorizons.core.config.ConfigEntryWithPresetOptions;
import com.seibel.distanthorizons.core.config.listeners.IConfigListener;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
import com.seibel.distanthorizons.coreapi.interfaces.config.IConfigEntry;
import com.seibel.distanthorizons.coreapi.util.StringUtil;
import org.apache.logging.log4j.LogManager;
@@ -12,23 +14,43 @@ import java.util.*;
public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<?>> implements IConfigListener
{
private static final Logger LOGGER = LogManager.getLogger();
private static final long MS_DELAY_BEFORE_APPLYING_PRESET = 1_000;
private static final long MS_DELAY_BEFORE_APPLYING_PRESET = 3_000;
private static IConfigGui configGui = SingletonInjector.INSTANCE.get(IConfigGui.class);
private static boolean guiListenersAdded = false;
protected final ArrayList<ConfigEntryWithPresetOptions<TPresetEnum, ?>> configList = new ArrayList<>();
/** this timer is used so each preset isn't applied while a user is clicking through the config options */
protected Timer presetApplicationTimer;
protected Timer applyPresetTimer = null;
/** the enum to apply after the timer expires or the UI screen changes. */
protected TPresetEnum waitingPresetEnum = null;
protected boolean changingPreset = false;
//=============//
// constructor //
//=============//
public AbstractPresetConfigEventHandler()
{
configGui.addOnScreenChangeListener(() -> this.onConfigUiClosed());
}
//=========//
// methods //
//=========//
/**
* Set the UI only config based on what is set in the file. <br>
* This should only be called once.
*/
public void setUiOnlyConfigValues()
{
TPresetEnum currentQualitySetting = this.getCurrentQualityPreset();
TPresetEnum currentQualitySetting = this.getCurrentPreset();
this.getPresetConfigEntry().set(currentQualitySetting);
}
@@ -40,45 +62,66 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
@Override
public void onConfigValueSet()
{
TPresetEnum presetEnum = this.getPresetConfigEntry().get();
// if the quick value is custom, nothing needs to be changed
if (presetEnum == this.getCustomPresetEnum())
// don't have this method run on top of itself
if (this.changingPreset)
{
return;
}
// stop the previous timer if one exists
if (this.presetApplicationTimer != null)
// if the quick value is custom, nothing needs to be changed
TPresetEnum presetEnum = this.getPresetConfigEntry().get();
if (presetEnum == this.getCustomPresetEnum())
{
this.presetApplicationTimer.cancel();
return;
}
this.waitingPresetEnum = presetEnum;
// stop the previous timer if one exists
if (this.applyPresetTimer != null)
{
this.applyPresetTimer.cancel();
}
// reset the timer
TimerTask task = new TimerTask()
{
public void run() { AbstractPresetConfigEventHandler.this.applyPreset(presetEnum); }
public void run() { AbstractPresetConfigEventHandler.this.applyPreset(); }
};
this.presetApplicationTimer = new Timer("PresetApplicationTimer");
this.presetApplicationTimer.schedule(task, MS_DELAY_BEFORE_APPLYING_PRESET);
this.applyPresetTimer = new Timer("ApplyPresetTimer");
this.applyPresetTimer.schedule(task, MS_DELAY_BEFORE_APPLYING_PRESET);
}
private void applyPreset(TPresetEnum presetEnum)
private void applyPreset()
{
LOGGER.debug("changing preset to: " + presetEnum);
this.changingPreset = true;
TPresetEnum newPresetEnum = this.waitingPresetEnum;
this.waitingPresetEnum = null;
for (ConfigEntryWithPresetOptions<TPresetEnum, ?> configEntry : this.configList)
// only continue if a preset was waiting to be applied
if (newPresetEnum == null)
{
configEntry.updateConfigEntry(presetEnum);
return;
}
LOGGER.info("changing preset to: " + newPresetEnum);
this.changingPreset = true;
// update the controlled config values
for (ConfigEntryWithPresetOptions<TPresetEnum, ?> configEntry : this.configList)
{
configEntry.updateConfigEntry(newPresetEnum);
}
// update the preset value (required to make sure the UI value changes correctly after the UI page changes).
this.setUiOnlyConfigValues();
this.changingPreset = false;
LOGGER.debug("preset active: " + presetEnum);
LOGGER.info("preset active: " + newPresetEnum);
}
@Override
public void onUiModify() { /* do nothing, we only care about modified config values */ }
@@ -95,7 +138,7 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
}
TPresetEnum newPreset = this.getCurrentQualityPreset();
TPresetEnum newPreset = this.getCurrentPreset();
TPresetEnum currentPreset = this.getPresetConfigEntry().get();
if (newPreset != currentPreset)
@@ -104,6 +147,15 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
}
}
public void onConfigUiClosed()
{
// apply the preset if one is waiting to be applied
if (this.applyPresetTimer != null)
{
this.applyPresetTimer.cancel();
this.applyPreset();
}
}
//================//
@@ -111,7 +163,7 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
//================//
/** @return what {@link TPresetEnum} is currently viable based on the {@link AbstractPresetConfigEventHandler#configList}. */
public TPresetEnum getCurrentQualityPreset()
public TPresetEnum getCurrentPreset()
{
// get all quick options
HashSet<TPresetEnum> possiblePresetSet = new HashSet<>(this.getPresetEnumList());
@@ -10,6 +10,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSha
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -24,23 +26,27 @@ public class ConfigFileHandling
private static final Logger LOGGER = ConfigBase.LOGGER;
public final ConfigBase configBase;
public final Path ConfigPath;
public final Path configPath;
public ConfigFileHandling(ConfigBase configBase)
{
this.configBase = configBase;
ConfigPath = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class)
configPath = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class)
.getInstallationDirectory().toPath().resolve("config").resolve(this.configBase.modName + ".toml");
}
/** Saves the entire config to the file */
public void saveToFile()
{
CommentedFileConfig config = CommentedFileConfig.builder(ConfigPath.toFile()).build();
if (!Files.exists(ConfigPath)) // Try to check if the config exists
CommentedFileConfig config = CommentedFileConfig.builder(configPath.toFile()).build();
if (!Files.exists(configPath)) // Try to check if the config exists
try
{
Files.createFile(ConfigPath);
if (!this.configPath.getParent().toFile().exists())
{
Files.createDirectory(this.configPath.getParent());
}
Files.createFile(configPath);
}
catch (IOException ex)
{
@@ -66,7 +72,7 @@ public class ConfigFileHandling
catch (Exception e)
{
// If it fails to save, crash game
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Failed to save config at [" + ConfigPath.toString() + "]", e);
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Failed to save config at [" + configPath.toString() + "]", e);
}
config.close();
}
@@ -77,11 +83,11 @@ public class ConfigFileHandling
*/
public void loadFromFile()
{
CommentedFileConfig config = CommentedFileConfig.builder(ConfigPath.toFile()).build();
CommentedFileConfig config = CommentedFileConfig.builder(configPath.toFile()).build();
// Attempt to load the file and if it fails then save config to file
try
{
if (Files.exists(ConfigPath))
if (Files.exists(configPath))
config.load();
else
{
@@ -114,7 +120,7 @@ public class ConfigFileHandling
catch (Exception e)
{
// If it fails to save, crash game
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Failed to save config at [" + ConfigPath.toString() + "]", e);
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Failed to save config at [" + configPath.toString() + "]", e);
}
config.close();
}
@@ -125,7 +131,7 @@ public class ConfigFileHandling
// Save an entry when only given the entry
public void saveEntry(ConfigEntry<?> entry)
{
CommentedFileConfig config = CommentedFileConfig.builder(ConfigPath.toFile()).build();
CommentedFileConfig config = CommentedFileConfig.builder(configPath.toFile()).build();
loadConfig(config);
saveEntry(entry, config);
config.save();
@@ -151,7 +157,7 @@ public class ConfigFileHandling
// Loads an entry when only given the entry
public void loadEntry(ConfigEntry<?> entry)
{
CommentedFileConfig config = CommentedFileConfig.builder(ConfigPath.toFile()).autosave().build();
CommentedFileConfig config = CommentedFileConfig.builder(configPath.toFile()).autosave().build();
loadConfig(config);
loadEntry(entry, config);
config.close();
@@ -205,7 +211,7 @@ public class ConfigFileHandling
// Creates the comment for an entry when only given the entry
public void createComment(ConfigEntry<?> entry)
{
CommentedFileConfig config = CommentedFileConfig.builder(ConfigPath.toFile()).autosave().build();
CommentedFileConfig config = CommentedFileConfig.builder(configPath.toFile()).autosave().build();
loadConfig(config);
createComment(entry, config);
config.close();
@@ -236,18 +242,32 @@ public class ConfigFileHandling
System.out.println("Loading file failed because of this expectation:\n" + e);
try
{ // Now try remaking the file and loading it
if (!ConfigPath.getParent().toFile().exists())
Files.createDirectory(ConfigPath.getParent());
else
Files.deleteIfExists(ConfigPath);
Files.createFile(ConfigPath);
if (!this.configPath.getParent().toFile().exists())
{
Files.createDirectory(this.configPath.getParent());
}
try
{
boolean fileDeleted = Files.deleteIfExists(this.configPath);
System.out.println("File at [" + this.configPath + "] was " + (fileDeleted ? "" : "not ") + "able to be deleted.");
}
catch (AccessDeniedException ignored) { /* temporary fix due to windows/Intellij issues either locking or changing the permissions of the file */ }
try
{
Files.createFile(this.configPath);
}
catch (FileAlreadyExistsException ignore) { /* temporary fix due to windows/Intellij issues either locking or changing the permissions of the file */ }
config.load();
}
catch (IOException ex)
{
System.out.println("Creating file failed");
ex.printStackTrace();
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path [" + ConfigPath + "]. Please check the file is ok and you have the permissions", ex);
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path [" + configPath + "]. Please check the file is ok and you have the permissions", ex);
}
}
}
@@ -69,7 +69,7 @@ public class ColumnRenderBufferBuilder
boolean enableTransparency = Config.Client.Advanced.Graphics.Quality.transparency.get().transparencyEnabled;
EVENT_LOGGER.trace("RenderRegion start QuadBuild @ " + renderSource.sectionPos);
boolean enableSkyLightCulling = Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling.get();
boolean enableSkyLightCulling = !clientLevel.getLevelWrapper().hasCeiling() && Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling.get();
int skyLightCullingBelow = Config.Client.Advanced.Graphics.AdvancedGraphics.caveCullingHeight.get();
// FIXME: Clamp also to the max world height.
@@ -226,8 +226,8 @@ public class FullDataToRenderDataTransformer
int hash = columnArrayView.getDataHash();
SingleColumnFullDataAccessor fullArrayView = chunkDataView.get(ox * dataToSourceScale, oz * dataToSourceScale);
convertColumnData(level,
sourceBlockX + sourceDataPointBlockWidth * relSourceX * dataToSourceScale,
sourceBlockZ + sourceDataPointBlockWidth * relSourceZ * dataToSourceScale,
sourceBlockX + sourceDataPointBlockWidth * relSourceX,
sourceBlockZ + sourceDataPointBlockWidth * relSourceZ,
columnArrayView, fullArrayView, 2);
changed |= hash != columnArrayView.getDataHash();
}
@@ -80,6 +80,24 @@ public class RenderMetaDataFile extends AbstractMetaDataContainerFile implements
// constructor //
//=============//
/**
* Can be used instead of {@link RenderMetaDataFile#createFromExistingFile} or {@link RenderMetaDataFile#createNewFileForPos},
* if we are uncertain whether a file exists or not.
*/
public static RenderMetaDataFile createFromExistingOrNewFile(RenderSourceFileHandler fileHandler, DhSectionPos pos) throws IOException
{
File file = fileHandler.computeRenderFilePath(pos);
if (file.exists())
{
return createFromExistingFile(fileHandler, file);
}
else
{
return createNewFileForPos(fileHandler, pos);
}
}
/**
* NOTE: should only be used if there is NOT an existing file.
*
@@ -310,12 +310,11 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
return null;
}
// File does not exist, create it.
// In this case, since 'creating' a file object doesn't actually do anything heavy on IO yet, we use CAS
// to avoid overhead of 'synchronized', and eat the mini-overhead of possibly creating duplicate objects.
// File probably doesn't exist, try creating it.
try
{
metaFile = RenderMetaDataFile.createNewFileForPos(this, pos);
// createFromExistingOrNewFile is due to a rare issue where the file may already exist but isn't in the file list
metaFile = RenderMetaDataFile.createFromExistingOrNewFile(this, pos);
}
catch (IOException e)
{
@@ -87,10 +87,6 @@ public class BatchGenerator implements IDhApiWorldGenerator
// generator parameters //
//======================//
// TODO implement
// @Override
// public EDhApiWorldGenThreadMode getThreadingMode() { return EDhApiWorldGenThreadMode.MULTI_THREADED; }
@Override
public byte getSmallestDataDetailLevel() { return LodUtil.BLOCK_DETAIL_LEVEL; }
@Override
@@ -29,14 +29,15 @@ public class GLState
public int vbo;
public int ebo;
public int fbo;
public int text;
public int activeTex;
public int text0;
public int texture2D;
/** IE: GL_TEXTURE0, GL_TEXTURE1, etc. */
public int activeTextureNumber;
public int texture0;
public boolean blend;
public int blendSrc;
public int blendDst;
public boolean depth;
public boolean depthWrite;
public boolean writeToDepthBuffer;
public int depthFunc;
public boolean stencil;
public int stencilFunc;
@@ -57,16 +58,16 @@ public class GLState
this.vbo = GL32.glGetInteger(GL32.GL_ARRAY_BUFFER_BINDING);
this.ebo = GL32.glGetInteger(GL32.GL_ELEMENT_ARRAY_BUFFER_BINDING);
this.fbo = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING);
this.text = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
this.activeTex = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE);
this.texture2D = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
this.activeTextureNumber = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE);
GL32.glActiveTexture(GL32.GL_TEXTURE0);
this.text0 = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
GL32.glActiveTexture(this.activeTex);
this.texture0 = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
GL32.glActiveTexture(this.activeTextureNumber);
this.blend = GL32.glIsEnabled(GL32.GL_BLEND);
this.blendSrc = GL32.glGetInteger(GL32.GL_BLEND_SRC);
this.blendDst = GL32.glGetInteger(GL32.GL_BLEND_DST);
this.depth = GL32.glIsEnabled(GL32.GL_DEPTH_TEST);
this.depthWrite = GL32.glGetInteger(GL32.GL_DEPTH_WRITEMASK) == GL32.GL_TRUE;
this.writeToDepthBuffer = GL32.glGetInteger(GL32.GL_DEPTH_WRITEMASK) == GL32.GL_TRUE;
this.depthFunc = GL32.glGetInteger(GL32.GL_DEPTH_FUNC);
this.stencil = GL32.glIsEnabled(GL32.GL_STENCIL_TEST);
this.stencilFunc = GL32.glGetInteger(GL32.GL_STENCIL_FUNC);
@@ -84,7 +85,7 @@ public class GLState
{
return "GLState{" +
"prog=" + this.prog + ", vao=" + this.vao + ", vbo=" + this.vbo + ", ebo=" + this.ebo + ", fbo=" + this.fbo +
", text=" + GLEnums.getString(this.text) + "@" + this.activeTex + ", text0=" + GLEnums.getString(this.text0) +
", text=" + GLEnums.getString(this.texture2D) + "@" + this.activeTextureNumber + ", text0=" + GLEnums.getString(this.texture0) +
", blend=" + this.blend + ", blendMode=" + GLEnums.getString(this.blendSrc) + "," + GLEnums.getString(this.blendDst) +
", depth=" + this.depth +
", depthFunc=" + GLEnums.getString(this.depthFunc) + ", stencil=" + this.stencil + ", stencilFunc=" +
@@ -97,7 +98,7 @@ public class GLState
public void restore()
{
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.fbo);
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, GL32.glIsFramebuffer(this.fbo) ? this.fbo : 0);
if (this.blend)
{
GL32.glEnable(GL32.GL_BLEND);
@@ -108,15 +109,16 @@ public class GLState
}
GL32.glActiveTexture(GL32.GL_TEXTURE0);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.text0);
GL32.glActiveTexture(this.activeTex);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.text);
GL32.glBindVertexArray(this.vao);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture0) ? this.texture0 : 0);
GL32.glActiveTexture(this.activeTextureNumber);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture2D) ? this.texture2D : 0);
GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0);
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, this.vbo);
GL32.glBindBuffer(GL32.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
GL32.glUseProgram(this.prog);
GL32.glUseProgram(GL32.glIsProgram(this.prog) ? this.prog : 0);
GL32.glDepthMask(this.depthWrite);
GL32.glDepthMask(this.writeToDepthBuffer);
GL32.glBlendFunc(this.blendSrc, this.blendDst);
if (this.depth)
{
@@ -30,8 +30,7 @@ import com.seibel.distanthorizons.core.render.glObject.GLProxy;
import com.seibel.distanthorizons.core.render.glObject.GLState;
import com.seibel.distanthorizons.core.render.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.core.render.glObject.buffer.QuadElementBuffer;
import com.seibel.distanthorizons.core.render.renderer.shaders.FogShader;
import com.seibel.distanthorizons.core.render.renderer.shaders.SSAORenderer;
import com.seibel.distanthorizons.core.render.renderer.shaders.*;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -255,12 +254,11 @@ public class LodRenderer
if (Config.Client.Advanced.Graphics.Quality.ssao.get())
{
// broken, causes renderer to crash
// TODO remove duplicate SSAO shader
//SSAOShader.INSTANCE.render(partialTicks); // For some reason this looks slightly different :/
profiler.popPush("LOD SSAO");
SSAORenderer.INSTANCE.render(partialTicks);
// TODO: Fix this file (or check the result is the same) so that SSAORenderer could be deleted
//SSAOShader.INSTANCE.render(partialTicks); // For some reason this looks slightly different :/
}
@@ -46,8 +46,7 @@ public class SSAOShader extends AbstractShaderRenderer
MC_RENDER.getTargetFrameBufferViewportWidth() / (float) MC_RENDER.getTargetFrameBufferViewportHeight(),
RenderUtil.getNearClipPlaneDistanceInBlocks(partialTicks),
(float) ((RenderUtil.getFarClipPlaneDistanceInBlocks() + LodUtil.REGION_WIDTH) * Math.sqrt(2)));
this.shader.setUniform(this.shader.getUniformLocation("gProj"), perspective);
this.shader.setUniform(this.shader.getUniformLocation("gSampleRad"), 3.0f);
this.shader.setUniform(this.shader.getUniformLocation("gFactor"), 0.8f);
@@ -0,0 +1,11 @@
package com.seibel.distanthorizons.core.wrapperInterfaces.config;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
public interface IConfigGui extends IBindable
{
void addOnScreenChangeListener(Runnable newListener);
void removeOnScreenChangeListener(Runnable oldListener);
}
+23 -24
View File
@@ -29,7 +29,7 @@ uniform float earthRadius;
*/
void main()
{
vPos = vec4(vPosition.x, vPosition.y, vPosition.z, vPosition.w); // This is so it can be passed to the fragment shader
vPos = vPosition; // This is so it can be passed to the fragment shader
vertexWorldPos = vPosition.xyz + modelOffset;
@@ -52,36 +52,35 @@ void main()
vertexWorldPos.y += my;
vertexWorldPos.z += mz;
// Old (disabled) vertex transformation logic - Leetom
#if 0
// Old (disabled) vertex transformation logic - Leetom
// Calculate the vertex pos due to curvature of the earth
// We use spherical coordinates to calculate the vertex position
if(vertexWorldPos.x == 0.0 && vertexWorldPos.z == 0.0)
{
// In the center. No curvature needed
}
else
{
float theta = atan(vertexWorldPos.z, vertexWorldPos.x); // in radians (-pi, pi)
float trueY = earthRadius + vertexWorldPos.y; // true Y position, or height
float phi = sqrt(vertexWorldPos.z * vertexWorldPos.z + vertexWorldPos.x * vertexWorldPos.x) / trueY;
// Convert spherical coordinates to cartesian coordinates
vertexWorldPos.x = trueY * sin(phi) * cos(theta);
vertexWorldPos.z = trueY * sin(phi) * sin(theta);
vertexWorldPos.y = trueY * cos(phi) - earthRadius;
}
// Calculate the vertex pos due to curvature of the earth
// We use spherical coordinates to calculate the vertex position
//if (vertexWorldPos.x == 0.0 && vertexWorldPos.z == 0.0)
//{
// // In the center. No curvature needed
//}
//else
//{
float theta = atan(vertexWorldPos.z, vertexWorldPos.x); // in radians (-pi, pi)
float trueY = earthRadius + vertexWorldPos.y; // true Y position, or height
float phi = sqrt(vertexWorldPos.z * vertexWorldPos.z + vertexWorldPos.x * vertexWorldPos.x) / trueY;
// Convert spherical coordinates to cartesian coordinates
vertexWorldPos.x = trueY * sin(phi) * cos(theta);
vertexWorldPos.z = trueY * sin(phi) * sin(theta);
vertexWorldPos.y = trueY * cos(phi) - earthRadius;
//}
#else
// new vertex transformation logic - stduhpf
// new vertex transformation logic - stduhpf
float localRadius = earthRadius + vertexYPos;// vertexWorldPos.y + cameraPosition.y - Center_Y;
float localRadius = earthRadius + vertexYPos;// vertexWorldPos.y + cameraPosition.y - Center_Y;
float phi = length(vertexWorldPos.xz) / localRadius;
vertexWorldPos.y += (cos(phi) - 1.) * localRadius;
vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi;
float phi = length(vertexWorldPos.xz) / localRadius;
vertexWorldPos.y += (cos(phi) - 1.0) * localRadius;
vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi;
#endif
uint lights = meta & 0xFFu;
@@ -18,8 +18,9 @@ uniform int noiseDropoff;
// method definitions
float fade(float value, float start, float end) {
return (clamp(value,start,end)-start)/(end-start);
return (clamp(value, start, end) - start) / (end - start);
}
// The random functions for diffrent dimentions
float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); }
float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); }
@@ -50,6 +51,7 @@ vec3 RGB2HSV(vec3 c) {
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 HSV2RGB(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
@@ -74,15 +76,10 @@ void main()
if (noiseEnabled) {
vec3 vertexNormal = normalize(cross(dFdx(vPos.xyz), dFdy(vPos.xyz)));
// This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable
vec3 fixedVPos = vec3(
vPos.x - vertexNormal.x * 0.001,
vPos.y - vertexNormal.y * 0.001,
vPos.z - vertexNormal.z * 0.001
);
vec3 fixedVPos = vPos.xyz - vertexNormal * 0.001;
float noiseAmplification = noiseIntensity / 100;
noiseAmplification = (-1 * pow(2*((fragColor.x + fragColor.y + fragColor.z) / 3) - 1, 2) + 1) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1
float noiseAmplification = noiseIntensity * 0.01;
noiseAmplification = (-1.0 * pow(2.0*((fragColor.x + fragColor.y + fragColor.z) / 3.0) - 1.0, 2.0) + 1.0) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1
noiseAmplification *= fragColor.w; // The effect would lessen on transparent objects
// Random value for each position
@@ -91,30 +88,20 @@ void main()
quantize(fixedVPos.y, noiseSteps),
quantize(fixedVPos.z, noiseSteps)
))
* 2. * noiseAmplification - noiseAmplification;
* 2.0 * noiseAmplification - noiseAmplification;
// Modifies the color
// A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color
vec3 newCol = fragColor.rgb + (vec3(1.0) - fragColor.rgb) * randomValue;
vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue;
// Clamps it and turns it back into a vec4
if (noiseDropoff == 0)
fragColor = vec4(
clamp(newCol.r, 0., 1.),
clamp(newCol.g, 0., 1.),
clamp(newCol.b, 0., 1.),
fragColor.w
);
fragColor = vec4(clamp(newCol.rgb, 0.0, 1.0), fragColor.w);
else
fragColor = mix(
vec4(
clamp(newCol.r, 0., 1.),
clamp(newCol.g, 0., 1.),
clamp(newCol.b, 0., 1.),
fragColor.w
), fragColor,
clamp(length(vertexWorldPos) / noiseDropoff, 0., 1.) // The further away it gets, the less noise gets applied
vec4(clamp(newCol.rgb, 0.0, 1.0), fragColor.w), fragColor,
min(length(vertexWorldPos) / noiseDropoff, 1.0) // The further away it gets, the less noise gets applied
);
// For testing
+14 -15
View File
@@ -59,16 +59,12 @@ float mod(float x, int y) {
vec3 calcViewPosition(float fragmentDepth)
{
vec4 ndc = vec4(
TexCoord.x * 2.0 - 1.0,
TexCoord.y * 2.0 - 1.0,
fragmentDepth * 2.0 - 1.0,
1.0
);
vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0);
ndc.xyz = ndc.xyz * 2.0 - 1.0;
// TODO: This inverse() should be moved CPU side
vec4 eyeCoord = inverse(gMvmProj) * ndc;
vec3 cameraPos = eyeCoord.xyz / eyeCoord.w;
return cameraPos;
return eyeCoord.xyz / eyeCoord.w;
}
/**
@@ -84,7 +80,7 @@ void main()
// a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to apply Fog to LODs, not to the sky outside the LODs
if (fragmentDepth != 1.0)
if (fragmentDepth < 1)
{
if (fullFogMode == 0)
{
@@ -98,17 +94,15 @@ void main()
float nearFogThickness = getNearFogThickness(horizontalDist);
float farFogThickness = getFarFogThickness(farDist);
float heightFogThickness = getHeightFogThickness(heightDist);
float mixedFogThickness =
clamp(
mixFogThickness(nearFogThickness, farFogThickness, heightFogThickness)
, 0.0, 1.0);
float mixedFogThickness = mixFogThickness(nearFogThickness, farFogThickness, heightFogThickness);
mixedFogThickness = clamp(mixedFogThickness, 0.0, 1.0);
fragColor = vec4(fogColor.r, fogColor.g, fogColor.b, mixedFogThickness);
fragColor = vec4(fogColor.rgb, mixedFogThickness);
}
else if (fullFogMode == 1)
{
// render everything with the fog color
fragColor = vec4(fogColor.r, fogColor.g, fogColor.b, 1.0);
fragColor = vec4(fogColor.rgb, 1.0);
}
else
{
@@ -123,6 +117,11 @@ void main()
fragColor = vec4(vec3(depthValue), 1.0); // Convert depth value to grayscale color
}
}
else
{
// every pixel needs to be set to something, otherwise the pixel may be undefined by some drivers (specifically Intel)
fragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}
@@ -26,6 +26,10 @@ float quantize(float val, int stepSize) {
return floor(val*stepSize)/stepSize;
}
vec3 quantize(vec3 val, int stepSize) {
return floor(val*stepSize)/stepSize;
}
// The modulus function dosnt exist in GLSL so I made my own
// To speed up the mod function, this only accepts full numbers for y
float mod(float x, int y) {
@@ -44,11 +48,7 @@ float mod(float x, int y) {
void main() {
// This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable
vec3 vertexNormal = normalize(cross(dFdx(vPos.xyz), dFdy(vPos.xyz)));
vec3 fixedVPos = vec3(
vPos.x - vertexNormal.x * 0.001,
vPos.y - vertexNormal.y * 0.001,
vPos.z - vertexNormal.z * 0.001
);
vec3 fixedVPos = vPos.xyz - vertexNormal * 0.001;
float noiseAmplification = noiseIntensity / 100;
@@ -56,29 +56,20 @@ void main() {
noiseAmplification *= vertexColor.w; // The effect would lessen on transparent objects
// Random value for each position
float randomValue = rand(vec3(
quantize(fixedVPos.x, noiseSteps),
quantize(fixedVPos.y, noiseSteps),
quantize(fixedVPos.z, noiseSteps)
))
* 2. * noiseAmplification - noiseAmplification;
float randomValue = rand(quantize(fixedVPos.xyz, noiseSteps))
* 2.0 * noiseAmplification - noiseAmplification;
// Modifies the color
// A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color
vec3 newCol = (vec3(1.0) - vertexColor.rgb) * randomValue;
vec3 newCol = (1.0 - vertexColor.rgb) * randomValue;
// Clamps it and turns it back into a vec4
fragColor = vec4(
clamp(newCol.r, 0., 1.),
clamp(newCol.g, 0., 1.),
clamp(newCol.b, 0., 1.),
clamp(length(vertexWorldPos) * distanceScale * noiseDropoff, 0., 1.) // The further away it gets, the less noise gets applied
);
fragColor = vec4(
0f, 0f, 0f,
randomValue // The further away it gets, the less noise gets applied
);
float distA = length(vertexWorldPos) * distanceScale * noiseDropoff;
fragColor = clamp(vec4(newCol.rgb, distA), 0.0, 1.0); // The further away it gets, the less noise gets applied
// The further away it gets, the less noise gets applied
fragColor = vec4(0.0, 0.0, 0.0, randomValue);
// For testing
// if (vertexColor.r != 69420.) {
+5 -8
View File
@@ -35,22 +35,19 @@ void main()
vec3 viewPos = calcViewPosition(TexCoord);
vec3 viewNormal = normalize(cross(dFdy(viewPos.xyz), dFdx(viewPos.xyz)) * -1.0);
vec3 randomVec = vec3(
0.0,
-1.0,
0.0
);
vec3 randomVec = vec3(0.0, -1.0, 0.0);
vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));
vec3 bitangent = cross(viewNormal, tangent);
mat3 TBN = mat3(tangent, bitangent, viewNormal);
float occlusion_factor = 0.0;
for (int i = 0; i < MAX_KERNEL_SIZE; i++) {
for (int i = 0; i < MAX_KERNEL_SIZE; i++)
{
vec3 samplePos = vec3(0.0) + (TBN * gKernel[i]);
samplePos = viewPos + samplePos * gSampleRad;
vec4 offset = vec4(samplePos, 1.0);
offset = gProj * offset;
vec4 offset = gProj * vec4(samplePos + viewPos, 1.0);
offset.xy /= offset.w;
offset.xy = offset.xy * HALF_2 + HALF_2;
@@ -13,8 +13,13 @@ void main()
float fragmentDepth = texture(gDepthMap, TexCoord).r;
// a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to apply SSAO to LODs, not to the sky outside the LODs
if (fragmentDepth != 1.0)
if (fragmentDepth < 1)
{
fragColor = vec4(0.0, 0.0, 0.0, 1-texture(gSSAOMap, TexCoord).r);
fragColor = vec4(0.0, 0.0, 0.0, 1-texture(gSSAOMap, TexCoord).r);
}
else
{
// every pixel needs to be set to something, otherwise the pixel may be undefined by some drivers (specifically Intel)
fragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}
@@ -29,7 +29,7 @@ uniform float mircoOffset;
*/
void main()
{
vPos = vec4(vPosition.x, vPosition.y, vPosition.z, vPosition.w); // This is so it can be passed to the fragment shader
vPos = vPosition; // This is so it can be passed to the fragment shader
vertexWorldPos = vPosition.xyz + modelOffset;
@@ -54,6 +54,7 @@ void main()
float light2 = (mod(float(lights), 16.0)+0.5) / 16.0;
float light = (float(lights/16u)+0.5) / 16.0;
vertexColor = vec4(texture(lightMap, vec2(light, light2)).xyz, 1.0);
if (!whiteWorld)
{
vertexColor *= color;