make VL fog exist when clouds are turned off

This commit is contained in:
Xonk 2023-06-14 18:42:33 -04:00
parent 06a764f437
commit b19c03d6b8
5 changed files with 78 additions and 79 deletions

View File

@ -902,7 +902,7 @@ void main() {
SSS = SubsurfaceScattering_sun(albedo, SHADOWBLOCKERDEPTBH, LabSSS, clamp(dot(np3, WsunVec),0.0,1.0)) ;
// if (isEyeInWater == 0) SSS *= lightleakfix; // light leak fix
if (isEyeInWater == 0) SSS *= lightleakfix; // light leak fix
#endif

View File

@ -220,6 +220,7 @@ void main() {
gl_FragData[0] = clamp(VL_Fog,0.0,65000.);
#endif
} else {
float dirtAmount = Dirt_Amount;

View File

@ -112,7 +112,9 @@
#define CaveFog_amount 1 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define Cloud_Fog // render the VL clouds a second time along with VL fog so you can fly through it and stuff. expect a noticeable performance hit.
// ----- TIME OF DAY FOG ----- //
#define TOD_Fog_mult 1.0 // [0.0 0.25 0.5 0.75 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
@ -304,7 +306,10 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] THIS WILL BREAK SUBSURF
#define Daily_Weather // different skies and fog for different days.
#ifdef VOLUMETRIC_CLOUDS
#define Cloud_Fog // render the VL clouds a second time along with VL fog so you can fly through it and stuff. expect a noticeable performance hit.
#define CLOUDS_SHADOWS // Casts shadows from clouds on the world
#ifdef CLOUDS_SHADOWS
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL
#endif

View File

@ -215,7 +215,7 @@ vec4 renderClouds(
vec3 dV_view = normalize(fragpos.xyz);
dV_view.y += 0.05;
// dV_view.y += 0.05;
vec3 dV_view2 = dV_view;
float mult2 = length(dV_view2);
@ -337,7 +337,7 @@ vec4 renderClouds(
// Assume fog color = sky gradient at long distance
vec3 fogColor = skyFromTex(normView, colortex4)/150. * 5.0;
float dist = max(cameraPosition.y+CumulusHeight,max(CumulusHeight,150))/(abs(normView.y)+0.001);
float fog = exp(dist / -5000.0 * (1.0+rainCloudwetness*8.));
float fog = exp(dist / -15000.0 * (1.0+rainCloudwetness*8.));
// if(IntersecTerrain) fog = 1.0;

View File

@ -146,7 +146,7 @@ vec4 getVolumetricRays(
/// really dumb lmao
vec4 InsideACloudFog(
vec3 fragpos,
vec2 Dither,
@ -154,10 +154,6 @@ vec4 InsideACloudFog(
vec3 MoonColor,
vec3 SkyColor
){
// #ifndef VOLUMETRIC_CLOUDS
// return vec4(0.0,0.0,0.0,1.0);
// #endif
float total_extinction = 1.0;
vec3 color = vec3(0.0);
@ -184,13 +180,13 @@ vec4 InsideACloudFog(
vec3 progress = start.xyz;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
vec3 progress_view = vec3(0.0);
float expFactor = 11.0;
////// lighitng stuff
float shadowStep = 200.;
vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
vec3 dV_Sun_small = dV_Sun/shadowStep;
float SdotV = dot(sunVec,normalize(fragpos));
@ -201,7 +197,8 @@ vec4 InsideACloudFog(
vec3 Fog_SkyCol = SkyColor;
vec3 Fog_SunCol = SunColor;
// if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun;
float mieDay = phaseg(SdotV, 0.75) * 3.14;
float mieDayMulti = phaseg(SdotV, 0.35) * 2;
@ -216,7 +213,7 @@ vec4 InsideACloudFog(
///////// fog part
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
float mie = phaseg(SdotV,0.7)*5.0 + 1.0;
@ -234,8 +231,10 @@ vec4 InsideACloudFog(
float mu = 1.0;
float muS = mu;
#ifdef Cumulus
float Shadows_for_Fog = 0.0;
for (int i=0;i<VL_SAMPLES;i++) {
float d = (pow(expFactor, float(i+Dither.x)/float(VL_SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+Dither.x)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
progress = start.xyz + d*dV;
@ -251,12 +250,10 @@ vec4 InsideACloudFog(
sh = shadow2D( shadow, pos).x;
}
float cloudhsadow = sh;
Shadows_for_Fog = sh;
#ifdef VL_CLOUDS_SHADOWS
cloudhsadow = sh * GetCloudShadow_VLFOG(progressW);
Shadows_for_Fog = sh * GetCloudShadow_VLFOG(progressW);
#endif
float densityVol = cloudVol(progressW);
@ -270,13 +267,13 @@ vec4 InsideACloudFog(
vec3 rL = rC*airCoef.x;
vec3 m = (airCoef.y+density)*mC;
vec3 DirectLight = (Fog_SunCol*cloudhsadow) * (rayL*rL+m*mie);
vec3 DirectLight = (Fog_SunCol*Shadows_for_Fog) * (rayL*rL+m*mie);
vec3 AmbientLight = Fog_SkyCol * m;
vec3 AtmosphericFog = Fog_SkyCol * (rL+m) ;
// extra fog effects
vec3 rainRays = ((Fog_SunCol/5)*cloudhsadow) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1.0) * rainStrength * RainFog_amount;
vec3 CaveRays = (Fog_SunCol*cloudhsadow) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
vec3 rainRays = ((Fog_SunCol/5)*Shadows_for_Fog) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1.0) * rainStrength * RainFog_amount;
vec3 CaveRays = (Fog_SunCol*Shadows_for_Fog) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
@ -284,6 +281,7 @@ vec4 InsideACloudFog(
total_extinction *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
progress_view = progressW;
float cumulus = GetCumulusDensity(progress_view, 1);
@ -323,12 +321,7 @@ vec4 InsideACloudFog(
total_extinction *= max(exp(-mult*muE),0.0);
}
if (total_extinction < 1e-5) break;
}
#endif
return vec4(color, total_extinction);
}