Merge branch 'main' of https://gitlab.com/jeseibel/distant-horizons-core
This commit is contained in:
@@ -17,7 +17,7 @@ It should be automatically included when pulling the full mod.
|
||||
LZ4 for Java (data compression)\
|
||||
https://github.com/lz4/lz4-java
|
||||
|
||||
Json & Toml for Java (config handling)\
|
||||
NightConfig for Json & Toml (config handling)\
|
||||
https://github.com/TheElectronWill/night-config
|
||||
|
||||
SVG Salamander for SVG's\
|
||||
|
||||
+3
-5
@@ -40,11 +40,9 @@ public interface IDhApiNoiseTextureConfig extends IDhApiConfigGroup
|
||||
IDhApiConfigValue<Double> noiseIntensity();
|
||||
|
||||
/**
|
||||
* Defines how far should the noise texture render before it fades away. <br><br>
|
||||
*
|
||||
* 0.0 - the noise texture will render the entire LOD render distance. <br>
|
||||
* 3.0 - the noise texture will fade away at 1/3 of the LOD render distance.
|
||||
* Defines how far should the noise texture render before it fades away. (in blocks) <br>
|
||||
* Set to 0 to disable noise from fading away
|
||||
*/
|
||||
IDhApiConfigValue<Double> noiseDropoff();
|
||||
IDhApiConfigValue<Integer> noiseDropoff();
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ public class DhApiNoiseTextureConfig implements IDhApiNoiseTextureConfig
|
||||
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity); }
|
||||
|
||||
@Override
|
||||
public IDhApiConfigValue<Double> noiseDropoff()
|
||||
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff); }
|
||||
public IDhApiConfigValue<Integer> noiseDropoff()
|
||||
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff); }
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.api.internal;
|
||||
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelUnloadEvent;
|
||||
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
@@ -34,6 +35,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This holds the methods that should be called by the host mod loader (Fabric,
|
||||
* Forge, etc.). Specifically server events.
|
||||
@@ -148,6 +152,32 @@ public class ServerApi
|
||||
IDhLevel dhLevel = SharedApi.getAbstractDhWorld().getLevel(level);
|
||||
if (dhLevel != null)
|
||||
{
|
||||
|
||||
// Save or populate the chunk wrapper's lighting
|
||||
// this is done so we don't have to worry about MC unloading the lighting data for this chunk
|
||||
if (chunk.isLightCorrect())
|
||||
{
|
||||
try
|
||||
{
|
||||
chunk.bakeDhLightingUsingMcLightingEngine();
|
||||
chunk.setUseDhLighting(true);
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
{
|
||||
LOGGER.warn(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// generate the chunk's lighting, ignoring neighbors.
|
||||
// not a perfect solution, but should prevent chunks from having completely broken lighting
|
||||
List<IChunkWrapper> nearbyChunkList = new LinkedList<>();
|
||||
nearbyChunkList.add(chunk);
|
||||
DhLightingEngine.INSTANCE.lightChunks(chunk, nearbyChunkList, level.hasSkyLight() ? 15 : 0);
|
||||
chunk.setUseDhLighting(true);
|
||||
}
|
||||
|
||||
|
||||
dhLevel.updateChunkAsync(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,16 +30,14 @@ import com.seibel.distanthorizons.core.config.eventHandlers.RenderCacheConfigEve
|
||||
import com.seibel.distanthorizons.core.config.eventHandlers.UnsafeValuesConfigListener;
|
||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler;
|
||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.RenderQualityPresetConfigEventHandler;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigCategory;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigLinkedEntry;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigUIComment;
|
||||
import com.seibel.distanthorizons.core.config.types.*;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryPerformance;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -468,14 +466,11 @@ public class Config
|
||||
+ "How intense should the noise should be?")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Double> noiseDropoff = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI doesn't support floats)
|
||||
.setMinDefaultMax(0d, 3d, null)
|
||||
public static ConfigEntry<Integer> noiseDropoff = new ConfigEntry.Builder<Integer>() // TODO: Make this a float (the ClassicConfigGUI doesn't support floats)
|
||||
.setMinDefaultMax(0, 1024, null)
|
||||
.comment(""
|
||||
+ "How far should the noise texture render before it fades away? \n"
|
||||
+ "\n"
|
||||
+ "0.0 - the noise texture will render the entire LOD render distance. \n"
|
||||
+ "3.0 - the noise texture will fade away at 1/3 of the LOD render distance. \n"
|
||||
+ "")
|
||||
+ "Defines how far should the noise texture render before it fades away. (in blocks) \n"
|
||||
+ "Set to 0 to disable noise from fading away")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -516,9 +511,9 @@ public class Config
|
||||
+ "Distant Horizons' and Minecraft's near/far clip planes, \n"
|
||||
+ "reducing overdraw. \n"
|
||||
+ "\n"
|
||||
+ "Only tested in Minecraft 1.18.2.\n"
|
||||
+ "Only functional on Fabric.\n"
|
||||
+ "Works best with an overdraw prevention setting of "+EOverdrawPrevention.MEDIUM+" or higher \n"
|
||||
+ " nd cave culling disabled. \n"
|
||||
+ " and cave culling is disabled. \n"
|
||||
+ "")
|
||||
.setPerformance(EConfigEntryPerformance.NONE)
|
||||
.build();
|
||||
@@ -1095,6 +1090,13 @@ public class Config
|
||||
+ " will render their debug wireframes.")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableWhiteWorld = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
+ "Stops vertex colors from being passed. \n"
|
||||
+ "Useful for debugging shaders")
|
||||
.build();
|
||||
|
||||
// Note: This will reset on game restart, and should have a warning on the tooltip
|
||||
public static ConfigEntry<Boolean> allowUnsafeValues = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
@@ -1109,6 +1111,8 @@ public class Config
|
||||
.build();
|
||||
|
||||
/** This class is used to debug the different features of the config GUI */
|
||||
// FIXME: WARNING: Some of the options in this class dont get show n in the default UI
|
||||
// This will throw a warning when opened in the default ui to tell you about it not showing
|
||||
public static class ExampleConfigScreen
|
||||
{
|
||||
// Defined in the lang, just a note about this screen
|
||||
@@ -1137,7 +1141,7 @@ public class Config
|
||||
public static ConfigEntry<Long> longTest = new ConfigEntry.Builder<Long>()
|
||||
.set(42069L)
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigEntry<Float> floatTest = new ConfigEntry.Builder<Float>()
|
||||
.set(0.42069f)
|
||||
.build();
|
||||
@@ -1149,6 +1153,15 @@ public class Config
|
||||
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
|
||||
.set(new ArrayList<String>(Arrays.asList("option 1", "option 2", "option 3")))
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
|
||||
.set(new HashMap<String, String>())
|
||||
.build();
|
||||
|
||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||
});
|
||||
|
||||
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
|
||||
|
||||
|
||||
+8
-4
@@ -112,9 +112,12 @@ public class ConfigFileHandling {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void saveEntry(ConfigEntry<?> entry, CommentedFileConfig workConfig) {
|
||||
if (!entry.getAppearance().showInFile) return;
|
||||
if (entry.getTrueValue() == null)
|
||||
throw new IllegalArgumentException("Entry ["+ entry.getNameWCategory() +"] is null, this may be a problem with ["+ configBase.modName +"]. Please contact the authors");
|
||||
|
||||
if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) {
|
||||
workConfig.set(entry.getNameWCategory(), ConfigTypeConverters.convertToString(entry.getType(), entry.getTrueValue()));
|
||||
Class<?> originalClass = ConfigTypeConverters.isClassConvertable(entry.getType());
|
||||
if (originalClass != null) {
|
||||
workConfig.set(entry.getNameWCategory(), ConfigTypeConverters.convertToString(originalClass, entry.getTrueValue()));
|
||||
return;
|
||||
}
|
||||
workConfig.set(entry.getNameWCategory(), entry.getTrueValue());
|
||||
@@ -139,8 +142,9 @@ public class ConfigFileHandling {
|
||||
entry.setWithoutSaving((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class<? extends Enum>) entry.getType())));
|
||||
return;
|
||||
}
|
||||
if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) {
|
||||
entry.setWithoutSaving((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory())));
|
||||
Class<?> originalClass = ConfigTypeConverters.isClassConvertable(entry.getType());
|
||||
if (originalClass != null) {
|
||||
entry.setWithoutSaving((T) ConfigTypeConverters.convertFromString(originalClass, workConfig.get(entry.getNameWCategory())));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -15,17 +15,25 @@ import java.util.Map;
|
||||
*/
|
||||
public class ConfigTypeConverters {
|
||||
// Once you've made a converter add it to here where the first value is the type you want to convert and the 2nd value is the converter
|
||||
public static final Map<Class, ConverterBase> convertObjects = new HashMap<Class, ConverterBase>() {{
|
||||
public static final Map<Class<?>, ConverterBase> convertObjects = new HashMap<Class<?>, ConverterBase>() {{
|
||||
put(Short.class, new ShortConverter());
|
||||
put(Long.class, new LongConverter());
|
||||
put(Float.class, new FloatConverter());
|
||||
put(Byte.class, new ByteConverter());
|
||||
|
||||
put(Map.class, new MapConverter());
|
||||
put(HashMap.class, new MapConverter());
|
||||
}};
|
||||
|
||||
public static String convertToString(Class clazz, Object value) {
|
||||
public static Class<?> isClassConvertable(Class<?> clazz) {
|
||||
for (int i = 0; i < convertObjects.size(); i++) {
|
||||
Class<?> selectedClass = (Class<?>) convertObjects.keySet().toArray()[i];
|
||||
if (selectedClass.isAssignableFrom(clazz))
|
||||
return selectedClass;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertToString(Class<?> clazz, Object value) {
|
||||
try {
|
||||
return convertObjects.get(clazz).convertToString(value);
|
||||
} catch (Exception e) {
|
||||
@@ -33,7 +41,7 @@ public class ConfigTypeConverters {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static Object convertFromString(Class clazz, String value) {
|
||||
public static Object convertFromString(Class<?> clazz, String value) {
|
||||
try {
|
||||
return convertObjects.get(clazz).convertFromString(value);
|
||||
} catch (Exception e) {
|
||||
|
||||
-171
@@ -1,171 +0,0 @@
|
||||
package com.seibel.distanthorizons.core.config.gui.standaloneTests;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.gui.AbstractScreen;
|
||||
import com.seibel.distanthorizons.core.config.gui.OpenGLConfigScreen;
|
||||
import com.seibel.distanthorizons.core.pos.Pos2D;
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import static org.lwjgl.glfw.Callbacks.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.system.MemoryStack.*;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
|
||||
/**
|
||||
* This just allows for a quicker testing of the config screen without loading up the whole game
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public class TestConfigMain {
|
||||
// The window handle
|
||||
private long window;
|
||||
public AbstractScreen abstractScreen;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestConfigMain().run();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
abstractScreen = new OpenGLConfigScreen();
|
||||
System.out.println("Hello LWJGL version " + Version.getVersion());
|
||||
|
||||
// ClientApi.INSTANCE.rendererStartupEvent();
|
||||
init();
|
||||
|
||||
Pos2D windowDim = getWindowDimentions(window);
|
||||
abstractScreen.width = windowDim.x;
|
||||
abstractScreen.height = windowDim.y;
|
||||
abstractScreen.init();
|
||||
loop();
|
||||
// Code isnt moved until loop is done (and it is only done if window is closed)
|
||||
|
||||
// ClientApi.INSTANCE.rendererShutdownEvent();
|
||||
// Free the window callbacks and destroy the window
|
||||
glfwFreeCallbacks(window);
|
||||
glfwDestroyWindow(window);
|
||||
|
||||
// Terminate GLFW and free the error callback
|
||||
glfwTerminate();
|
||||
glfwSetErrorCallback(null).free();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// Setup an error callback. The default implementation
|
||||
// will print the error message in System.err.
|
||||
GLFWErrorCallback.createPrint(System.err).set();
|
||||
|
||||
// Initialize GLFW. Most GLFW functions will not work before doing this.
|
||||
if ( !glfwInit() )
|
||||
throw new IllegalStateException("Unable to initialize GLFW");
|
||||
|
||||
// Configure GLFW
|
||||
glfwDefaultWindowHints(); // optional, the current window hints are already the default
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
|
||||
|
||||
// Create the window
|
||||
window = glfwCreateWindow(640, 480, "DH Test config", NULL, NULL);
|
||||
if ( window == NULL )
|
||||
throw new RuntimeException("Failed to create the GLFW window");
|
||||
|
||||
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
|
||||
// Is this really nessesery
|
||||
// glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
|
||||
// if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
|
||||
// glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
||||
// });
|
||||
|
||||
// Get the thread stack and push a new frame
|
||||
try ( MemoryStack stack = stackPush() ) {
|
||||
IntBuffer pWidth = stack.mallocInt(1); // int*
|
||||
IntBuffer pHeight = stack.mallocInt(1); // int*
|
||||
|
||||
// Get the window size passed to glfwCreateWindow
|
||||
glfwGetWindowSize(window, pWidth, pHeight);
|
||||
|
||||
// Get the resolution of the primary monitor
|
||||
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||||
|
||||
// Center the window
|
||||
glfwSetWindowPos(
|
||||
window,
|
||||
(vidmode.width() - pWidth.get(0)) / 2,
|
||||
(vidmode.height() - pHeight.get(0)) / 2
|
||||
);
|
||||
} // the stack frame is popped automatically
|
||||
|
||||
// Make the OpenGL context current
|
||||
glfwMakeContextCurrent(window);
|
||||
// Enable v-sync
|
||||
glfwSwapInterval(1);
|
||||
|
||||
// Make the window visible
|
||||
glfwShowWindow(window);
|
||||
GL.createCapabilities();
|
||||
}
|
||||
|
||||
private void loop() {
|
||||
// This line is critical for LWJGL's interoperation with GLFW's
|
||||
// OpenGL context, or any context that is managed externally.
|
||||
// LWJGL detects the context that is current in the current thread,
|
||||
// creates the GLCapabilities instance and makes the OpenGL
|
||||
// bindings available for use.
|
||||
GL.createCapabilities();
|
||||
|
||||
// Set the clear color (if not set it would just be black)
|
||||
// glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Set this so we can use it for the delta time
|
||||
lastLoopTime = getTime();
|
||||
|
||||
// Run the rendering loop until the user has attempted to close
|
||||
// the window or has pressed the ESCAPE key.
|
||||
// (only works if glfwPollEvents() is called)
|
||||
while ( !glfwWindowShouldClose(window) ) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer (will cause a ghosting effect if not called)
|
||||
|
||||
// Poll for window events. (this allows the window to be closed)
|
||||
glfwPollEvents();
|
||||
|
||||
Pos2D windowDim = getWindowDimentions(window);
|
||||
abstractScreen.width = windowDim.x;
|
||||
abstractScreen.height = windowDim.y;
|
||||
|
||||
abstractScreen.render(getDelta());
|
||||
|
||||
|
||||
glfwSwapBuffers(window); // swap the color buffers
|
||||
}
|
||||
abstractScreen.onClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Pos2D getWindowDimentions(long window) {
|
||||
IntBuffer w = BufferUtils.createIntBuffer(1);
|
||||
IntBuffer h = BufferUtils.createIntBuffer(1);
|
||||
glfwGetWindowSize(window, w, h);
|
||||
return new Pos2D(w.get(0), h.get(0));
|
||||
}
|
||||
|
||||
|
||||
private double lastLoopTime;
|
||||
private float timeCount;
|
||||
public double getTime() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
public float getDelta() {
|
||||
double time = getTime();
|
||||
float delta = (float) (time - lastLoopTime);
|
||||
lastLoopTime = time;
|
||||
timeCount += delta;
|
||||
return delta;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,13 @@ package com.seibel.distanthorizons.core.config.types;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
|
||||
/**
|
||||
* Adds a categoty to the config
|
||||
* Adds a category to the config
|
||||
* See our config file for more information on how to use it
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public class ConfigCategory extends AbstractConfigType<Class, ConfigCategory> {
|
||||
/** This should not be set by anything other than the config system itself */
|
||||
public String destination; // Where the category goes to
|
||||
|
||||
private ConfigCategory(EConfigEntryAppearance appearance, Class value, String destination) {
|
||||
|
||||
@@ -7,12 +7,8 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryPerformance;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.config.IConfigEntry;
|
||||
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.electronwill.nightconfig.core.NullObject.NULL_OBJECT;
|
||||
|
||||
/**
|
||||
* Use for making the config variables
|
||||
@@ -44,29 +40,7 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
|
||||
private ConfigEntry(EConfigEntryAppearance appearance, T value, String comment, T min, T max, boolean allowApiOverride, EConfigEntryPerformance performance, ArrayList<IConfigListener> listenerList)
|
||||
{
|
||||
super(appearance, value);
|
||||
|
||||
// runtime check to make sure the config value is supported by NightConfig,
|
||||
// unfortunately we can't do this type of check statically without Java 16
|
||||
if (value == null)
|
||||
{
|
||||
throw new IllegalArgumentException("ConfigEntry setup failure. TOML doesn't support saving null values.");
|
||||
}
|
||||
// all of these types were taken from NightConfig's writing code
|
||||
else if (!(value instanceof List)
|
||||
&& !(value instanceof CharSequence) // String
|
||||
&& !(value instanceof Enum)
|
||||
&& !(value instanceof Temporal) // Date or DateTime
|
||||
&& !(value instanceof Float || value instanceof Double)
|
||||
&& !(value instanceof Number)
|
||||
&& !(value instanceof Boolean)
|
||||
// optional type that is specific to NightConfig, currently commented out so we aren't tied quite so tightly to NightConfig
|
||||
//&& !(value instanceof Config) // NightConfig interface
|
||||
)
|
||||
{
|
||||
throw new IllegalArgumentException("ConfigEntry setup failure. Value type ["+value.getClass()+"] is not supported by NightConfig.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.defaultValue = value;
|
||||
this.comment = comment;
|
||||
this.min = min;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.seibel.distanthorizons.core.config.types;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
|
||||
public class ConfigUIButton extends AbstractConfigType<Runnable, ConfigUIButton> {
|
||||
public ConfigUIButton(Runnable runnable) {
|
||||
super(EConfigEntryAppearance.ONLY_IN_GUI, runnable);
|
||||
}
|
||||
|
||||
public void runAction() {
|
||||
new Thread(this.value).start();
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractConfigType.Builder<Runnable, Builder> {
|
||||
/** Appearance shouldn't be changed */
|
||||
@Override
|
||||
public Builder setAppearance(EConfigEntryAppearance newAppearance) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConfigUIButton build() {
|
||||
return new ConfigUIButton(this.tmpValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public class ConfigUIComment extends AbstractConfigType<String, ConfigUIComment>{
|
||||
public class ConfigUIComment extends AbstractConfigType<String, ConfigUIComment> {
|
||||
public ConfigUIComment() {
|
||||
super(EConfigEntryAppearance.ONLY_IN_GUI, "");
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
/** measured in dataPoints */
|
||||
public static final int WIDTH = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 1;
|
||||
public static final byte DATA_FORMAT_VERSION = 2;
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "CompleteFullDataSource".hashCode();
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
/** aka max detail level */
|
||||
public static final byte MAX_SECTION_DETAIL = SECTION_SIZE_OFFSET + SPARSE_UNIT_DETAIL;
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 1;
|
||||
public static final byte DATA_FORMAT_VERSION = 2;
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "HighDetailIncompleteFullDataSource".hashCode();
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
/** measured in dataPoints */
|
||||
public static final int WIDTH = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
|
||||
|
||||
public static final byte DATA_FORMAT_VERSION = 1;
|
||||
public static final byte DATA_FORMAT_VERSION = 2;
|
||||
/** written to the binary file to mark what {@link IFullDataSource} the binary file corresponds to */
|
||||
public static final long TYPE_ID = "LowDetailIncompleteFullDataSource".hashCode();
|
||||
|
||||
|
||||
+2
-1
@@ -29,7 +29,8 @@ import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
*/
|
||||
public class FullDataToRenderDataTransformer
|
||||
{
|
||||
private static final IBlockStateWrapper AIR = SingletonInjector.INSTANCE.get(IWrapperFactory.class).getAirBlockStateWrapper();
|
||||
private static final IWrapperFactory WRAPPER_FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
||||
private static final IBlockStateWrapper AIR = WRAPPER_FACTORY.getAirBlockStateWrapper();
|
||||
|
||||
|
||||
|
||||
|
||||
+1
@@ -175,6 +175,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
|
||||
this.fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(this.baseMetaData.dataTypeId, this.baseMetaData.binaryDataFormatVersion);
|
||||
if (this.fullDataSourceLoader == null)
|
||||
{
|
||||
// TODO add a hard coded dictionary of known ID name combos so we can easily see in the log if the ID is valid or if the data was corrupted/old
|
||||
throw new IOException("Invalid file: Data type loader not found: "+this.baseMetaData.dataTypeId+"(v"+this.baseMetaData.binaryDataFormatVersion +")");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.seibel.distanthorizons.core.jar;
|
||||
|
||||
import com.electronwill.nightconfig.core.Config;
|
||||
import com.electronwill.nightconfig.core.io.ParsingMode;
|
||||
import com.electronwill.nightconfig.json.JsonFormat;
|
||||
|
||||
/**
|
||||
* Get info on the git for the mod <br>
|
||||
* Warning: Gets generated on runtime
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public final class ModGitInfo {
|
||||
static {
|
||||
// Warning: Atm, this file is in the common subproject as the processResources task in gradle doesnt work for core
|
||||
String s = JarUtils.convertInputStreamToString(JarUtils.accessFile("build_info.json"));
|
||||
|
||||
Config jsonObject = Config.inMemory();
|
||||
JsonFormat.minimalInstance().createParser().parse(s, jsonObject, ParsingMode.REPLACE);
|
||||
|
||||
Git_Main_Commit = jsonObject.get("git_main_commit");
|
||||
Git_Core_Commit = jsonObject.get("git_core_commit");
|
||||
Git_Main_Branch = jsonObject.get("git_main_branch");
|
||||
}
|
||||
|
||||
public static final String Git_Main_Commit;
|
||||
public static final String Git_Core_Commit;
|
||||
public static final String Git_Main_Branch;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class BaseJFrame extends JFrame {
|
||||
// Creates a list with all the options in it
|
||||
List<String> langsToChoose = new ArrayList<>();
|
||||
try(
|
||||
final InputStreamReader isr = new InputStreamReader(JarUtils.accessFile("assets/lod/lang"), StandardCharsets.UTF_8);
|
||||
final InputStreamReader isr = new InputStreamReader(JarUtils.accessFile("assets/distanthorizons/lang"), StandardCharsets.UTF_8);
|
||||
final BufferedReader br = new BufferedReader(isr)
|
||||
) {
|
||||
List<Object> col = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(br.lines().toArray())));
|
||||
@@ -87,11 +87,11 @@ public class BaseJFrame extends JFrame {
|
||||
// Try to set the icons for them
|
||||
try {
|
||||
lightMode = new JButton(new ImageIcon(
|
||||
new FlatSVGIcon(JarUtils.accessFile("assets/lod/textures/jar/themeLight.svg")).getImage() // Get the image
|
||||
new FlatSVGIcon(JarUtils.accessFile("assets/distanthorizons/textures/jar/themeLight.svg")).getImage() // Get the image
|
||||
.getScaledInstance(themeButtonSize, themeButtonSize, Image.SCALE_DEFAULT) // Scale it to the correct size
|
||||
));
|
||||
darkMode = new JButton(new ImageIcon(
|
||||
new FlatSVGIcon(JarUtils.accessFile("assets/lod/textures/jar/themeDark.svg")).getImage() // Get the image
|
||||
new FlatSVGIcon(JarUtils.accessFile("assets/distanthorizons/textures/jar/themeDark.svg")).getImage() // Get the image
|
||||
.getScaledInstance(themeButtonSize, themeButtonSize, Image.SCALE_DEFAULT) // Scale it to the correct size
|
||||
));
|
||||
} catch (Exception e) {e.printStackTrace();}
|
||||
@@ -139,8 +139,7 @@ public class BaseJFrame extends JFrame {
|
||||
// This part of the code is taken from the official java docs at https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
|
||||
// Specify the look and feel to use by defining the LOOKANDFEEL constant
|
||||
// Valid values are: null (use the default), "Metal", "System", "Motif",
|
||||
// and "GTK"
|
||||
// Valid values are: null (use the default), "Metal", "System", "Motif", and "GTK"
|
||||
final static String LOOKANDFEEL = "GTK";
|
||||
private static void initLookAndFeel() {
|
||||
String lookAndFeel = null;
|
||||
|
||||
+6
-6
@@ -17,6 +17,7 @@ public class ModrinthGetter {
|
||||
public static final String projectID = "distanthorizons";
|
||||
public static boolean initted = false;
|
||||
public static ArrayList<Config> projectRelease;
|
||||
public static Map<String, Config> idToJson = new HashMap<>();
|
||||
|
||||
public static List<String> releaseID = new ArrayList<>(); // This list contains the release ID's
|
||||
public static List<String> mcVersions = new ArrayList<>(); // List of available Minecraft versions in the mod
|
||||
@@ -44,6 +45,7 @@ public class ModrinthGetter {
|
||||
String workingID = currentRelease.get("id").toString();
|
||||
|
||||
releaseID.add(workingID);
|
||||
idToJson.put(workingID, currentRelease);
|
||||
releaseNames.put(workingID, currentRelease.get("name").toString().replaceAll(" - 1\\..*", ""));
|
||||
changeLogs.put(workingID, currentRelease.get("changelog").toString());
|
||||
try {
|
||||
@@ -88,11 +90,9 @@ public class ModrinthGetter {
|
||||
return downloadUrl.get(mcVerToReleaseID.get(mcVer).get(0));
|
||||
}
|
||||
public static String getLatestShaForVersion(String mcVer) {
|
||||
return ((Config)
|
||||
((ArrayList) projectRelease.get(
|
||||
mcVersions.indexOf(mcVer)
|
||||
).get("files")).get(0))
|
||||
.get("hashes.sha1")
|
||||
.toString();
|
||||
return (((ArrayList<Config>) idToJson.get(
|
||||
mcVerToReleaseID.get(mcVer).get(0)
|
||||
).get("files")).get(0).get("hashes.sha1")
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
@@ -107,6 +108,10 @@ public class SelfUpdater {
|
||||
deleteOldOnClose = true;
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " successfully updated. It will apply on game's relaunch");
|
||||
new Thread(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, ModInfo.READABLE_NAME+ " updated, this will be applied on game restart.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
|
||||
}).start();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Failed to update "+ModInfo.READABLE_NAME+" to version "+ModrinthGetter.getLatestNameForVersion(minecraftVersion));
|
||||
|
||||
@@ -57,10 +57,11 @@ public class LodFogConfig
|
||||
// TODO: Move these out of here
|
||||
public final int earthCurveRatio;
|
||||
|
||||
// Noise Values
|
||||
public final boolean noiseEnable;
|
||||
public final int noiseSteps;
|
||||
public final float noiseIntensity;
|
||||
public final float noiseDropoff;
|
||||
public final int noiseDropoff;
|
||||
|
||||
|
||||
public static LodFogConfig generateFogConfig()
|
||||
@@ -82,7 +83,7 @@ public class LodFogConfig
|
||||
noiseEnable = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseEnabled.get();
|
||||
noiseSteps = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseSteps.get();
|
||||
noiseIntensity = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity.get().floatValue();
|
||||
noiseDropoff = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff.get().floatValue();
|
||||
noiseDropoff = Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff.get();
|
||||
|
||||
|
||||
if (fogDrawMode != EFogDrawMode.FOG_DISABLED)
|
||||
|
||||
+15
-2
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.render.renderer;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.Shader;
|
||||
@@ -53,6 +54,7 @@ public class LodRenderProgram extends ShaderProgram
|
||||
public final int earthRadiusUniform;
|
||||
|
||||
public final int lightMapUniform;
|
||||
|
||||
// Fog Uniforms
|
||||
public final int fogColorUniform;
|
||||
public final int fogScaleUniform;
|
||||
@@ -67,6 +69,9 @@ public class LodRenderProgram extends ShaderProgram
|
||||
public final int noiseIntensityUniform;
|
||||
public final int noiseDropoffUniform;
|
||||
|
||||
// Debug Uniform
|
||||
public final int whiteWorldUniform;
|
||||
|
||||
public final LodFogConfig fogConfig;
|
||||
|
||||
// This will bind VertexAttribute
|
||||
@@ -85,7 +90,7 @@ public class LodRenderProgram extends ShaderProgram
|
||||
|
||||
lightMapUniform = getUniformLocation("lightMap");
|
||||
|
||||
// Fog uniforms
|
||||
// Fog Uniforms
|
||||
fullFogModeUniform = getUniformLocation("fullFogMode");
|
||||
fogColorUniform = getUniformLocation("fogColor");
|
||||
fogScaleUniform = tryGetUniformLocation("fogScale");
|
||||
@@ -94,12 +99,16 @@ public class LodRenderProgram extends ShaderProgram
|
||||
nearFogStartUniform = tryGetUniformLocation("nearFogStart");
|
||||
nearFogLengthUniform = tryGetUniformLocation("nearFogLength");
|
||||
|
||||
// Noise uniforms
|
||||
// Noise Uniforms
|
||||
noiseEnabledUniform = getUniformLocation("noiseEnabled");
|
||||
noiseStepsUniform = getUniformLocation("noiseSteps");
|
||||
noiseIntensityUniform = getUniformLocation("noiseIntensity");
|
||||
noiseDropoffUniform = getUniformLocation("noiseDropoff");
|
||||
|
||||
// Debug Uniform
|
||||
whiteWorldUniform = getUniformLocation("whiteWorld");
|
||||
|
||||
|
||||
// TODO: Add better use of the LODFormat thing
|
||||
int vertexByteCount = LodUtil.LOD_VERTEX_FORMAT.getByteSize();
|
||||
if (GLProxy.getInstance().VertexAttributeBufferBindingSupported)
|
||||
@@ -122,6 +131,7 @@ public class LodRenderProgram extends ShaderProgram
|
||||
if (earthRadiusUniform != -1) setUniform(earthRadiusUniform,
|
||||
/*6371KM*/ 6371000.0f / fogConfig.earthCurveRatio);
|
||||
|
||||
// Noise Uniforms
|
||||
setUniform(noiseEnabledUniform, fogConfig.noiseEnable);
|
||||
setUniform(noiseStepsUniform, fogConfig.noiseSteps);
|
||||
setUniform(noiseIntensityUniform, fogConfig.noiseIntensity);
|
||||
@@ -178,6 +188,9 @@ public class LodRenderProgram extends ShaderProgram
|
||||
setUniform(fullFogModeUniform, fullFogMode ? 1 : 0);
|
||||
setUniform(fogColorUniform, fogColor);
|
||||
|
||||
// Debug
|
||||
setUniform(whiteWorldUniform, Config.Client.Advanced.Debugging.enableWhiteWorld.get());
|
||||
|
||||
float nearFogLen = vanillaDrawDistance * 0.2f / lodDrawDistance;
|
||||
float nearFogStart = vanillaDrawDistance * (VERSION_CONSTANTS.isVanillaRenderedChunkSquare() ? (float)Math.sqrt(2.) : 1.f) / lodDrawDistance;
|
||||
if (nearFogStartUniform != -1) setUniform(nearFogStartUniform, nearFogStart);
|
||||
|
||||
@@ -161,8 +161,6 @@ public class LodRenderer
|
||||
drawSaveGLState.end("drawSaveGLState");
|
||||
|
||||
GLProxy glProxy = GLProxy.getInstance();
|
||||
if (Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get())
|
||||
MC_RENDER.tryDisableVanillaFog();
|
||||
|
||||
//===================//
|
||||
// draw params setup //
|
||||
@@ -252,7 +250,7 @@ public class LodRenderer
|
||||
bufferHandler.renderOpaque(this);
|
||||
|
||||
if (Config.Client.Advanced.Graphics.Quality.ssao.get()) {
|
||||
// SSAOShader.INSTANCE.render(partialTicks);
|
||||
// SSAOShader.INSTANCE.render(partialTicks); // For some reason this looks slightly different :/
|
||||
SSAORenderer.INSTANCE.render(partialTicks);
|
||||
}
|
||||
{
|
||||
|
||||
+7
-4
@@ -29,7 +29,7 @@ public abstract class AbstractShaderRenderer {
|
||||
|
||||
protected final ShaderProgram shader;
|
||||
protected final ShaderProgram applyShader;
|
||||
protected GLVertexBuffer boxBuffer;
|
||||
public GLVertexBuffer boxBuffer;
|
||||
protected VertexAttribute va;
|
||||
boolean init = false;
|
||||
|
||||
@@ -46,9 +46,8 @@ public abstract class AbstractShaderRenderer {
|
||||
protected AbstractShaderRenderer(ShaderProgram shader, ShaderProgram applyShader) {
|
||||
this.shader = shader;
|
||||
this.applyShader = applyShader;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (init) return;
|
||||
init = true;
|
||||
@@ -56,7 +55,7 @@ public abstract class AbstractShaderRenderer {
|
||||
va = VertexAttribute.create();
|
||||
va.bind();
|
||||
// Pos
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
setVertexAttributes();
|
||||
va.completeAndCheck(Float.BYTES * 2);
|
||||
|
||||
// Some shader stuff needs to be set a bit later than
|
||||
@@ -65,6 +64,10 @@ public abstract class AbstractShaderRenderer {
|
||||
createBuffer();
|
||||
}
|
||||
|
||||
/** Sets all the vertex attributes */
|
||||
void setVertexAttributes() {
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
};
|
||||
/** Overwrite this to apply uniforms to the shader */
|
||||
void setShaderUniforms(float partialTicks) {};
|
||||
/** Overwrite this to apply uniforms to the apply shader */
|
||||
|
||||
+27
-5
@@ -6,6 +6,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.fog.LodFogConfig;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.Shader;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.glObject.vertexAttribute.VertexAttribute;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
@@ -21,7 +22,10 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
|
||||
|
||||
// public final int modelOffsetUniform;
|
||||
public final int worldYOffsetUniform;
|
||||
// public final int worldYOffsetUniform;
|
||||
|
||||
public final int gProjUniform;
|
||||
public final int gDepthMapUniform;
|
||||
|
||||
// Fog Uniforms
|
||||
public final int fogColorUniform;
|
||||
@@ -36,13 +40,16 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
// This code is just a temp fix so that it looks fine for the time being
|
||||
// and even with the jank soloution, i cannot get it to work
|
||||
super(new ShaderProgram(
|
||||
() -> Shader.loadFile("shaders/fog/fog.vert", false, new StringBuilder()).toString(),
|
||||
() -> Shader.loadFile("shaders/normal.vert", false, new StringBuilder()).toString(),
|
||||
() -> fogConfig.loadAndProcessFragShader("shaders/fog/fog.frag", false).toString(),
|
||||
"fragColor", new String[] { "vPosition", "vPos", "color" }
|
||||
"fragColor", new String[] { "vPosition" }
|
||||
));
|
||||
|
||||
// modelOffsetUniform = this.shader.getUniformLocation("modelOffset");
|
||||
worldYOffsetUniform = this.shader.getUniformLocation("worldYOffset");
|
||||
// worldYOffsetUniform = this.shader.tryGetUniformLocation("worldYOffset");
|
||||
|
||||
gProjUniform = this.shader.getUniformLocation("gProj");
|
||||
gDepthMapUniform = this.shader.getUniformLocation("gDepthMap");
|
||||
// Fog uniforms
|
||||
fogColorUniform = this.shader.getUniformLocation("fogColor");
|
||||
fullFogModeUniform = this.shader.getUniformLocation("fullFogMode");
|
||||
@@ -53,6 +60,10 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
nearFogLengthUniform = this.shader.tryGetUniformLocation("nearFogLength");
|
||||
}
|
||||
|
||||
@Override
|
||||
void setVertexAttributes() {
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
};
|
||||
|
||||
@Override
|
||||
void setShaderUniforms(float partialTicks) {
|
||||
@@ -62,8 +73,19 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
vanillaDrawDistance += 32; // Give it a 2 chunk boundary for near fog.
|
||||
|
||||
|
||||
this.shader.setUniform(worldYOffsetUniform, (float) MC.getWrappedClientWorld().getMinHeight());
|
||||
Mat4f perspective = Mat4f.perspective(
|
||||
(float) MC_RENDER.getFov(partialTicks),
|
||||
MC_RENDER.getTargetFrameBufferViewportWidth() / (float) MC_RENDER.getTargetFrameBufferViewportHeight(),
|
||||
RenderUtil.getNearClipPlaneDistanceInBlocks(partialTicks),
|
||||
(float) ((lodDrawDistance + LodUtil.REGION_WIDTH) * Math.sqrt(2)));
|
||||
|
||||
|
||||
|
||||
// if (worldYOffsetUniform != -1) this.shader.setUniform(worldYOffsetUniform, (float) MC.getWrappedClientWorld().getMinHeight());
|
||||
|
||||
|
||||
this.shader.setUniform(this.shader.getUniformLocation("gProj"), perspective);
|
||||
GL32.glUniform1i(gDepthMapUniform, 0);
|
||||
// Fog
|
||||
this.shader.setUniform(fullFogModeUniform, MC_RENDER.isFogStateSpecial() ? 1 : 0);
|
||||
this.shader.setUniform(fogColorUniform, MC_RENDER.isFogStateSpecial() ? getSpecialFogColor(partialTicks) : getFogColor(partialTicks));
|
||||
|
||||
+8
-2
@@ -1,6 +1,7 @@
|
||||
package com.seibel.distanthorizons.core.render.renderer.shaders;
|
||||
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.glObject.vertexAttribute.VertexAttribute;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
@@ -16,9 +17,9 @@ public class SSAOShader extends AbstractShaderRenderer {
|
||||
public SSAOShader() {
|
||||
super(
|
||||
new ShaderProgram("shaders/normal.vert", "shaders/ssao/ao.frag",
|
||||
"fragColor", new String[]{"vPos"}),
|
||||
"fragColor", new String[]{"vPosition"}),
|
||||
new ShaderProgram("shaders/normal.vert", "shaders/ssao/apply-frag.frag",
|
||||
"fragColor", new String[]{"vPos"})
|
||||
"fragColor", new String[]{"vPosition"})
|
||||
);
|
||||
|
||||
}
|
||||
@@ -28,6 +29,11 @@ public class SSAOShader extends AbstractShaderRenderer {
|
||||
kernel = genKernel();
|
||||
}
|
||||
|
||||
@Override
|
||||
void setVertexAttributes() {
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
void setShaderUniforms(float partialTicks) {
|
||||
Mat4f perspective = Mat4f.perspective(
|
||||
|
||||
+29
@@ -53,6 +53,7 @@ public interface IChunkWrapper extends IBindable
|
||||
long getLongChunkPos();
|
||||
|
||||
void setIsDhLightCorrect(boolean isDhLightCorrect);
|
||||
void setUseDhLighting(boolean useDhLighting);
|
||||
boolean isLightCorrect();
|
||||
|
||||
|
||||
@@ -65,6 +66,34 @@ public interface IChunkWrapper extends IBindable
|
||||
int getBlockLight(int relX, int relY, int relZ);
|
||||
int getSkyLight(int relX, int relY, int relZ);
|
||||
|
||||
/**
|
||||
* Populates DH's saved lighting using MC's lighting engine.
|
||||
* This is generally done in cases where MC's lighting is correct now, but may not be later (like when a chunk is unloading).
|
||||
*
|
||||
* @throws IllegalStateException if the chunk's lighting isn't valid. This is done to prevent accidentally baking broken lighting.
|
||||
*/
|
||||
default void bakeDhLightingUsingMcLightingEngine() throws IllegalStateException
|
||||
{
|
||||
if (!this.isLightCorrect())
|
||||
{
|
||||
throw new IllegalStateException("Unable to bake lighting for for chunk ["+this.getChunkPos()+"], Minecraft lighting not valid.");
|
||||
}
|
||||
|
||||
// get the lighting for every relative block pos
|
||||
for (int relX = 0; relX < LodUtil.CHUNK_WIDTH; relX++)
|
||||
{
|
||||
for (int relZ = 0; relZ < LodUtil.CHUNK_WIDTH; relZ++)
|
||||
{
|
||||
for (int y = this.getMinBuildHeight(); y < this.getMaxBuildHeight(); y++)
|
||||
{
|
||||
this.setDhSkyLight(relX, y, relZ, this.getSkyLight(relX, y, relZ));
|
||||
this.setDhBlockLight(relX, y, relZ, this.getBlockLight(relX, y, relZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<DhBlockPos> getBlockLightPosList();
|
||||
|
||||
|
||||
-3
@@ -134,8 +134,5 @@ public interface IMinecraftRenderWrapper extends IBindable
|
||||
|
||||
ILightMapWrapper getLightmapWrapper();
|
||||
|
||||
// Try and disable vanilla fog. Return true if successful, or false if not able to.
|
||||
boolean tryDisableVanillaFog();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
"distanthorizons.config.client.advanced.graphics.noiseTextureSettings.noiseDropoff":
|
||||
"Noise Dropoff",
|
||||
"distanthorizons.config.client.advanced.graphics.noiseTextureSettings.noiseDropoff.@tooltip":
|
||||
"How far should the noise texture render before it fades away? \n\n0.0 - the noise texture will render the entire LOD render distance. \n3.0 - the noise texture will fade away at 1/3 of the LOD render distance. ",
|
||||
"Defines how far should the noise texture render before it fades away. (in blocks). \nSet to 0 to disable noise from fading away.",
|
||||
|
||||
|
||||
"distanthorizons.config.client.advanced.graphics.advancedGraphics":
|
||||
@@ -237,7 +237,7 @@
|
||||
"distanthorizons.config.client.advanced.graphics.advancedGraphics.seamlessOverdraw":
|
||||
"(Experimental) Seamless Overdraw",
|
||||
"distanthorizons.config.client.advanced.graphics.advancedGraphics.seamlessOverdraw.@tooltip":
|
||||
"Buggy experimental option that will attempt to match up \nDistant Horizons' and Minecraft's near/far clip planes, \nreducing overdraw.",
|
||||
"Buggy experimental option that will attempt to match up \nDistant Horizons' and Minecraft's near/far clip planes, \nreducing overdraw. \n\nNote: only works with Fabric.",
|
||||
"distanthorizons.config.client.advanced.graphics.advancedGraphics.brightnessMultiplier":
|
||||
"Brightness Multiplier",
|
||||
"distanthorizons.config.client.advanced.graphics.advancedGraphics.brightnessMultiplier.@tooltip":
|
||||
@@ -383,7 +383,11 @@
|
||||
"distanthorizons.config.client.advanced.debugging.debugWireframeRendering":
|
||||
"Enable Debug Wireframe Rendering",
|
||||
"distanthorizons.config.client.advanced.debugging.debugWireframeRendering.@tooltip":
|
||||
"If enabled, various wireframes for debugging internal functions will be drawn.",
|
||||
"If enabled, various wireframes for debugging internal functions will be drawn.",
|
||||
"distanthorizons.config.client.advanced.debugging.enableWhiteWorld":
|
||||
"Enable white world",
|
||||
"distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip":
|
||||
"If enabled, vertex color will not be passed.\nUseful for debugging shaders.",
|
||||
"distanthorizons.config.client.advanced.debugging.allowUnsafeValues":
|
||||
"Allow Unsafe UI Values",
|
||||
"distanthorizons.config.client.advanced.debugging.allowUnsafeValues.@tooltip":
|
||||
@@ -460,6 +464,8 @@
|
||||
"Float test",
|
||||
"distanthorizons.config.client.advanced.debugging.exampleConfigScreen.stringTest":
|
||||
"String test",
|
||||
"distanthorizons.config.client.advanced.debugging.exampleConfigScreen.uiButtonTest":
|
||||
"UI Button test",
|
||||
"distanthorizons.config.client.advanced.debugging.exampleConfigScreen.listTest":
|
||||
"List (ArrayList) test",
|
||||
"distanthorizons.config.client.advanced.debugging.exampleConfigScreen.mapTest":
|
||||
|
||||
@@ -6,16 +6,18 @@ in vec4 vPos;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// Fog Uniforms
|
||||
uniform float fogScale;
|
||||
uniform float fogVerticalScale;
|
||||
uniform float nearFogStart;
|
||||
uniform float nearFogLength;
|
||||
uniform int fullFogMode;
|
||||
|
||||
// Noise Uniforms
|
||||
uniform bool noiseEnabled;
|
||||
uniform int noiseSteps;
|
||||
uniform float noiseIntensity;
|
||||
uniform float noiseDropoff;
|
||||
uniform int noiseDropoff;
|
||||
|
||||
/* ========MARCO DEFINED BY RUNTIME CODE GEN=========
|
||||
|
||||
@@ -84,20 +86,80 @@ vec3 HSV2RGB(vec3 c) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Fragment Shader
|
||||
*
|
||||
*
|
||||
* author: James Seibel
|
||||
* author: coolGi
|
||||
* version: 7-2-2023
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
vec4 returnColor;
|
||||
fragColor = vertexColor;
|
||||
|
||||
|
||||
// TODO: Move into its own function instead of in an if statement
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
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
|
||||
noiseAmplification *= fragColor.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;
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
// 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
|
||||
);
|
||||
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
|
||||
);
|
||||
|
||||
// For testing
|
||||
// if (fragColor.r != 69420.) {
|
||||
// fragColor = vec4(
|
||||
// mod(fixedVPos.x, 1),
|
||||
// mod(fixedVPos.y, 1),
|
||||
// mod(fixedVPos.z, 1),
|
||||
// fragColor.w);
|
||||
// }
|
||||
}
|
||||
|
||||
// TODO: Move into its own function instead of in an if statement
|
||||
// This is so that it can apply after the SSAO (work for this has started in the FogShader file and fog/fog.frag shader)
|
||||
if (fullFogMode != 0) {
|
||||
returnColor = vec4(fogColor.rgb, 1.0);
|
||||
fragColor = vec4(fogColor.rgb, 1.0);
|
||||
} else {
|
||||
// TODO: add a white texture to support Optifine shaders
|
||||
//vec4 textureColor = texture(texImage, textureCoord);
|
||||
@@ -115,59 +177,8 @@ void main()
|
||||
float mixedFogThickness = clamp(mixFogThickness(
|
||||
nearFogThickness, farFogThickness, heightFogThickness), 0.0, 1.0);
|
||||
|
||||
returnColor = mix(vertexColor, vec4(fogColor.rgb, 1.0), mixedFogThickness);
|
||||
}
|
||||
|
||||
if (noiseEnabled) {
|
||||
// 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
|
||||
);
|
||||
|
||||
|
||||
float noiseAmplification = noiseIntensity / 100;
|
||||
noiseAmplification = (-1 * pow(2*((returnColor.x + returnColor.y + returnColor.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
|
||||
noiseAmplification *= returnColor.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;
|
||||
|
||||
|
||||
// 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 = returnColor.rgb + (vec3(1.0) - returnColor.rgb) * randomValue;
|
||||
|
||||
// Clamps it and turns it back into a vec4
|
||||
returnColor = mix(
|
||||
vec4(
|
||||
clamp(newCol.r, 0., 1.),
|
||||
clamp(newCol.g, 0., 1.),
|
||||
clamp(newCol.b, 0., 1.),
|
||||
returnColor.w
|
||||
), returnColor,
|
||||
clamp(length(vertexWorldPos) * fogScale * noiseDropoff, 0., 1.) // The further away it gets, the less noise gets applied
|
||||
);
|
||||
|
||||
// For testing
|
||||
// if (returnColor.r != 69420.) {
|
||||
// returnColor = vec4(
|
||||
// mod(fixedVPos.x, 1),
|
||||
// mod(fixedVPos.y, 1),
|
||||
// mod(fixedVPos.z, 1),
|
||||
// returnColor.w);
|
||||
// }
|
||||
fragColor = mix(fragColor, vec4(fogColor.rgb, 1.0), mixedFogThickness);
|
||||
}
|
||||
|
||||
// If "w" is just set to just 1. then it would crash
|
||||
fragColor = returnColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,13 +190,13 @@ float linearFog(float x, float fogStart, float fogLength, float fogMin, float fo
|
||||
}
|
||||
|
||||
float exponentialFog(float x, float fogStart, float fogLength,
|
||||
float fogMin, float fogRange, float fogDensity) {
|
||||
float fogMin, float fogRange, float fogDensity) {
|
||||
x = max((x-fogStart)/fogLength, 0.0) * fogDensity;
|
||||
return fogMin + fogRange - fogRange/exp(x);
|
||||
}
|
||||
|
||||
float exponentialSquaredFog(float x, float fogStart, float fogLength,
|
||||
float fogMin, float fogRange, float fogDensity) {
|
||||
float fogMin, float fogRange, float fogDensity) {
|
||||
x = max((x-fogStart)/fogLength, 0.0) * fogDensity;
|
||||
return fogMin + fogRange - fogRange/exp(x*x);
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
in vec3 vertexWorldPos;
|
||||
in float vertexYPos;
|
||||
//in vec2 TexCoord;
|
||||
in vec2 TexCoord;
|
||||
|
||||
//in float vertexYPos;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D gDepthMap;
|
||||
uniform mat4 gProj;
|
||||
|
||||
uniform float fogScale;
|
||||
uniform float fogVerticalScale;
|
||||
@@ -15,6 +17,20 @@ uniform int fullFogMode;
|
||||
uniform vec4 fogColor;
|
||||
|
||||
|
||||
/* ========MARCO DEFINED BY RUNTIME CODE GEN=========
|
||||
|
||||
float farFogStart;
|
||||
float farFogLength;
|
||||
float farFogMin;
|
||||
float farFogRange;
|
||||
float farFogDensity;
|
||||
|
||||
float heightFogStart;
|
||||
float heightFogLength;
|
||||
float heightFogMin;
|
||||
float heightFogRange;
|
||||
float heightFogDensity;
|
||||
*/
|
||||
|
||||
// method definitions
|
||||
// ==== The below 5 methods will be run-time generated. ====
|
||||
@@ -42,6 +58,20 @@ float mod(float x, int y) {
|
||||
}
|
||||
|
||||
|
||||
vec3 calcViewPosition(vec2 coords) {
|
||||
float fragmentDepth = texture(gDepthMap, coords).r;
|
||||
|
||||
vec4 ndc = vec4(
|
||||
coords.x * 2.0 - 1.0,
|
||||
coords.y * 2.0 - 1.0,
|
||||
fragmentDepth * 2.0 - 1.0,
|
||||
1.0
|
||||
);
|
||||
|
||||
vec4 vs_pos = inverse(gProj) * ndc;
|
||||
vs_pos.xyz = vs_pos.xyz / vs_pos.w;
|
||||
return vs_pos.xyz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fragment shader for fog.
|
||||
@@ -50,6 +80,9 @@ float mod(float x, int y) {
|
||||
* version: 2023-6-21
|
||||
*/
|
||||
void main() {
|
||||
float vertexYPos = 100f;
|
||||
vec3 vertexWorldPos = calcViewPosition(TexCoord);
|
||||
|
||||
if (fullFogMode != 0) {
|
||||
fragColor = vec4(fogColor.r, fogColor.g, fogColor.b, 1.);
|
||||
} else {
|
||||
@@ -70,16 +103,10 @@ void main() {
|
||||
|
||||
// Testing
|
||||
// if (fragColor.r != 6969.) { // This line is so that the compiler doesnt delete the previos code
|
||||
//// fragColor = vec4(
|
||||
//// mod(vertexWorldPos.x, 1),
|
||||
//// mod(vertexWorldPos.y, 1),
|
||||
//// mod(vertexWorldPos.z, 1),
|
||||
//// 1.
|
||||
//// );
|
||||
// fragColor = vec4(
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(texture(gDepthMap, TexCoord).x, 1),
|
||||
// mod(texture(gDepthMap, TexCoord).y, 1),
|
||||
// mod(texture(gDepthMap, TexCoord).z, 1),
|
||||
// 1.
|
||||
// );
|
||||
// }
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#version 150 core
|
||||
|
||||
|
||||
//uniform vec3 modelOffset;
|
||||
uniform float worldYOffset;
|
||||
|
||||
in vec2 vPos;
|
||||
in uvec4 vPosition;
|
||||
out vec3 vertexWorldPos;
|
||||
out float vertexYPos;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// vertexWorldPos = vPosition.xyz + modelOffset;
|
||||
vertexYPos = vPosition.y + worldYOffset;
|
||||
|
||||
gl_Position = vec4(vPos, 1.0, 1.0);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#version 150 core
|
||||
|
||||
in vec2 vPos;
|
||||
in vec2 vPosition;
|
||||
out vec2 TexCoord;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vPos, 1.0, 1.0);
|
||||
TexCoord = vPos.xy * 0.5 + 0.5;
|
||||
gl_Position = vec4(vPosition, 1.0, 1.0);
|
||||
TexCoord = vPosition.xy * 0.5 + 0.5;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#version 150 core
|
||||
|
||||
in vec2 TexCoord;
|
||||
in vec2 ViewRay;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ out vec4 vertexColor;
|
||||
out vec3 vertexWorldPos;
|
||||
out float vertexYPos;
|
||||
|
||||
uniform bool whiteWorld;
|
||||
|
||||
uniform mat4 combinedMatrix;
|
||||
uniform vec3 modelOffset;
|
||||
uniform float worldYOffset;
|
||||
@@ -51,7 +53,9 @@ void main()
|
||||
|
||||
float light2 = (mod(float(lights), 16.0)+0.5) / 16.0;
|
||||
float light = (float(lights/16u)+0.5) / 16.0;
|
||||
vertexColor = color * vec4(texture(lightMap, vec2(light, light2)).xyz, 1.0);
|
||||
vertexColor = vec4(texture(lightMap, vec2(light, light2)).xyz, 1.0);
|
||||
if (!whiteWorld)
|
||||
vertexColor *= color;
|
||||
|
||||
gl_Position = combinedMatrix * vec4(vertexWorldPos + vec3(mx, 0, mz), 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user