Removed old fog
This commit is contained in:
+5
-31
@@ -53,13 +53,6 @@ public class LodRenderProgram extends ShaderProgram
|
||||
public final int earthRadiusUniform;
|
||||
|
||||
public final int lightMapUniform;
|
||||
// Fog Uniforms
|
||||
public final int fogColorUniform;
|
||||
public final int fogScaleUniform;
|
||||
public final int fogVerticalScaleUniform;
|
||||
public final int nearFogStartUniform;
|
||||
public final int nearFogLengthUniform;;
|
||||
public final int fullFogModeUniform;
|
||||
|
||||
// Noise Uniforms
|
||||
public final int noiseEnabledUniform;
|
||||
@@ -71,10 +64,11 @@ public class LodRenderProgram extends ShaderProgram
|
||||
|
||||
// This will bind VertexAttribute
|
||||
public LodRenderProgram(LodFogConfig fogConfig) {
|
||||
super(() -> Shader.loadFile(fogConfig.earthCurveRatio!=0 ? VERTEX_CURVE_SHADER_PATH : VERTEX_SHADER_PATH,
|
||||
false, new StringBuilder()).toString(),
|
||||
() -> fogConfig.loadAndProcessFragShader(FRAGMENT_SHADER_PATH, false).toString(),
|
||||
"fragColor", new String[] { "vPosition", "color" });
|
||||
super(
|
||||
fogConfig.earthCurveRatio!=0 ? VERTEX_CURVE_SHADER_PATH : VERTEX_SHADER_PATH,
|
||||
FRAGMENT_SHADER_PATH,
|
||||
"fragColor", new String[] { "vPosition", "color" }
|
||||
);
|
||||
this.fogConfig = fogConfig;
|
||||
|
||||
combinedMatUniform = getUniformLocation("combinedMatrix");
|
||||
@@ -85,15 +79,6 @@ public class LodRenderProgram extends ShaderProgram
|
||||
|
||||
lightMapUniform = getUniformLocation("lightMap");
|
||||
|
||||
// Fog Uniforms
|
||||
fullFogModeUniform = getUniformLocation("fullFogMode");
|
||||
fogColorUniform = getUniformLocation("fogColor");
|
||||
fogScaleUniform = tryGetUniformLocation("fogScale");
|
||||
fogVerticalScaleUniform = tryGetUniformLocation("fogVerticalScale");
|
||||
// near
|
||||
nearFogStartUniform = tryGetUniformLocation("nearFogStart");
|
||||
nearFogLengthUniform = tryGetUniformLocation("nearFogLength");
|
||||
|
||||
// Noise Uniforms
|
||||
noiseEnabledUniform = getUniformLocation("noiseEnabled");
|
||||
noiseStepsUniform = getUniformLocation("noiseSteps");
|
||||
@@ -175,17 +160,6 @@ public class LodRenderProgram extends ShaderProgram
|
||||
setUniform(lightMapUniform, lightmapBindPoint);
|
||||
|
||||
if (worldYOffsetUniform != -1) setUniform(worldYOffsetUniform, (float)worldYOffset);
|
||||
|
||||
// Fog
|
||||
setUniform(fullFogModeUniform, fullFogMode ? 1 : 0);
|
||||
setUniform(fogColorUniform, fogColor);
|
||||
|
||||
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);
|
||||
if (nearFogLengthUniform != -1) setUniform(nearFogLengthUniform, nearFogLen);
|
||||
if (fogScaleUniform != -1) setUniform(fogScaleUniform, 1.f/lodDrawDistance);
|
||||
if (fogVerticalScaleUniform != -1) setUniform(fogVerticalScaleUniform, 1.f/worldHeight);
|
||||
}
|
||||
|
||||
public void setModelPos(Vec3f modelPos) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#version 150 core
|
||||
|
||||
in vec4 vertexColor;
|
||||
in vec3 vertexWorldPos;
|
||||
@@ -6,45 +7,12 @@ 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 int noiseDropoff;
|
||||
|
||||
/* ========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;
|
||||
*/
|
||||
|
||||
uniform vec4 fogColor;
|
||||
|
||||
// method definitions
|
||||
// ==== The below 5 methods will be run-time generated. ====
|
||||
float getNearFogThickness(float dist);
|
||||
float getFarFogThickness(float dist);
|
||||
float getHeightFogThickness(float dist);
|
||||
float calculateFarFogDepth(float horizontal, float dist, float nearFogStart);
|
||||
float calculateHeightFogDepth(float vertical, float realY);
|
||||
float mixFogThickness(float near, float far, float height);
|
||||
// =========================================================
|
||||
|
||||
float fade(float value, float start, float end) {
|
||||
return (clamp(value,start,end)-start)/(end-start);
|
||||
@@ -155,47 +123,4 @@ void main()
|
||||
// fragColor.w);
|
||||
// }
|
||||
}
|
||||
|
||||
// TODO: Move into its own function instead of in an if statement
|
||||
if (fullFogMode != 0) {
|
||||
fragColor = vec4(fogColor.rgb, 1.0);
|
||||
} else {
|
||||
// TODO: add a white texture to support Optifine shaders
|
||||
//vec4 textureColor = texture(texImage, textureCoord);
|
||||
//fragColor = vertexColor * textureColor;
|
||||
|
||||
float horizontalDist = length(vertexWorldPos.xz) * fogScale;
|
||||
float heightDist = calculateHeightFogDepth(
|
||||
vertexWorldPos.y, vertexYPos) * fogVerticalScale;
|
||||
float farDist = calculateFarFogDepth(horizontalDist,
|
||||
length(vertexWorldPos.xyz) * fogScale, nearFogStart);
|
||||
|
||||
float nearFogThickness = getNearFogThickness(horizontalDist);
|
||||
float farFogThickness = getFarFogThickness(farDist);
|
||||
float heightFogThickness = getHeightFogThickness(heightDist);
|
||||
float mixedFogThickness = clamp(mixFogThickness(
|
||||
nearFogThickness, farFogThickness, heightFogThickness), 0.0, 1.0);
|
||||
|
||||
fragColor = mix(fragColor, vec4(fogColor.rgb, 1.0), mixedFogThickness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Are these still needed?
|
||||
float linearFog(float x, float fogStart, float fogLength, float fogMin, float fogRange) {
|
||||
x = clamp((x-fogStart)/fogLength, 0.0, 1.0);
|
||||
return fogMin + fogRange * x;
|
||||
}
|
||||
|
||||
float exponentialFog(float x, float fogStart, float fogLength,
|
||||
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) {
|
||||
x = max((x-fogStart)/fogLength, 0.0) * fogDensity;
|
||||
return fogMin + fogRange - fogRange/exp(x*x);
|
||||
}
|
||||
@@ -19,6 +19,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. ====
|
||||
|
||||
Reference in New Issue
Block a user