From 3cda692d97165acdd195ae2d1cd22aa0136254bb Mon Sep 17 00:00:00 2001 From: Xonk Date: Thu, 8 Jun 2023 18:44:09 -0400 Subject: [PATCH] tweak some cloud lighting a bit. also tweak VL biome fog a little --- shaders/composite1.fsh | 1 + shaders/lib/ROBOBO_sky.glsl | 18 +++++++++--------- shaders/lib/climate_settings.glsl | 2 +- shaders/lib/settings.glsl | 7 +++++-- shaders/lib/volumetricClouds.glsl | 15 +++++++-------- shaders/lib/volumetricFog.glsl | 14 +++++++------- shaders/shaders.properties | 2 +- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 91ad3ad..4bbaafe 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -840,6 +840,7 @@ void main() { vec4 cloud = texture2D_bicubic(colortex0,texcoord*CLOUDS_QUALITY); background = background*cloud.a + cloud.rgb; + gl_FragData[0].rgb = clamp(fp10Dither(background ,triangularize(noise)),0.0,65000.); #endif }else{//land diff --git a/shaders/lib/ROBOBO_sky.glsl b/shaders/lib/ROBOBO_sky.glsl index 64c2489..cf75da3 100644 --- a/shaders/lib/ROBOBO_sky.glsl +++ b/shaders/lib/ROBOBO_sky.glsl @@ -110,7 +110,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s vec3 increment = viewVector * stepSize; vec3 position = viewVector * sd.x + viewPosition; position += increment * (0.34*noise); - vec2 phaseSun = sky_phase(dot(viewVector, sunVector ), sky_mieg); + vec2 phaseSun = sky_phase(dot(viewVector, sunVector ), sky_mieg) ; vec2 phaseMoon = sky_phase(dot(viewVector, moonVector), sky_mieg); vec3 scatteringSun = vec3(0.0); @@ -128,19 +128,19 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s for (int i = 0; i < iSteps; ++i, position += increment) { vec3 density = sky_density(length(position)); if (density.y > 1e35) break; - vec3 stepAirmass = density * stepSize; - vec3 stepOpticalDepth = sky_coefficientsAttenuation * stepAirmass; + vec3 stepAirmass = density * stepSize ; + vec3 stepOpticalDepth = sky_coefficientsAttenuation * stepAirmass ; - vec3 stepTransmittance = exp2(-stepOpticalDepth * rLOG2); - vec3 stepTransmittedFraction = clamp01((stepTransmittance - 1.0) / -stepOpticalDepth); - vec3 stepScatteringVisible = transmittance * stepTransmittedFraction; + vec3 stepTransmittance = exp2(-stepOpticalDepth * rLOG2) ; + vec3 stepTransmittedFraction = clamp01((stepTransmittance - 1.0) / -stepOpticalDepth) ; + vec3 stepScatteringVisible = transmittance * stepTransmittedFraction ; - scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun ) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps); + scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun ) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps) ; scatteringMoon += sky_coefficientsScattering * (stepAirmass.xy * phaseMoon) * stepScatteringVisible * sky_transmittance(position, moonVector, jSteps); // Nice way to fake multiple scattering. - scatteringAmbient += sky_coefficientsScattering * stepAirmass.xy * (stepScatteringVisible * low_sun); + scatteringAmbient += sky_coefficientsScattering * stepAirmass.xy * (stepScatteringVisible * low_sun ); - transmittance *= stepTransmittance; + transmittance *= stepTransmittance ; } vec3 scattering = scatteringSun * sunColorBase + (scatteringAmbient) * background + scatteringMoon*moonColorBase ; diff --git a/shaders/lib/climate_settings.glsl b/shaders/lib/climate_settings.glsl index f3f4b18..708609f 100644 --- a/shaders/lib/climate_settings.glsl +++ b/shaders/lib/climate_settings.glsl @@ -169,7 +169,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0); BiomeColors.b = isSwamps*0.35 + isJungles*0.8; // insure the biome colors are locked to the fog shape and lighting, but not its orignal color. - BiomeColors *= dot(FinalFogColor,vec3(0.33)); + BiomeColors *= dot(FinalFogColor,vec3(0.21, 0.72, 0.07)); // these range 0.0-1.0. they will never overlap. float Inbiome = isJungles+isSwamps; diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 2b11f14..5f9e5bb 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -44,6 +44,10 @@ #define TORCH_B 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.0] #define AO_in_sunlight // control if ambient occlusion appears in sunlit areas. // #define ambientSSS_view + + + +#define Refraction // --- DOF --- #define DOF_QUALITY -1 // [-1 0 1 2 3 4] @@ -68,8 +72,8 @@ // #define SPLIT_RENDER // AAAAAAAAAAAAAAAA // --- FOG/VOLUMETRICS --- +#define Biome_specific_environment // makes the fog density and color look unique in certain biomes. (swamps, jungles, lush caves, giant pines, dark forests) -#define Refraction #define Cave_fog // cave fog.... #define CaveFogFallOff 1.3 // [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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] #define CaveFogColor_R 0.1 // [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.0] @@ -210,7 +214,6 @@ #define Spring_Leaf_G 0.8 // the color of the plants during this season [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 Spring_Leaf_B 0.8 // the color of the plants during this season [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 Biome_specific_environment // makes the fog density and color look unique in certain biomes. (swamps, jungles, lush caves, giant pines, dark forests) const float ambientOcclusionLevel = 1.0; // this controls vanilla minecrafts ambient occlusion. [0.0 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.0 ] const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ] #define Puddle_Size 1.0 // [0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5] diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index 3c22871..bd13615 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -142,11 +142,9 @@ vec3 Cloud_lighting( vec3 skyLighting = SkyColors; #ifdef Altostratus - float Coverage; float Density; + float Coverage = 0.0; float Density = 0.0; DailyWeather_Alto(Coverage,Density); - skyLighting += sunContributionMulti * exp(SunShadowing * -3) * clamp(Coverage * (1-Density),0,1); - - // skyLighting += (sunContributionMulti * 5.0 * exp(SunShadowing * -3)) * exp(altoShadow * -0.1); + skyLighting += sunContributionMulti * exp(-SunShadowing) * clamp((1.0 - abs(pow(Density*4.0 - 1.1,4.0))) * Coverage,0,1) ; #endif skyLighting *= exp(SkyShadowing * AmbientShadow * coeeff/2 ) * lesspowder ; @@ -162,7 +160,7 @@ vec3 Cloud_lighting( vec3 moonLighting = exp(MoonShadowing * coeeff / 3) * moonContribution * powder; - return skyLighting + moonLighting + sunLighting ; + return skyLighting + moonLighting + sunLighting ; // return skyLighting; } @@ -174,7 +172,7 @@ float phaseg(float x, float g){ } float CustomPhase(float LightPos, float S_1, float S_2){ - float SCALE = S_2; // remember the epislons 0.001 is fine. + float SCALE = S_2 + 0.001; // remember the epislons 0.001 is fine. float N = S_1; float N2 = N / SCALE; @@ -244,7 +242,7 @@ vec4 renderClouds( if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun; - float mieDay = phaseg(SdotV, 0.75) * 2; + float mieDay = phaseg(SdotV, 0.75) * 3.14; float mieDayMulti = phaseg(SdotV, 0.35) * 2; vec3 sunContribution = SunColor * mieDay; @@ -289,7 +287,8 @@ vec4 renderClouds( float phase = PhaseHG(-SdotV, (1.0-cumulus)); - float ambientlightshadow = 1.0-clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0); + 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); vec3 Sint = (S - S * exp(-mult*muE)) / muE; diff --git a/shaders/lib/volumetricFog.glsl b/shaders/lib/volumetricFog.glsl index d7b37a1..0260a70 100644 --- a/shaders/lib/volumetricFog.glsl +++ b/shaders/lib/volumetricFog.glsl @@ -78,6 +78,12 @@ vec4 getVolumetricRays( vec3 sunColor = lightCol.rgb / 80.0; vec3 skyCol0 = AmbientColor / 150. * 5.; // * max(abs(WsunVec.y)/150.0,0.); + #ifdef Biome_specific_environment + // recolor change sun and sky color to some color, but make sure luminance is preserved. + BiomeFogColor(sunColor); + BiomeFogColor(skyCol0); + #endif + vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5); vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6); @@ -126,15 +132,9 @@ vec4 getVolumetricRays( // extra fog effects vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount; vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.); - - // vec3 RAAAAY = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) ; - + vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ; - #ifdef Biome_specific_environment - BiomeFogColor(vL0); // ????? - #endif - vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance; absorbance *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333)); } diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 2b53ae5..04a2cd8 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -225,7 +225,7 @@ uniform.float.Alto_Cov = smooth( if( \ uniform.float.Alto_Den = smooth( if( \ moonPhase == 0, 0.1, \ - moonPhase == 1, 0.1, \ + moonPhase == 1, 0.25, \ moonPhase == 2, 0.0, \ moonPhase == 3, 0.0, \ moonPhase == 4, 0.0, \