custommods
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
#if MC_VERSION >= 11900
|
||||
uniform float darknessFactor;
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#include "/lib/atmospherics/sunGlare.glsl"
|
||||
#endif
|
||||
|
||||
vec3 Fog1(vec3 color, float lWorldPos, float lViewPos, vec3 nViewPos, vec3 extra, float NdotU) {
|
||||
#if defined OVERWORLD && !defined ONESEVEN && !defined TWO
|
||||
#if FOG1_TYPE < 2
|
||||
float fog = lWorldPos / far * (1.0/FOG1_DISTANCE_M);
|
||||
#else
|
||||
float fog = lViewPos / far * (1.025/FOG1_DISTANCE_M);
|
||||
#endif
|
||||
|
||||
fog *= fog;
|
||||
fog *= fog;
|
||||
fog *= fog * fog;
|
||||
fog = 1.0 - exp(-6.0 * fog);
|
||||
|
||||
if (fog > 0.0) {
|
||||
vec3 artificialFogColor = GetSkyColor(lightCol, NdotU, nViewPos, false);
|
||||
artificialFogColor = SunGlare(artificialFogColor, nViewPos, lightCol);
|
||||
#ifdef CAVE_SKY_FIX
|
||||
artificialFogColor *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fog);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined NETHER && defined NETHER_FOG // extra = nether smoke (if enabled)
|
||||
#if FOG1_TYPE > 0
|
||||
float fog = lViewPos / far * (1.0/FOG1_DISTANCE_M);
|
||||
#else
|
||||
float fog = lWorldPos / far * (1.0/FOG1_DISTANCE_M);
|
||||
#endif
|
||||
fog *= fog;
|
||||
fog *= fog;
|
||||
fog = 1.0 - exp(-8.0 * fog);
|
||||
|
||||
vec3 artificialFogColor = pow((netherCol * 2.5) / NETHER_I, vec3(2.2)) * 4;
|
||||
#ifdef NETHER_SMOKE
|
||||
artificialFogColor += extra * fog;
|
||||
#endif
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fog);
|
||||
#endif
|
||||
|
||||
#ifdef END // extra = ender nebula (if enabled)
|
||||
float fog = lWorldPos / far * (1.5/FOG1_DISTANCE_M);
|
||||
fog = 1.0 - exp(-0.1 * pow(fog, 10.0));
|
||||
if (fog > 0.0) {
|
||||
vec3 artificialFogColor = endCol * (0.035 + 0.02 * vsBrightness);
|
||||
#ifdef ENDER_NEBULA
|
||||
artificialFogColor += extra * fog;
|
||||
#endif
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fog);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TWO
|
||||
float fog = lWorldPos / far * (4.0/FOG1_DISTANCE_M);
|
||||
fog = 1.0 - exp(-0.1 * pow(fog, 3.0));
|
||||
|
||||
//float NdotU = 1.0 - max(dot(nViewPos, upVec), 0.0);
|
||||
NdotU = 1.0 - max(NdotU, 0.0);
|
||||
NdotU = NdotU * NdotU;
|
||||
#ifndef ABYSS
|
||||
vec3 midnightPurple = vec3(0.0003, 0.0004, 0.002) * 1.25;
|
||||
vec3 midnightFogColor = fogColor * fogColor * 0.3;
|
||||
#else
|
||||
vec3 midnightPurple = skyColor * skyColor * 0.00075;
|
||||
vec3 midnightFogColor = fogColor * fogColor * 0.09;
|
||||
#endif
|
||||
vec3 artificialFogColor = mix(midnightPurple, midnightFogColor, NdotU);
|
||||
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fog);
|
||||
#endif
|
||||
|
||||
#ifdef SEVEN
|
||||
float fog = lWorldPos / far * (1.5/FOG1_DISTANCE_M);
|
||||
fog = 1.0 - exp(-0.1 * pow(fog, 10.0));
|
||||
float cosT = dot(nViewPos, upVec);
|
||||
vec3 twilightPurple = vec3(0.005, 0.006, 0.018);
|
||||
vec3 twilightGreen = vec3(0.015, 0.03, 0.02);
|
||||
#ifdef TWENTY
|
||||
twilightPurple = twilightGreen * 0.1;
|
||||
#endif
|
||||
vec3 artificialFogColor = 2 * (twilightPurple * 2 * clamp(pow(cosT, 0.7), 0.0, 1.0) + twilightGreen * (1-clamp(pow(cosT, 0.7), 0.0, 1.0)));
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fog);
|
||||
#endif
|
||||
|
||||
#ifdef ONESEVEN
|
||||
float fogoneseven = lWorldPos / 16 * (1.35-sunVisibility*0.35);
|
||||
fogoneseven = 1.0 - exp(-0.1 * pow(fogoneseven, 3.0));
|
||||
|
||||
if (fogoneseven > 0.0) {
|
||||
vec3 artificialFogColor = GetSkyColor(lightCol, NdotU, nViewPos, false);
|
||||
artificialFogColor = SunGlare(artificialFogColor, nViewPos, lightCol);
|
||||
color.rgb = mix(color.rgb, artificialFogColor, fogoneseven);
|
||||
}
|
||||
#endif
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
vec3 Fog2(vec3 color, float lViewPos, vec3 worldPos) {
|
||||
|
||||
#ifdef OVERWORLD
|
||||
#ifdef FOG2_ALTITUDE_MODE
|
||||
float altitudeFactor = (worldPos.y + eyeAltitude + 1000.0 - FOG2_ALTITUDE) * 0.001;
|
||||
if (altitudeFactor > 0.965 && altitudeFactor < 1.0) altitudeFactor = pow(altitudeFactor, 1.0 - (altitudeFactor - 0.965) * 28.57);
|
||||
altitudeFactor = clamp(pow(altitudeFactor, 20.0), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
//duplicate 307309760
|
||||
float fog2 = lViewPos / pow(far, 0.25) * 0.112 * (1.0 + rainStrengthS * FOG2_RAIN_DISTANCE_M)
|
||||
* (1.0 - sunVisibility * 0.25 * (1.0 - rainStrengthS)) / FOG2_DISTANCE_M;
|
||||
fog2 = (1.0 - (exp(-50.0 * pow(fog2*0.125, 3.25) * eBS)));
|
||||
fog2 *= min(FOG2_OPACITY * (3.0 + rainStrengthS * FOG2_RAIN_OPACITY_M - sunVisibility * 2.0), 1.0);
|
||||
#ifdef FOG2_ALTITUDE_MODE
|
||||
fog2 *= pow(clamp((eyeAltitude - FOG2_ALTITUDE*0.2) / FOG2_ALTITUDE, 0.0, 1.0), 2.5 - FOG2_RAIN_ALTITUDE_M * rainStrengthS * 2.5);
|
||||
fog2 *= 1.0 - altitudeFactor * (1.0 - FOG2_RAIN_ALTITUDE_M * rainStrengthS);
|
||||
#endif
|
||||
|
||||
float sunVisibility2 = sunVisibility * sunVisibility;
|
||||
float sunVisibility4 = sunVisibility2 * sunVisibility2;
|
||||
float sunVisibility8 = sunVisibility4 * sunVisibility4;
|
||||
float timeBrightness2 = sqrt1(timeBrightness);
|
||||
vec3 fogColor2 = mix(lightCol*0.5, skyColor*skyMult*1.25, timeBrightness2);
|
||||
fogColor2 = mix(ambientNight*ambientNight, fogColor2, sunVisibility8);
|
||||
if (rainStrengthS > 0.0) {
|
||||
float rainStrengthS2 = 1.0 - (1.0 - rainStrengthS) * (1.0 - rainStrengthS);
|
||||
vec3 rainFogColor = FOG2_RAIN_BRIGHTNESS_M * skyColCustom * (0.01 + 0.05 * sunVisibility8 + 0.1 * timeBrightness2);
|
||||
rainFogColor *= mix(SKY_RAIN_NIGHT, SKY_RAIN_DAY, sunVisibility);
|
||||
fogColor2 = mix(fogColor2, rainFogColor, rainStrengthS2);
|
||||
}
|
||||
fogColor2 *= FOG2_BRIGHTNESS;
|
||||
#ifdef CAVE_SKY_FIX
|
||||
fogColor2 *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
|
||||
color.rgb = mix(color.rgb, fogColor2, fog2);
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
float fog2 = lViewPos / pow(far, 0.25) * 0.035 * (32.0/FOG2_END_DISTANCE_M);
|
||||
fog2 = 1.0 - (exp(-50.0 * pow(fog2*0.125, 4.0)));
|
||||
#ifdef FOG2_ALTITUDE_MODE
|
||||
float altitudeFactor = clamp((worldPos.y + eyeAltitude + 100.0 - FOG2_END_ALTITUDE) * 0.01, 0.0, 1.0);
|
||||
if (altitudeFactor > 0.75 && altitudeFactor < 1.0) altitudeFactor = pow(altitudeFactor, 1.0 - (altitudeFactor - 0.75) * 4.0);
|
||||
fog2 *= 1.0 - altitudeFactor;
|
||||
#endif
|
||||
fog2 = clamp(fog2, 0.0, 0.125) * (7.0 + fog2);
|
||||
fog2 = 1 - pow(1 - fog2, 2.0 - fog2);
|
||||
vec3 fogColor2 = endCol * (0.035 + 0.02 * vsBrightness);
|
||||
color.rgb = mix(color.rgb, fogColor2 * FOG2_END_BRIGHTNESS, fog2 * FOG2_END_OPACITY);
|
||||
#endif
|
||||
|
||||
#if defined SEVEN && !defined TWENTY
|
||||
float fog2 = lViewPos / pow(far, 0.25) * 0.035 * (1.0 + rainStrengthS) * (3.2/FOG2_DISTANCE_M);
|
||||
fog2 = 1.0 - (exp(-50.0 * pow(fog2*0.125, 4.0) * eBS));
|
||||
float altitudeFactor = (worldPos.y + eyeAltitude + 1000.0 - 90 * (1 + rainStrengthS*0.5)) * 0.001;
|
||||
if (altitudeFactor > 0.965 && altitudeFactor < 1.0) altitudeFactor = pow(altitudeFactor, 1.0 - (altitudeFactor - 0.965) * 28.57);
|
||||
fog2 *= 1.0 - altitudeFactor;
|
||||
fog2 = clamp(fog2, 0.0, 0.125) * (7.0 + fog2);
|
||||
vec3 fogColor2 = vec3(0.015, 0.03, 0.02);
|
||||
color.rgb = mix(color.rgb, fogColor2, fog2 * 0.80);
|
||||
#endif
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
vec3 WaterFog(vec3 color, float lViewPos, float fogrange) {
|
||||
float fog = lViewPos / fogrange;
|
||||
fog = 1.0 - exp(-3.0 * fog * fog);
|
||||
color *= pow(max(underwaterColor.rgb, vec3(0.1)), vec3(0.5)) * 3.0;
|
||||
color = mix(color, 0.8 * pow(underwaterColor.rgb * (1.0 - blindFactor), vec3(2.0)), fog);
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
vec3 LavaFog(vec3 color, float lViewPos) {
|
||||
#ifndef LAVA_VISIBILITY
|
||||
float fog = (lViewPos - gl_Fog.start) * gl_Fog.scale;
|
||||
fog *= fog;
|
||||
fog = 1.0 - exp(- fog);
|
||||
fog = clamp(fog, 0.0, 1.0);
|
||||
#else
|
||||
float fog = lViewPos * 0.02;
|
||||
fog = 1.0 - exp(-3.0 * fog);
|
||||
#if MC_VERSION >= 11700
|
||||
if (gl_Fog.start / far < 0.0) fog = min(lViewPos * 0.01, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//duplicate 792763950
|
||||
#ifndef VANILLA_UNDERLAVA_COLOR
|
||||
vec3 lavaFogColor = vec3(0.6, 0.35, 0.15);
|
||||
#else
|
||||
vec3 lavaFogColor = pow(fogColor, vec3(2.2));
|
||||
#endif
|
||||
color.rgb = mix(color.rgb, lavaFogColor, fog);
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
vec3 SnowFog(vec3 color, float lViewPos) {
|
||||
float fog = lViewPos * 0.3;
|
||||
fog = (1.0 - exp(-4.0 * fog * fog * fog));
|
||||
color.rgb = mix(color.rgb, vec3(0.1, 0.15, 0.2), fog);
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
vec3 BlindFog(vec3 color, float lViewPos) {
|
||||
float fog = lViewPos *0.04* (5.0 / blindFactor);
|
||||
fog = (1.0 - exp(-6.0 * fog * fog * fog)) * blindFactor;
|
||||
color.rgb = mix(color.rgb, vec3(0.0), fog);
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
|
||||
#if MC_VERSION >= 11900
|
||||
vec3 DarknessFog(vec3 color, float lViewPos) {
|
||||
float fog = lViewPos * 0.06;
|
||||
fog = (1.0 - exp(-6.0 * fog * fog * fog)) * darknessFactor;
|
||||
color.rgb = mix(color.rgb, darknessColor, fog);
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 startFog(vec3 color, vec3 nViewPos, float lViewPos, vec3 worldPos, vec3 extra, float NdotU) {
|
||||
#if !defined GBUFFER_CODING
|
||||
if (isEyeInWater == 0) {
|
||||
#ifdef FOG2
|
||||
color.rgb = Fog2(color.rgb, lViewPos, worldPos);
|
||||
#endif
|
||||
#ifdef FOG1
|
||||
color.rgb = Fog1(color.rgb, length(worldPos.xz), lViewPos, nViewPos, extra, NdotU);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (blindFactor < 0.001) {
|
||||
if (isEyeInWater == 1) color.rgb = WaterFog(color.rgb, lViewPos, waterFog * (1.0 + eBS));
|
||||
if (isEyeInWater == 2) color.rgb = LavaFog(color.rgb, lViewPos);
|
||||
#if MC_VERSION >= 11700
|
||||
if (isEyeInWater == 3) color.rgb = SnowFog(color.rgb, lViewPos);
|
||||
#endif
|
||||
} else color.rgb = BlindFog(color.rgb, lViewPos);
|
||||
#if MC_VERSION >= 11900
|
||||
if (darknessFactor > 0.001) color.rgb = DarknessFog(color.rgb, lViewPos);
|
||||
#endif
|
||||
|
||||
return color.rgb;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
float rainbowTime = sqrt3(max(pow2(pow2(sunVisibility * shadowFade)) - timeBrightness * 2.5, 0.0));
|
||||
#ifdef RAINBOW_AFTER_RAIN_CHECK
|
||||
rainbowTime *= sqrt3(max(wetness - 0.1, 0.0) * (1.0 - rainStrength) * (1.0 - rainStrengthS)) * isRainy;
|
||||
#endif
|
||||
|
||||
if (rainbowTime > 0.001) {
|
||||
float rainbowDistance = max(far, 256.0) * 0.25;
|
||||
float rainbowLength = max(far, 256.0) * 0.75;
|
||||
|
||||
vec3 rainbowTranslucent = translucent;
|
||||
if (water) rainbowTranslucent = vec3(float(isEyeInWater == 1));
|
||||
|
||||
vec4 viewPosZ1 = gbufferProjectionInverse * (vec4(texCoord, z1, 1.0) * 2.0 - 1.0);
|
||||
viewPosZ1 /= viewPosZ1.w;
|
||||
float lViewPosZ1 = length(viewPosZ1.xyz);
|
||||
float lViewPosZ0 = length(viewPos.xyz);
|
||||
|
||||
float rainbowCoord = 1.0 - (cosS + 0.75) / (0.0625 * RAINBOW_DIAMETER);
|
||||
|
||||
float rainbowFactor = clamp(1.0 - rainbowCoord, 0.0, 1.0) * clamp(rainbowCoord, 0.0, 1.0);
|
||||
rainbowFactor *= rainbowFactor * (3.0 - 2.0 * rainbowFactor);
|
||||
rainbowFactor *= min(max(lViewPosZ1 - rainbowDistance, 0.0) / rainbowLength, 1.0);
|
||||
rainbowFactor *= rainbowTime;
|
||||
#ifdef CAVE_SKY_FIX
|
||||
rainbowFactor *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
|
||||
if (rainbowFactor > 0.0) {
|
||||
#if RAINBOW_STYLE == 1
|
||||
float rainbowCoordM = pow(rainbowCoord, 1.4 + max(rainbowCoord - 0.5, 0.0) * 1.6);
|
||||
rainbowCoordM = smoothstep(0.0, 1.0, rainbowCoordM) * 0.85;
|
||||
rainbowCoordM += (dither - 0.5) * 0.1;
|
||||
vec3 rainbow = clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbowCoordM += 0.1;
|
||||
rainbow += clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbowCoordM -= 0.2;
|
||||
rainbow += clamp(abs(mod(rainbowCoordM * 6.0 + vec3(-0.55,4.3,2.2) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbow /= 3.0;
|
||||
rainbow.r += pow2(max(rainbowCoord - 0.5, 0.0)) * (max(1.0 - rainbowCoord, 0.0)) * 26.0;
|
||||
rainbow = pow(rainbow, vec3(2.2)) * vec3(0.25, 0.075, 0.25) * 3.0;
|
||||
#else
|
||||
float rainbowCoordM = pow(rainbowCoord, 1.35);
|
||||
rainbowCoordM = smoothstep(0.0, 1.0, rainbowCoordM);
|
||||
vec3 rainbow = clamp(abs(mod(rainbowCoordM * 6.0 + vec3(0.0,4.0,2.0) ,6.0)-3.0)-1.0, 0.0, 1.0);
|
||||
rainbow *= rainbow * (3.0 - 2.0 * rainbow);
|
||||
rainbow = pow(rainbow, vec3(2.2)) * vec3(0.25, 0.075, 0.25) * 3.0;
|
||||
#endif
|
||||
|
||||
if (z1 > z0 && lViewPosZ0 < rainbowDistance + rainbowLength)
|
||||
rainbow *= mix(rainbowTranslucent, vec3(1.0),
|
||||
clamp((lViewPosZ0 - rainbowDistance) / rainbowLength, 0.0, 1.0)
|
||||
);
|
||||
if (isEyeInWater == 1) rainbow *= float(water) * 0.05;
|
||||
|
||||
color.rgb += rainbow * rainbowFactor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
vec3 GetSkyColor(vec3 lightCol, float NdotU, vec3 nViewPos, bool isReflection) {
|
||||
float timeBrightnessInv = 1.0 - timeBrightness;
|
||||
float timeBrightnessInv2 = timeBrightnessInv * timeBrightnessInv;
|
||||
float timeBrightnessInv4 = timeBrightnessInv2 * timeBrightnessInv2;
|
||||
float timeBrightnessInv8 = timeBrightnessInv4 * timeBrightnessInv4;
|
||||
|
||||
float NdotSp = clamp(dot(nViewPos, sunVec) * 0.5 + 0.5, 0.001, 1.0);
|
||||
float NdotS = NdotSp * NdotSp;
|
||||
NdotS *= NdotS;
|
||||
|
||||
float absNdotU = abs(NdotU);
|
||||
|
||||
vec3 skyColor2 = skyColor * skyColor;
|
||||
|
||||
vec3 sky = mix(sqrt1(skyColor) * 0.47, skyColor2 * 0.9, absNdotU);
|
||||
sky = sky * (0.5 + 0.5 * sunVisibility) * skyMult;
|
||||
|
||||
#ifdef ONESEVEN
|
||||
sky = vec3(0.812, 0.741, 0.674) * 0.5;
|
||||
#endif
|
||||
|
||||
float horizon = 1.0 - max(NdotU + 0.1, 0.0) * (1.0 - 0.25 * NdotS * sunVisibility);
|
||||
horizon = min(horizon, 0.9);
|
||||
horizon *= horizon;
|
||||
|
||||
float lightmix = NdotS * max(1.0 - absNdotU * 2.0, 0.0) * 0.5 + horizon + 0.05;
|
||||
lightmix *= sunVisibility * (1.0 - rainStrengthS) * timeBrightnessInv8;
|
||||
|
||||
sky *= 2.0 - 0.5 * timeBrightnessInv4;
|
||||
sky *= mix(SKY_NOON, SKY_DAY, timeBrightnessInv4);
|
||||
|
||||
float mult = 0.1 * (1.0 + rainStrengthS) + horizon * (0.3 + 0.1 * sunVisibility);
|
||||
|
||||
float meFactorP = min((1.0 - min(moonBrightness, 0.6) / 0.6) * 0.115, 0.075);
|
||||
float meNdotU = 1.0 - absNdotU;
|
||||
float meFactor = meFactorP * meNdotU * meNdotU * 15.0 * max(timeBrightnessInv4 - rainStrengthS, 0.0);
|
||||
vec3 meColor = mix(lightMorning, lightEvening, mefade);
|
||||
meColor *= meColor;
|
||||
meColor *= meColor;
|
||||
meColor *= meFactor * meFactor * NdotS;
|
||||
|
||||
vec3 finalSky = mix(sky * (1.0 - pow2(lightmix)), lightCol * sqrt(lightCol), lightmix);
|
||||
|
||||
vec3 nightSky = ambientNight * ambientNight * (3.25 + 2.25 * max(sqrt1(NdotU), 0.0));
|
||||
nightSky *= mix(SKY_NIGHT, 1.0, sunVisibility);
|
||||
finalSky += nightSky;
|
||||
|
||||
finalSky *= max(1.0 - length(meColor) * 0.5, 0.0);
|
||||
finalSky += meColor * 0.8;
|
||||
|
||||
if (isReflection) {
|
||||
float invNdotU = max(-NdotU, 0.0);
|
||||
float groundFactor = 0.5 * (11.0 * rainStrengthS + 1.0) * (-5.0 * sunVisibility + 6.0);
|
||||
float ground = exp(-groundFactor / (invNdotU * 6.0));
|
||||
ground = smoothstep(0.0, 1.0, ground);
|
||||
mult *= (1.0 - ground);
|
||||
}
|
||||
|
||||
//duplicate 98765
|
||||
vec3 weatherSky = weatherCol * weatherCol;
|
||||
weatherSky *= GetLuminance(ambientCol / (weatherSky)) * 1.4;
|
||||
weatherSky *= mix(SKY_RAIN_NIGHT, SKY_RAIN_DAY, sunVisibility);
|
||||
weatherSky = max(weatherSky, skyColor2 * 0.75); // Lightning Sky Color
|
||||
weatherSky *= rainStrengthS;
|
||||
finalSky = mix(finalSky, weatherSky, rainStrengthS) * mult;
|
||||
|
||||
finalSky = pow(finalSky, vec3(1.125));
|
||||
|
||||
return finalSky;
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
#if !defined END && !defined SEVEN && !defined NETHER
|
||||
float CloudNoise(vec2 coord, vec2 wind) {
|
||||
float noise = texture2D(noisetex, coord*0.125 + wind * 0.25).x * 7.0;
|
||||
noise+= texture2D(noisetex, coord*0.0625 + wind * 0.15).x * 12.0;
|
||||
noise+= texture2D(noisetex, coord*0.03125 + wind * 0.05).x * 12.0;
|
||||
noise+= texture2D(noisetex, coord*0.015625 + wind * 0.05).x * 24.0;
|
||||
return noise * 0.34;
|
||||
}
|
||||
|
||||
float CloudCoverage(float noise, float coverage, float NdotU, float cosS) {
|
||||
float noiseCoverageCosS = abs(cosS);
|
||||
noiseCoverageCosS *= noiseCoverageCosS;
|
||||
noiseCoverageCosS *= noiseCoverageCosS;
|
||||
float NdotUmult = 0.365;
|
||||
#ifdef AURORA
|
||||
float auroraMult = max(1.0 - sunVisibility - rainStrengthS, 0.0);
|
||||
#ifdef AURORA_BIOME_CHECK
|
||||
auroraMult *= isSnowy;
|
||||
#endif
|
||||
#ifdef AURORA_FULL_MOON_CHECK
|
||||
auroraMult *= float(moonPhase == 0);
|
||||
#endif
|
||||
NdotUmult *= 1.0 + 2.5 * auroraMult;
|
||||
#endif
|
||||
float noiseCoverage = coverage * coverage + CLOUD_AMOUNT
|
||||
* (1.0 + noiseCoverageCosS * 0.175)
|
||||
* (1.0 + NdotU * NdotUmult * (1.0-rainStrengthS*3.0))
|
||||
- 2.5;
|
||||
|
||||
return max(noise - noiseCoverage, 0.0);
|
||||
}
|
||||
|
||||
vec4 DrawCloud(vec3 viewPos, float dither, vec3 lightCol, vec3 ambientCol, float NdotU, int sampleCount) {
|
||||
float cosS = dot(normalize(viewPos), sunVec);
|
||||
|
||||
#if AA > 1
|
||||
dither = fract(16.0 * frameTimeCounter + dither);
|
||||
#endif
|
||||
|
||||
float timeBrightnessS = sqrt1(timeBrightness);
|
||||
|
||||
float cloud = 0.0;
|
||||
float cloudGradient = 0.0;
|
||||
float gradientMix = dither * 0.1667;
|
||||
float colorMultiplier = CLOUD_BRIGHTNESS * (0.23 + 0.07 * timeBrightnessS);
|
||||
float noiseMultiplier = CLOUD_THICKNESS * 0.125;
|
||||
float scattering = 0.5 * pow(cosS * 0.5 * (2.0 * sunVisibility - 1.0) + 0.5, 6.0);
|
||||
|
||||
float cloudHeightFactor = max(1.11 - 0.0015 * eyeAltitude, 0.0);
|
||||
cloudHeightFactor *= cloudHeightFactor;
|
||||
float cloudHeight = CLOUD_HEIGHT * cloudHeightFactor * 0.5;
|
||||
|
||||
#if !defined GBUFFERS_WATER && !defined DEFERRED
|
||||
float skytime = frametime;
|
||||
#else
|
||||
float skytime = cloudtime;
|
||||
#endif
|
||||
float cloudSpeedFactor = 0.003;
|
||||
vec2 wind = vec2(skytime * CLOUD_SPEED * cloudSpeedFactor, 0.0);
|
||||
#ifdef SEVEN
|
||||
wind *= 8;
|
||||
#endif
|
||||
|
||||
vec3 cloudColor = vec3(0.0);
|
||||
|
||||
float stretchFactor = 2.5;
|
||||
float coordFactor = 0.009375;
|
||||
|
||||
if (NdotU > 0.025) { //duplicate 78634
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz);
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
if (cloud > 0.99) break;
|
||||
vec2 planeCoord = wpos.xz * ((cloudHeight + (i + dither) * stretchFactor * 6.0 / sampleCount) / wpos.y) * 0.0085;
|
||||
vec2 coord = cameraPosition.xz * 0.00025 + planeCoord;
|
||||
|
||||
float ang1 = (i + frametime * 0.025) * 2.391;
|
||||
float ang2 = ang1 + 2.391;
|
||||
coord += mix(vec2(cos(ang1), sin(ang1)), vec2(cos(ang2), sin(ang2)), dither * 0.25 + 0.75) * coordFactor;
|
||||
|
||||
float coverage = float(i - 3.0 + dither) * 0.725;
|
||||
|
||||
float noise = CloudNoise(coord, wind);
|
||||
noise = CloudCoverage(noise, coverage, NdotU, cosS) * noiseMultiplier;
|
||||
noise = noise / sqrt(noise * noise + 1.0);
|
||||
|
||||
cloudGradient = mix(cloudGradient,
|
||||
mix(gradientMix * gradientMix, 1.0 - noise, 0.25),
|
||||
noise * (1.0 - cloud));
|
||||
|
||||
cloud += max(noise - cloud * 0.95, 0.0);
|
||||
cloud = mix(cloud, 1.0, rainStrengthS * pow2(noise * noise));
|
||||
gradientMix += 0.2 * (6.0 / sampleCount);
|
||||
}
|
||||
|
||||
float meFactorP = min((1.0 - min(moonBrightness, 0.6) / 0.6) * 0.115, 0.075);
|
||||
vec3 meColor = vec3(0.0);
|
||||
if (cosS > 0.0) {
|
||||
float meNdotU = 1.0 - NdotU;
|
||||
float meFactor = meFactorP * meNdotU * meNdotU * 12.0 * (1.0 - rainStrengthS);
|
||||
meColor = mix(lightMorning, lightEvening, mefade);
|
||||
meColor *= meColor;
|
||||
meColor *= meColor;
|
||||
meColor *= meFactor * meFactor * cosS;
|
||||
}
|
||||
|
||||
float sunVisibilityM = pow(sunVisibility, 4.0 - meFactorP * 24.0);
|
||||
vec3 skyColor2 = skyColor * skyColor;
|
||||
|
||||
vec3 cloudNightColor = ambientCol * 8.0;
|
||||
vec3 cloudDayColor = pow(lightCol, vec3(1.5)) * 1.5;
|
||||
vec3 cloudUpColor = mix(cloudNightColor, cloudDayColor, sunVisibilityM);
|
||||
cloudUpColor *= 1.0 + scattering;
|
||||
cloudUpColor += max(meColor, vec3(0.0));
|
||||
|
||||
vec3 cloudDownColor = skyColor2 * 0.225 * sunVisibility * skyMult;
|
||||
|
||||
//duplicate 98765
|
||||
vec3 weatherSky = weatherCol * weatherCol;
|
||||
weatherSky *= GetLuminance(ambientCol / (weatherSky)) * 1.4;
|
||||
weatherSky *= mix(SKY_RAIN_NIGHT, SKY_RAIN_DAY, sunVisibility);
|
||||
weatherSky = max(weatherSky, skyColor2 * 0.75); // Lightning Sky Color
|
||||
weatherSky *= rainStrengthS;
|
||||
#ifdef LIGHT_SHAFTS
|
||||
weatherSky *= 12.5 + scattering * 47.5 * (1.0 + sunVisibility);
|
||||
#else
|
||||
weatherSky *= 12.5 + scattering * 47.5;
|
||||
#endif
|
||||
cloudUpColor = mix(cloudUpColor, weatherSky, rainStrengthS * rainStrengthS);
|
||||
|
||||
cloudColor = mix(cloudDownColor, cloudUpColor, cloudGradient);
|
||||
|
||||
cloud *= pow2(pow2(1.0 - exp(- (10.0 - 8.2 * rainStrengthS) * NdotU))); //duplicate 78634
|
||||
}
|
||||
|
||||
return vec4(cloudColor * colorMultiplier, cloud * CLOUD_OPACITY);
|
||||
}
|
||||
|
||||
#ifdef AURORA
|
||||
float AuroraNoise(vec2 coord, vec2 wind) {
|
||||
float noise = texture2D(noisetex, coord * 0.175 + wind * 0.25).x;
|
||||
noise+= texture2D(noisetex, coord * 0.04375 + wind * 0.15).x * 5.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
vec3 DrawAurora(vec3 viewPos, float dither, int sampleCount, float NdotU) {
|
||||
#if AA > 1
|
||||
dither = fract(16.0 * frameTimeCounter + dither);
|
||||
#endif
|
||||
|
||||
float gradientMix = dither / sampleCount;
|
||||
float visibility = (1.0 - sunVisibility) * (1.0 - rainStrengthS);
|
||||
visibility *= visibility;
|
||||
|
||||
#ifdef AURORA_BIOME_CHECK
|
||||
visibility *= isSnowy;
|
||||
#endif
|
||||
#ifdef AURORA_FULL_MOON_CHECK
|
||||
visibility *= float(moonPhase == 0);
|
||||
#endif
|
||||
|
||||
#if !defined GBUFFERS_WATER && !defined DEFERRED
|
||||
float skytime = frametime;
|
||||
#else
|
||||
float skytime = cloudtime;
|
||||
#endif
|
||||
|
||||
vec2 wind = vec2(skytime * 0.00005);
|
||||
|
||||
vec3 aurora = vec3(0.0);
|
||||
|
||||
float NdotUM = min(1.08 - NdotU, 1.0);
|
||||
NdotUM *= NdotUM;
|
||||
NdotUM = 1.0 - NdotUM * NdotUM;
|
||||
|
||||
if (NdotU > 0.0 && visibility > 0.0) {
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz);
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
vec2 planeCoord = wpos.xz * ((8.0 * AURORA_HEIGHT + (i + dither) * 7.0 / sampleCount) / wpos.y) * 0.004;
|
||||
vec2 coord = cameraPosition.xz * 0.00001 + planeCoord;
|
||||
|
||||
float noise = AuroraNoise(coord, wind);
|
||||
noise = max(1.0 - 1.5 / (1.0 - NdotU * 0.8) * abs(noise - 3.0), 0.0);
|
||||
|
||||
if (noise > 0.0) {
|
||||
noise *= texture2D(noisetex, coord * 0.25 + wind * 0.25).x;
|
||||
noise *= 0.5 * texture2D(noisetex, coord + wind * 16.0).x + 0.75;
|
||||
noise = noise * noise * 3.0 / sampleCount;
|
||||
noise *= NdotUM;
|
||||
|
||||
vec3 auroracolor = mix(
|
||||
auroraDCol,
|
||||
auroraUCol,
|
||||
pow(gradientMix, 0.4));
|
||||
|
||||
aurora += noise * auroracolor * exp2(-6.0 * i / sampleCount);
|
||||
}
|
||||
gradientMix += 1.0 / sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
aurora = aurora * visibility * 1.5;
|
||||
|
||||
return aurora;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SEVEN
|
||||
float GetNoise(vec2 pos) {
|
||||
return fract(sin(dot(pos, vec2(12.9898, 4.1414))) * 43758.54953);
|
||||
}
|
||||
|
||||
vec3 DrawStars(inout vec3 color, vec3 viewPos, float NdotU) {
|
||||
vec3 wpos = vec3(gbufferModelViewInverse * vec4(viewPos, 1.0));
|
||||
vec3 planeCoord = 0.75 * wpos / (wpos.y + length(wpos.xz));
|
||||
vec2 wind = 0.75 * vec2(frametime, 0.0);
|
||||
#ifdef SEVEN
|
||||
wind = vec2(0.0);
|
||||
#endif
|
||||
vec2 coord = planeCoord.xz * 0.5 + wind * 0.00125;
|
||||
coord = floor(coord*1024.0) / 1024.0;
|
||||
|
||||
float multiplier = 5.0 * (1.0 - rainStrengthS) * (1 - (sunVisibility*0.9 + pow(timeBrightness, 0.05)*0.1)) * pow(NdotU, 2.0);
|
||||
|
||||
#ifdef SEVEN
|
||||
multiplier = sqrt2(NdotU) * 5.0 * (1.0 - rainStrengthS);
|
||||
#endif
|
||||
|
||||
float star = 1.0;
|
||||
if (NdotU > 0.0) {
|
||||
star *= GetNoise(coord.xy);
|
||||
star *= GetNoise(coord.xy+0.1);
|
||||
star *= GetNoise(coord.xy+0.23);
|
||||
}
|
||||
star = max(star - 0.825, 0.0) * multiplier;
|
||||
|
||||
vec3 stars = star * lightNight * lightNight * 160;
|
||||
|
||||
return vec3(stars);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined END && defined ENDER_NEBULA
|
||||
float GetNebulaStarNoise(vec2 pos) {
|
||||
return fract(sin(dot(pos, vec2(12.9898, 4.1414))) * 43758.54953);
|
||||
}
|
||||
|
||||
float NebulaNoise(vec2 coord, vec2 wind) {
|
||||
float noise = texture2D(noisetex, coord * 0.175 + wind * 0.25).x;
|
||||
noise+= texture2D(noisetex, coord * 0.04375 + wind * 0.15).x * 5.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
vec3 DrawEnderNebula(vec3 viewPos, float dither, vec3 lightCol, inout vec3 nebulaStars) {
|
||||
float NdotU = dot(normalize(viewPos), upVec);
|
||||
|
||||
bool dragonBattle = gl_Fog.start / far < 0.5;
|
||||
//if (gl_FragCoord.x < 960) dragonBattle = false;
|
||||
//dragonBattle = true;
|
||||
|
||||
#if AA > 1
|
||||
dither = fract(16.0 * frameTimeCounter + dither);
|
||||
#endif
|
||||
|
||||
int sampleCount = 20;
|
||||
|
||||
float gradientMix = dither / sampleCount;
|
||||
|
||||
#if !defined GBUFFERS_WATER && !defined DEFERRED
|
||||
float skytime = frametime;
|
||||
#else
|
||||
float skytime = cloudtime;
|
||||
#endif
|
||||
|
||||
vec2 wind = vec2(skytime * 0.000035 * NEBULA_SPEED);
|
||||
|
||||
vec3 nebula = vec3(0.0);
|
||||
|
||||
float NdotUM = abs(NdotU);
|
||||
NdotUM = 1.0 - NdotUM;
|
||||
NdotUM = pow(NdotUM, (2.0 - NdotUM) * (NEBULA_DISTRIBUTION - 0.8)) * 0.85;
|
||||
NdotUM = max(NdotUM, 0.0);
|
||||
float compression = pow(NdotUM, NEBULA_COMPRESSION);
|
||||
dither *= dragonBattle ? 0.5 + 0.5 * NEBULA_SMOOTHING : NEBULA_SMOOTHING;
|
||||
|
||||
vec3 nebulaPurple = 12.0 * lightCol * NEBULA_PURPLE_BRIGHTNESS;
|
||||
vec3 nebulaOrange = endOrangeCol * NEBULA_ORANGE_BRIGHTNESS * 4.0;
|
||||
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos * 1000.0, 1.0)).xyz);
|
||||
if (dragonBattle) {
|
||||
nebulaPurple *= 0.3;
|
||||
nebulaOrange *= 2.0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
vec2 planeCoord = wpos.xz * (1.0 + (i + dither) * compression * 6.0 / sampleCount) * NEBULA_SIZE;
|
||||
vec2 coord = planeCoord + cameraPosition.xz * 0.00004;
|
||||
|
||||
float noise = NebulaNoise(coord, wind);
|
||||
noise = max(0.75 - 1.0 / abs(noise - (4.0 + NdotUM * 2.0)), 0.0) * 3.0;
|
||||
|
||||
if (noise > 0.0) {
|
||||
noise *= texture2D(noisetex, abs(coord * 0.25) + wind * 4.0).x;
|
||||
float fireNoise = texture2D(noisetex, abs(coord * 0.2) + wind * 8.0).x;
|
||||
noise *= 0.5 * fireNoise + 0.75;
|
||||
noise = noise * noise * 3.0 / sampleCount;
|
||||
noise *= NdotUM;
|
||||
|
||||
vec3 nebulaColor = nebulaPurple;
|
||||
nebulaColor += nebulaOrange * pow(fireNoise, 5.0);
|
||||
nebulaColor *= gradientMix;
|
||||
|
||||
nebula += noise * nebulaColor * exp2(-6.0 * i / sampleCount);
|
||||
}
|
||||
gradientMix += 1.0 / sampleCount;
|
||||
}
|
||||
|
||||
vec3 starCoord = 0.75 * wpos / (abs(wpos.y) + length(wpos.xz));
|
||||
vec2 starCoord2 = starCoord.xz * 0.5;
|
||||
if (NdotU < 0.0) starCoord2 += 100.0;
|
||||
float starFactor = 1024.0;
|
||||
starCoord2 = floor(starCoord2 * starFactor) / starFactor;
|
||||
float star = 1.0;
|
||||
star *= GetNebulaStarNoise(starCoord2.xy);
|
||||
star *= GetNebulaStarNoise(starCoord2.xy+0.1);
|
||||
star *= GetNebulaStarNoise(starCoord2.xy+0.23);
|
||||
star = max(star - 0.7, 0.0);
|
||||
star *= star;
|
||||
nebulaStars = star * lightCol * 120.0 * (1.0 - NdotUM) * NEBULA_STAR_BRIGHTNESS;
|
||||
|
||||
if (dragonBattle) {
|
||||
nebulaStars *= vec3(2.0, 1.0, 0.5);
|
||||
nebula *= vec3(2.0, 3.0, 2.0) * 0.7;
|
||||
}
|
||||
|
||||
return nebula * 2.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined NETHER && defined NETHER_SMOKE
|
||||
float SmokeNoise(vec2 coord, vec2 wind) {
|
||||
float noise = texture2D(noisetex, coord * 0.175 + wind * 0.25).x;
|
||||
noise+= texture2D(noisetex, coord * 0.04375 + wind * 0.15).x * 5.0;
|
||||
|
||||
return noise;
|
||||
}
|
||||
|
||||
vec3 DrawNetherSmoke(vec3 viewPos, float dither, vec3 lightCol) {
|
||||
float NdotU = dot(normalize(viewPos), upVec);
|
||||
|
||||
#if AA > 1
|
||||
dither = fract(16.0 * frameTimeCounter + dither);
|
||||
#endif
|
||||
|
||||
int sampleCount = 20;
|
||||
|
||||
float gradientMix = dither / sampleCount;
|
||||
|
||||
#if !defined GBUFFERS_WATER && !defined DEFERRED
|
||||
float skytime = frametime;
|
||||
#else
|
||||
float skytime = cloudtime;
|
||||
#endif
|
||||
|
||||
vec2 wind = vec2(skytime * 0.00005);
|
||||
|
||||
vec3 smoke = vec3(0.0);
|
||||
|
||||
float NdotUM = abs(NdotU);
|
||||
NdotUM = 1.0 - NdotUM;
|
||||
|
||||
vec3 wpos = normalize((gbufferModelViewInverse * vec4(viewPos, 1.0)).xyz);
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
vec2 planeCoord = wpos.xz * (1.0 + (i + dither) * 6.0 / sampleCount) * 0.03;
|
||||
vec2 coord = planeCoord + cameraPosition.xz * 0.0017;
|
||||
|
||||
float noise = SmokeNoise(coord, wind);
|
||||
noise = max(0.75 - 1.0 / abs(noise - 6.0), 0.0) * 3.0;
|
||||
|
||||
if (noise > 0.0) {
|
||||
noise *= texture2D(noisetex, abs(coord * 0.25) + wind * 8.0).x;
|
||||
float heightNoise = wpos.y;
|
||||
float fireNoise = texture2D(noisetex, abs(coord * 0.2) + (heightNoise + cameraPosition.y * 0.01) * 0.01 + wind * -4.0).x;
|
||||
noise = noise * noise * 3.0 / sampleCount;
|
||||
noise *= NdotUM;
|
||||
|
||||
vec3 smokeColor = pow(lightCol, vec3(0.6, 0.5, 0.6)) * 12.0 * pow(fireNoise, 5.0);
|
||||
smokeColor *= gradientMix;
|
||||
|
||||
smoke += noise * smokeColor * exp2(-6.0 * i / sampleCount);
|
||||
}
|
||||
gradientMix += 1.0 / sampleCount;
|
||||
}
|
||||
|
||||
return smoke * 2.0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
vec3 SunGlare(vec3 color, vec3 nViewPos, vec3 lightCol) {
|
||||
float cosSp = dot(nViewPos, lightVec);
|
||||
if (cosSp > 0.0) {
|
||||
float cosS = cosSp;
|
||||
cosS *= cosS;
|
||||
cosS *= cosS;
|
||||
cosS *= cosS;
|
||||
float visfactor = 0.075;
|
||||
|
||||
float sunGlare = cosS;
|
||||
sunGlare = visfactor / (1.0 - (1.0 - visfactor) * sunGlare) - visfactor;
|
||||
sunGlare *= cosSp;
|
||||
|
||||
sunGlare *= 0.25 * SUN_GLARE_STRENGTH * (1.0 - rainStrengthS);
|
||||
|
||||
float shadowTime = abs(sunVisibility - 0.5) * 2.0;
|
||||
shadowTime *= shadowTime;
|
||||
sunGlare *= shadowTime * shadowTime;
|
||||
|
||||
vec3 finalSunGlare = lightCol * sunGlare;
|
||||
|
||||
if (isEyeInWater == 1) finalSunGlare *= underwaterColor.rgb * underwaterColor.rgb * 200.0;
|
||||
|
||||
color += finalSunGlare;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
vec4 GetVolumetricClouds(float depth0, float depth1, vec3 vlAlbedo, float dither, vec4 viewPos) {
|
||||
vec4 clouds = vec4(0.0);
|
||||
|
||||
//Color+
|
||||
float sunVisibility2 = sunVisibility * sunVisibility;
|
||||
float sunVisibility4 = sunVisibility2 * sunVisibility2;
|
||||
|
||||
vec3 cloudNightColor = ambientCol * 2.0;
|
||||
vec3 cloudDayColor = pow(lightCol, vec3(1.5)) * (0.5 + 0.5 * timeBrightness);
|
||||
vec3 cloudRainColor = normalize(pow(lightCol, vec3(1.0 + sunVisibility4))) * (0.015 + 0.1 * sunVisibility4 + 0.1 * timeBrightness);
|
||||
|
||||
vec3 cloudUpColor = mix(cloudNightColor, cloudDayColor, sunVisibility4);
|
||||
cloudUpColor = mix(cloudUpColor, cloudRainColor, rainStrengthS);
|
||||
|
||||
vec3 cloudDownColor = cloudUpColor * 0.35;
|
||||
|
||||
float cloudAmountM = 0.075 * CLOUD_AMOUNT * (1.0 - 0.35 * rainStrengthS);
|
||||
|
||||
//Settings
|
||||
float cloudAltitude = 128.0;
|
||||
float cloudThickness = 24.0;
|
||||
int sampleCount = 20;
|
||||
float minDistFactor = 160.0 / sampleCount * sqrt(far / 256.0);
|
||||
|
||||
//Ray Trace
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
float minDist = (i + dither) * minDistFactor;
|
||||
|
||||
if (depth1 < minDist || (depth0 < minDist && vlAlbedo == vec3(0.0))) break;
|
||||
|
||||
float distX = GetDistX(minDist);
|
||||
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord, distX, 1.0) * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
vec4 wpos = gbufferModelViewInverse * viewPos;
|
||||
vec3 worldPos = wpos.xyz + cameraPosition.xyz + vec3(cloudtime * 2.0, 0.0, 0.0);
|
||||
|
||||
float yFactor = max(cloudThickness - abs(worldPos.y - cloudAltitude), 0.0) / cloudThickness;
|
||||
float disFalloff = max(32.0 - max(length(wpos.xz) - 256.0, 0.0), 0.0) / 32.0;
|
||||
float smoke = 0.0;
|
||||
if (yFactor * disFalloff > 0.001) {
|
||||
worldPos.xz *= 2.0;
|
||||
smoke = texture2D(noisetex, worldPos.xz * 0.0002 ).r * 0.5;
|
||||
smoke += texture2D(noisetex, worldPos.xz * 0.0001 ).r;
|
||||
smoke += texture2D(noisetex, worldPos.xz * 0.00005 ).r;
|
||||
smoke += texture2D(noisetex, worldPos.xz * 0.000025).r * 2.0;
|
||||
}
|
||||
|
||||
smoke *= disFalloff;
|
||||
smoke *= sqrt1(yFactor) * 0.35;
|
||||
smoke = max(smoke - cloudAmountM, 0.0);
|
||||
|
||||
float blend = ( (worldPos.y - cloudAltitude) / cloudThickness + 1.0 ) * 0.5;
|
||||
blend = clamp(blend, 0.0, 1.0);
|
||||
blend *= blend;
|
||||
vec3 cloudColorSample = mix(cloudDownColor, cloudUpColor, blend);
|
||||
if (depth0 < minDist) cloudColorSample *= vlAlbedo;
|
||||
clouds.rgb = mix(cloudColorSample, clouds.rgb, min(clouds.a, 1.0));
|
||||
|
||||
clouds.a += smoke * 256.0 / sampleCount;
|
||||
}
|
||||
|
||||
clouds *= 0.9;
|
||||
clouds += clouds * dither * 0.19;
|
||||
clouds = sqrt(clouds);
|
||||
|
||||
return clouds;
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
vec4 DistortShadow(vec4 shadowpos, float distortFactor) {
|
||||
shadowpos.xy *= 1.0 / distortFactor;
|
||||
shadowpos.z = shadowpos.z * 0.2;
|
||||
shadowpos = shadowpos * 0.5 + 0.5;
|
||||
|
||||
return shadowpos;
|
||||
}
|
||||
|
||||
void GetShadowSpace(inout vec3 worldposition, inout vec4 vlposition, float shadowdepth, vec2 texCoord) {
|
||||
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord, shadowdepth, 1.0) * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
vec4 wpos = gbufferModelViewInverse * viewPos;
|
||||
worldposition = wpos.xyz / wpos.w;
|
||||
wpos = shadowModelView * wpos;
|
||||
wpos = shadowProjection * wpos;
|
||||
wpos /= wpos.w;
|
||||
|
||||
float distb = sqrt(wpos.x * wpos.x + wpos.y * wpos.y);
|
||||
float distortFactor = 1.0 - shadowMapBias + distb * shadowMapBias;
|
||||
wpos = DistortShadow(wpos,distortFactor);
|
||||
|
||||
#if defined WATER_CAUSTICS && defined OVERWORLD && defined SMOKEY_WATER_LIGHTSHAFTS
|
||||
if (isEyeInWater == 1.0) {
|
||||
vec3 worldPos = ViewToWorld(viewPos.xyz);
|
||||
vec3 causticpos = worldPos.xyz + cameraPosition.xyz;
|
||||
float caustic = getCausticWaves(causticpos.xyz * 0.25);
|
||||
wpos.xy *= 1.0 + caustic * 0.0125;
|
||||
}
|
||||
#endif
|
||||
|
||||
vlposition = wpos;
|
||||
}
|
||||
|
||||
//Volumetric light from Robobo1221 (highly modified)
|
||||
vec3 GetVolumetricRays(float depth0, float depth1, vec3 vlAlbedo, float dither, float cosS) {
|
||||
vec3 vl = vec3(0.0);
|
||||
|
||||
#if AA > 1
|
||||
float ditherAnimate = 1.61803398875 * mod(float(frameCounter), 3600.0);
|
||||
dither = fract(dither + ditherAnimate);
|
||||
#endif
|
||||
|
||||
#ifdef OVERWORLD
|
||||
float visibility = 0.055;
|
||||
if (isEyeInWater == 1) visibility = 0.19;
|
||||
|
||||
float endurance = 1.20;
|
||||
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
if (isEyeInWater == 0) endurance *= min(2.0 + rainStrengthS*rainStrengthS - sunVisibility * sunVisibility, 2.0);
|
||||
else visibility *= 1.0 + 2.0 * pow(max(cosS, 0.0), 128.0) * float(sunVisibility > 0.5) * (1.0 - rainStrengthS);
|
||||
|
||||
if (endurance >= 1.0) visibility *= max((cosS + endurance) / (endurance + 1.0), 0.0);
|
||||
else visibility *= pow(max((cosS + 1.0) / 2.0, 0.0), (11.0 - endurance*10.0));
|
||||
#else
|
||||
if (isEyeInWater == 0) endurance *= min(1.0 + rainStrengthS*rainStrengthS, 2.0);
|
||||
else visibility *= 1.0 + 2.0 * pow(max(cosS, 0.0), 128.0) * float(sunVisibility > 0.5) * (1.0 - rainStrengthS);
|
||||
|
||||
if (endurance >= 1.0) cosS = max((cosS + endurance) / (endurance + 1.0), 0.0);
|
||||
else cosS = pow(max((cosS + 1.0) / 2.0, 0.0), (11.0 - endurance*10.0));
|
||||
#endif
|
||||
#ifdef CAVE_SKY_FIX
|
||||
visibility *= 1.0 - isEyeInCave;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
float visibility = 0.14285;
|
||||
#endif
|
||||
|
||||
if (visibility > 0.0) {
|
||||
#ifdef END
|
||||
float maxDist = 192.0 * (1.5 - isEyeInWater);
|
||||
#else
|
||||
float maxDist = 288.0;
|
||||
if (isEyeInWater == 1) maxDist = min(288.0, shadowDistance * 0.75);
|
||||
#endif
|
||||
|
||||
vec3 worldposition = vec3(0.0);
|
||||
vec4 vlposition = vec4(0.0);
|
||||
|
||||
vec3 watercol = underwaterColor.rgb / UNDERWATER_I;
|
||||
watercol = pow(watercol, vec3(2.3)) * 55.0;
|
||||
|
||||
#ifdef END
|
||||
float minDistFactor = 5.0;
|
||||
#else
|
||||
float minDistFactor = 11.0;
|
||||
|
||||
minDistFactor *= clamp(far, 128.0, 512.0) / 192.0;
|
||||
|
||||
float fovFactor = gbufferProjection[1][1] / 1.37;
|
||||
float x = abs(texCoord.x - 0.5);
|
||||
x = 1.0 - x*x;
|
||||
x = pow(x, max(3.0 - fovFactor, 0.0));
|
||||
minDistFactor *= x;
|
||||
maxDist *= x;
|
||||
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
#else
|
||||
float lightBrightnessM = smoothstep(0.0, 1.0, 1.0 - pow2(1.0 - max(timeBrightness, moonBrightness)));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef END
|
||||
int sampleCount = 9;
|
||||
#else
|
||||
float addition = 0.5;
|
||||
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
int sampleCount = 9;
|
||||
if (isEyeInWater == 0) {
|
||||
sampleCount = 7;
|
||||
minDistFactor *= 0.5;
|
||||
}
|
||||
float sampleIntensity = 2.5;
|
||||
#else
|
||||
int sampleCount = 9;
|
||||
float sampleIntensity = 1.95;
|
||||
#endif
|
||||
|
||||
#if LIGHT_SHAFT_QUALITY == 2
|
||||
if (isEyeInWater == 0) {
|
||||
float qualityFactor = 1.42857;
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
sampleCount = 10;
|
||||
#else
|
||||
sampleCount = 13;
|
||||
#endif
|
||||
sampleIntensity /= qualityFactor;
|
||||
minDistFactor /= 1.7; // pow(qualityFactor, 1.5)
|
||||
addition *= qualityFactor;
|
||||
}
|
||||
#endif
|
||||
#if LIGHT_SHAFT_QUALITY == 3
|
||||
if (isEyeInWater == 0) {
|
||||
int qualityFactor = 4;
|
||||
sampleCount *= qualityFactor;
|
||||
sampleIntensity /= qualityFactor;
|
||||
minDistFactor /= 8; // pow(qualityFactor, 1.5)
|
||||
addition *= qualityFactor;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
#ifdef END
|
||||
float minDist = exp2(i + dither) - 0.9;
|
||||
#else
|
||||
float minDist = 0.0;
|
||||
if (isEyeInWater == 0) {
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
minDist = pow(i + dither + addition, 1.5) * minDistFactor;
|
||||
#else
|
||||
minDist = pow(i + dither + addition, 1.5) * minDistFactor * (0.3 - 0.1 * lightBrightnessM);
|
||||
#endif
|
||||
} else minDist = pow2(i + dither + 0.5) * minDistFactor * 0.045;
|
||||
#endif
|
||||
|
||||
//if (depth0 >= far*0.9999) break;
|
||||
if (minDist >= maxDist) break;
|
||||
|
||||
if (depth1 < minDist || (depth0 < minDist && vlAlbedo == vec3(0.0))) break;
|
||||
|
||||
GetShadowSpace(worldposition, vlposition, GetDistX(minDist), texCoord.st);
|
||||
//vlposition.z += 0.00002;
|
||||
|
||||
if (length(vlposition.xy * 2.0 - 1.0) < 1.0) {
|
||||
vec3 vlsample = vec3(shadow2D(shadowtex0, vlposition.xyz).z);
|
||||
|
||||
if (depth0 < minDist) vlsample *= vlAlbedo;
|
||||
|
||||
#ifdef END
|
||||
if (isEyeInWater == 1) vlsample *= watercol;
|
||||
vl += vlsample;
|
||||
#else
|
||||
if (isEyeInWater == 0) {
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
vl += vlsample * sampleIntensity;
|
||||
#else
|
||||
vlsample *= cosS;
|
||||
|
||||
vl += vlsample * sampleIntensity;
|
||||
#endif
|
||||
} else {
|
||||
vlsample *= watercol;
|
||||
float sampleFactor = sqrt(minDist / maxDist);
|
||||
|
||||
#if LIGHT_SHAFT_MODE == 3
|
||||
vlsample *= cosS;
|
||||
#endif
|
||||
|
||||
vl += vlsample * sampleFactor * 0.55;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
vl += 1.0;
|
||||
}
|
||||
}
|
||||
vl = sqrt(vl * visibility);
|
||||
|
||||
#ifdef END
|
||||
#else
|
||||
#if LIGHT_SHAFT_MODE == 2
|
||||
if (isEyeInWater == 0) {
|
||||
float vlPower = max(1.75 - rainStrengthS + sunVisibility*0.25, 1.0);
|
||||
vl = pow(vl, vec3(vlPower));
|
||||
}
|
||||
#else
|
||||
if (isEyeInWater == 0) {
|
||||
float vlPower = 2.0 - lightBrightnessM;
|
||||
vl = pow(vl, vec3(vlPower));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vl *= 0.9;
|
||||
vl += vl * dither * 0.19;
|
||||
}
|
||||
|
||||
#ifdef GBUFFER_CODING
|
||||
vl = vec3(0.0);
|
||||
#endif
|
||||
|
||||
return vl;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//Water fog is now located in multiple programs in different forms. I will put all of them here when I feel like it.
|
||||
//Update: It's been multiple months and I'm still feeling too lazy to do it.
|
||||
Reference in New Issue
Block a user