add fake planet shadow effect (in WORLD submenu)

This commit is contained in:
Xonk
2026-01-06 01:32:31 -05:00
parent ad69f4f9c9
commit b47230e820
7 changed files with 60 additions and 2 deletions
+3
View File
@@ -929,6 +929,9 @@ void main() {
DirectLightColor = lightCol.rgb / 2400.0;
AmbientLightColor = averageSkyCol_Clouds / 900.0;
#ifdef FAKE_PLANET
DirectLightColor = getPlanetAbsorb(feetPlayerPos + cameraPosition, WsunVec, colortex4);
#endif
#ifdef USE_CUSTOM_DIFFUSE_LIGHTING_COLORS
DirectLightColor.rgb = luma(DirectLightColor.rgb) * vec3(DIRECTLIGHT_DIFFUSE_R,DIRECTLIGHT_DIFFUSE_G,DIRECTLIGHT_DIFFUSE_B);
AmbientLightColor = luma(AmbientLightColor) * vec3(INDIRECTLIGHT_DIFFUSE_R,INDIRECTLIGHT_DIFFUSE_G,INDIRECTLIGHT_DIFFUSE_B);
+22
View File
@@ -23,6 +23,7 @@ flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 averageSkyCol;
flat varying vec3 lightSourceColor;
flat varying vec3 sunColor;
flat varying vec3 sunColor2;
flat varying vec3 moonColor;
flat varying float exposure;
flat varying float avgBrightness;
@@ -346,6 +347,27 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
if(worldTimeChangeCheck) mixhistory = 1.0;
}
#ifdef FAKE_PLANET
vec2 pixelPos2 = vec2(16,1);
if (gl_FragCoord.x > pixelPos2.x && gl_FragCoord.x < pixelPos2.x + 1 && gl_FragCoord.y > pixelPos2.y){
if(worldTimeChangeCheck) mixhistory = 1.0;
vec3 pos = vec3(0.0);
pos.y = clamp(gl_FragCoord.y/256.0,0.0,1.0);
// approximate how much atmosphere the sun is travelling through and scale abso
pos.y = pos.y / (1.0/abs(WsunVec.y))*5.0;
vec2 variable = vec2(0);
vec3 absorb = vec3(0.0);
vec3 transmittance = calculateAtmosphere(vec3(0.0), pos, vec3(0.0,1.0,0.0), pos, vec3(0.0), variable, absorb, 25, 0.0);
transmittance = min(sunColor2 * absorb, sunColor2);
gl_FragData[0] = vec4(transmittance, 1.0);
}
#endif
#endif
#if defined NETHER_SHADER || defined END_SHADER
+2
View File
@@ -20,6 +20,7 @@ flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 averageSkyCol;
flat varying vec3 sunColor;
flat varying vec3 sunColor2;
flat varying vec3 moonColor;
flat varying vec3 lightSourceColor;
flat varying vec3 zenithColor;
@@ -163,6 +164,7 @@ void main() {
vec3 skyAbsorb = vec3(0.0);
sunColor = calculateAtmosphere(vec3(0.0), sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.0);
sunColor = sunColorBase/4000.0 * skyAbsorb;
sunColor2 = sunColorBase/4000.0;
moonColor = moonColorBase/4000.0;
// lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis;
+4
View File
@@ -282,6 +282,10 @@ vec4 GetVolumetricFog(
rayProgress = gbufferModelViewInverse[3].xyz + cameraPosition + d*rayStartPos;
localRayProgress = gbufferModelViewInverse[3].xyz + cameraPosition + d*localRayStartPos;
#ifdef FAKE_PLANET
LightColor = getPlanetAbsorb(rayProgress, WsunVec, colortex4);
#endif
vec3 shadows = getShadows(mix(rayProgress, localRayProgress, localFogExists), sunVector, d, start, shadowMapRayStartPos, shadowMapRayProgress, flatPhase, sunPhase);
#if defined LIGHTNING_FLASH && defined LIGHTNINGFLASH_VL
+5
View File
@@ -120,6 +120,11 @@
#endif
#if defined VOLUMETRIC_CLOUD_RELATED_SETTINGS
// #define FAKE_PLANET
#define FAKE_PLANET_START_HEIGHT -100 // [-1000 -900 -800 -700 -600 -500 -300 200 -190 -180 -170 -160 -150 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 300 400 500 600 700 800 900 1000]
#define FAKE_PLANET_GRADIENT_LENGTH 2000 // [0 1 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 300 400 500 600 700 800 900 1000 1250 1500 1750 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000]
#define CloudLayer0
#define CloudLayer0_height 250.0 // [-300.0 -290.0 -280.0 -270.0 -260.0 -250.0 -240.0 -230.0 -220.0 -210.0 -200.0 -190.0 -180.0 -170.0 -160.0 -150.0 -140.0 -130.0 -120.0 -110.0 -100.0 -90.0 -80.0 -70.0 -60.0 -50.0 -40.0 -30.0 -20.0 -10.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 110.0 120.0 130.0 140.0 150.0 160.0 170.0 180.0 190.0 200.0 210.0 220.0 230.0 240.0 250.0 260.0 270.0 280.0 290.0 300.0 310.0 320.0 330.0 340.0 350.0 360.0 370.0 380.0 390.0 400.0 410.0 420.0 430.0 440.0 450.0 460.0 470.0 480.0 490.0 500.0 510.0 520.0 530.0 540.0 550.0 560.0 570.0 580.0 590.0 600.0 700.0 800.0 900.0 1000.0 1250.0 1500.0 1750.0 2000.0 2250.0 2500.0 2750.0 3000.0 4000.0 5000.0]
#define CloudLayer0_tallness 100.0 // [0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 110.0 120.0 130.0 140.0 150.0 160.0 170.0 180.0 190.0 200.0 210.0 220.0 230.0 240.0 250.0 260.0 270.0 280.0 290.0 300.0 310.0 320.0 330.0 340.0 350.0 360.0 370.0 380.0 390.0 400.0 410.0 420.0 430.0 440.0 450.0 460.0 470.0 480.0 490.0 500.0 510.0 520.0 530.0 540.0 550.0 560.0 570.0 580.0 590.0 600.0 700.0 800.0 900.0 1000.0 1250.0 1500.0 1750.0 2000.0 2250.0 2500.0 2750.0 3000.0 4000.0 5000.0]
+22
View File
@@ -20,6 +20,20 @@ float densityAtPos(in vec3 pos){
return mix(xy.r,xy.g, f.y);
}
vec3 getPlanetAbsorb(in vec3 worldPos, in vec3 sunVector, sampler2D colortex){
float position = clamp((worldPos.y - (FAKE_PLANET_START_HEIGHT + 1.0/abs(sunVector.y*0.1)))*256.0 / FAKE_PLANET_GRADIENT_LENGTH,0.0,257.0);
// float position = clamp((worldPos.y + 60.0)*256.0 / 1500.0,0.0,257.0);
vec3 skyAbsorb = texture2D(colortex, vec2(16.5, position)*texelSize).rgb / 2400.0;
#ifdef ReflectedFog
return skyAbsorb*2400.0/150.0 * 2.5;
#else
return skyAbsorb;
#endif
}
float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight, float maxHeight){
vec3 samplePos = position*vec3(0.25, 0.005, 0.25);
@@ -118,6 +132,10 @@ float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight,
}
float getPlanetShadow(vec3 playerPos, vec3 WsunVec){
#ifdef FAKE_PLANET
return 1.0;
#endif
float planetShadow = min(max(playerPos.y - (-100.0 + 1.0 / abs(WsunVec.y*0.1)),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));
@@ -268,6 +286,10 @@ vec4 raymarchCloud(
float planetShadow = getPlanetShadow(rayPosition, sunVector);
sunScattering *= planetShadow;
#ifdef FAKE_PLANET
sunScattering = getPlanetAbsorb(rayPosition, WsunVec, colortex4);
#endif
float distanceFactor = length(rayDirection);
float densityTresholdCheck = 0.0;
File diff suppressed because one or more lines are too long