DOUBLE LAYER CLOUDS TEST 4. a few tweaks to the sky. fixed auto-exposure. fixed water glowing in dark places. fixed RP skies glowing.

This commit is contained in:
Xonk
2023-12-11 16:12:25 -05:00
parent 3893c87607
commit d0c2712da0
12 changed files with 44 additions and 59 deletions

View File

@ -95,21 +95,8 @@ vec3 sky_transmittance(vec3 position, vec3 direction, const float steps) {
vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 sunVector, vec3 moonVector, out vec2 pid, out vec3 transmittance, const int iSteps, float noise) {
const int jSteps = 4;
// viewVector.y = viewVector.y - 0.05;
// float GroundDarkening = max(exp2(-15 * clamp(-viewVector.y,0.0,1.0)) * 0.7+0.3, clamp(sunVector.y*2.0,0.0,1.0)); // darken the ground in the sky.
float GroundDarkening2 = exp(-100 * pow(max(-viewVector.y*5,0.0),2)); // darken the ground in the sky.
float GroundDarkening = max(GroundDarkening2 * 0.7+0.3,clamp(sunVector.y*2.0,0.0,1.0));
// viewVector.y = max(viewVector.y,0.0);
float planetGround = exp(-100 * pow(max(-viewVector.y*5,0.0),2)); // darken the ground in the sky.
float GroundDarkening = max(planetGround * 0.7+0.3,clamp(sunVector.y*2.0,0.0,1.0));
vec3 viewPos = (sky_planetRadius + eyeAltitude) * upVector;
@ -149,8 +136,8 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s
vec3 stepTransmittedFraction = clamp01((stepTransmittance - 1.0) / -stepOpticalDepth) ;
vec3 stepScatteringVisible = transmittance * stepTransmittedFraction * GroundDarkening ;
scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps) * GroundDarkening2;
scatteringMoon += sky_coefficientsScattering * (stepAirmass.xy * phaseMoon) * stepScatteringVisible * sky_transmittance(position, moonVector, jSteps) * GroundDarkening2;
scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps) * planetGround;
scatteringMoon += sky_coefficientsScattering * (stepAirmass.xy * phaseMoon) * stepScatteringVisible * sky_transmittance(position, moonVector, jSteps) * planetGround;
// Nice way to fake multiple scattering.
scatteringAmbient += sky_coefficientsScattering * stepAirmass.xy * stepScatteringVisible * low_sun;

View File

@ -18,7 +18,7 @@ float cloudVol(in vec3 pos){
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
float fogYstart = SEA_LEVEL-6;
float fogYstart = FOG_START_HEIGHT+3;
float mult = exp( -max((pos.y - fogYstart) / 35.,0.0));
float fog_shape = 1.0 - densityAtPosFog(samplePos * 24.0 );
@ -29,7 +29,7 @@ float cloudVol(in vec3 pos){
float heightlimit = exp2( -max((pos.y - fogYstart * (1.0+snowStorm)) / 25.,0.0));
float CloudyFog = max((fog_shape*1.2 - fog_eroded*0.2) - 0.75,0.0) * heightlimit ;
float UniformFog = exp( max(pos.y - fogYstart,0.0) / -25) + 0.05;
float UniformFog = exp( max(pos.y - fogYstart,0.0) / -25);
// UniformFog = 1.0;
// float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 72. * rainStrength * noPuddleAreas * RainFog_amount;
@ -42,7 +42,10 @@ float cloudVol(in vec3 pos){
TimeOfDayFog(UniformFog, CloudyFog);
return CloudyFog + UniformFog + RainFog;
float testfogshapes = exp(sqrt(max(pos.y - fogYstart - 5,0.0)) / -1) * 50;
return CloudyFog + UniformFog + RainFog;// + testfogshapes;
}
float phaseRayleigh(float cosTheta) {

View File

@ -144,6 +144,8 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8
#define VL_SAMPLES 8 // [4 6 8 10 12 14 16 20 24 30 40 50]
#define FOG_START_HEIGHT 60 // [-200 -190 -180 -170 -160 -150 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200]
#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]
#define Morning_Uniform_Fog 1.0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.]
#define Noon_Uniform_Fog 0.0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.]
@ -338,7 +340,7 @@ uniform int moonPhase;
#define Cumulus
#define Cumulus_coverage 0.7 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define Cumulus_density 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
#define Cumulus_density 0.5 // [0.01 0.F02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
#define Cumulus_height 250 // [-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 700 800 900 1000]
#define Cumulus2_coverage 0.7 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]

View File

@ -59,8 +59,8 @@ float cloudCov(in vec3 pos, vec3 samplePos, float minHeight, float maxHeight){
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 1500);
}
float CloudLarge = max(texture2D(noisetex, SampleCoords0 ).b+thedistance,thedistance);
float CloudSmall = max(texture2D(noisetex, SampleCoords1 ).r+thedistance,thedistance);
float CloudLarge = texture2D(noisetex, SampleCoords0 ).b+thedistance;
float CloudSmall = texture2D(noisetex, SampleCoords1 ).r+thedistance;
float coverage = abs(pow(CloudLarge,1)*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
float FirstLayerCoverage = DailyWeather_Cumulus(coverage);
@ -294,8 +294,8 @@ vec4 renderClouds(
float skyScatter = clamp((CloudBaseHeights - 20 - progress_view.y) / 275.0,0.0,1.0);
vec3 Lighting = DoCloudLighting(muE, cumulus, SkyColor * skylightOcclusion, skyScatter, sunLight, sunScattering, sunMultiScattering, distantfog);
vec3 indirectSunlight = sunIndirectScattering * skylightOcclusion * exp(-20.0 * pow(abs(upperLayerOcclusion - 0.3),2)) * exp((cumulus*cumulus) * -10.0) ;
Lighting += indirectSunlight ;
// vec3 indirectSunlight = sunIndirectScattering * skylightOcclusion * exp(-20.0 * pow(abs(upperLayerOcclusion - 0.3),2)) * exp((cumulus*cumulus) * -10.0) ;
// Lighting += indirectSunlight ;
@ -308,22 +308,7 @@ vec4 renderClouds(
}
#endif
//////////////////////////////////////////
////// fade off in the distance stuff
////////////////////////////////////////
return vec4(color, total_extinction);
vec3 normView = normalize(dV_view);
// Assume fog color = sky gradient at long distance
vec4 fogColor = vec4(skyFromTex(normView, colortex4)/30.0, 0.0);
float fog = clamp(abs(max(cameraPosition.y, 255.0) + MaxHeight_0) / max(abs(MinHeight_0-cameraPosition.y),0.00001) * abs(normView.y),0,1);
fog = max(1.0 - clamp(exp((fog*fog) * -35.0),0.0,1.0),0.0);
// fog = max(1.0 - clamp(exp2(fog * -10.0),0.0,1.0),0.0);
return mix(fogColor, vec4(color, total_extinction), fog);
}
#endif