Made it so shader auto updates when noise settings change

This commit is contained in:
coolGi
2023-01-28 20:52:09 +10:30
parent deaef0b88d
commit ee8c698d77
6 changed files with 29 additions and 14 deletions
@@ -485,7 +485,7 @@ public class Config
.build();
public static ConfigEntry<Double> noiseIntensity = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI dosnt support floats)
.set(15d)
.set(12.5d)
.comment("How intense the noise should be")
.build();
}
@@ -42,6 +42,7 @@ import static com.seibel.lod.core.render.glObject.GLProxy.GL_LOGGER;
* @author James Seibel
* @version 2022-11-24
*/
// TODO: Move lots out of here, there should be a listener hooked onto the config to update the shader
public class LodFogConfig
{
private static final IOptifineAccessor OPTIFINE = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
@@ -57,7 +58,12 @@ public class LodFogConfig
final boolean drawNearFog;
public final int earthCurveRatio; // FIXME: Move this out of here
// TODO: Move these out of here
public final int earthCurveRatio;
public final boolean noiseEnable;
public final int noiseSteps;
public final float noiseIntensity;
public static LodFogConfig generateFogConfig()
@@ -73,7 +79,13 @@ public class LodFogConfig
/** sets all fog options from the config */
private LodFogConfig(EFogDrawMode fogDrawMode)
{
earthCurveRatio = Config.Client.Graphics.AdvancedGraphics.earthCurveRatio.get(); //FIXME: Move this out of here
// TODO: Move these out of here
earthCurveRatio = Config.Client.Graphics.AdvancedGraphics.earthCurveRatio.get();
noiseEnable = Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseEnable.get();
noiseSteps = Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseSteps.get();
noiseIntensity = Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseIntensity.get().floatValue();
if (fogDrawMode != EFogDrawMode.FOG_DISABLED)
{
@@ -425,12 +437,15 @@ public class LodFogConfig
return Float.compare(that.heightFogHeight, heightFogHeight) == 0 &&
drawNearFog == that.drawNearFog && Objects.equals(farFogSetting, that.farFogSetting) &&
Objects.equals(heightFogSetting, that.heightFogSetting) && heightFogMixMode == that.heightFogMixMode &&
heightFogMode == that.heightFogMode && earthCurveRatio == that.earthCurveRatio;
heightFogMode == that.heightFogMode
// TODO: Move these out of here
&& earthCurveRatio == that.earthCurveRatio
&& noiseEnable == that.noiseEnable && noiseSteps == that.noiseSteps && noiseIntensity == that.noiseIntensity;
}
@Override
public int hashCode()
{
return Objects.hash(farFogSetting, heightFogSetting, heightFogMixMode, heightFogMode, heightFogHeight, drawNearFog, earthCurveRatio);
return Objects.hash(farFogSetting, heightFogSetting, heightFogMixMode, heightFogMode, heightFogHeight, drawNearFog, earthCurveRatio, noiseEnable, noiseSteps, noiseIntensity);
}
}
@@ -21,7 +21,6 @@ package com.seibel.lod.core.render.renderer;
import java.awt.Color;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.render.fog.LodFogConfig;
import com.seibel.lod.core.render.glObject.GLProxy;
@@ -120,9 +119,9 @@ public class LodRenderProgram extends ShaderProgram {
if (earthRadiusUniform != -1) setUniform(earthRadiusUniform,
/*6371KM*/ 6371000.0f / fogConfig.earthCurveRatio);
setUniform(noiseEnabledUniform, Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseEnable.get());
setUniform(noiseStepsUniform, Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseSteps.get());
setUniform(noiseIntensityUniform, Config.Client.Graphics.AdvancedGraphics.NoiseSettings.noiseIntensity.get().floatValue());
setUniform(noiseEnabledUniform, fogConfig.noiseEnable);
setUniform(noiseStepsUniform, fogConfig.noiseSteps);
setUniform(noiseIntensityUniform, fogConfig.noiseIntensity);
}
// If not usable, return a new LodFogConfig to be constructed
+2 -1
View File
@@ -24,7 +24,8 @@ uniform float earthRadius;
* author: James Seibel
* author: TomTheFurry
* author: stduhpf
* version: 2022-8-13
* updated: coolGi
* version: 24-1-2023
*/
void main()
{
@@ -85,7 +85,8 @@ vec3 HSV2RGB(vec3 c) {
* Fragment Shader
*
* author: James Seibel
* version: 11-26-2021
* author: coolGi
* version: 24-1-2023
*/
void main()
{
@@ -21,10 +21,9 @@ uniform float mircoOffset;
* Vertex Shader
*
* author: James Seibel
* version: 12-8-2021
*
* updated: TomTheFurry
* version: 15-2-2022
* updated: coolGi
* version: 24-1-2023
*/
void main()
{