// MinecraftPT — Sky_Overworld_FS // Renders the sky into the background (colortex12) where no geometry was drawn. #include "/Lib/Settings.glsl" #include "/Lib/Utilities.glsl" #include "/Lib/BasicFunctions/LightingConstants.glsl" #include "/Lib/BasicFunctions/PrecomputedAtmosphere.glsl" #include "/Lib/IndividualFunctions/EndSky.glsl" #include "/Lib/IndividualFunctions/PlanarClouds.glsl" #include "/Lib/IndividualFunctions/CloudShadow.glsl" uniform sampler2D depthtex0; layout(location = 0) out vec4 colorOut; void main(){ ivec2 texelCoord = ivec2(gl_FragCoord.xy); float depth = texelFetch(depthtex0, texelCoord, 0).r; if (depth < 1.0){ // Not sky — preserve scene discard; } // Reconstruct view ray vec4 viewPos = gbufferProjectionInverse * vec4(vec2(texelCoord) / screenSize * 2.0 - 1.0, 1.0, 1.0); vec3 viewDir = normalize(viewPos.xyz / viewPos.w); vec3 worldDir = normalize(mat3(gbufferModelViewInverse) * viewDir); vec3 sunDir = GetSunDirWorld(); // Sky radiance vec3 color = GetSkyRadiance(worldDir, sunDir); #ifdef DIMENSION_END color = GetEndSky(worldDir, sunDir); #elif defined DIMENSION_NETHER // Nether: dark smoky red-brown atmosphere color = vec3(0.18, 0.06, 0.03) * 1.2; color += vec3(0.5, 0.2, 0.1) * 0.3 * (1.0 - abs(worldDir.y) * 0.5); #endif // Planar clouds #ifdef PLANAR_CLOUDS if (PLANAR_CLOUDS > 0){ // Ray-plane intersection with cloud layer float cloudAlt = mix(PC_ALTITUDE, CLOUD_CLEAR_ALTITUDE, wetness * 0.5); if (worldDir.y > 0.001){ float t = (cloudAlt - cameraPosition.y) / worldDir.y; if (t > 0.0){ vec3 cloudPos = cameraPosition + worldDir * t; vec3 cloudColor; float cloudDensity = GetPlanarCloudDensity(cloudPos.xz, frameTimeCounter * CLOUD_SPEED, cloudColor); if (cloudDensity > 0.01){ // Soft cloud edge vec3 cloudLight = mix(GetCloudAtmoIrradiance(), GetCloudSunIrradiance(), 0.8); color = mix(color, cloudLight, cloudDensity * 0.8); } } } } #endif colorOut = vec4(color, 1.0); }