Added resourecpack sky support. made use of iris dimensions.properties and added fallback shader.

This commit is contained in:
Xonk
2023-10-10 23:02:00 -04:00
parent 69e605b38b
commit 1168da157d
82 changed files with 738 additions and 84 deletions

View File

@ -99,7 +99,6 @@ void main() {
#ifndef OVERWORLD_SHADER
lightmap.y = 1.0;
#endif
#ifdef WEATHER
gl_FragData[1].a = TEXTURE.a; // for bloomy rain and stuff
#endif
@ -144,6 +143,7 @@ void main() {
float cloudShadow = GetCloudShadow(feetPlayerPos);
Direct_lighting = (lightCol.rgb/80.0) * Shadows * cloudShadow;
#ifndef LINES
Direct_lighting *= phaseg(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), 0.65)*2 + 0.5;
@ -168,6 +168,10 @@ void main() {
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, Torch_Color, lightmap.x, nothing, nothing, nothing);
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), Torch_Color, lightmap.x, vec3(0.0), feetPlayerPos);
#endif
#ifndef LINES
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
#else

View File

@ -88,10 +88,13 @@ void main() {
WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition);
#endif
#ifndef WEATHER
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
#endif
}

View File

@ -15,6 +15,7 @@ varying vec4 color;
flat varying vec4 lightCol;
#endif
const bool colortex4MipmapEnabled = true;
uniform sampler2D noisetex;
uniform sampler2D depthtex1;
@ -452,6 +453,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos );
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, WS_normal, feetPlayerPos);
#endif
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
#ifdef Glass_Tint

View File

@ -80,7 +80,7 @@ void main() {
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
lmtexcoord.zw = lmcoord;
vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz;
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
gl_Position = toClipSpace3(position);

View File

@ -201,11 +201,11 @@ void main() {
if (LabSSS > 0.0 && !hand && NdotL < 0.001) minshadowfilt += 50;
#endif
gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0);
gl_FragData[0].y = 0;
if (z < 1.0 && !hand){
gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0);
gl_FragData[0].y = 0;
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
#ifdef Variable_Penumbra_Shadows

View File

@ -38,6 +38,12 @@ const bool colortex5MipmapEnabled = true;
// #define LIGHTSOURCE_REFLECTION
#endif
#ifdef FALLBACK_SHADER
uniform sampler2D colortex4;
uniform float nightVision;
// #define LIGHTSOURCE_REFLECTION
#endif
uniform sampler2D noisetex; //noise
uniform sampler2D depthtex1; //depth
uniform sampler2D depthtex0; //depth
@ -51,7 +57,8 @@ uniform sampler2D colortex5; //TAA buffer/previous frame
uniform sampler2D colortex6; //Noise
uniform sampler2D colortex7; //water?
uniform sampler2D colortex8; //Specular
// uniform sampler2D colortex10;
uniform sampler2D colortex9; //Specular
uniform sampler2D colortex10;
uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha)
@ -615,6 +622,7 @@ void main() {
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
vec4 data = texture2D(colortex1,texcoord);
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));
@ -702,30 +710,48 @@ void main() {
#ifdef OVERWORLD_SHADER
vec3 Background = vec3(0.0);
vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0;
vec4 Clouds = texture2D_bicubic(colortex0, texcoord*CLOUDS_QUALITY);
vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2;
Background += stars(orbitstar) * 10.0;
#ifndef ambientLight_only
Background += drawSun(dot(lightCol.a * WsunVec, feetPlayerPos_normalized),0, DirectLightColor,vec3(0.0));
Background += drawMoon(feetPlayerPos_normalized, lightCol.a * WsunVec, DirectLightColor*20, Background);
#if RESOURCEPACK_SKY == 2
Background += toLinear(texture2D(colortex10, texcoord).rgb * (255.0 * 2.0));
#else
#if RESOURCEPACK_SKY == 1
Background += toLinear(texture2D(colortex10, texcoord).rgb * (255.0 * 2.0));
#endif
Background += drawSun(dot(lightCol.a * WsunVec, feetPlayerPos_normalized),0, DirectLightColor,vec3(0.0));
Background += drawMoon(feetPlayerPos_normalized, lightCol.a * WsunVec, DirectLightColor*20, Background);
#endif
Background *= clamp( (feetPlayerPos_normalized.y+ 0.02)*5.0 + (eyeAltitude - 319)/800000 ,0.0,1.0);
vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0;
Background += Sky;
Background = Background * Clouds.a + Clouds.rgb;
#ifdef VOLUMETRIC_CLOUDS
vec4 Clouds = texture2D_bicubic(colortex0, texcoord*CLOUDS_QUALITY);
Background = Background * Clouds.a + Clouds.rgb;
#endif
gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise)), 0.0, 65000.);
#endif
#ifdef NETHER_SHADER
#if defined NETHER_SHADER || defined END_SHADER
gl_FragData[0].rgb = vec3(0);
#endif
#ifdef END_SHADER
gl_FragData[0].rgb = vec3(0);
#ifdef FALLBACK_SHADER
vec3 Background = vec3(0.5,0.3,1.0)*0.025;
Background += vec3(0.8,1.0,0.5) * 0.5 * pow(normalize(-feetPlayerPos_normalized).y*0.5+0.5,3.0);
Background += stars(feetPlayerPos_normalized) * 100.0 * pow(normalize(feetPlayerPos_normalized).y*0.5+0.5,3.0);
gl_FragData[0].rgb = clamp(Background, 0.0, 65000.);
#endif
} else {
feetPlayerPos += gbufferModelViewInverse[3].xyz;
@ -835,8 +861,7 @@ void main() {
SSRT_Shadows(toScreenSpace(vec3(texcoord/RENDER_SCALE, z)), normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), !inShadowmapBounds && LabSSS > 0.0, inShadowmapBounds, SS_shadow, SS_shadowSSS);
Shadows = min(Shadows, SS_shadow);
// if (!inShadowmapBounds) Direct_SSS *= exp(-5 * SS_shadowSSS) * lightmapAsShadows;
if (!inShadowmapBounds) ShadowBlockerDepth = max(ShadowBlockerDepth, SS_shadowSSS);
#else
@ -931,6 +956,10 @@ void main() {
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized);
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos);
// if(hand) Indirect_lighting = vec3(TORCH_R,TORCH_G,TORCH_B) * 0.3;
#endif
////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
@ -1104,7 +1133,7 @@ void main() {
float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane
vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.3, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision));
waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol);
}
#endif

View File

@ -55,6 +55,11 @@ uniform ivec2 eyeBrightnessSmooth;
#include "/lib/end_fog.glsl"
#endif
#ifdef FALLBACK_SHADER
uniform sampler2D colortex4;
#include "/lib/fallback_fog.glsl"
#endif
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
float interleaved_gradientNoise(){
@ -237,10 +242,8 @@ void main() {
#ifdef OVERWORLD_SHADER
vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, lightCol.rgb/80.0, averageSkyCol/30.0);
#endif
#ifdef NETHER_SHADER
vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, noise_2);
#endif
#ifdef END_SHADER
#if defined NETHER_SHADER || defined END_SHADER || defined FALLBACK_SHADER
vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, noise_2);
#endif
@ -268,7 +271,6 @@ void main() {
vec3 vl = vec3(0.0);
waterVolumetrics(vl, vec3(0.0), viewPos, estEyeDepth, estEyeDepth, length(viewPos), noise_1, totEpsilon, scatterCoef, ambientColVol, lightColVol*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)) , dot(normalize(viewPos), normalize(sunVec* lightCol.a ) ));
gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.);
#else
vec3 fragpos0 = toScreenSpace(vec3(texcoord - TAA_Offset*texelSize*0.5,z));
vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.6, vec3(0.2,0.4,1.0) * MIN_LIGHT_AMOUNT*0.01);

View File

@ -235,7 +235,7 @@ void main() {
float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g;
float refractedalpha2 = texture2D(colortex7,refractedCoord).a;
if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids
if( refractedalpha <= 0.001 || z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids
#endif
/// --- MAIN COLOR BUFFER --- ///
@ -245,11 +245,11 @@ void main() {
float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
#if defined OVERWORLD_SHADER && defined BorderFog
vec3 sky = skyFromTex(np3,colortex4) / 150. * 5.0;
vec3 sky = skyFromTex(np3, colortex4).rgb / 30.0;
float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ;
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix);
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog);
#endif
vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth);
@ -263,7 +263,7 @@ void main() {
color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb;
#ifdef BorderFog
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix);
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog);
#endif
}

View File

@ -9,8 +9,11 @@ const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6-
const int colortex4Format = RGBA16F; //light values and skyboxes (everything)
const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final)
const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
const int colortex8Format = RGBA8; // Specular Texture
const int colortex9Format = RGBA8; // rain in alpha
const int colortex10Format = RGBA16; // resourcepack Skies
const int colortex9Format = RGBA8; // flat normals and vanilla AO
const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals
const int colortex15Format = RGBA8; // flat normals and vanilla AO
*/

View File

@ -18,7 +18,6 @@ flat varying float rodExposure;
flat varying float avgBrightness;
flat varying float exposureF;
// uniform sampler2D colortex4;
uniform sampler2D noisetex;
uniform float frameTime;
@ -84,6 +83,10 @@ float blueNoise(){
#include "/lib/end_fog.glsl"
#endif
#ifdef FALLBACK_SHADER
uniform sampler2D colortex4;
#include "/lib/fallback_fog.glsl"
#endif
void main() {
@ -168,7 +171,7 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
}
#endif
#ifdef NETHER_SHADER
#if defined NETHER_SHADER || defined END_SHADER || defined FALLBACK_SHADER
vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0);
//Sky gradient with clouds
@ -187,26 +190,26 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
}
#endif
#ifdef END_SHADER
/* ---------------------- FOG SHADER ---------------------- */
vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0);
// /* ---------------------- FOG SHADER ---------------------- */
// vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0);
//Sky gradient with clouds
if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){
vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2);
vec3 viewVector = cartToSphere(p);
// //Sky gradient with clouds
// if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){
// vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2);
// vec3 viewVector = cartToSphere(p);
vec3 BackgroundColor = vec3(0.0);
// vec3 BackgroundColor = vec3(0.0);
vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887));
// vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887));
BackgroundColor += VL_Fog.rgb/5.0;
// BackgroundColor += VL_Fog.rgb/5.0;
gl_FragData[0] = vec4(BackgroundColor, 1.0);
// gl_FragData[0] = vec4(BackgroundColor, 1.0);
}
// }
#ifdef END_SHADER
/* ---------------------- TIMER ---------------------- */
float flash = 0.0;

View File

@ -109,7 +109,7 @@ void main() {
/// TOOO DAMN BLUE
// // only need to sample one spot for this
// averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.;
vec3 minimimlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.0005 + nightVision);
vec3 minimimlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.003 + nightVision);
averageSkyCol_Clouds = max(averageSkyCol_Clouds, minimimlight);
averageSkyCol = max(averageSkyCol, minimimlight);