shader reformatting

This commit is contained in:
James Seibel
2026-02-05 16:49:30 -06:00
parent 35d3614c88
commit be3e618aca
2 changed files with 36 additions and 48 deletions
@@ -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;
}
+35 -46
View File
@@ -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)
{