mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-23 01:59:39 +08:00
make VL fog exist when clouds are turned off
This commit is contained in:
parent
06a764f437
commit
b19c03d6b8
@ -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
|
||||
|
||||
|
||||
|
@ -211,7 +211,7 @@ void main() {
|
||||
|
||||
|
||||
vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
|
||||
|
||||
|
||||
#ifdef Cloud_Fog
|
||||
vec4 VL_CLOUDFOG = InsideACloudFog(fragpos, vec2(R2_dither(),blueNoise()), lightCol.rgb/80., moonColor/150., (avgAmbient*2.0) * 8./150./3.);
|
||||
gl_FragData[0] = clamp(VL_CLOUDFOG,0.0,65000.);
|
||||
@ -220,6 +220,7 @@ void main() {
|
||||
gl_FragData[0] = clamp(VL_Fog,0.0,65000.);
|
||||
#endif
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
float dirtAmount = Dirt_Amount;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
|
||||
@ -200,23 +196,24 @@ 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;
|
||||
|
||||
vec3 sunContribution = SunColor * mieDay;
|
||||
vec3 sunContributionMulti = SunColor * mieDayMulti ;
|
||||
|
||||
float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4);
|
||||
vec3 moonContribution = MoonColor * mieNight;
|
||||
|
||||
float timing = 1.0 - clamp(pow(abs(dV_Sun.y)/150.0,2.0),0.0,1.0);
|
||||
|
||||
|
||||
|
||||
///////// fog part
|
||||
float mieDay = phaseg(SdotV, 0.75) * 3.14;
|
||||
float mieDayMulti = phaseg(SdotV, 0.35) * 2;
|
||||
|
||||
vec3 sunContribution = SunColor * mieDay;
|
||||
vec3 sunContributionMulti = SunColor * mieDayMulti ;
|
||||
|
||||
float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4);
|
||||
vec3 moonContribution = MoonColor * mieNight;
|
||||
|
||||
float timing = 1.0 - clamp(pow(abs(dV_Sun.y)/150.0,2.0),0.0,1.0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
|
||||
float mie = phaseg(SdotV,0.7)*5.0 + 1.0;
|
||||
@ -233,60 +230,61 @@ vec4 InsideACloudFog(
|
||||
|
||||
float mu = 1.0;
|
||||
float muS = mu;
|
||||
|
||||
float Shadows_for_Fog = 0.0;
|
||||
|
||||
#ifdef Cumulus
|
||||
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;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
for (int i=0;i<VL_SAMPLES;i++) {
|
||||
|
||||
//project into biased shadowmap space
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
|
||||
float sh = 1.0;
|
||||
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;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float cloudhsadow = sh;
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
cloudhsadow = sh * GetCloudShadow_VLFOG(progressW);
|
||||
#endif
|
||||
|
||||
float densityVol = cloudVol(progressW);
|
||||
//Water droplets(fog)
|
||||
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24 * Haze_amount;
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density)*mC;
|
||||
|
||||
vec3 DirectLight = (Fog_SunCol*cloudhsadow) * (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 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays ) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
|
||||
|
||||
color += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*total_extinction;
|
||||
total_extinction *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
|
||||
//project into biased shadowmap space
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
|
||||
float sh = 1.0;
|
||||
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
|
||||
Shadows_for_Fog = sh;
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
Shadows_for_Fog = sh * GetCloudShadow_VLFOG(progressW);
|
||||
#endif
|
||||
|
||||
float densityVol = cloudVol(progressW);
|
||||
//Water droplets(fog)
|
||||
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24 * Haze_amount;
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density)*mC;
|
||||
|
||||
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)*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 ;
|
||||
|
||||
color += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*total_extinction;
|
||||
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);
|
||||
|
||||
|
||||
float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight - 75)) / 9.0 ),0.0,1.0);
|
||||
|
||||
if(cumulus > 1e-5){
|
||||
@ -314,7 +312,7 @@ vec4 InsideACloudFog(
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos);
|
||||
Sunlight += HighAlt_shadow;
|
||||
#endif
|
||||
|
||||
|
||||
float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ;
|
||||
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, timing);
|
||||
|
||||
@ -323,12 +321,7 @@ vec4 InsideACloudFog(
|
||||
total_extinction *= max(exp(-mult*muE),0.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (total_extinction < 1e-5) break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (total_extinction < 1e-5) break;
|
||||
}
|
||||
return vec4(color, total_extinction);
|
||||
}
|
Loading…
Reference in New Issue
Block a user