re-add resourcepack skybox support

This commit is contained in:
Xonk
2025-03-21 21:50:36 -04:00
parent 89d62f3754
commit da3d14958a
10 changed files with 46 additions and 357 deletions

View File

@ -786,6 +786,8 @@ void main() {
vec4 data = texelFetch2D(colortex1, ivec2(gl_FragCoord.xy), 0);
vec3 skyboxCol = data.rgb;
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps
// vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w));
@ -1299,6 +1301,7 @@ void main() {
}else{
vec3 Background = vec3(0.0);
#ifdef OVERWORLD_SHADER
float atmosphereGround = 1.0 - exp2(-50.0 * pow(clamp(feetPlayerPos_normalized.y+0.025,0.0,1.0),2.0) ); // darken the ground in the sky.
@ -1330,21 +1333,16 @@ void main() {
vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/1200.0 * Sky_Brightness;
Background += Sky;
#endif
#if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 2 || RESOURCEPACK_SKY == 3
vec3 resourcePackskyBox = skyboxCol * clamp(unsigned_WsunVec.y*2.0,0.1,1.0);
// #if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 2 || RESOURCEPACK_SKY == 3
// vec3 resourcePackskyBox = toLinear(texture2D(colortex10, texcoord).rgb * 5.0) * 15.0 * clamp(unsigned_WsunVec.y*2.0,0.1,1.0);
#ifdef SKY_GROUND
resourcePackskyBox *= atmosphereGround;
#endif
// #ifdef SKY_GROUND
// resourcePackskyBox *= atmosphereGround;
// #endif
Background += resourcePackskyBox;
#endif
// Background += resourcePackskyBox;
// #endif
#if defined OVERWORLD_SHADER && defined VOLUMETRIC_CLOUDS && !defined CLOUDS_INTERSECT_TERRAIN
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
Background = Background * Clouds.a + Clouds.rgb;
#endif
gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise_2)), 0.0, 65000.);

View File

@ -1,123 +1,10 @@
#include "/lib/settings.glsl"
//Computes volumetric clouds at variable resolution (default 1/4 res)
flat varying vec3 sunColor;
// flat varying vec3 moonColor;
flat varying vec3 averageSkyCol;
flat varying float tempOffsets;
// uniform float far;
uniform float near;
uniform sampler2D depthtex0;
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
uniform sampler2D dhDepthTex1;
#endif
// uniform sampler2D colortex4;
uniform sampler2D noisetex;
uniform sampler2D colortex12;
flat varying vec3 WsunVec;
uniform float sunElevation;
uniform vec3 sunVec;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform vec2 texelSize;
uniform float frameTimeCounter;
uniform float rainStrength;
uniform int frameCounter;
uniform int framemod8;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform vec3 cameraPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferProjection;
// flat varying vec2 TAA_Offset;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2. - 1.;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
#include "/lib/DistantHorizons_projections.glsl"
float R2_dither(){
#ifdef TAA
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
#else
vec2 coord = gl_FragCoord.xy;
#endif
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
}
float interleaved_gradientNoise(){
vec2 alpha = vec2(0.75487765, 0.56984026);
vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
return noise;
}
#include "/lib/TAA_jitter.glsl"
float blueNoise(){
#ifdef TAA
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
#else
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a);
#endif
}
vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec));
}
uniform float far;
float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near));
}
uniform int dhRenderDistance;
#include "/lib/lightning_stuff.glsl"
#include "/lib/sky_gradient.glsl"
#include "/lib/res_params.glsl"
#define CLOUDS_INTERSECT_TERRAIN
uniform float eyeAltitude;
#ifdef Daily_Weather
flat varying vec4 dailyWeatherParams0;
flat varying vec4 dailyWeatherParams1;
#else
vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0);
vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0);
#endif
#include "/lib/volumetricClouds.glsl"
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -125,34 +12,25 @@ uniform float eyeAltitude;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
#if defined OVERWORLD_SHADER
/* RENDERTARGETS:1,2 */
#endif
void main() {
vec2 texcoord = gl_FragCoord.xy * texelSize;
gl_FragData[0] = texelFetch2D(colortex1, ivec2(gl_FragCoord.xy),0);
#if defined OVERWORLD_SHADER && defined VOLUMETRIC_CLOUDS && !defined CLOUDS_INTERSECT_TERRAIN
vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5);
if(texelFetch2D(depthtex0, ivec2(gl_FragCoord.xy), 0).x < 1.0 || texelFetch2D(dhDepthTex, ivec2(gl_FragCoord.xy), 0).x < 1.0) {
// doing this for precision reasons, DH does NOT like depth => 1.0
}else{
vec2 halfResTC2 = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY+0.5+offsets[framemod8]*CLOUDS_QUALITY*0.5);
#ifdef CLOUDS_INTERSECT_TERRAIN
float depth = texelFetch2D(depthtex0, ivec2(halfResTC2), 0).x;
gl_FragData[0].rgb = texelFetch2D(colortex2, ivec2(gl_FragCoord.xy),0).rgb * 10.0;
gl_FragData[0].a = 0.0;
#ifdef DISTANT_HORIZONS
float DH_depth = texelFetch2D(dhDepthTex, ivec2(halfResTC2),0).x;
vec3 viewPos = toScreenSpace_DH(halfResTC*texelSize, depth, DH_depth);
#else
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, depth));
#endif
#else
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, 1.0));
#endif
}
vec3 tesvar = vec3(0.0);
vec4 VolumetricClouds = renderClouds(viewPos, vec2(R2_dither(), blueNoise()), sunColor/80.0, averageSkyCol/30.0,tesvar);
gl_FragData[1] = vec4(0,0,0,0);
gl_FragData[0] = VolumetricClouds;
#else
gl_FragData[0] = vec4(0.0,0.0,0.0,1.0);
#endif
}

View File

@ -1,56 +1,9 @@
#include "/lib/settings.glsl"
// uniform int dhRenderDistance;
#ifdef Daily_Weather
flat varying vec4 dailyWeatherParams0;
flat varying vec4 dailyWeatherParams1;
#endif
flat varying vec3 averageSkyCol;
flat varying vec3 sunColor;
// flat varying vec3 moonColor;
flat varying float tempOffsets;
flat varying vec3 WsunVec;
uniform mat4 gbufferModelViewInverse;
uniform vec3 sunPosition;
uniform float sunElevation;
uniform sampler2D colortex4;
uniform int frameCounter;
uniform float frameTimeCounter;
#include "/lib/util.glsl"
#include "/lib/res_params.glsl"
#include "/lib/Shadow_Params.glsl"
void main() {
gl_Position = ftransform();
gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(CLOUDS_QUALITY+0.01,0.0,1.0)*2.0-1.0;
#if defined Daily_Weather
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0);
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0);
#endif
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
// moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb;
// sunColor = texelFetch2D(colortex4,ivec2(8,37),0).rgb;
// moonColor = texelFetch2D(colortex4,ivec2(9,37),0).rgb;
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);// * (float(sunElevation > 1e-5)*2.0-1.0);
// WsunVec = normalize(LightDir);
tempOffsets = HaltonSeq2(frameCounter%10000);
#ifdef TAA_UPSCALING
gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0;
#endif
}
}