diff --git a/shaders/block.properties b/shaders/block.properties index 4842213..2b5da46 100644 --- a/shaders/block.properties +++ b/shaders/block.properties @@ -1,13 +1,15 @@ #if MC_VERSION >= 11300 + block.2100 = minecraft:end_portal + ####### ----- SSS and waving ----- ####### ##ground waving block.10001 = minecraft:beetroots minecraft:potatoes minecraft:carrots minecraft:wheat minecraft:nether_wart minecraft:kelp minecraft:large_fern:half=upper minecraft:peony:half=upper minecraft:rose_bush:half=upper minecraft:lilac:half=upper minecraft:crimson_roots minecraft:nether_sprouts minecraft:warped_roots minecraft:seagrass minecraft:tall_seagrass:half=upper minecraft:sunflower:half=upper minecraft:tall_grass:half=upper minecraft:wither_rose minecraft:lily_of_the_valley minecraft:cornflower minecraft:sweet_berry_bush minecraft:oxeye_daisy minecraft:pink_tulip minecraft:white_tulip minecraft:orange_tulip minecraft:red_tulip minecraft:azure_bluet minecraft:allium minecraft:blue_orchid minecraft:poppy minecraft:dandelion minecraft:grass minecraft:dead_bush minecraft:oak_sapling minecraft:spruce_sapling minecraft:birch_sapling minecraft:jungle_sapling minecraft:acacia_sapling minecraft:dark_oak_sapling minecraft:fern ##air waving - block.10003 =minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves + block.10003 =minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves ####### ----- SSS ----- ####### @@ -38,7 +40,6 @@ ####### ----- misc ----- ####### - block.222 = end_portal end_gateway end_portal_frame block.8 = minecraft:water minecraft:flowing_water diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 9da574e..5342d06 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -622,15 +622,17 @@ vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){ return scatter; } -void ScreenSpace_SSS(inout float sss, vec3 fragpos, vec2 noise, vec3 normal){ +void ScreenSpace_SSS(inout float sss, vec3 fragpos, vec2 noise, vec3 normal, bool isleaves){ ivec2 pos = ivec2(gl_FragCoord.xy); const float tan70 = tan(70.*3.14/180.); float dist = 1.0 + (clamp(fragpos.z*fragpos.z/50.0,0,2)); // shrink sample size as distance increases float mulfov2 = gbufferProjection[1][1]/(tan70 * dist); + float maxR2_2 = fragpos.z*fragpos.z*mulfov2*2./50.0; + float dist3 = clamp(1-exp( fragpos.z*fragpos.z / -50),0,1); - float maxR2_2 = mix(10, fragpos.z*fragpos.z*mulfov2*2./50.0, dist3); + if(isleaves) maxR2_2 = mix(10, maxR2_2, dist3); float rd = mulfov2 * 0.1; @@ -738,7 +740,7 @@ vec3 Moon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeStars) #include "lib/PhotonGTAO.glsl" - +uniform float detectThunderStorm; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -822,9 +824,8 @@ void main() { bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01; - bool boatMask = abs(dataUnpacked1.w-0.6) <0.01; + bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; // bool translucent2 = abs(dataUnpacked1.w-0.6) <0.01; // Weak translucency - // bool translucent3 = abs(dataUnpacked1.w-0.55) <0.01; // all blocks // bool translucent4 = abs(dataUnpacked1.w-0.65) <0.01; // Weak translucency bool entities = abs(dataUnpacked1.w-0.45) < 0.01; @@ -1043,7 +1044,7 @@ void main() { #ifdef Ambient_SSS #if indirect_effect != 1 - if (!hand) ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals); + if (!hand) ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); #endif Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3) * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1) ; // Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3); @@ -1143,9 +1144,11 @@ void main() { LabEmission(FINAL_COLOR, albedo, SpecularTex.a); // #endif - if(lightningBolt) FINAL_COLOR.rgb += vec3(Lightning_R,Lightning_G,Lightning_B) * 150.0; + // if(lightningBolt) FINAL_COLOR.rgb += vec3(Lightning_R,Lightning_G,Lightning_B) * 255.0; gl_FragData[0].rgb = FINAL_COLOR; + // if(LabSSS > 0.0) gl_FragData[0].rgb = vec3(0,25,0); + } ////// ----- Apply Clouds ----- ////// @@ -1168,8 +1171,5 @@ void main() { if (isEyeInWater == 0) waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec)); } - - // gl_FragData[0].rgb *= GetCloudSkyOcclusion(p3 + cameraPosition); - /* DRAWBUFFERS:3 */ } \ No newline at end of file diff --git a/shaders/composite2.fsh b/shaders/composite2.fsh index 830cd81..4e36a13 100644 --- a/shaders/composite2.fsh +++ b/shaders/composite2.fsh @@ -197,6 +197,63 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE inColor += vL; } +vec4 RainRays(vec3 rayStart, vec3 rayEnd, float rayLength, float dither, vec3 ambient, vec3 lightSource, float VdotL){ + int spCount = 8; + + vec3 start = toShadowSpaceProjected(rayStart); + vec3 end = toShadowSpaceProjected(rayEnd); + vec3 dV = (end-start); + + + //limit ray length at 32 blocks for performance and reducing integration error + //you can't see above this anyway + float maxZ = min(rayLength,1000)/(1e-8+rayLength); + + // min(length(dVWorld),far)/length(dVWorld); + dV *= maxZ; + vec3 dVWorld = mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; + rayLength *= maxZ; + float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; + vec3 progressW = (gbufferModelViewInverse[3].xyz+cameraPosition); + vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a; + + + + float absorbance = 1.0; + vec3 vL = vec3(0.0); + + vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6); + + + //Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx) + float mie = phaseg(VdotL,0.7); + float rayL = phaseRayleigh(VdotL); + + float cloudShadow = 1; + float expFactor = 11.0; + for (int i=0;i 0.0){ + // rays = RainRays(vec3(0.0), fragpos, length(fragpos), R2_dither(), (avgAmbient*2.0) * 8./150./3., lightCol.rgb, dot(normalize(fragpos), normalize(sunVec) )); + // VL_CLOUDFOG += rays * rainStrength; + // } + + gl_FragData[0] = clamp(VL_CLOUDFOG ,0.0,65000.); #else vec4 VL_Fog = getVolumetricRays(fragpos,blueNoise(),avgAmbient); gl_FragData[0] = clamp(VL_Fog,0.0,65000.); diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index fca2e1b..73abbdd 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -282,8 +282,6 @@ void main() { float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); if(rainDrops > 0.0) vl.a *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0); - - /// lava. if (isEyeInWater == 2){ color.rgb = vec3(4.0,0.5,0.1); diff --git a/shaders/entity.properties b/shaders/entity.properties index 684ed49..fec20b9 100644 --- a/shaders/entity.properties +++ b/shaders/entity.properties @@ -8,6 +8,4 @@ entity.1100 = slime giant ender_dragon ghast sheep #weak sss (same as weak sss for blocks) entity.1200 = player frog chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned elder_gaurdian endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager wither trader_llama -entity.12345 = minecraft:lightning_bolt - -entity.2468 = minecraft:boat \ No newline at end of file +entity.12345 = minecraft:lightning_bolt weather2:lightning_bolt \ No newline at end of file diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh index 61b207f..dce5ba7 100644 --- a/shaders/gbuffers_all_solid.fsh +++ b/shaders/gbuffers_all_solid.fsh @@ -32,8 +32,9 @@ uniform int framemod8; #ifdef POM varying vec4 vtexcoordam; // .st for add, .pq for mul varying vec4 vtexcoord; - #endif + + #include "/lib/res_params.glsl" varying vec4 lmtexcoord; @@ -81,6 +82,8 @@ in vec3 velocity; flat varying float blockID; flat varying float EMISSIVE; flat varying int LIGHTNING; +flat varying int PORTAL; + flat varying float HELD_ITEM_BRIGHTNESS; flat varying int PHYSICSMOD_SNOW; @@ -186,8 +189,13 @@ vec3 toClipSpace3(vec3 viewSpacePosition) { { return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy); } + vec4 readNoise(in vec2 coord) + { + return texture2DGradARB(noisetex,(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy); + } #endif + float luma(vec3 color) { return dot(color,vec3(0.21, 0.72, 0.07)); } @@ -229,6 +237,12 @@ vec3 blackbody2(float Temp) return srgbToLinear2(col); } +uniform float near; + + +float ld(float dist) { + return (2.0 * near) / (far + near - dist * (far - near)); +} //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -275,7 +289,7 @@ void main() { #ifndef HAND #ifdef WORLD #ifdef Puddles - Puddle_shape = (1.0 - clamp(exp(-15 * pow(texture2D(noisetex, worldpos.xz * (0.015 * Puddle_Size) ).b ,5)),0,1)) * lightmap ; + Puddle_shape = (1.0 - clamp(exp(-15 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b ,5)),0,1)) * lightmap ; Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5 ,0.0,1.0); Puddle_shape *= rainfall; #endif @@ -294,7 +308,7 @@ void main() { gl_FragDepth = gl_FragCoord.z; #ifdef WORLD - if (dist < MAX_OCCLUSION_DISTANCE) { + if (dist < MAX_OCCLUSION_DISTANCE && PORTAL > 0) { float depthmap = readNormal(vtexcoord.st).a; float used_POM_DEPTH = 1.0; @@ -331,6 +345,8 @@ void main() { // #endif } } + + #endif @@ -340,6 +356,41 @@ void main() { vec4 Albedo = texture2DGradARB(texture, adjustedTexCoord.xy, dcdx,dcdy) * color; + float endportalGLow = 0; + // if (dist < MAX_OCCLUSION_DISTANCE && PORTAL > 0) { + + // Albedo = vec4(0,0,0,1); + // float used_POM_DEPTH = 1.0; + // float depth = 0.2; + + // if ( viewVector.z < 0.0) { + // float noise = interleaved_gradientNoise_temp(); + + // vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * 0.6 ; + // used_POM_DEPTH = 1.0; + + // vec3 coord = vec3(-abs(worldpos.zx)/4, 1.0); + + // coord += interval * noise; + + // float sumVec = noise; + + // for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - depth + depth * (1-readNoise(coord.st).r - readNoise((-coord.st*3 )).b*0.2) ) < coord.p && coord.p >= 0.0; ++loopCount) { + // coord = coord+interval ; + // sumVec += 1.0 ; + + // endportalGLow += 0.01*0.6; + // } + + // vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval; + + + // Albedo.rgb += vec3(0.5,0.75,1.0) * sqrt(endportalGLow); + // endportalGLow = clamp(pow(endportalGLow*3.5,5),0,1); + + // } + // } + #ifdef ENTITIES if(NameTags == 1) Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; @@ -425,6 +476,8 @@ void main() { #else gl_FragData[2].a = EMISSIVE; #endif + + if(PORTAL > 0) gl_FragData[2].a = clamp(endportalGLow * 0.9 ,0,0.9); #if SSS_TYPE == 0 gl_FragData[2].b = 0.0; @@ -542,7 +595,12 @@ void main() { #ifdef WORLD vec4 Albedo = texture2D(texture, lmtexcoord.xy, bias) * color; - if(LIGHTNING > 0) Albedo = vec4(1); + #ifdef WhiteWorld + Albedo.rgb = vec3(1.0); + #endif + + if(LIGHTNING > 0) Albedo = vec4(1); + #ifdef AEROCHROME_MODE vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS); @@ -569,9 +627,6 @@ void main() { } #endif - #ifdef WhiteWorld - Albedo.rgb = vec3(1.0); - #endif #ifdef DISABLE_ALPHA_MIPMAPS Albedo.a = texture2DLod(texture,lmtexcoord.xy,0).a; diff --git a/shaders/gbuffers_all_solid.vsh b/shaders/gbuffers_all_solid.vsh index 0498f20..5363bca 100644 --- a/shaders/gbuffers_all_solid.vsh +++ b/shaders/gbuffers_all_solid.vsh @@ -57,6 +57,7 @@ flat varying int LIGHTNING; flat varying float SSSAMOUNT; flat varying float EMISSIVE; flat varying int NameTags; +flat varying int PORTAL; in vec3 at_velocity; out vec3 velocity; @@ -206,14 +207,22 @@ void main() { normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0); FlatNormals = normalMat.xyz; - - blockID = mc_Entity.x; velocity = at_velocity; - NameTags = 0; -PHYSICSMOD_SNOW = 0; + + + + PORTAL = 0; + + #ifdef WORLD + if(blockEntityId == 2100) PORTAL = 255; + #endif + + NameTags = 0; + PHYSICSMOD_SNOW = 0; + #ifdef ENTITIES #ifdef ENTITY_PHYSICSMOD_SNOW @@ -227,9 +236,11 @@ PHYSICSMOD_SNOW = 0; // if(gl_Color.a >= 0.24 && gl_Color.a <= 0.25 ) gl_Position = vec4(10,10,10,1); if(entityId == 1100 || entityId == 1200 || entityId == 2468) normalMat.a = 0.45; + #endif + if(mc_Entity.x == 10003) normalMat.a = 0.55; /////// ----- EMISSIVE STUFF ----- /////// EMISSIVE = 0.0; diff --git a/shaders/gbuffers_all_translucent.fsh b/shaders/gbuffers_all_translucent.fsh index aba0c73..6ba5755 100644 --- a/shaders/gbuffers_all_translucent.fsh +++ b/shaders/gbuffers_all_translucent.fsh @@ -69,7 +69,6 @@ flat varying vec3 avgAmbient; #include "lib/clouds.glsl" #include "lib/stars.glsl" #include "lib/volumetricClouds.glsl" - #define OVERWORLD #include "lib/diffuse_lighting.glsl" diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 47e4601..b73e2d4 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -299,6 +299,7 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] THIS WILL BREAK SUBSURF #define SSR_STEPS 30 //[10 15 20 25 30 35 40 50 100 200 400] #define SUN_MICROFACET_SPECULAR // If enabled will use realistic rough microfacet model, else will just reflect the sun. No performance impact. #define USE_QUARTER_RES_DEPTH // Uses a quarter resolution depth buffer to raymarch screen space reflections, improves performance but may introduce artifacts +#define Dynamic_SSR_quality // rougher reflections have lower quality. this improves performance a bit in alot of scenes #ifdef Specular_Reflections #define Puddles // yes diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index 70c2d1a..e61273d 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -134,7 +134,7 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool spos += stepv; //small bias - float biasamount = (0.0002 + 0.0015*depthcancleoffset ) / dist; + float biasamount = (0.0002 + 0.0015*pow(depthcancleoffset,5) ) / dist; // float biasamount = 0.0002 / dist; if(hand) biasamount = 0.01; minZ = maxZ-biasamount / ld(spos.z); @@ -147,10 +147,29 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool return vec3(1.1); } + +// vec3 sampleGGXVNDF(vec3 V_, float roughness, float U1, float U2){ +// // stretch view +// vec3 V = normalize(vec3(roughness * V_.x, roughness * V_.y, V_.z)); +// // orthonormal basis +// vec3 T1 = (V.z < 0.9999) ? normalize(cross(V, vec3(0,0,1))) : vec3(1,0,0); +// vec3 T2 = cross(T1, V); +// // sample point with polar coordinates (r, phi) +// float a = 1.0 / (1.0 + V.z); +// float r = sqrt(U1*0.25); +// float phi = (U2 229.5/255.0 ? clamp((albedo / max(pow(luma(albedo),0.1),0.4)) + fresnel,0.0,1.0) : vec3(1.0); vec3 Metals = f0.y > 229.5/255.0 ? clamp(albedo + fresnel,0.0,1.0) : vec3(1.0); SunReflection *= Metals; diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index 4f1d721..d18fe49 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -386,7 +386,7 @@ float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){ // assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud. #ifdef Cumulus vec3 lowShadowStart = WorldPos + WorldSpace_sunVec/abs(WorldSpace_sunVec.y) * max((MaxCumulusHeight - 60) - WorldPos.y,0.0) ; - shadow += GetCumulusDensity(lowShadowStart,0)*Cumulus_density; + shadow += max(GetCumulusDensity(lowShadowStart,0) - 0.2,0.0)*Cumulus_density; #endif #ifdef Altostratus diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 0d39d33..32ee474 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -82,7 +82,7 @@ screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds] screen.World = [LabPBR] [Waving_Stuff] [Water] AEROCHROME_MODE AEROCHROME_PINKNESS AEROCHROME_WOOL_ENABLED ### SPECULARS screen.Reflections.columns=2 - screen.Reflections = Specular_Reflections Sun_specular_Strength Screen_Space_Reflections reflection_quality Rough_reflections Roughness_Threshold Sky_reflection + screen.Reflections = Specular_Reflections Sun_specular_Strength Screen_Space_Reflections reflection_quality Rough_reflections Roughness_Threshold Sky_reflection Dynamic_SSR_quality ### WAVING STUFF screen.Waving_Stuff.columns=1 screen.Waving_Stuff = WAVY_STRENGTH WAVY_SPEED WAVY_PLANTS