Add moon texture with phases, moon and sun can now illuminate clouds at the same time

This commit is contained in:
Merlin1809 committed 2025-05-31 01:27:30 +02:00
1 parent 8fea6f2b84
commit e2af9da16b
19 files changed
+291 -162

No files matched your search

+1 -3
View File
@@ -229,8 +229,6 @@ void main() {
float viewDist = length(localPos.xyz);
float ditherFade = smoothstep(max(far-7,7), far-1, viewDist);
if (step(bayerDither()/ditherFade, ditherFade) == 0.0) {
discard;
}
if (step(bayerDither()/ditherFade, ditherFade) == 0.0) discard;
#endif
}
+1 -3
View File
@@ -458,9 +458,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
float viewDist = length(mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz);
float ditherFade = smoothstep(max(far-9,9), far-1, viewDist);
if (step(bayerDither()/ditherFade, ditherFade) == 0.0) {
discard;
}
if (step(bayerDither()/ditherFade, ditherFade) == 0.0) discard;
}
#endif
}
+22 -21
View File
@@ -37,6 +37,7 @@ varying vec4 color;
uniform int renderStage;
uniform int isEyeInWater;
uniform vec3 sunPosition;
uniform sampler2D texture;
uniform sampler2D noisetex;
@@ -240,6 +241,13 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
{
return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy);
}
vec4 texture2D_POMSwitch(
sampler2D sampler,
vec2 lightmapCoord,
vec4 dcdxdcdy
){
return texture2DGradARB(sampler, lightmapCoord, dcdxdcdy.xy, dcdxdcdy.zw);
}
#endif
uniform float near;
@@ -248,13 +256,6 @@ float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near));
}
vec4 texture2D_POMSwitch(
sampler2D sampler,
vec2 lightmapCoord,
vec4 dcdxdcdy
){
return texture2DGradARB(sampler, lightmapCoord, dcdxdcdy.xy, dcdxdcdy.zw);
}
float luma(vec3 color) {
return dot(color,vec3(0.21, 0.72, 0.07));
@@ -388,6 +389,10 @@ void main() {
gl_FragData[1] = vec4(0.0,0.0,0.0,TEXTURE.a); // for bloomy rain and stuff
#endif
#if !defined WEATHER || (defined DISTANT_HORIZONS && defined DH_CHUNK_FADING)
float viewDist = length(mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz);
#endif
#ifndef WEATHER
#ifndef LINES
gl_FragData[0].a = TEXTURE.a;
@@ -477,13 +482,15 @@ void main() {
if(SELECTION_BOX > 0) gl_FragData[0].rgba = vec4(toLinear(vec3(SELECT_BOX_COL_R, SELECT_BOX_COL_G, SELECT_BOX_COL_B)), 1.0);
float LITEMATICA_SCHEMATIC_THING_MASK = 0.0;
if (renderStage == MC_RENDER_STAGE_NONE){
LITEMATICA_SCHEMATIC_THING_MASK = 0.1;
gl_FragData[0] = vec4(toLinear(color.rgb), color.a);
}
// float LITEMATICA_SCHEMATIC_THING_MASK = 0.0;
// if (renderStage == MC_RENDER_STAGE_NONE){
// LITEMATICA_SCHEMATIC_THING_MASK = 0.1;
// gl_FragData[0] = vec4(toLinear(color.rgb), color.a);
// }
gl_FragData[2] = vec4(encodeVec2(vec2(0.0)), encodeVec2(vec2(0.0)), encodeVec2(vec2(0.0)), encodeVec2(0.0, LITEMATICA_SCHEMATIC_THING_MASK));
// gl_FragData[2] = vec4(encodeVec2(vec2(0.0)), encodeVec2(vec2(0.0)), encodeVec2(vec2(0.0)), encodeVec2(0.0, LITEMATICA_SCHEMATIC_THING_MASK));
if (length(viewPos-normalize(sunPosition)*viewDist) < 0.03*viewDist && SELECTION_BOX > 0) discard; // dirty fix for sun shining through selection box
#else
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
#endif
@@ -496,16 +503,10 @@ void main() {
#endif
#if defined DISTANT_HORIZONS
#ifdef DH_CHUNK_FADING
float viewDist = length(mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz);
#if defined DISTANT_HORIZONS && defined DH_CHUNK_FADING
float ditherFade = smoothstep(0.98*far, 1.0*far, viewDist);
if (step(ditherFade, bayerDither()) == 0.0) {
discard;
}
#endif
if (step(ditherFade, bayerDither()) == 0.0) discard;
#endif
#endif
+2 -2
View File
@@ -13,7 +13,7 @@ varying vec4 lmtexcoord;
varying vec4 color;
uniform sampler2D colortex4;
flat varying float exposure;
// flat varying float exposure;
#ifdef LINES
flat varying int SELECTION_BOX;
@@ -118,7 +118,7 @@ void main() {
color = gl_Color;
exposure = texelFetch2D(colortex4,ivec2(10,37),0).r;
// exposure = texelFetch2D(colortex4,ivec2(10,37),0).r;
// color.rgb = worldpos;
#ifdef LINES
+1 -3
View File
@@ -455,13 +455,11 @@ void main() {
vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color;
#if defined DISTANT_HORIZONS
#ifdef DH_CHUNK_FADING
#if defined DISTANT_HORIZONS && defined DH_CHUNK_FADING
float viewDist = length(playerpos);
float ditherFade = smoothstep(0.98 * far, 1.03 * far, viewDist);
Albedo.a *= step(ditherFade, bayerDither());
#endif
#endif
#if defined HAND
+2 -7
View File
@@ -455,16 +455,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
gl_FragData[0].a = 1.0/255.0;
}
#if defined DISTANT_HORIZONS
#ifdef DH_CHUNK_FADING
#if defined DISTANT_HORIZONS && defined DH_CHUNK_FADING
float viewDist = length((mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz));
float ditherFade = smoothstep(0.98 * far, 1.03 * far, viewDist);
if (step(ditherFade, bayerDither()) == 0.0) {
discard;
}
#endif
if (step(ditherFade, bayerDither()) == 0.0) discard;
#endif
#endif
#endif
+44 -27
View File
@@ -80,6 +80,12 @@ uniform sampler2D colortex13;
uniform sampler2D colortex14;
uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha)
#ifdef REALMOON
uniform sampler2D moon;
#endif
uniform float sunElevation;
#ifdef IS_LPV_ENABLED
uniform usampler1D texBlockData;
uniform sampler3D texLpv1;
@@ -727,6 +733,11 @@ void applyPuddles(
// albedo = mix(albedo, vec3(1.0), snow);
}
vec3 projectAndDivide(mat4 projectionMatrix, vec3 position) {
vec4 homogeneousPos = projectionMatrix * vec4(position, 1.0);
return homogeneousPos.xyz / homogeneousPos.w;
}
void main() {
@@ -1299,33 +1310,9 @@ void main() {
#if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0 || RESOURCEPACK_SKY == 3
// vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2;
vec3 orbitstar = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE,1.0)));
vec3 worldDir = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE,1.0)));
float radiance = worldTime / 24000.0 * 6.28319;
float sunRotRad = radians(sunPathRotation);
vec3 rotationAxis = vec3(0.0, sin(sunRotRad), cos(sunRotRad));
float c = cos(radiance);
float s = sin(radiance);
float t = 1.0 - c;
mat3 tiltRotation = mat3(
t * rotationAxis.x * rotationAxis.x + c,
t * rotationAxis.x * rotationAxis.y - s * rotationAxis.z,
t * rotationAxis.x * rotationAxis.z + s * rotationAxis.y,
t * rotationAxis.x * rotationAxis.y + s * rotationAxis.z,
t * rotationAxis.y * rotationAxis.y + c,
t * rotationAxis.y * rotationAxis.z - s * rotationAxis.x,
t * rotationAxis.x * rotationAxis.z - s * rotationAxis.y,
t * rotationAxis.y * rotationAxis.z + s * rotationAxis.x,
t * rotationAxis.z * rotationAxis.z + c
);
orbitstar = tiltRotation * orbitstar;
vec3 orbitstar = customRotation(sunPathRotation, worldTime) * worldDir;
#if defined OVERWORLD_SHADER && defined TWILIGHT_FOREST_FLAG
Background += stars(orbitstar) * 100.0;
@@ -1337,8 +1324,38 @@ void main() {
Background += drawSun(dot(unsigned_WsunVec, feetPlayerPos_normalized), 0, DirectLightColor,vec3(0.0));
vec3 moonLightCol = moonCol / 2400.0;
#ifdef REALMOON
vec3 tangent = normalize(cross(WmoonVec, vec3(0.0, 1.0, 0.0)));
vec3 binormal = cross(WmoonVec, tangent);
vec3 dirDiff = worldDir - WmoonVec;
Background += drawMoon(feetPlayerPos_normalized, WmoonVec, moonLightCol, Background);
float u = dot(dirDiff, tangent);
float v = dot(dirDiff, binormal);
float moonAngularRadius = acos(0.9992);
u = u / (2.0 * moonAngularRadius) + 0.5;
v = -v / (2.0 * moonAngularRadius) + 0.5;
vec2 moonUV = vec2(u, v);
float moonVis = smoothstep(0.08, -0.03, -sunElevation);
float moonphaseMult = 1.0;
#ifdef MOONPHASE_BASED_MOONLIGHT
if (moonPhase == 0) moonphaseMult = 1.0;
if (moonPhase == 1) moonphaseMult = smoothstep(0.85, 0.65, u + pow(abs(0.8*(v-0.5)), 2.0));
if (moonPhase == 2) moonphaseMult = smoothstep(0.6, 0.4, u);
if (moonPhase == 3) moonphaseMult = smoothstep(0.35, 0.15, u - pow(abs(0.8*(v-0.5)), 2.0));
if (moonPhase == 4) moonphaseMult = 0.0;
if (moonPhase == 5) moonphaseMult = smoothstep(0.65, 0.85, u + pow(abs(0.8*(v-0.5)), 2.0));
if (moonPhase == 6) moonphaseMult = smoothstep(0.4, 0.6, u);
if (moonPhase == 7) moonphaseMult = smoothstep(0.15, 0.35, u - pow(abs(0.8*(v-0.5)), 2.0));
#endif
vec3 moonTex = (1 - moonVis*vec3(0.0, 0.5, 0.7)) * moonphaseMult * texture2D(moon, sphereMap(moonUV)).rgb;
Background += pow(moonTex, vec3(3.2)) * 20.0 * drawRealMoon(feetPlayerPos_normalized, WmoonVec, Background);
#else
Background += drawMoon(feetPlayerPos_normalized, WmoonVec, moonLightCol, Background);
#endif
// Background += drawSun(dot(WmoonVec, feetPlayerPos_normalized),0, moonLightCol,vec3(0.0));
#endif
+7 -1
View File
@@ -3,6 +3,8 @@
#define EXCLUDE_WRITE_TO_LUT
flat varying vec4 lightCol;
flat varying vec3 sunlightCol;
flat varying vec3 moonlightCol;
flat varying vec3 averageSkyCol;
flat varying vec3 averageSkyCol_Clouds;
@@ -25,6 +27,8 @@ uniform sampler2D colortex7;
uniform sampler2D colortex10;
flat varying vec3 WsunVec;
flat varying vec3 WrealSunVec;
flat varying vec3 WmoonVec;
uniform vec3 sunVec;
uniform float sunElevation;
@@ -522,12 +526,14 @@ void main() {
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14;
vec3 directLightColor = lightCol.rgb / 2400.0;
vec3 directSunlightColor = sunlightCol / 2400.0;
vec3 directMoonlightColor = moonlightCol / 2400.0;
vec3 indirectLightColor = averageSkyCol / 1200.0;
vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 1200.0;
float cloudPlaneDistance = 0.0;
#if defined OVERWORLD_SHADER
vec4 VolumetricClouds = GetVolumetricClouds(viewPos0, BN, WsunVec, directLightColor, indirectLightColor, cloudPlaneDistance);
vec4 VolumetricClouds = GetVolumetricClouds(viewPos0, BN, WrealSunVec, WmoonVec, directSunlightColor, directMoonlightColor, indirectLightColor, cloudPlaneDistance);
#ifdef CAVE_FOG
#if (CAVE_DETECTION == 0.0) || (CAVE_DETECTION == 1.0)
+8 -1
View File
@@ -3,6 +3,8 @@
#include "/lib/res_params.glsl"
flat varying vec4 lightCol;
flat varying vec3 sunlightCol;
flat varying vec3 moonlightCol;
flat varying vec3 averageSkyCol;
flat varying vec3 averageSkyCol_Clouds;
@@ -14,6 +16,8 @@ flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 WsunVec;
flat varying vec3 WrealSunVec;
flat varying vec3 WmoonVec;
flat varying vec3 refractedSunVec;
uniform vec2 texelSize;
@@ -50,6 +54,8 @@ void main() {
#ifdef OVERWORLD_SHADER
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
sunlightCol = texelFetch2D(colortex4,ivec2(8,37),0).rgb;
moonlightCol = texelFetch2D(colortex4,ivec2(9,37),0).rgb;
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
@@ -72,9 +78,10 @@ void main() {
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
vec3 moonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
vec3 WmoonVec = moonVec;
WmoonVec = moonVec;
if(dot(-moonVec, WsunVec) < 0.9999) WmoonVec = -moonVec;
WrealSunVec = WsunVec;
WsunVec = mix(WmoonVec, WsunVec, clamp(lightCol.a,0,1));
refractedSunVec = refract(lightCol.a*WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333);
+4 -3
View File
@@ -42,6 +42,7 @@ uniform float frameTimeCounter;
uniform float rainStrength;
uniform float eyeAltitude;
uniform vec3 sunVec;
uniform vec3 moonVec;
uniform vec2 texelSize;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
@@ -70,6 +71,7 @@ vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.);
#include "/lib/waterBump.glsl"
vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec;
vec3 WmoonVec = mat3(gbufferModelViewInverse)*moonVec;
// vec3 WsunVec = normalize(LightDir);
vec3 toShadowSpaceProjected(vec3 p3){
@@ -317,8 +319,6 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
if(dot(-WmoonVec, WsunVec) < 0.9999) WmoonVec = -WmoonVec;
WsunVec = mix(WmoonVec, WsunVec, clamp(float(sunElevation > 1e-5)*2.0-1.0 ,0,1));
vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150.0;
sky = mix(averageSkyCol_Clouds * AmbientLightTint * 0.25, sky, pow(clamp(viewVector.y+1.0,0.0,1.0),5.0));
@@ -329,9 +329,10 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
#endif
float rejection = 1.0;
float cloudPlaneDistance = 0.0;
vec4 volumetricClouds = GetVolumetricClouds(viewPos, vec2(noise, 1.0-noise), WsunVec, suncol*2.5, skyGroundCol/30.0, cloudPlaneDistance);
vec4 volumetricClouds = GetVolumetricClouds(viewPos, vec2(noise, 1.0-noise), WsunVec, WmoonVec, sunColor*2.5, moonColor*2.5, skyGroundCol/30.0, cloudPlaneDistance);
float atmosphereAlpha = 1.0;
WsunVec = mix(WmoonVec, WsunVec, clamp(float(sunElevation > 1e-5)*2.0-1.0 ,0,1));
vec4 volumetricFog = GetVolumetricFog(viewPos, WsunVec, vec2(noise, 1.0-noise), suncol*2.5, skyGroundCol/30.0, averageSkyCol_Clouds*5.0, atmosphereAlpha, volumetricClouds.rgb, cloudPlaneDistance);
sky = sky * volumetricClouds.a + volumetricClouds.rgb / 5.0;
@@ -5,6 +5,8 @@
uniform float nightVision;
flat varying vec4 lightCol;
flat varying vec3 sunlightCol;
flat varying vec3 moonlightCol;
flat varying vec3 averageSkyCol;
flat varying vec3 averageSkyCol_Clouds;
flat varying float exposure;
@@ -27,6 +29,8 @@ uniform sampler2D colortex11;
uniform sampler2D colortex14;
flat varying vec3 WsunVec;
flat varying vec3 WrealSunVec;
flat varying vec3 WmoonVec;
uniform vec3 sunVec;
uniform float sunElevation;
@@ -314,6 +318,8 @@ void main() {
#endif
vec3 directLightColor = lightCol.rgb / 2400.0;
vec3 directSunlightColor = sunlightCol / 2400.0;
vec3 directMoonlightColor = moonlightCol / 2400.0;
vec3 indirectLightColor = averageSkyCol / 1200.0;
vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 1200.0;
@@ -349,7 +355,7 @@ void main() {
float cloudPlaneDistance = 0.0;
#ifdef OVERWORLD_SHADER
vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WsunVec, directLightColor, indirectLightColor, cloudPlaneDistance);
vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WrealSunVec, WmoonVec, directSunlightColor, directMoonlightColor, indirectLightColor, cloudPlaneDistance);
float atmosphereAlpha = 1.0;
vec4 VolumetricFog = GetVolumetricFog(viewPos1, WsunVec, vec2(noise_1, noise_2), directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb,cloudPlaneDistance);
@@ -3,12 +3,16 @@
#include "/lib/res_params.glsl"
flat varying vec4 lightCol;
flat varying vec3 sunlightCol;
flat varying vec3 moonlightCol;
flat varying vec3 averageSkyCol;
flat varying vec3 averageSkyCol_Clouds;
#include "/lib/scene_controller.glsl"
flat varying vec3 WsunVec;
flat varying vec3 WrealSunVec;
flat varying vec3 WmoonVec;
flat varying vec3 refractedSunVec;
// flat varying float tempOffsets;
@@ -51,6 +55,8 @@ void main() {
#ifdef OVERWORLD_SHADER
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
sunlightCol = texelFetch2D(colortex4,ivec2(8,37),0).rgb;
moonlightCol = texelFetch2D(colortex4,ivec2(9,37),0).rgb;
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
@@ -69,14 +75,14 @@ void main() {
averageSkyCol_Clouds = vec3(15);
#endif
lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0;
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
vec3 moonVec = normalize(mat3(gbufferModelViewInverse) * moonPosition);
vec3 WmoonVec = moonVec;
WmoonVec = moonVec;
if(dot(-moonVec, WsunVec) < 0.9999) WmoonVec = -moonVec;
WrealSunVec = WsunVec;
WsunVec = mix(WmoonVec, WsunVec, clamp(lightCol.a,0,1));
refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333);
+2 -1
View File
@@ -13,7 +13,8 @@ option.CAVE_DETECTION = Cave detection
option.sunPathRotation = Sun Angle
option.sun_illuminance = Sun Illuminance
option.moon_illuminance = Moon Illuminance
option.MOONPHASE_BASED_MOONLIGHT = Moonphase brightness levels
option.MOONPHASE_BASED_MOONLIGHT = Moonphase Brightness Levels
option.REALMOON = Realistic Moon
screen.Misc_Settings = §cDebugging§r/Experimental Settings
screen.Mod_support = Settings For Supported Mods
+5 -2
View File
@@ -316,6 +316,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.
#define moonColorG 0.9121 //[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 ]
#define moonColorB 0.8948 //[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 ]
#define REALMOON
#define MOONPHASE_BASED_MOONLIGHT
uniform int moonPhase;
@@ -328,7 +329,8 @@ uniform int moonPhase;
#ifdef MOONPHASE_BASED_MOONLIGHT
#define phasebrightness (abs(4-moonPhase))
#define moonlightbrightness (phasebrightness/4.0)
#define moonColorBase (blackbody(Moon_temp) * moon_illuminance) * moonlightbrightness
#define moonColorBase2 blackbody(Moon_temp) * moon_illuminance
#define moonColorBase moonColorBase2 * moonlightbrightness
#else
#define moonColorBase blackbody(Moon_temp) * moon_illuminance
#endif
@@ -798,7 +800,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
// #define PLANET_CURVATURE
#define CURVATURE_AMOUNT 1.0 // [-10.0 -9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 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 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
#define DH_CHUNK_FADING
// #define OLD_INDIRECT_SSS
///////////////////////////////////////////
@@ -819,6 +820,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define DH_OVERDRAW_PREVENTION
#define OVERDRAW_MAX_DISTANCE 128 // [0 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256]
#define DH_CHUNK_FADING
#define DH_AMBIENT_OCCLUSION
#define DH_SUBSURFACE_SCATTERING
#define DH_SCREENSPACE_REFLECTIONS
+24 -2
View File
@@ -7,6 +7,24 @@ vec3 drawSun(float cosY, float sunInt,vec3 nsunlight, vec3 inColor){
return (inColor+nsunlight/0.0008821203*pow(smoothstep(cos(0.0093084168595*3.2),cos(0.0093084168595*1.8),cosY),3.)*0.62);
}
const float pi = 3.141592653589793238462643383279502884197169;
vec2 sphereMap(vec2 uv) {
vec2 position = 2.0 * uv - 1.0;
float radius = dot(position, position);
if (radius > 1.0) return vec2(0.0);
float z = sqrt(1.0 - radius);
float longitude = atan(position.x, z);
float latitude = acos(position.y);
float u = (longitude + pi) / (2.0 * pi);
float v = latitude / pi;
return vec2(u, v);
}
vec3 drawMoon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeStars){
@@ -39,10 +57,14 @@ vec3 drawMoon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeSt
return Shape * pow(clamp(dot(sunNormal,LightDir)/5,0.0,1.5),5) * Color * 10.0 + clamp(Shape * 4.0 * pow(shape2/200,2.0),0.0,1.0)*0.004;
*/
}
vec3 drawRealMoon(vec3 PlayerPos, vec3 WorldSunVec, inout vec3 occludeStars){
const float pi = 3.141592653589793238462643383279502884197169;
float Shape = min(max(dot(WorldSunVec,PlayerPos)-0.9992,0.0)/(1.0-0.9992),1.0);// * clamp(-dot(WorldSunVec,PlayerPos),0,1);
occludeStars *= max(1.0-Shape*50,0.0);
return Shape * moonColorBase2/4000 * 3.0;
}
float w0(float a)
{
+28
View File
@@ -194,3 +194,31 @@ float HaltonSeq2(int index)
}
return r;
}
mat3 customRotation(float rotationAngle, float worldTime) {
float radiance = worldTime / 24000.0 * 6.28319;
float sunRotRad = radians(rotationAngle);
vec3 rotationAxis = vec3(0.0, sin(sunRotRad), cos(sunRotRad));
float c = cos(radiance);
float s = sin(radiance);
float t = 1.0 - c;
mat3 tiltRotation = mat3(
t * rotationAxis.x * rotationAxis.x + c,
t * rotationAxis.x * rotationAxis.y - s * rotationAxis.z,
t * rotationAxis.x * rotationAxis.z + s * rotationAxis.y,
t * rotationAxis.x * rotationAxis.y + s * rotationAxis.z,
t * rotationAxis.y * rotationAxis.y + c,
t * rotationAxis.y * rotationAxis.z - s * rotationAxis.x,
t * rotationAxis.x * rotationAxis.z - s * rotationAxis.y,
t * rotationAxis.y * rotationAxis.z + s * rotationAxis.x,
t * rotationAxis.z * rotationAxis.z + c
);
return tiltRotation;
}
+120 -82
View File
@@ -10,6 +10,8 @@ uniform int worldDay;
uniform int worldTime;
float cloud_movement = (worldTime + mod(worldDay,100)*24000.0) / 24.0 * Cloud_Speed;
float sunMultiplier = smoothstep(500.0, 0.0, worldTime) + smoothstep(11500.0, 13500.0, worldTime) * smoothstep(13500.0, 11500.0, worldTime) + smoothstep(23500.0, 24000.0, worldTime);
float lightningTimer = floor(frameTimeCounter * 11.0);
float randomSeed = fract(sin(dot(vec2(lightningTimer), vec2(12.9898,78.233))) * 43758.5453);
float lightningFlash = mix(0.3, 1.5, randomSeed);
@@ -107,7 +109,7 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
float curl_strength = 1.3;
for (int i = 0; i < 3; ++i) {
float detail = texture(noisetex, coord * detail_frequency + curl * curl_strength).r;
float detail = texture2D(noisetex, coord * detail_frequency + curl * curl_strength).r;
smallCloud -= detail * detail_amplitude;
@@ -139,6 +141,48 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
return shape;
}
float tallness = maxHeight - minHeight;
float posToMax = maxHeight - position.y;
if(LayerIndex == CUMULONIMBUS_LAYER){
float cumulonimbusScale = 1.0;
smallCloud = texture2D(noisetex, (samplePos.zx - cloud_movement*6.0) / 17000.0 * cumulonimbusScale * 0.2).b;
smallCloud = abs(smallCloud* -2.3);
float val = 1.3 + Rain_coverage * rainStrength;
float shape = min(max(val - smallCloud,0.0)/sqrt(val),1.0) * smoothstep(5000.0, 10000.0, length(position.xz - cameraPosition.xz));
shape = min(min(shape, clamp(posToMax,0,1)), 1.0 - clamp(minHeight - position.y,0,1));
float bottomShape = 1.0-pow(1.0-min(max(position.y-minHeight,0.0) / 5.0, 1.0), 5.0);
float topShape = min(max(posToMax,0.0) / max(tallness,1.0),1.0);
topShape = min(exp(-1.0 * (1.0-topShape)), 1.0-pow(1.0-topShape,5.0));
float topShape2 = min(max(posToMax,0.0) / max(tallness,1.0),1.0);
topShape2 = min(exp(-0.1 * (1.0-topShape2)), 1.0-pow(1.0-topShape2,7.0));
shape = max((shape - 1.0) + topShape * bottomShape + (1- topShape2) * bottomShape, 0.0);
if(shape > 0.001){
if (LOD < 1) return max(shape - 0.27*0.5,0.0);
samplePos.xz -= cloud_movement/4.0;
samplePos.xz += pow( max(position.y - (minHeight+20.0), 0.0) / (max(tallness,1.0)*0.20), 1.5);
float omShape = 1.0 - shape;
float erosion = (1.0 - densityAtPos(samplePos * 100.0 * cumulonimbusScale*0.05)) * sqrt(omShape);
float falloff = 1.0 - clamp((posToMax)/200.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 370.0 * cumulonimbusScale*0.05) - falloff) * 0.65 * (omShape) * (1.0-falloff*0.5);
erosion = erosion*erosion*erosion*erosion;
return max(shape - erosion*0.5,0.0);
} else return 0.0;
}
if(LayerIndex == LARGECUMULUS_LAYER){
coverage = parameters.largeCumulus.x;
coverage += Rain_coverage * rainStrength;
@@ -171,56 +215,15 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
}
// clamp density of the cloud within its upper/lower bounds
shape = min(min(shape, clamp(maxHeight - position.y,0,1)), 1.0 - clamp(minHeight - position.y,0,1));
// carve out the upper part of clouds. make sure it rounds out at its upper bound
float topShape = min(max(maxHeight-position.y,0.0) / max(maxHeight-minHeight,1.0),1.0);
float topShape2 = 1.0;
shape = min(min(shape, clamp(posToMax,0,1)), 1.0 - clamp(minHeight - position.y,0,1));
float bottomShape = 1.0-pow(1.0-min(max(position.y-minHeight,0.0) / 25.0, 1.0), 5.0);
// carve out the upper part of clouds. make sure it rounds out at its upper bound
float topShape = min(max(posToMax,0.0) / max(tallness,1.0),1.0);
topShape = min(exp(-0.5 * (1.0-topShape)), 1.0-pow(1.0-topShape,5.0));
shape = max((shape - 1.0) + topShape * bottomShape + (1- topShape2) * bottomShape, 0.0);
if(LayerIndex == CUMULONIMBUS_LAYER){
float cumulonimbusScale = 1.0;
smallCloud = texture2D(noisetex, (samplePos.zx - cloud_movement*6.0) / 17000.0 * cumulonimbusScale * 0.2).b;
smallCloud = abs(smallCloud* -2.3);
float val = 1.3 + Rain_coverage * rainStrength;
float shape = min(max(val - smallCloud,0.0)/sqrt(val),1.0) * smoothstep(5000.0, 10000.0, length(position.xz - cameraPosition.xz));
shape = min(min(shape, clamp(maxHeight - position.y,0,1)), 1.0 - clamp(minHeight - position.y,0,1));
bottomShape = 1.0-pow(1.0-min(max(position.y-minHeight,0.0) / 5.0, 1.0), 5.0);
topShape = min(max(maxHeight-position.y,0.0) / max(maxHeight-minHeight,1.0),1.0);
topShape = min(exp(-1.0 * (1.0-topShape)), 1.0-pow(1.0-topShape,5.0));
topShape2 = min(max(maxHeight-position.y,0.0) / max(maxHeight-minHeight,1.0),1.0);
topShape2 = min(exp(-0.1 * (1.0-topShape2)), 1.0-pow(1.0-topShape2,7.0));
shape = max((shape - 1.0) + topShape * bottomShape + (1- topShape2) * bottomShape, 0.0);
if(shape > 0.001){
if (LOD < 1) return max(shape - 0.27*0.5,0.0);
samplePos.xz -= cloud_movement/4.0;
samplePos.xz += pow( max(position.y - (minHeight+20.0), 0.0) / (max(maxHeight-minHeight,1.0)*0.20), 1.5);
float erosion = (1.0 - densityAtPos(samplePos * 100.0 * cumulonimbusScale*0.05)) * sqrt(1.0-shape);
float falloff = 1.0 - clamp((maxHeight - position.y)/200.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 370.0 * cumulonimbusScale*0.05) - falloff) * 0.65 * (1.0-shape) * (1.0-falloff*0.5);
erosion = erosion*erosion*erosion*erosion;
return max(shape - erosion*0.5,0.0);
} else return 0.0;
}
shape = max((shape - 1.0) + topShape * bottomShape, 0.0);
/// erosion noise
if(shape > 0.001){
@@ -233,23 +236,24 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
// da wind
// if(LayerIndex == SMALLCUMULUS_LAYER)
samplePos.xz += pow( max(position.y - (minHeight+20.0), 0.0) / (max(maxHeight-minHeight,1.0)*0.20), 1.5);
samplePos.xz += pow(max(position.y - (minHeight+20.0), 0.0) / (max(tallness,1.0)*0.20), 1.5);
float erosion = 0.0;
float omShape = 1.0 - shape;
if(LayerIndex == SMALLCUMULUS_LAYER){
erosion += (1.0-densityAtPos(samplePos * 200.0 * CloudLayer0_scale)) * sqrt(1.0-shape);
erosion += (1.0-densityAtPos(samplePos * 200.0 * CloudLayer0_scale)) * sqrt(omShape);
float falloff = 1.0 - clamp((maxHeight - position.y)/100.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 600.0 * CloudLayer0_scale) - falloff) * 0.75 * (1.0-shape) * (1.0-falloff*0.25);
float falloff = 1.0 - clamp((posToMax)/100.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 600.0 * CloudLayer0_scale) - falloff) * 0.75 * (omShape) * (1.0-falloff*0.25);
erosion = erosion*erosion*erosion*erosion;
}
if(LayerIndex == LARGECUMULUS_LAYER){
erosion += (1.0 - densityAtPos(samplePos * 100.0 * CloudLayer1_scale)) * sqrt(1.0-shape);
erosion += (1.0 - densityAtPos(samplePos * 100.0 * CloudLayer1_scale)) * sqrt(omShape);
float falloff = 1.0 - clamp((maxHeight - position.y)/200.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 450.0 * CloudLayer1_scale) - falloff) * 0.75 * (1.0-shape) * (1.0-falloff*0.5);
float falloff = 1.0 - clamp((posToMax)/200.0,0.0,1.0);
erosion += abs(densityAtPos(samplePos * 450.0 * CloudLayer1_scale) - falloff) * 0.75 * (omShape) * (1.0-falloff*0.5);
erosion = erosion*erosion*erosion*erosion;
}
@@ -261,9 +265,9 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
}
float getPlanetShadow(vec3 playerPos, vec3 WsunVec){
float planetShadow = min(max(playerPos.y - (-100.0 + 1.0 / abs(WsunVec.y*0.1)),0.0) / 100.0, 1.0);
float planetShadow = min(max(playerPos.y - (-100.0 + 1.0 / max(WsunVec.y*0.1, 0.0)),0.0) / 100.0, 1.0);
planetShadow = mix(pow(1.0-pow(1.0-planetShadow,2.0),2.0), 1.0, pow(abs(WsunVec.y),2.0));
planetShadow = mix(pow(1.0-pow(1.0-planetShadow,2.0),2.0), 1.0, pow(max(WsunVec.y, 0.0),2.0));
return planetShadow;
}
@@ -317,6 +321,7 @@ float getCloudScattering(
int LayerIndex,
vec3 rayPosition,
vec3 sunVector,
vec3 moonVector,
float dither,
float minHeight,
float maxHeight,
@@ -333,9 +338,9 @@ float getCloudScattering(
for (int i = 0; i < samples; i++){
if((LayerIndex == ALTOSTRATUS_LAYER) || (LayerIndex == CIRRUS_LAYER)){
shadowRayPosition = rayPosition + sunVector * (1.0 + i * dither) / (pow(abs(sunVector.y*0.5),3.0) * 0.995 + 0.005);
shadowRayPosition = rayPosition + step(0.0, sunVector.y) * sunVector * (1.0 + i * dither) / (pow(abs(sunVector.y*0.5),3.0) * 0.995 + 0.005) + step(0.0, moonVector.y) * moonVector * (1.0 + i * dither) / (pow(abs(moonVector.y*0.5),3.0) * 0.995 + 0.005);
}else{
shadowRayPosition = rayPosition + sunVector * (1.0 + i + dither)*20.0;
shadowRayPosition = rayPosition + step(0.0, sunVector.y) * sunVector * (1.0 + i + dither)*20.0 + step(0.0, moonVector.y) * moonVector * (1.0 + i + dither)*20.0;
}
// float fadeddensity = density * pow(clamp((shadowRayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0);
@@ -347,12 +352,15 @@ float getCloudScattering(
}
vec3 getCloudLighting(
int LayerIndex,
float shape,
float shapeFaded,
float sunShadowMask,
vec3 directLightCol,
vec3 directLightCol_multi,
vec3 directLightCol2,
vec3 directLightCol_multi2,
float indirectShadowMask,
vec3 indirectLightCol
@@ -360,6 +368,7 @@ vec3 getCloudLighting(
float powderEffect = 1.0-exp(-14.0*shapeFaded); powderEffect *= powderEffect; powderEffect *= 2.0;
vec3 directScattering = directLightCol_multi * powderEffect * exp(-3.0*sunShadowMask) + directLightCol * exp(-10.0*sunShadowMask);
directScattering += directLightCol_multi2 * powderEffect * exp(-3.0*sunShadowMask) + directLightCol2 * exp(-10.0*sunShadowMask);
vec3 indirectScattering = indirectLightCol * mix(1.0, exp2(-5.0*shape), indirectShadowMask*indirectShadowMask);
// return indirectScattering;
@@ -380,8 +389,11 @@ vec4 raymarchCloud(
float maxHeight,
vec3 sunVector,
vec3 moonVector,
vec3 sunScattering,
vec3 sunMultiScattering,
vec3 sunMultiScattering,
vec3 moonScattering,
vec3 moonMultiScattering,
vec3 skyScattering,
float referenceDistance,
@@ -392,9 +404,15 @@ vec4 raymarchCloud(
vec3 color = vec3(0.0);
float totalAbsorbance = 1.0;
float planetShadow = getPlanetShadow(rayPosition, sunVector);
sunScattering *= planetShadow;
sunMultiScattering *= planetShadow;
if(LayerIndex == SMALLCUMULUS_LAYER || LayerIndex == LARGECUMULUS_LAYER || LayerIndex == CUMULONIMBUS_LAYER) {
float planetShadow = getPlanetShadow(rayPosition, sunVector);
sunScattering *= planetShadow;
sunMultiScattering *= planetShadow;
planetShadow = getPlanetShadow(rayPosition, moonVector);
moonScattering *= planetShadow;
moonMultiScattering *= planetShadow;
}
float distanceFactor = length(rayDirection);
@@ -408,11 +426,14 @@ vec4 raymarchCloud(
if((LayerIndex == ALTOSTRATUS_LAYER) || (LayerIndex == CIRRUS_LAYER)){
float density = 0.0;
vec3 newPos = rayPosition - cameraPosition;
if(LayerIndex == ALTOSTRATUS_LAYER) {
density = parameters.altostratus.y;
density *= smoothstep(75000, 60000, length(newPos));
} else {
density = parameters.cirrus.y;
density *= smoothstep(135000, 100000, length(newPos));
}
bool ifAboveOrBelowPlane = max(mix(-1.0, 1.0, clamp(cameraPosition.y - minHeight,0.0,1.0)) * normalize(rayDirection).y,0.0) > 0.0;
@@ -420,7 +441,7 @@ vec4 raymarchCloud(
// check if the ray staring position is going farther than the reference distance, if yes, dont begin marching. this is to check for intersections with the world.
// check if the camera is above or below the cloud plane, so it doesnt waste work on the opposite hemisphere
#ifndef VL_CLOUDS_DEFERRED
if(length(rayPosition - cameraPosition) > referenceDistance || ifAboveOrBelowPlane) return vec4(color, totalAbsorbance);
if(length(newPos) > referenceDistance || ifAboveOrBelowPlane) return vec4(color, totalAbsorbance);
#else
if(ifAboveOrBelowPlane) return vec4(color, totalAbsorbance);
#endif
@@ -429,23 +450,23 @@ vec4 raymarchCloud(
float shapeWithDensity = shape*density;
if(shapeWithDensity > mix(1e-5, 0.06, dither)){
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
cloudPlaneDistance.x = length(newPos); cloudPlaneDistance.y = 0.0;
}
// check if the pixel has visible clouds before doing work.
if(shapeWithDensity > 1e-5){
// can add the initial cloud shape sample for a free shadow starting step :D
float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y));
float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, moonVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y));
float indirectShadowMask = 0.5;
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensity, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering);
vec3 lighting = getCloudLighting(LayerIndex, shapeWithDensity, shapeWithDensity, sunShadowMask, sunScattering, sunMultiScattering, moonScattering, moonMultiScattering, indirectShadowMask, skyScattering);
vec3 newPos = rayPosition - cameraPosition;
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
newPos.y = min(newPos.y,0.0);
float distancefog = exp(-0.00025*length(newPos));
float distancefog = exp(-0.00015*length(newPos));
vec3 atmosphereHaze = (sampledSkyCol - sampledSkyCol * distancefog);
lighting = lighting * distancefog + atmosphereHaze;
@@ -493,8 +514,6 @@ vec4 raymarchCloud(
if (shapeAtLightningPos < 0.1) lightningPos = vec3(0.0);
}
for(int i = 0; i < samples; i++) {
@@ -521,7 +540,7 @@ vec4 raymarchCloud(
// can add the initial cloud shape sample for a free shadow starting step :D
float indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0);
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density);
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, moonVector, dither, minHeight, maxHeight, density);
vec3 shadowStartPos = vec3(0.0);
// do cloud shadows from one layer to another
@@ -538,7 +557,7 @@ vec4 raymarchCloud(
sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * parameters.altostratus.y * (1.0-abs(sunVector.y));
#endif
vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion);
vec3 lighting = getCloudLighting(LayerIndex, shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, moonScattering, moonMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion);
vec3 newPos = rayPosition - cameraPosition;
newPos.xz /= max(newPos.y,0.0)*0.0025 + 1.0;
@@ -560,7 +579,7 @@ vec4 raymarchCloud(
if (horizontalDistLightining < 6000.0 && rainStrength == 0.0 && lightningPos != vec3(0.0)) {
lightningIntensity = smoothstep(6000.0, 0.0, horizontalDistLightining) * smoothstep(-0.05, 1.0, shapeWithDensity) * lightningFlash;
lightningIntensity = smoothstep(6000.0, 0.0, horizontalDistLightining) * smoothstep(0.15, 1.0, shapeWithDensity) * lightningFlash;
lightningIntensity *= (1.0 - smoothstep(minHeight, 1.05 * maxHeight, rayPosition.y));
lightningIntensity *= smoothstep(17000, 14000, horizontalDist);
@@ -579,7 +598,7 @@ vec4 raymarchCloud(
color += (lighting - lighting * densityCoeff) * totalAbsorbance;
if(LayerIndex == CUMULONIMBUS_LAYER) {
color *= mix(smoothstep(minHeight, maxHeight, rayPosition.y/(2.4*shape)) + lightningIntensity, 1.0, mix((1-shapeWithDensity)*smoothstep(12000, 15000, horizontalDist), 1.0, rainStrength));
color *= mix(smoothstep(minHeight, maxHeight, rayPosition.y/(2.4*shape)), 1.0, mix((1-shapeWithDensity)*smoothstep(12000, 15000, horizontalDist), 1.0, rainStrength));
}
totalAbsorbance *= densityCoeff;
@@ -623,7 +642,9 @@ vec4 GetVolumetricClouds(
vec3 viewPos,
vec2 dither,
vec3 sunVector,
vec3 moonVector,
vec3 directLightCol,
vec3 directLightCol2,
vec3 indirectLightCol,
inout float cloudPlaneDistance
@@ -659,8 +680,12 @@ vec4 GetVolumetricClouds(
vec4 NormPlayerPos = normalize(gbufferModelViewInverse * vec4(viewPos, 1.0) + vec4(gbufferModelViewInverse[3].xyz,0.0));
vec3 signedSunVec = sunVector;
vec3 unignedSunVec = sunVector;// * (float(sunElevation > 1e-5)*2.0-1.0);
float SdotV = dot(unignedSunVec, NormPlayerPos.xyz);
vec3 unsignedSunVec = sunVector; //mix(moonVector, sunVector, clamp(float(sunElevation > 1e-5)*2.0-1.0 ,0,1));
vec3 signedMoonVec = moonVector;
vec3 unsignedMoonVec = moonVector;
float SdotV = dot(unsignedSunVec, NormPlayerPos.xyz);
float SdotV2 = dot(unsignedMoonVec, NormPlayerPos.xyz);
#ifdef SKY_GROUND
NormPlayerPos.y += 0.03 * heightRelativeToClouds;
@@ -700,22 +725,33 @@ vec4 GetVolumetricClouds(
float startDistance = length(playerPos);
float sunVis = clamp(sunElevation,0.0,0.05)/0.05*clamp(sunElevation,0.0,0.05)/0.05;
float moonVis = clamp(-sunElevation,0.0,0.05)/0.05*clamp(-sunElevation,0.0,0.05)/0.05;
#if defined EXCLUDE_WRITE_TO_LUT && defined USE_CUSTOM_CLOUD_LIGHTING_COLORS
directLightCol = dot(directLightCol,vec3(0.21, 0.72, 0.07)) * vec3(DIRECTLIGHT_CLOUDS_R,DIRECTLIGHT_CLOUDS_G,DIRECTLIGHT_CLOUDS_B);
directLightCol2 = dot(directLightCol2,vec3(0.21, 0.72, 0.07)) * vec3(DIRECTLIGHT_CLOUDS_R,DIRECTLIGHT_CLOUDS_G,DIRECTLIGHT_CLOUDS_B);
indirectLightCol = dot(indirectLightCol,vec3(0.21, 0.72, 0.07)) * vec3(INDIRECTLIGHT_CLOUDS_R,INDIRECTLIGHT_CLOUDS_G,INDIRECTLIGHT_CLOUDS_B);
#endif
///------- do color stuff outside of the raymarcher loop
vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14;
vec3 sunMultiScattering = directLightCol;
vec3 moonScattering = directLightCol2 * (phaseCloud(SdotV2, 0.85) + phaseCloud(SdotV2, 0.75)) * 3.14;
vec3 moonMultiScattering = directLightCol2;
vec3 skyScattering = indirectLightCol * 2.0;
vec3 sunScattering2 = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14 * sunVis;
vec3 sunMultiScattering2 = directLightCol * sunVis;
vec3 moonScattering2 = directLightCol2 * (phaseCloud(SdotV2, 0.85) + phaseCloud(SdotV2, 0.75)) * 3.14 * moonVis;
vec3 moonMultiScattering2 = directLightCol2 * moonVis;
////------- RENDER SMALL CUMULUS CLOUDS
vec4 smallCumulusClouds = cloudColor;
vec2 cloudLayer0_Distance = vec2(startDistance, 1.0);
#ifdef CloudLayer0
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer0_Distance);
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unsignedSunVec, unsignedMoonVec, sunScattering2, sunMultiScattering2, moonScattering2, moonMultiScattering2, skyScattering, lViewPosM, sampledSkyCol, cloudLayer0_Distance);
#endif
////------- RENDER LARGE CUMULUS CLOUDS
@@ -732,7 +768,7 @@ vec4 GetVolumetricClouds(
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
vec2 cloudLayer1_Distance = vec2(startDistance, 1.0);
if(smallCumulusClouds.a > 1e-5 || cameraPosition.y > minHeight) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer1_Distance);
if(smallCumulusClouds.a > 1e-5 || cameraPosition.y > minHeight) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unsignedSunVec, unsignedMoonVec, sunScattering2, sunMultiScattering2, moonScattering2, moonMultiScattering2, skyScattering, lViewPosM, sampledSkyCol, cloudLayer1_Distance);
#endif
////------- RENDER CUMULONIMBUS CLOUDS
@@ -748,11 +784,13 @@ vec4 GetVolumetricClouds(
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
vec2 cloudLayer4_Distance = vec2(startDistance, 1.0);
cumulonimbusClouds = raymarchCloud(CUMULONIMBUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer4_Distance);
cumulonimbusClouds = raymarchCloud(CUMULONIMBUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unsignedSunVec, unsignedMoonVec, sunScattering2, sunMultiScattering2, moonScattering2, moonMultiScattering2, skyScattering, lViewPosM, sampledSkyCol, cloudLayer4_Distance);
#endif
moonVis = smoothstep(-0.03, 0.08, -sunElevation);
moonScattering2 = directLightCol2 * (phaseCloud(SdotV2, 0.85) + phaseCloud(SdotV2, 0.75)) * 3.14 * moonVis;
moonMultiScattering2 = directLightCol2 * moonVis;
////------- RENDER ALTOSTRATUS CLOUDS
vec4 altoStratusClouds = cloudColor;
@@ -766,7 +804,7 @@ vec4 GetVolumetricClouds(
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
vec2 cloudLayer2_Distance = vec2(startDistance, 1.0);
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer2_Distance);
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unsignedSunVec, unsignedMoonVec, sunScattering, sunMultiScattering, moonScattering2, moonMultiScattering2, skyScattering, lViewPosM, sampledSkyCol, cloudLayer2_Distance);
#endif
////------- RENDER CIRRUS CLOUDS
@@ -782,7 +820,7 @@ vec4 GetVolumetricClouds(
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
vec2 cloudLayer3_Distance = vec2(startDistance, 1.0);
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) cirrusClouds = raymarchCloud(CIRRUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, lViewPosM, sampledSkyCol, cloudLayer3_Distance);
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) cirrusClouds = raymarchCloud(CIRRUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unsignedSunVec, unsignedMoonVec, sunScattering, sunMultiScattering, moonScattering * moonVis, moonMultiScattering * moonVis, skyScattering, lViewPosM, sampledSkyCol, cloudLayer3_Distance);
#endif
////------- BLEND LAYERS
+5 -1
View File
@@ -26,6 +26,10 @@ iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUS
moon=false
#endif
#ifdef REALMOON
customTexture.moon = texture/moon.png
#endif
#ifdef LPV_ENABLED
shadow.enabled = true
shadow.culling = reversed
@@ -149,7 +153,7 @@ SHADER_VERSION_LABEL <empty> \
######## LIGHTING
### DIRECT LIGHT
screen.Direct_Light.columns=1
screen.Direct_Light =[Shadows] [Subsurface_Scattering] [Sun_and_Moon_Colors] OLD_LIGHTLEAK_FIX sunPathRotation sun_illuminance MOONPHASE_BASED_MOONLIGHT moon_illuminance
screen.Direct_Light =[Shadows] [Subsurface_Scattering] [Sun_and_Moon_Colors] OLD_LIGHTLEAK_FIX sunPathRotation sun_illuminance MOONPHASE_BASED_MOONLIGHT moon_illuminance REALMOON
screen.Shadows.columns=1
screen.Shadows = TRANSLUCENT_COLORED_SHADOWS SCREENSPACE_CONTACT_SHADOWS RENDER_ENTITY_SHADOWS RENDER_PLAYER_SHADOWS entityShadowDistanceMul <empty> [Filtering] shadowMapResolution shadowDistance OPTIMIZED_SHADOW_DISTANCE
Binary file not shown.

After

Width:  |  Height:  |  Size: 46 MiB