diff --git a/core/src/main/resources/shaders/fade/dhFade.frag b/core/src/main/resources/shaders/fade/dhFade.frag index 598f7c3f4..a12562b7b 100644 --- a/core/src/main/resources/shaders/fade/dhFade.frag +++ b/core/src/main/resources/shaders/fade/dhFade.frag @@ -40,7 +40,6 @@ void main() // the DH texture will have white if nothing was written to that pixel. - // TODO replace with a depth texture check, this feels janky if (dhColor == vec4(1)) { // if not done vanilla clouds will render incorrectly at night @@ -60,7 +59,7 @@ void main() // as the depth increases from the camera float fadeStep = smoothstep(startFade, endFade, dhFragmentDistance); fragColor = mix(combinedMcDhColor, dhColor, fadeStep); - fragColor.a = 1.0; // TODO is setting the alpha needed? + fragColor.a = 1.0; } diff --git a/core/src/main/resources/shaders/fog/fog.frag b/core/src/main/resources/shaders/fog/fog.frag index 6b75f6d6a..16ecf15a3 100644 --- a/core/src/main/resources/shaders/fog/fog.frag +++ b/core/src/main/resources/shaders/fog/fog.frag @@ -44,15 +44,10 @@ uniform float uCameraBlockYPos; -const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189); - - - //====================// // method definitions // //====================// -float InterleavedGradientNoise(const in vec2 pixel); vec3 calcViewPosition(float fragmentDepth); float getFarFogThickness(float dist); @@ -103,10 +98,6 @@ void main() // test //fragColor.a = heightFogThickness; - - // dither fog (to smooth out aliasing) - //float dither = InterleavedGradientNoise(gl_FragCoord.xy) - 0.5; - //fragColor.a += dither / 255.0; } else if (fogMode == 1) { @@ -130,15 +121,10 @@ void main() } -// -// methods // -// -float InterleavedGradientNoise(const in vec2 pixel) -{ - float x = dot(pixel, MAGIC.xy); - return fract(MAGIC.z * fract(x)); -} +//================// +// helper methods // +//================// vec3 calcViewPosition(float fragmentDepth) { @@ -151,35 +137,9 @@ vec3 calcViewPosition(float fragmentDepth) -float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) -{ - worldDist = (worldDist - fogStart) / fogLength; - worldDist = clamp(worldDist, 0.0, 1.0); - return fogMin + fogRange * worldDist; -} - -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); -} - - - -// -// generated methods // -// -// TODO cleanup comment regions +//=========// +// far fog // +//=========// float getFarFogThickness(float dist) { @@ -219,6 +179,35 @@ float getHeightFogThickness(float dist) } } +float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange) +{ + worldDist = (worldDist - fogStart) / fogLength; + worldDist = clamp(worldDist, 0.0, 1.0); + return fogMin + fogRange * worldDist; +} + +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); +} + + + +//============// +// height fog // +//============// + /** 1 = full fog, 0 = no fog */ float calculateHeightFogDepth(float worldYPos) {