re-do border fog. make the sunlight get absorbed by the sky more (it gets more colorful). clean up the fog with clouds function

This commit is contained in:
Xonk
2023-12-27 15:04:36 -05:00
parent 2d64880893
commit 3d58394509
7 changed files with 62 additions and 88 deletions

View File

@ -3,6 +3,7 @@
flat varying vec3 zMults;
flat varying vec2 TAA_Offset;
flat varying vec3 skyGroundColor;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
@ -251,17 +252,6 @@ void main() {
/// --- REFRACTION --- ///
#ifdef Refraction
// refractedCoord = clamp(refractedCoord + (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE ,-1.0,1.0);
// // refractedCoord = clamp(refractedCoord - tangentNormals, refractedCoord-0.5,refractedCoord);
// // if(tangentNormals.xy <= vec2(0.0, 0.0) ) refractedCoord = abs(refractedCoord - tangentNormals);
// // refractedCoord += tangentNormals * 0.1 * RENDER_SCALE;
// float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g;
// // float refractedalpha2 = texture2D(colortex7,refractedCoord).a;
// if( refractedalpha <= 0.001) refractedCoord = texcoord; // remove refracted coords on solids
ApplyDistortion(refractedCoord, tangentNormals, vec2(z2,z));
#endif
@ -272,11 +262,10 @@ void main() {
float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
#if defined OVERWORLD_SHADER && defined BorderFog
vec3 sky = skyFromTex(np3, colortex4).rgb / 30.0;
float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ;
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog);
float fog = exp2(-100.0 * pow(clamp(1.0-length(p3)/far,0.0,1.0),2.0));
fog *= exp(-30.0*(pow(clamp(np3.y,0.0,1.0),2.0))) ;
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, skyGroundColor, fog);
#endif
vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth);
@ -291,7 +280,7 @@ void main() {
#ifdef BorderFog
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog);
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, skyGroundColor, fog);
#endif
}

View File

@ -1,3 +1,5 @@
#include "/lib/settings.glsl"
varying vec2 texcoord;
flat varying vec3 zMults;
uniform float far;
@ -13,6 +15,13 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#ifdef BorderFog
uniform sampler2D colortex4;
flat varying vec3 skyGroundColor;
#endif
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -21,6 +30,9 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
void main() {
#ifdef BorderFog
skyGroundColor = texelFetch2D(colortex4,ivec2(1,37),0).rgb / 30.0;
#endif
TAA_Offset = offsets[framemod8];

View File

@ -119,26 +119,19 @@ void main() {
////////////////////////////////////////
vec2 planetSphere = vec2(0.0);
vec3 sky = vec3(0.0);
vec3 skyAbsorb = vec3(0.0);
float sunVis = clamp(sunElevation,0.0,0.05)/0.05*clamp(sunElevation,0.0,0.05)/0.05;
float moonVis = clamp(-sunElevation,0.0,0.05)/0.05*clamp(-sunElevation,0.0,0.05)/0.05;
// zenithColor = calculateAtmosphere(vec3(0.0), vec3(0.0,1.0,0.0), vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,tempOffsets.x);
skyAbsorb = vec3(0.0);
vec3 absorb = vec3(0.0);
vec3 skyAbsorb = vec3(0.0);
sunColor = calculateAtmosphere(vec3(0.0), sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.0);
sunColor = sunColorBase/4000. * skyAbsorb;
skyAbsorb = vec3(1.0);
moonColor = calculateAtmosphere(vec3(0.0), -sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5);
sunColor = sunColorBase/4000. * (skyAbsorb);
// skyAbsorb = vec3(1.0);
// moonColor = calculateAtmosphere(vec3(0.0), -sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5);
moonColor = moonColorBase/4000.0;
lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis;
// WsunVec = ( float(sunElevation > 1e-5)*2-1. )*normalize(mat3(gbufferModelViewInverse) * sunPosition);
#endif
//////////////////////////////

View File

@ -6,9 +6,9 @@ uniform sampler2D colortex7;
uniform vec2 texelSize;
uniform float frameTimeCounter;
uniform sampler2D shadowcolor0;
uniform sampler2D shadowtex0;
uniform sampler2D shadowtex1;
// uniform sampler2D shadowcolor0;
// uniform sampler2D shadowtex0;
// uniform sampler2D shadowtex1;
#include "/lib/color_transforms.glsl"
#include "/lib/color_dither.glsl"
@ -161,28 +161,5 @@ void main() {
applyContrast(FINAL_COLOR, CONTRAST); // for fun
gl_FragColor.rgb = FINAL_COLOR;
// uniform sampler2D shadowcolor0;
// uniform sampler2D shadowtex0;
// uniform sampler2D shadowtex1;
// vec2 coord = gl_FragCoord.xy;
// int invertChecker = int(mod(coord.x,2)) * int(mod(coord.y,2));
// int checker = int(mod(coord.x*coord.y,2));
// int checker2 = int(mod(coord.x*coord.y+1,2));
// gl_FragColor.rgb = vec3(0.2) * checker * checker2;
// if( hideGUI == 1){
// vec2 texrood = texcoord * vec2(2.0, 1.0) - vec2(1.0, 0.0);
// if(texcoord.x > 0.5) gl_FragColor.rgb = texture2D(shadowcolor0, texrood).rgb;
// // if(texrood.x > 0.49 && texrood.x < 0.51 && texrood.y > 0.49 && texrood.y < 0.51) gl_FragColor.rgb = vec3(1,0,0);
// }
}