From 6c41c008c0195f92c397aec7d464cc18a5a9a2c1 Mon Sep 17 00:00:00 2001 From: Xonk Date: Wed, 15 Jan 2025 23:08:16 -0500 Subject: [PATCH] remake and improve underwater lighting. add new method for indirect SSS. improve nametag rendering. fix translucent rendering on DH LODs. begin work on WIP cloud raymarcher --- shaders/block.properties | 8 +- shaders/dimension.properties | 29 +- shaders/dimensions/DH_translucent.fsh | 62 ++--- shaders/dimensions/DH_translucent.vsh | 8 +- shaders/dimensions/all_particles.fsh | 6 + shaders/dimensions/all_solid.vsh | 7 +- shaders/dimensions/all_translucent.fsh | 83 ++++-- shaders/dimensions/all_translucent.vsh | 16 +- shaders/dimensions/composite.fsh | 119 +++++++- shaders/dimensions/composite1.fsh | 257 ++++++++++++----- shaders/dimensions/composite2.fsh | 258 +++++++++--------- shaders/dimensions/composite2.vsh | 2 +- shaders/dimensions/composite3.fsh | 98 +++---- shaders/dimensions/composite5.fsh | 3 +- shaders/dimensions/deferred.fsh | 5 +- .../dimensions/fogBehindTranslucent_pass.fsh | 64 ++--- shaders/entity.properties | 3 + shaders/lang/en_us.lang | 5 +- shaders/lib/Shadows.glsl | 2 +- shaders/lib/indirect_lighting_effects.glsl | 99 +------ shaders/lib/settings.glsl | 18 +- shaders/lib/specular.glsl | 208 +------------- shaders/lib/volumetricClouds.glsl | 17 +- shaders/shaders.properties | 17 +- 24 files changed, 701 insertions(+), 693 deletions(-) diff --git a/shaders/block.properties b/shaders/block.properties index 9a2212d..66a3093 100644 --- a/shaders/block.properties +++ b/shaders/block.properties @@ -83,18 +83,18 @@ block.54=minecraft:melon_stem minecraft:pumpkin_stem minecraft:flowering_azalea vinery:taiga_grape_bush_white vinery:taiga_grape_bush_red vinery:savanna_grape_bush_white vinery:savanna_grape_bush_red vinery:white_grape_bush vinery:red_grape_bush ## ground waving vertical models. this exists to brighten up the sides of grass and stuff in shaded places they blend in better with the world. -block.55=minecraft:fern \ +block.55 = minecraft:closed_eyeblossom minecraft:open_eyeblossom minecraft:fern \ biomesoplenty:bush \ - conquest:acacia_sapling conquest:alder_tree_sapling conquest:apple_tree_sapling conquest:aspen_tree_sapling conquest:birch_sapling conquest:cherry_tree_sapling conquest:dark_oak_sapling conquest:downy_willow_tree_sapling conquest:gorse_tree_sapling conquest:grape_vine_sapling conquest:horse_chestnut_tree_sapling conquest:jungle_sapling conquest:larch_tree_sapling conquest:mallorn_tree_sapling conquest:oak_sapling conquest:orange_tree_sapling conquest:pear_tree_sapling conquest:pine_tree_sapling conquest:plum_tree_sapling conquest:rowan_tree_sapling conquest:spruce_sapling conquest:willow_tree_sapling conquest:angelica conquest:black_knapweed conquest:buttercups conquest:cornflower conquest:dandelion conquest:elanor conquest:goldenrod conquest:harebell conquest:lily_of_the_valley conquest:lobelia_flowers conquest:marsh_ragwort conquest:meadow_saffron conquest:mediterranean_wild_tulip conquest:moorland_spotted_orchid conquest:niphredil conquest:orange_tulip conquest:orpine conquest:oxeye_daisy conquest:pasque_flower conquest:pink_tulip conquest:poppy conquest:red_tulip conquest:rock_rose conquest:sea_lavender conquest:simbelmyne conquest:white_clematis conquest:white_tulip conquest:wild_dagga conquest:allium conquest:barley conquest:bean_pole conquest:beetroots conquest:cabbage conquest:carrots conquest:common_beans conquest:corn conquest:flax conquest:heirloom_wheat_crops conquest:hemp conquest:lavender conquest:peas conquest:potatoes conquest:rice conquest:thyme conquest:tobacco conquest:turnips conquest:water_mint conquest:wheat conquest:wild_basil conquest:wild_parsley conquest:wild_wheat conquest:common_meadow_grass conquest:cotton_grass conquest:dead_grass conquest:deergrass conquest:grass conquest:kentucky_bluegrass conquest:lush_grass conquest:purple_moor_grass conquest:sea_arrowgrass conquest:seagrass conquest:sweet_grass conquest:timothy_grass conquest:wavy_hair_grass conquest:pine_cones conquest:spruce_cones conquest:beautyberry_bush conquest:bilberry_bush conquest:blackberry_bush conquest:bog_blueberry_bush conquest:broom_bush conquest:dead_bush conquest:hawthorn_bush conquest:lingonberry_bush conquest:raspberry_bush conquest:alpine_sow_thristle conquest:athelas conquest:autumnal_dwarf_birch conquest:birdsfoot_trefoil conquest:bog_asphodel conquest:bottle_sedge conquest:cattails conquest:common_cow_wheat conquest:cow_parsley conquest:cross leaved heath conquest:dead_reeds conquest:dead_shrubs conquest:desert_shrub conquest:dogs_mercury conquest:dooryard_dock conquest:dry_reeds conquest:greater_fen_sedge conquest:greater_wood_rush conquest:green_meadow_fescue conquest:green_spurge conquest:heather conquest:meadow_fescue conquest:melancholy_thristle conquest:nettles conquest:nightshade conquest:papyrus conquest:purple_wolfs_bane conquest:red_common_cow_wheat conquest:rosebay_willowherb conquest:rushes conquest:wild_shrub conquest:sedge conquest:small_fescue conquest:small_scabious conquest:sweet_woodruff conquest:wild_overgrown_nettles conquest:wild_shrub conquest:wood_horsetail conquest:woodland_sedge conquest:wormwood conquest:yellow_wolfs_bane conquest:autumnal_bracken conquest:bracken conquest:dark_autumnal_bracken conquest:dead_bracken conquest:fern conquest:fern_1 conquest:fern_2 conquest:harts_tongue_fern conquest:cypress conquest:young_tree conquest:young_frozen_tree conquest:cross_leaved_heath conquest:jungle_ground_cover conquest:alpine_sow_thistle conquest:duckweed conquest:red_mushroom conquest:brown_mushroom \ + conquest:warped_fungus conquest:acacia_sapling conquest:alder_tree_sapling conquest:apple_tree_sapling conquest:aspen_tree_sapling conquest:birch_sapling conquest:cherry_tree_sapling conquest:dark_oak_sapling conquest:downy_willow_tree_sapling conquest:gorse_tree_sapling conquest:grape_vine_sapling conquest:horse_chestnut_tree_sapling conquest:jungle_sapling conquest:larch_tree_sapling conquest:mallorn_tree_sapling conquest:oak_sapling conquest:orange_tree_sapling conquest:pear_tree_sapling conquest:pine_tree_sapling conquest:plum_tree_sapling conquest:rowan_tree_sapling conquest:spruce_sapling conquest:willow_tree_sapling conquest:angelica conquest:black_knapweed conquest:buttercups conquest:cornflower conquest:dandelion conquest:elanor conquest:goldenrod conquest:harebell conquest:lily_of_the_valley conquest:lobelia_flowers conquest:marsh_ragwort conquest:meadow_saffron conquest:mediterranean_wild_tulip conquest:moorland_spotted_orchid conquest:niphredil conquest:orange_tulip conquest:orpine conquest:oxeye_daisy conquest:pasque_flower conquest:pink_tulip conquest:poppy conquest:red_tulip conquest:rock_rose conquest:sea_lavender conquest:simbelmyne conquest:white_clematis conquest:white_tulip conquest:wild_dagga conquest:allium conquest:barley conquest:bean_pole conquest:beetroots conquest:cabbage conquest:carrots conquest:common_beans conquest:corn conquest:flax conquest:heirloom_wheat_crops conquest:hemp conquest:lavender conquest:peas conquest:potatoes conquest:rice conquest:thyme conquest:tobacco conquest:turnips conquest:water_mint conquest:wheat conquest:wild_basil conquest:wild_parsley conquest:wild_wheat conquest:common_meadow_grass conquest:cotton_grass conquest:dead_grass conquest:deergrass conquest:grass conquest:kentucky_bluegrass conquest:lush_grass conquest:purple_moor_grass conquest:sea_arrowgrass conquest:seagrass conquest:sweet_grass conquest:timothy_grass conquest:wavy_hair_grass conquest:pine_cones conquest:spruce_cones conquest:beautyberry_bush conquest:bilberry_bush conquest:blackberry_bush conquest:bog_blueberry_bush conquest:broom_bush conquest:dead_bush conquest:hawthorn_bush conquest:lingonberry_bush conquest:raspberry_bush conquest:alpine_sow_thristle conquest:athelas conquest:autumnal_dwarf_birch conquest:birdsfoot_trefoil conquest:bog_asphodel conquest:bottle_sedge conquest:cattails conquest:common_cow_wheat conquest:cow_parsley conquest:cross leaved heath conquest:dead_reeds conquest:dead_shrubs conquest:desert_shrub conquest:dogs_mercury conquest:dooryard_dock conquest:dry_reeds conquest:greater_fen_sedge conquest:greater_wood_rush conquest:green_meadow_fescue conquest:green_spurge conquest:heather conquest:meadow_fescue conquest:melancholy_thristle conquest:nettles conquest:nightshade conquest:papyrus conquest:purple_wolfs_bane conquest:red_common_cow_wheat conquest:rosebay_willowherb conquest:rushes conquest:wild_shrub conquest:sedge conquest:small_fescue conquest:small_scabious conquest:sweet_woodruff conquest:wild_overgrown_nettles conquest:wild_shrub conquest:wood_horsetail conquest:woodland_sedge conquest:wormwood conquest:yellow_wolfs_bane conquest:autumnal_bracken conquest:bracken conquest:dark_autumnal_bracken conquest:dead_bracken conquest:fern conquest:fern_1 conquest:fern_2 conquest:harts_tongue_fern conquest:cypress conquest:young_tree conquest:young_frozen_tree conquest:cross_leaved_heath conquest:jungle_ground_cover conquest:alpine_sow_thistle conquest:duckweed conquest:red_mushroom conquest:brown_mushroom \ flying_stuff:blow_flower flying_stuff:fiery_short_grass flying_stuff:fiery_grass flying_stuff:small_arid_bush flying_stuff:metallic_shorter_grass flying_stuff:firey_tree_sapling flying_stuff:abyss_grass flying_stuff:arid_grass flying_stuff:fiery_tree_sapling flying_stuff:lavic_tree_sapling flying_stuff:short_lavic_grass flying_stuff:warmth_radish_plant \ meadow:eriophorum meadow:pine_sapling meadow:alpine_poppy meadow:delphinium meadow:saxifrage meadow:enzian meadow:fire_lily ## air waving ## add a newline to organize for modded blocks #ifdef BOES_EARTH_BLOCKSTATES -block.56=minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves snow:is_on_leaves=true vine:is_on_leaves=true \ +block.56= minecraft:pale_hanging_moss minecraft:pale_oak_leaves minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves snow:is_on_leaves=true vine:is_on_leaves=true \ #else -block.56=minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves \ +block.56= minecraft:pale_hanging_moss minecraft:pale_oak_leaves minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves \ #endif beachparty:palm_leaves \ biomesoplenty:redwood_leaves biomesoplenty:origin_leaves biomesoplenty:flowering_oak_leaves biomesoplenty:cypress_leaves biomesoplenty:snowblossom_leaves biomesoplenty:rainbow_birch_leaves biomesoplenty:fir_leaves biomesoplenty:pine_leaves biomesoplenty:red_maple_leaves biomesoplenty:orange_maple_leaves biomesoplenty:yellow_maple_leaves biomesoplenty:redwood_leaves biomesoplenty:mahogany_leaves biomesoplenty:jacaranda_leaves biomesoplenty:palm_leaves biomesoplenty:willow_leaves biomesoplenty:dead_leaves biomesoplenty:magic_leaves biomesoplenty:umbran_leaves biomesoplenty:hellbark_leaves biomesoplenty:empyreal_leaves \ diff --git a/shaders/dimension.properties b/shaders/dimension.properties index 59dc943..9c76b9d 100644 --- a/shaders/dimension.properties +++ b/shaders/dimension.properties @@ -8,8 +8,27 @@ # dimension.world-1 = minecraft:the_nether # dimension.WHATEVER = somemod:whateverdimension -dimension.world0 = minecraft:overworld -dimension.world-1 = minecraft:the_nether -dimension.world1 = minecraft:the_end - -dimension.worldx = * +#if DIMENSION_FALLBACK_SHADER == 0 + dimension.world0 = minecraft:overworld * + dimension.world-1 = minecraft:the_nether + dimension.world1 = minecraft:the_end + dimension.worldx = +#endif +#if DIMENSION_FALLBACK_SHADER == 1 + dimension.world0 = minecraft:overworld + dimension.world-1 = minecraft:the_nether * + dimension.world1 = minecraft:the_end + dimension.worldx = +#endif +#if DIMENSION_FALLBACK_SHADER == 2 + dimension.world0 = minecraft:overworld + dimension.world-1 = minecraft:the_nether + dimension.world1 = minecraft:the_end * + dimension.worldx = +#endif +#if DIMENSION_FALLBACK_SHADER == 3 + dimension.world0 = minecraft:overworld + dimension.world-1 = minecraft:the_nether + dimension.world1 = minecraft:the_end + dimension.worldx = * +#endif \ No newline at end of file diff --git a/shaders/dimensions/DH_translucent.fsh b/shaders/dimensions/DH_translucent.fsh index 1a52519..4c33628 100644 --- a/shaders/dimensions/DH_translucent.fsh +++ b/shaders/dimensions/DH_translucent.fsh @@ -161,21 +161,6 @@ uniform int framemod8; #include "/lib/TAA_jitter.glsl" - - -// float DH_ld(float dist) { -// return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane)); -// } -// float DH_invLinZ (float lindepth){ -// return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane); -// } - -// float linearizeDepthFast(const in float depth, const in float near, const in float far) { -// return (near * far) / (depth * (near - far) + far); -// } - -// uniform float far; - vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater){ float quality = mix(5,SSR_STEPS,fresnel); @@ -204,12 +189,11 @@ vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater) // float sp = DH_inv_ld(sqrt(texelFetch2D(colortex12,ivec2(spos.xy/texelSize/4),0).a/65000.0)); float sp = DH_inv_ld(sqrt(texelFetch2D(colortex12,ivec2(spos.xy/texelSize/4),0).a/64000.0)); - if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp); - + if(sp < max(minZ,maxZ) && sp > min(minZ,maxZ)) return vec3(spos.xy/RENDER_SCALE,sp); spos += stepv; //small bias - minZ = maxZ-0.0000035/DH_ld(spos.z); + minZ = maxZ-0.00005/DH_ld(spos.z); maxZ += stepv.z; } @@ -290,7 +274,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) float material = 0.7; if(iswater) material = 1.0; - vec3 normals = normals_and_materials.xyz; + vec3 normals = normalize(normals_and_materials.xyz); + if (!gl_FrontFacing) normals = -normals; + + vec3 worldSpaceNormals = mat3(gbufferModelViewInverse) * normals; + vec3 viewPos = pos.xyz; vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; float transition = exp(-25* pow(clamp(1.0 - length(playerPos)/(far-8),0.0,1.0),2)); @@ -305,18 +293,22 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) if(length(playerPos) < clamp(far-16*4, 16, maxOverdrawDistance) ){ discard; return;} #endif - if(iswater && abs(normals.y) > 0.0){ - vec3 posxz = playerPos+cameraPosition; + vec3 waterNormals = worldSpaceNormals; + if(iswater && abs(worldSpaceNormals.y) > 0.1){ + vec3 posxz = playerPos+cameraPosition; + vec3 bump = normalize(getWaveNormal(posxz, true)); float bumpmult = 10.0 * WATER_WAVE_STRENGTH; + bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - normals.xz = bump.xy; + waterNormals.xz = bump.xy; } + + normals = worldToView(waterNormals); - normals = worldToView(normals); gl_FragData[0] = gcolor; // float UnchangedAlpha = gl_FragData[0].a; @@ -346,7 +338,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #ifdef OVERWORLD_SHADER vec3 DirectLightColor = lightCol.rgb/2400.0; - float NdotL = clamp(dot(normals, normalize(WsunVec2)),0.0,1.0); + float NdotL = clamp(dot(worldSpaceNormals, WsunVec),0.0,1.0); NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); float Shadows = 1.0; @@ -383,12 +375,12 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) Direct_lighting = DirectLightColor * NdotL * Shadows; - vec3 AmbientLightColor = averageSkyCol_Clouds/900.0; + vec3 AmbientLightColor = averageSkyCol_Clouds/900.0 ; - vec3 ambientcoefs = normals_and_materials.xyz / dot(abs(normals_and_materials.xyz), vec3(1.0)); + vec3 ambientcoefs = worldSpaceNormals.xyz / dot(abs(worldSpaceNormals.xyz), vec3(1.0)); float SkylightDir = ambientcoefs.y*1.5; - float skylight = max(pow(viewToWorld(normals_and_materials.xyz).y*0.5+0.5,0.1) + SkylightDir, 0.2); + float skylight = max(pow(worldSpaceNormals.y*0.5+0.5,0.1) + SkylightDir, 0.2); AmbientLightColor *= skylight; #endif @@ -407,7 +399,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 BackgroundReflection = FinalColor; vec3 SunReflection = vec3(0.0); - float roughness = 0.035; + float roughness = 0.0; float f0 = 0.02; // f0 = 0.9; @@ -440,21 +432,19 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) SunReflection = (DirectLightColor * Shadows) * GGX(normalize(normals), -normalize(viewPos), normalize(WsunVec2), roughness, f0) * (1.0-Reflections.a); #endif - Reflections_Final = mix(BackgroundReflection, Reflections.rgb, Reflections.a) * fresnel; + Reflections_Final = mix(FinalColor, mix(BackgroundReflection, Reflections.rgb, Reflections.a), fresnel); Reflections_Final += SunReflection; - //correct alpha channel with fresnel - float alpha0 = gl_FragData[0].a; - - gl_FragData[0].a = -gl_FragData[0].a * fresnel + gl_FragData[0].a + fresnel; - - // prevent reflections from being darkened by buffer blending - gl_FragData[0].rgb = clamp(FinalColor / gl_FragData[0].a*alpha0*(1.0-fresnel) * 0.1 + Reflections_Final / gl_FragData[0].a * 0.1,0.0,65100.0); + gl_FragData[0].a = gl_FragData[0].a + (1.0-gl_FragData[0].a) * fresnel; + + gl_FragData[0].rgb = clamp(Reflections_Final / gl_FragData[0].a * 0.1,0.0,65000.0); if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.0); #else gl_FragData[0].rgb = FinalColor*0.1; #endif + + // gl_FragData[0].rgb = normals*0.1; #ifdef DH_OVERDRAW_PREVENTION float distancefade = min(max(1.0 - length(playerPos)/clamp(far-16*4, 16, maxOverdrawDistance),0.0)*5,1.0); diff --git a/shaders/dimensions/DH_translucent.vsh b/shaders/dimensions/DH_translucent.vsh index 4d9372f..941175f 100644 --- a/shaders/dimensions/DH_translucent.vsh +++ b/shaders/dimensions/DH_translucent.vsh @@ -91,17 +91,17 @@ void main() { // gl_Position = toClipSpace3(position); - normals_and_materials = vec4(normalize(gl_Normal), 1.0); + normals_and_materials = vec4(mat3(gbufferModelView) * gl_Normal, 1.0); gcolor = gl_Color; lightmapCoords = gl_MultiTexCoord1.xy; - lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + #ifdef OVERWORLD_SHADER #if defined Daily_Weather dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); @@ -112,10 +112,6 @@ void main() { WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); WsunVec2 = lightCol.a * normalize(sunPosition); - - - - #ifdef TAA_UPSCALING diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index 1733e3c..ed52bf7 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -63,6 +63,8 @@ uniform vec2 texelSize; uniform ivec2 eyeBrightnessSmooth; uniform float rainStrength; uniform float nightVision; +uniform float waterEnteredAltitude; + flat varying float HELD_ITEM_BRIGHTNESS; @@ -433,6 +435,10 @@ void main() { Shadows *= GetCloudShadow(feetPlayerPos+cameraPosition, WsunVec); #endif + if(isEyeInWater == 1){ + float distanceFromWaterSurface = max(-(feetPlayerPos.y + (cameraPosition.y - waterEnteredAltitude)),0.0) ; + directLightColor *= exp(-vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B) * distanceFromWaterSurface); + } Direct_lighting = directLightColor * Shadows; // #ifndef LINES diff --git a/shaders/dimensions/all_solid.vsh b/shaders/dimensions/all_solid.vsh index 32f8074..4af662a 100644 --- a/shaders/dimensions/all_solid.vsh +++ b/shaders/dimensions/all_solid.vsh @@ -191,6 +191,11 @@ void main() { gl_Position = ftransform(); + #if defined ENTITIES && defined IS_IRIS + // force out of frustum + if (entityId == 1599) gl_Position.z -= 10000; + #endif + vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; /////// ----- COLOR STUFF ----- /////// @@ -300,7 +305,7 @@ void main() { mc_Entity.x == BLOCK_AMETHYST_BUD_MEDIUM || mc_Entity.x == BLOCK_AMETHYST_BUD_LARGE || mc_Entity.x == BLOCK_AMETHYST_CLUSTER || mc_Entity.x == BLOCK_BAMBOO || mc_Entity.x == BLOCK_SAPLING || mc_Entity.x == BLOCK_VINE ) { - SSSAMOUNT = 0.0; + SSSAMOUNT = 0.5; } // low #ifdef MISC_BLOCK_SSS diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index d3bd525..4810474 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -35,6 +35,9 @@ uniform vec4 entityColor; flat varying float HELD_ITEM_BRIGHTNESS; +#if defined ENTITIES && defined IS_IRIS + flat varying int NAMETAG; +#endif uniform sampler2D noisetex; uniform sampler2D depthtex1; @@ -45,6 +48,7 @@ uniform sampler2D depthtex0; #endif uniform sampler2D colortex7; uniform sampler2D colortex12; +uniform sampler2D colortex13; uniform sampler2D colortex14; uniform sampler2D colortex5; uniform sampler2D colortex3; @@ -102,6 +106,8 @@ uniform float sunIntensity; uniform vec3 sunColor; uniform vec3 nsunColor; +uniform float waterEnteredAltitude; + #include "/lib/util.glsl" #include "/lib/Shadow_Params.glsl" #include "/lib/color_transforms.glsl" @@ -180,13 +186,16 @@ float blueNoise(){ #define PW_POINTS 2 //[2 4 6 8 16 32] varying vec3 viewVector; -vec3 getParallaxDisplacement(vec3 posxz) { +vec3 getParallaxDisplacement(vec3 playerPos) { - vec3 parallaxPos = posxz; - vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH; - // float waterHeight = (1.0 - (getWaterHeightmap(posxz.xz)*0.5+0.5)) * 2.0 - 1.0; - float waterHeight = getWaterHeightmap(posxz.xz) * 2.0; - parallaxPos.xz -= waterHeight * vec; + float waterHeight = getWaterHeightmap(-playerPos.xz) ; + waterHeight = exp(-20*sqrt(waterHeight)); + // waterHeight *= 2.0; + + vec3 parallaxPos = playerPos; + + parallaxPos.xz += (viewVector.xy / -viewVector.z) * waterHeight; + // parallaxPos.xz -= (viewVec.xy / viewVec.z) * waterHeight * 0.5; return parallaxPos; } @@ -516,8 +525,13 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); // TangentNormal = clamp(TangentNormal + (blueNoise()*2.0-1.0)*0.005,-1.0,1.0); + float nameTagMask = 0.0; - gl_FragData[2] = vec4(encodeVec2(TangentNormal*0.5+0.5), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), 1.0); + #if defined ENTITIES && defined IS_IRIS + if(NAMETAG > 0) nameTagMask = 0.1; + #endif + + gl_FragData[2] = vec4(encodeVec2(TangentNormal*0.5+0.5), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), encodeVec2(0.0, nameTagMask)); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// SPECULARS ///////////////////////////////////// @@ -559,6 +573,12 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #ifdef OVERWORLD_SHADER vec3 DirectLightColor = lightCol.rgb/2400.0; + + if(isEyeInWater == 1){ + float distanceFromWaterSurface = max(-(feetPlayerPos.y + (cameraPosition.y - waterEnteredAltitude)),0.0) ; + DirectLightColor *= exp(-vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B) * distanceFromWaterSurface); + } + float NdotL = clamp(dot(normal, normalize(WsunVec*mat3(gbufferModelViewInverse))),0.0,1.0); NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); float Shadows = 1.0; @@ -595,18 +615,6 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #endif #ifdef END_SHADER - // float vortexBounds = clamp(vortexBoundRange - length(feetPlayerPos+cameraPosition), 0.0,1.0); - // vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds); - - - // float lightningflash = texelFetch2D(colortex4,ivec2(1,1),0).x/150.0; - // vec3 lightColors = LightSourceColors(vortexBounds, lightningflash); - - // float NdotL = clamp(dot(worldSpaceNormal, normalize(-lightPos))*0.5+0.5,0.0,1.0); - - // NdotL *= NdotL; - - // Direct_lighting = lightColors * endFogPhase(lightPos) * NdotL; float vortexBounds = clamp(vortexBoundRange - length(feetPlayerPos+cameraPosition), 0.0,1.0); vec3 lightPos = LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition,vortexBounds); @@ -651,6 +659,17 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo; + // vec4 vlBehingTranslucents = texture2D(colortex13, gl_FragCoord.xy*texelSize * VL_RENDER_RESOLUTION).rgba; + + // vec3 totEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);// dirtEpsilon*dirtAmount + waterEpsilon; + // vec3 scatterCoef = Dirt_Amount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; + + // vec3 transmittance = exp(-totEpsilon * vlBehingTranslucents.a*50); + // FinalColor *= transmittance; + + // FinalColor = FinalColor * vlBehingTranslucents.a +vlBehingTranslucents.rgb ; + + #if EMISSIVE_TYPE == 2 || EMISSIVE_TYPE == 3 Emission(FinalColor, Albedo, SpecularTex.b, exposure); #endif @@ -711,9 +730,17 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #else gl_FragData[0].rgb = FinalColor*0.1; #endif + + #if defined DISTANT_HORIZONS && defined DH_OVERDRAW_PREVENTION && !defined HAND - bool WATER = texture2D(colortex7, gl_FragCoord.xy*texelSize).a > 0.0 && length(feetPlayerPos) > far-16*4 && texture2D(depthtex1, gl_FragCoord.xy*texelSize).x >= 1.0; + #if OVERDRAW_MAX_DISTANCE == 0 + float maxOverdrawDistance = far; + #else + float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE; + #endif + + bool WATER = texture2D(colortex7, gl_FragCoord.xy*texelSize).a > 0.0 && length(feetPlayerPos) > clamp(far-16*4, 16, maxOverdrawDistance) && texture2D(depthtex1, gl_FragCoord.xy*texelSize).x >= 1.0; if(WATER) gl_FragData[0].a = 0.0; #endif @@ -735,10 +762,22 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) gl_FragData[0].rgb = Direct_lighting * 0.1; #endif - // gl_FragData[3].a = clamp(lightmap.y,0.0,1.0); + // gl_FragData[0] = vec4(tbnMatrix * viewPos,1); gl_FragData[3] = vec4(encodeVec2(lightmap.x, lightmap.y), 1, 1, 1); - + #if defined ENTITIES && defined IS_IRIS + if(NAMETAG > 0) { + // WHY DO THEY HAVE TO AHVE LIGHTING AAAAAAUGHAUHGUAHG + #ifndef OVERWORLD_SHADER + lightmap.y = 0.0; + #endif + + vec3 nameTagLighting = Albedo.rgb * max(max(lightmap.y*lightmap.y*lightmap.y , lightmap.x*lightmap.x*lightmap.x), 0.025); + + // in vanilla they have a special blending mode/no blending, or something. i cannot change the buffer blend mode without changing the rest of the entities :/ + gl_FragData[0] = vec4(nameTagLighting.rgb * 0.1, UnchangedAlpha * 0.75); + } + #endif } } \ No newline at end of file diff --git a/shaders/dimensions/all_translucent.vsh b/shaders/dimensions/all_translucent.vsh index fb10c20..f4dac6a 100644 --- a/shaders/dimensions/all_translucent.vsh +++ b/shaders/dimensions/all_translucent.vsh @@ -46,6 +46,9 @@ uniform mat4 gbufferModelView; varying vec3 viewVector; flat varying int glass; +#if defined ENTITIES && defined IS_IRIS + flat varying int NAMETAG; +#endif attribute vec4 at_tangent; attribute vec4 mc_Entity; @@ -140,6 +143,7 @@ void main() { float curvature = length(worldpos) / (16*8); worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; #endif + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; gl_Position = toClipSpace3(position); @@ -169,6 +173,11 @@ void main() { // translucent blocks if (mc_Entity.x >= 301 && mc_Entity.x <= 321) mat = 0.7; + + #if defined ENTITIES && defined IS_IRIS + NAMETAG = 0; + if (entityId == 1600) NAMETAG = 1; + #endif tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); @@ -212,7 +221,12 @@ void main() { 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; + #if defined ENTITIES && defined IS_IRIS + // remove jitter for nametags lol + if (entityId != 1600) gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; + #else + gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; + #endif #endif #if DOF_QUALITY == 5 diff --git a/shaders/dimensions/composite.fsh b/shaders/dimensions/composite.fsh index 87e83b7..74d2134 100644 --- a/shaders/dimensions/composite.fsh +++ b/shaders/dimensions/composite.fsh @@ -197,6 +197,7 @@ vec2 SpiralSample( return vec2(x, y); } + vec2 CleanSample( int samples, float totalSamples, float noise ){ @@ -250,21 +251,21 @@ float convertHandDepth_2(in float depth, bool hand) { } vec2 SSAO( - vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise + vec3 viewPos, vec3 normal, vec3 flatnormal, bool hand, bool leaves, float noise ){ - int samples = 7; + int samples = 14; float occlusion = 0.0; float sss = 0.0; + float THING = 0.0; - vec3 normalizedNormals = normalize(normal); vec2 jitterOffsets = TAA_Offset*texelSize*0.5 * RENDER_SCALE - texelSize*0.5; // scale the offset radius down as distance increases. float linearViewDistance = length(viewPos); float distanceScale = hand ? 30.0 : mix(40.0, 10.0, pow(clamp(1.0 - linearViewDistance/50.0,0.0,1.0),2.0)); - float depthCancelation = (linearViewDistance*linearViewDistance) / distanceScale * 0.5; - - float leaf = leaves ? -0.5 : 0.0; + float depthCancelation = (linearViewDistance*linearViewDistance) / distanceScale ; + + // float leaf = leaves ? -0.5 : 0.0; int n = 0; for (int i = 0; i < samples; i++) { @@ -287,23 +288,34 @@ vec2 SSAO( vec3 viewPosDiff = offsetViewPos - viewPos; float viewPosDiffSquared = dot(viewPosDiff, viewPosDiff); + float threshHold = max(1.0 - viewPosDiffSquared/depthCancelation, 0.0); + if (viewPosDiffSquared > 1e-5){ - if(viewPosDiffSquared < depthCancelation){ - float NdotV = clamp(dot(viewPosDiff*inversesqrt(viewPosDiffSquared), normalizedNormals),0.0,1.0); - occlusion += NdotV * clamp(1.0-(viewPosDiffSquared/depthCancelation),0.0,1.0); - } + n += 1; + float preAo = 1.0 - clamp(dot(normalize(viewPosDiff), flatnormal)*25.0,0.0,1.0); + occlusion += max(0.0, dot(normalize(viewPosDiff), normal) - preAo) * threshHold; #ifdef Ambient_SSS - sss += clamp(0.0 - dot(viewPosDiff, normalizedNormals),0.0,1.0) * exp(-10.0 * occlusion); + #ifdef OLD_INDIRECT_SSS + sss += clamp(-dot(normalize(viewPosDiff), flatnormal),0.0,1.0) * exp(-10*occlusion); + #else + sss += clamp(-dot(normalize(viewPosDiff), flatnormal) - occlusion/n,0.0,1.0) * 0.25 + + min(-normalize(mat3(gbufferModelViewInverse) * viewPosDiff).y - occlusion/n,1.0) * threshHold; + // + min(-dot(normalize(mat3(gbufferModelViewInverse) * viewPosDiff),clamp(normalize(WsunVec),-vec3(0.35,1.0,0.35),vec3(0.35,1.0,0.35))) - occlusion/n,1.0) * threshHold; + #endif #endif - n += 1; } } } - return max(1.0 - vec2(occlusion*AO_Strength, sss)/n, 0.0); + + float finaalAO = max(1.0 - occlusion*AO_Strength/n, 0.0); + float finalSSS = sss/n; + + return vec2(finaalAO, finalSSS); } + float ScreenSpace_SSS( vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise ){ @@ -343,6 +355,7 @@ float ScreenSpace_SSS( if (viewPosDiffSquared > 1e-5){ sss += clamp(leaf - dot(viewPosDiff, normalizedNormals),0.0,1.0); + // sss += -(normalize(mat3(gbufferModelViewInverse)*viewPosDiff) + occlusion/n) * threshHold; n += 1; } } @@ -350,6 +363,77 @@ float ScreenSpace_SSS( return max(1.0 - sss/n, 0.0); } +vec2 spiralSampling( + int samples, float totalSamples, float noise +){ + + // this will be used to make 1 full rotation of the spiral. the mulitplication is so it does nearly a single rotation, instead of going past where it started + float variance = noise * 0.897; + + // for every sample input, it will have variance applied to it. + float variedSamples = float(samples) + variance; + + // for every sample, the sample position must change its distance from the origin. + // otherwise, you will just have a circle. + float spiralShape = variedSamples / (totalSamples + variance); + + float shape = 2.26; + float theta = variedSamples * (PI * shape); + + float x = cos(theta) * spiralShape; + float y = sin(theta) * spiralShape; + + return vec2(x, y); +} + +// vec3 getViewPos(in vec2 uv, in float depth, in mat4 inverseProj ){ + +// } +float getNoise(in vec2 fragCoord){ + return fract(0.75487765 * fragCoord.x + 0.56984026 * fragCoord.y); +} +float calculateSSAO( + vec2 fragCoord, vec2 uv, vec3 viewPos, vec3 normal, in mat4 inverseProj +){ +// SETTINGS +int SAMPLES = 50; +float RADIUS = 0.0005; +vec2 SCALE_RADIUS = vec2(1280.0, 720.0 * aspectRatio); + +float linearViewDistance = length(viewPos); +float distanceScale = mix(40.0, 1.0, pow(clamp(1.0 - linearViewDistance/50.0,0.0,1.0),2.0)); +float depthCancelation = (linearViewDistance*linearViewDistance) / distanceScale; + +float noise = getNoise(fragCoord); +float average = 0.0; +float occlusion = 0.0; + +for (int i = 0; i < SAMPLES; i++) { +vec2 offsets = (spiralSampling(i, float(SAMPLES - 1), noise) / distanceScale) * RADIUS * SCALE_RADIUS; +vec2 offsetUV = uv + offsets; + +if (offsetUV.x >= 0 && offsetUV.y >= 0 && offsetUV.x <= 1.0 && offsetUV.y <= 1.0 ) { +float sampleDepth = texture(depthtex0, offsetUV).x; +// vec3 offsetViewPos = getViewPos(offsetUV, sampleDepth, inverseProj); +vec3 offsetViewPos = toScreenSpace(vec3(offsetUV, sampleDepth)); +vec3 viewPosDiff = offsetViewPos - viewPos; + +float viewPosDiffSquared = dot(viewPosDiff, viewPosDiff); +float threshHold = max(1.0 - viewPosDiffSquared/depthCancelation, 0.0); +if (viewPosDiffSquared > 1e-5){ +occlusion += max(0.0, dot(normalize(viewPosDiff), normal)) * threshHold; +average += 1.0; +} + +} + +} + +float finalAO = max(1.0 - occlusion / average, 0.0); +finalAO = finalAO*finalAO*finalAO*finalAO; +return finalAO; +} + vec4 encode (vec3 n, vec2 lightmaps){ n.xy = n.xy / dot(abs(n), vec3(1.0)); n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; @@ -469,7 +553,8 @@ void main() { float noise = R2_dither(); vec2 texcoord = gl_FragCoord.xy*texelSize; - float z = texture2D(depthtex1,texcoord).x; + float z = texture(depthtex1,texcoord).x; + // float z = texelFetch2D(depthtex1,ivec2(gl_FragCoord.xy),0).x; #ifdef DISTANT_HORIZONS float DH_depth1 = texture2D(dhDepthTex1,texcoord).x; @@ -534,8 +619,12 @@ void main() { if(z >= 1.0) FlatNormals = normal; - vec2 SSAO_SSS = SSAO(viewPos, worldToView(FlatNormals), hand, isLeaf, noise); + vec2 SSAO_SSS = SSAO(viewPos, worldToView(normal),worldToView(FlatNormals), hand, isLeaf, noise); + #ifndef OLD_INDIRECT_SSS + SSAO_SSS.y = clamp(SSAO_SSS.y + 0.5 * lightmap.y*lightmap.y,0.0,1.0); + #endif + // SSAO_SSS.y = clamp(SSAO_SSS.y + 0.5,0.0,1.0); if(swappedDepth >= 1.0) SSAO_SSS = vec2(1.0,0.0); gl_FragData[1].xy = SSAO_SSS; diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index b4692de..b1650ff 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -9,6 +9,7 @@ #extension GL_ARB_shading_language_packing: enable #endif + #include "/lib/util.glsl" #include "/lib/res_params.glsl" @@ -100,6 +101,7 @@ uniform mat4 gbufferPreviousModelView; // uniform vec3 cameraPosition; uniform vec3 previousCameraPosition; +uniform float updateFadeTime; // uniform float far; uniform float near; @@ -133,6 +135,7 @@ flat varying float exposure; uniform int heldItemId; uniform int heldItemId2; #endif +uniform float waterEnteredAltitude; void convertHandDepth(inout float depth) { @@ -343,7 +346,6 @@ float blueNoise(){ vec4 blueNoise(vec2 coord){ return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; } - // vec3 toShadowSpaceProjected(vec3 feetPlayerPos){ // mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection); @@ -825,7 +827,6 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa // float scatterDepth = max(1.0 - Scattering/density,0.0); // scatterDepth = exp((1.0-scatterDepth) * -7.0); - // scatterDepth = mix(exp(Scattering * -10.0), scatterDepth, distantSSS); // // this is for SSS when there is no shadow blocker depth // #if defined BASIC_SHADOW_FILTER && defined Variable_Penumbra_Shadows @@ -851,14 +852,18 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa // float scatterDepth = Scattering;//max(1.0 - Scattering/density,0.0); float scatterDepth = max(1.0 - Scattering/density, 0.0); + scatterDepth = mix(exp(Scattering * -10.0), scatterDepth, distantSSS); scatterDepth *= exp(-7.0 * (1.0-scatterDepth)); - vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(20.0 - 19*scatterDepth) * sss_absorbance_multiplier); + // vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(20.0 - 19*scatterDepth) * sss_absorbance_multiplier); - scatterDepth = mix(exp(Scattering * -10.0), scatterDepth, distantSSS); + // scatterDepth = mix(exp(Scattering * -10.0), scatterDepth, distantSSS); - vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve);// * vec3(1.0); + // vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve);// * vec3(1.0); + vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -20.0); + + vec3 scatter = scatterDepth * mix(absorbColor, vec3(1.0), scatterDepth) * pow(Density, LabSSS_Curve); scatter *= 1.0 + CustomPhase(lightPos)*6.0; // ~10x brighter at the peak @@ -867,18 +872,17 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){ - // Scattering *= sss_density_multiplier; - - float scatterDepth = 1.0 - pow(Scattering, 0.5 + Density * 2.5); - // float scatterDepth = 1.0 - Scattering; + #ifdef OLD_INDIRECT_SSS + float scatterDepth = 1.0 - pow(1.0-Scattering, 0.5 + Density * 2.5); + vec3 absorbColor = vec3(1.0) * exp(-(15.0 - 10.0*scatterDepth) * sss_absorbance_multiplier * 0.01); + vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve); + #else + float scatterDepth = pow(Scattering,4); + scatterDepth = 1-pow(1-scatterDepth,5); - // PBR at its finest :clueless: - // vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -20.0 * sss_absorbance_multiplier); - - // vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.0,1.2), 0.0) * -20.0); - vec3 absorbColor = vec3(1.0) * exp(-(15.0 - 10.0*scatterDepth) * sss_absorbance_multiplier * 0.01); - - vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve); + vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -1.0 * sss_absorbance_multiplier); + vec3 scatter = scatterDepth * mix(absorbColor, vec3(1.0), scatterDepth) * pow(Density, LabSSS_Curve); + #endif return scatter; } @@ -910,32 +914,45 @@ uniform float wetness; void applyPuddles( in vec3 worldPos, in vec3 flatNormals, in float lightmap, in bool isWater, inout vec3 albedo, inout vec3 normals, inout float roughness, inout float f0 ){ + vec3 unchangedNormals = normals; + + float halfWet = min(wetnessAmount,1.0); float fullWet = clamp(wetnessAmount - 2.0,0.0,1.0); // halfWet = 1.0; - // fullWet = 0.0; + // fullWet = 1.0; float noise = texture2D(noisetex, worldPos.xz * 0.02).b; - float puddles = max(halfWet - noise,0.0); - puddles = clamp(halfWet - exp(-20.0 * puddles*puddles*puddles*puddles*puddles),0.0,1.0); - // puddles *= halfWet; - float lightmapMax = min(max(lightmap - 0.9,0.0) * 10.0,1.0); - float lightmapMin = min(max(lightmap - 0.8,0.0) * 5.0,1.0); + float lightmapMax = min(max(lightmap - 0.9,0.0) * 10.0,1.0) ; + float lightmapMin = min(max(lightmap - 0.8,0.0) * 5.0,1.0) ; lightmap = clamp(lightmapMax + noise*lightmapMin*2.0,0.0,1.0); - lightmap = pow(1.0-pow(1.0-lightmap,3.0),2.0); - - float wetnessStages = mix(puddles, 1.0, fullWet) * lightmap; - - // if(isWater || (!isWater && isEyeInWater == 1)) wetnessStages = 1.0; + float puddles = max(halfWet - noise,0.0); + puddles = clamp(halfWet - exp(-25.0 * puddles*puddles*puddles*puddles*puddles),0.0,1.0); + + float wetnessStages = mix(puddles, 1.0, fullWet) * lightmap; + if(isWater) wetnessStages = 0.0; + normals = mix(normals, flatNormals, puddles * lightmap * clamp(flatNormals.y,0.0,1.0)); roughness = mix(roughness, 1.0, wetnessStages); if(f0 < 229.5/255.0 ) albedo = pow(albedo * (1.0 - 0.08*wetnessStages), vec3(1.0 + 0.7*wetnessStages)); + //////////////// snow + + // float upnormal = clamp(-(normals / dot(abs(normals),vec3(1.0))).y+clamp(flatNormals.y,0.5,1.0),0,1); + // halfWet = clamp(halfWet - upnormal - (1.0-lightmap),0.0,1.0); + // float snow = max(halfWet - noise,0.0); + // snow = clamp(halfWet - exp(-20.0 * snow*snow*snow*snow*snow),0.0,1.0); + + // if(isWater || f0 > 229.5/255.0) snow = 0.0; + + // normals = mix(normals, unchangedNormals, snow); + // roughness = mix(roughness, 0.5, snow); + // albedo = mix(albedo, vec3(1.0), snow); } vec2 smoothfilterUV(in vec2 uv) @@ -957,6 +974,63 @@ vec2 smoothfilterUV(in vec2 uv) return uv; } +float calculateSSAO( + vec3 viewPos, vec3 normal, float noise +){ + int samples = 50; + float occlusion = 0.0; + float sss = 0.0; + + vec2 jitterOffsets = TAA_Offset*texelSize * 0.5 * RENDER_SCALE - texelSize*0.5; + + // scale the offset radius down as distance increases. + float linearViewDistance = length(viewPos); + float distanceScale = mix(40.0, 10.0, pow(clamp(1.0 - linearViewDistance/50.0,0.0,1.0),2.0)); + float depthCancelation = (linearViewDistance*linearViewDistance) / distanceScale ; + + int n = 0; + + for (int i = 0; i < samples; i++) { + + vec2 offsets = CleanSample(i, samples - 1, noise) / distanceScale; + + ivec2 offsetUV = ivec2(gl_FragCoord.xy + offsets*vec2(viewWidth, viewHeight*aspectRatio)*RENDER_SCALE); + + if (offsetUV.x >= 0 && offsetUV.y >= 0 && offsetUV.x < viewWidth*RENDER_SCALE.x && offsetUV.y < viewHeight*RENDER_SCALE.y ) { + + float sampleDepth = texelFetch2D(depthtex1, offsetUV, 0).x; + vec2 scaledUV = (offsetUV*texelSize - jitterOffsets) * (1.0/RENDER_SCALE); + + vec3 offsetViewPos = toScreenSpace(vec3(scaledUV, sampleDepth)); + + vec3 viewPosDiff = offsetViewPos - viewPos; + vec3 viewPosDiff_world = mat3(gbufferModelViewInverse) * viewPosDiff; + + float viewPosDiffSquared = dot(viewPosDiff, viewPosDiff); + float threshHold = clamp(1.0 - viewPosDiffSquared/depthCancelation, 0.0,1.0); + + if (viewPosDiffSquared > 1e-5){ + n += 1; + + occlusion += max(0.0, dot(normalize(viewPosDiff), normal) - 0.5) * threshHold; + + // vec3 dir = (-normalize(viewPosDiff_world) * threshHold + 0.5) * (1.0-occlusion/n); + vec3 dir = -(normalize(viewPosDiff_world) + occlusion/n) * threshHold; + + sss += dir.y; + } + + } + } + + float finalAO = max(1.0 - occlusion / n, 0.0); + float finalSSS = sss/n; + + finalAO = pow(finalAO,10); + + return finalAO; +} + void main() { vec3 DEBUG = vec3(1.0); @@ -975,8 +1049,12 @@ void main() { // float noise = fract(R2_samples(3).y + bnoise.y); // #endif - float z0 = texture2D(depthtex0,texcoord).x; - float z = texture2D(depthtex1,texcoord).x; + // float z0 = texture2D(depthtex0,texcoord).x; + // float z = texture2D(depthtex1,texcoord).x; + + float z0 = texelFetch2D(depthtex0, ivec2(gl_FragCoord.xy), 0).x; + float z = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy), 0).x; + float swappedDepth = z; bool isDHrange = z >= 1.0; @@ -1098,12 +1176,12 @@ void main() { ////// --------------- COLORS --------------- ////// - float dirtAmount = Dirt_Amount; + // float dirtAmount = Dirt_Amount; // float dirtAmount = Dirt_Amount + 0.01; vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon * dirtAmount + waterEpsilon; - // vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; + vec3 totEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);//dirtEpsilon * dirtAmount + waterEpsilon; + vec3 scatterCoef = Dirt_Amount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; vec3 Absorbtion = vec3(1.0); vec3 AmbientLightColor = vec3(0.0); @@ -1169,30 +1247,44 @@ void main() { float Vdiff = distance(feetPlayerPos, playerPos0); float estimatedDepth = Vdiff * abs(feetPlayerPos_normalized.y);// assuming water plane - float viewerWaterDepth = Vdiff * (1.0 - clamp(exp(-Vdiff),0.0,1.0)); + // float viewerWaterDepth = Vdiff;// * (1.0 - clamp(exp(-Vdiff),0.0,1.0)); // force the absorbance to start way closer to the water surface in low light areas, so the water is visible in caves and such. #if MINIMUM_WATER_ABSORBANCE > -1 float minimumAbsorbance = MINIMUM_WATER_ABSORBANCE*0.1; #else - float minimumAbsorbance = (1.0 - lightLeakFix)*0.75; + float minimumAbsorbance = (1.0 - lightLeakFix); #endif - viewerWaterDepth += max(estimatedDepth - 1.0, minimumAbsorbance); + // viewerWaterDepth += max(estimatedDepth - 1.0, minimumAbsorbance); - Absorbtion = exp( -2.0 * totEpsilon * viewerWaterDepth); + Absorbtion = exp(-totEpsilon * max(Vdiff, minimumAbsorbance)); + + // Absorbtion = exp( -2.0 * totEpsilon * viewerWaterDepth); // brighten up the fully absorbed parts of water when night vision activates. // if( nightVision > 0.0 ) Absorbtion += exp( -50.0 * totEpsilon) * 50.0 * 7.0 * nightVision; - if( nightVision > 0.0 ) Absorbtion += exp( -30.0 * totEpsilon) * 10.0 * nightVision * 10.0; + // if( nightVision > 0.0 ) Absorbtion += exp( -30.0 * totEpsilon) * 10.0 * nightVision * 10.0; + + // things to note about sunlight in water + // sunlight gets absorbed by water on the way down to the floor, and on the way back up to your eye. im gonna ingore the latter part lol + // based on the angle of the sun, sunlight will travel through more/less water to reach the same spot. scale absorbtion depth accordingly + vec3 sunlightAbsorbtion = exp(-totEpsilon * (estimatedDepth/abs(WsunVec.y))); if (isEyeInWater == 1){ estimatedDepth = 1.0; - viewerWaterDepth = max(0.9-lightmap.y,0.0)*3.0; - Absorbtion = exp( -2.0 * totEpsilon * viewerWaterDepth); - DirectLightColor *= Absorbtion; + // viewerWaterDepth = max(0.9-lightmap.y,0.0)*3.0; + float distanceFromWaterSurface = max(-(feetPlayerPos.y + (cameraPosition.y - waterEnteredAltitude)),0.0) ; + + Absorbtion = exp(-totEpsilon * distanceFromWaterSurface); + + sunlightAbsorbtion = exp(-totEpsilon * (distanceFromWaterSurface/abs(WsunVec.y))); } + + DirectLightColor *= sunlightAbsorbtion; + + if( nightVision > 0.0 ) Absorbtion += exp(-totEpsilon * 25.0) * nightVision; // apply caustics to the lighting, and make sure they dont look weird DirectLightColor *= mix(1.0, waterCaustics(feetPlayerPos + cameraPosition, WsunVec)*WATER_CAUSTICS_BRIGHTNESS + 0.25, clamp(estimatedDepth,0,1)); @@ -1257,9 +1349,11 @@ void main() { float shadowMapFalloff2 = shadowmapFade; #endif - // shadowMapFalloff = 1.0; - // shadowMapFalloff2 = 1.0; - + if(isEyeInWater == 1){ + shadowMapFalloff = 1.0; + shadowMapFalloff2 = 1.0; + } + // un-distort #ifdef DISTORT_SHADOWMAP float distortFactor = calcDistort(projectedShadowPosition.xy); @@ -1362,14 +1456,26 @@ void main() { // skylight = min(skylight, mix(0.95, 2.5, pow(1-pow(1-SSAO_SSS.x, 0.5),2.0) )); // #endif - float SkylightDir = (slopednormal / dot(abs(slopednormal),vec3(1.0))).y; - + // vec3 lastLightPos = feetPlayerPos + (cameraPosition - lastKnownLightlevel);// - vec3(0,0,0); + // lastLightPos.y = min(lastLightPos.y,0.0); + + vec3 indirectNormal = slopednormal / dot(abs(slopednormal),vec3(1.0)); + + //(slopednormal / dot(abs(slopednormal),vec3(1.0))).y; + float SkylightDir = indirectNormal.y; if(isGrass) SkylightDir = 1.0; - SkylightDir = clamp(SkylightDir*0.7+0.3, 0.0, pow(1-pow(1-SSAO_SSS.x, 0.5),2.0) * 0.7 + 0.3); + SkylightDir = clamp(SkylightDir*0.7+0.3, 0.0, pow(1-pow(1-SSAO_SSS.x, 0.5),4.0) * 0.7 + 0.3); + // SkylightDir = SkylightDir*0.7+0.3; + // float indirectPointLight = clamp(dot(slopednormal, -normalize(lastLightPos)),0,1); + // float lightAttenuation = 1.0-clamp(1.0-length(lastLightPos)/16,0,1); + // SkylightDir = mix(mix(SkylightDir, indirectPointLight, updateFadeTime), SkylightDir, max(lightAttenuation,min(max(lightmap.y-0.9,0)/0.1,1))); + + // skylight = mix(0.2, 2.5, SkylightDir); + skylight = mix(0.2 + 2.3*(1.0-lightmap.y), 2.5, SkylightDir); - skylight = mix(0.2 + 2.3*(1.0-lightmap.y), 2.5, SkylightDir); + // skylight = 2.5; #endif @@ -1435,10 +1541,11 @@ void main() { SkySSS = SSAO_SSS.y; float vanillaAO_curve = pow(1.0 - vanilla_AO*vanilla_AO,5.0); - float SSAO_curve = pow(SSAO_SSS.x,6.0); + float SSAO_curve = pow(SSAO_SSS.x,4.0); // use the min of vanilla ao so they dont overdarken eachother - AO = vec3( min(vanillaAO_curve, SSAO_curve) ); + // AO = vec3( min(vanillaAO_curve, SSAO_curve) ); + AO = vec3( SSAO_curve ); Indirect_lighting *= AO; #endif @@ -1468,13 +1575,15 @@ void main() { ///////////////////////////// SKY SSS ///////////////////////////// #if defined Ambient_SSS && defined OVERWORLD_SHADER && indirect_effect == 1 if (!hand){ - vec3 ambientColor = AmbientLightColor * mix(0.2,2.5,lightmap.y*lightmap.y) * ambient_brightness; // x2.5 to match the brightness of upfacing skylight + vec3 ambientColor = AmbientLightColor * ambientsss_brightness * 3.0;//mix(0.2,2.5,lightmap.y*lightmap.y); // x2.5 to match the brightness of upfacing skylight Indirect_SSS = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS); - Indirect_SSS *= lightmap.y*lightmap.y;//*lightmap.y; + Indirect_SSS *= lightmap.y; + // if(texcoord.x>0.5) oIndirect_SSS *= 0.0; // apply to ambient light. - Indirect_lighting = max(Indirect_lighting, Indirect_SSS * ambientColor * ambientsss_brightness); + Indirect_lighting = max(Indirect_lighting, Indirect_SSS * ambientColor ); + // Indirect_lighting += Indirect_SSS * ambientColor; // #ifdef OVERWORLD_SHADER // if(LabSSS > 0.0) Indirect_lighting += (1.0-SkySSS) * LightningPhase * lightningEffect * pow(lightmap.y,10); @@ -1487,6 +1596,9 @@ void main() { ///////////////////////////////////////////////////////////////////////// + // shadowColor *= 0.0; + // SSSColor *= 0.0; + #ifdef SSS_view albedo = vec3(1); NdotL = 0; @@ -1495,11 +1607,14 @@ void main() { Direct_lighting *= AO; #endif #ifdef OVERWORLD_SHADER - // Direct_lighting = max(shadowColor*NdotL, SSSColor); + + #ifdef AO_in_sunlight - Direct_lighting = (shadowColor*NdotL + SSSColor) * (AO*0.7+0.3); + // Direct_lighting = max(shadowColor*NdotL * (AO*0.7+0.3), SSSColor); + Direct_lighting = shadowColor*NdotL*(AO*0.7+0.3) + SSSColor * (1.0-NdotL); #else - Direct_lighting = shadowColor*NdotL + SSSColor; + // Direct_lighting = max(shadowColor*NdotL, SSSColor); + Direct_lighting = shadowColor*NdotL + SSSColor * (1.0-NdotL); #endif #endif @@ -1515,17 +1630,13 @@ void main() { #if defined DEFERRED_SPECULAR vec3 specularNoises = vec3(BN.xy, blueNoise()); - // DoSpecularReflections(FINAL_COLOR, viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, shadowColor, lightmap.y, hand); - - FINAL_COLOR = specularReflections(viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, FINAL_COLOR, shadowColor, lightmap.y, hand, isWater || (!isWater && isEyeInWater == 1)); + vec3 specularNormal = slopednormal; + if (dot(slopednormal, (feetPlayerPos_normalized)) > 0.0) specularNormal = FlatNormals; + + FINAL_COLOR = specularReflections(viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, specularNormal, SpecularTex.r, SpecularTex.g, albedo, FINAL_COLOR, shadowColor, lightmap.y, hand, isWater || (!isWater && isEyeInWater == 1)); #endif - gl_FragData[0].rgb = FINAL_COLOR; - // gl_FragData[0].rgb = vec3(1) * Absorbtion; - - - }else{ vec3 Background = vec3(0.0); @@ -1613,11 +1724,22 @@ void main() { gl_FragData[0].rgb = viewPos * 0.001; #endif #if DEBUG_VIEW == debug_FILTERED_STUFF - + // if(hideGUI == 1){ // gl_FragData[0].rgb = texture2D(colortex14, texcoord).xyz; - if(hideGUI == 1) gl_FragData[0].rgb = vec3(1) * (1.0 - SSAO_SSS.y); - if(hideGUI == 0) gl_FragData[0].rgb = vec3(1) * pow(SSAO_SSS.x,6.0); - if(swappedDepth >= 1.0) gl_FragData[0].rgb = vec3(0.5); + // gl_FragData[0].rgb = vec3(1) * pow(1-texture2D(colortex14, texcoord).y,1); + // gl_FragData[0].rgb = vec3(1) * texture2D(colortex14, texcoord).x; + float value = SSAO_SSS.y; + + value = pow(value,5); + value = 1-pow(1-value,5); + + // value = calculateSSAO(viewPos,worldToView(testNorm),R2_dither()); + + if(hideGUI == 1) value = pow(SSAO_SSS.x,6); + gl_FragData[0].rgb = vec3(value); + + if(swappedDepth >= 1.0) gl_FragData[0].rgb = vec3(1.0); + // } // if(hideGUI == 0) gl_FragData[0].rgb = vec3(1) * exp(-10*filteredShadow.y);//exp(-7*(1-clamp(1.0 - filteredShadow.x,0.0,1.0))); #endif // gl_FragData[0].rgb = albedo*30; @@ -1630,5 +1752,6 @@ void main() { // gl_FragData[0].rgb = vec3(1) * filteredShadow.y; // if(swappedDepth >= 1.0) gl_FragData[0].rgb += vec3(0.5); + /* RENDERTARGETS:3 */ } \ No newline at end of file diff --git a/shaders/dimensions/composite2.fsh b/shaders/dimensions/composite2.fsh index c3c866d..485d2c4 100644 --- a/shaders/dimensions/composite2.fsh +++ b/shaders/dimensions/composite2.fsh @@ -255,7 +255,9 @@ void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEn } -vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ +uniform float waterEnteredAltitude; + +vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ int spCount = 8; vec3 start = toShadowSpaceProjected(rayStart); @@ -274,6 +276,16 @@ vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, vec3 absorbance = vec3(1.0); vec3 vL = vec3(0.0); + // float distanceFromWaterSurface = -(normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/(waterEnteredAltitude/2)) * 0.5 + 0.5; + // distanceFromWaterSurface = clamp(distanceFromWaterSurface, 0.0,1.0); + // distanceFromWaterSurface = exp(-7.0*distanceFromWaterSurface*distanceFromWaterSurface); + + // float distanceFromWaterSurface2 = normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/waterEnteredAltitude; + // distanceFromWaterSurface2 = clamp(-distanceFromWaterSurface2,0.0,1.0); + + // distanceFromWaterSurface2 = exp(-7*pow(distanceFromWaterSurface2,1.5)); + + #ifdef OVERWORLD_SHADER float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.1,1.0); float phase = fogPhase(VdotL) * 5.0; @@ -289,6 +301,8 @@ vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld; + float distanceFromWaterSurface = max(-(progressW.y - waterEnteredAltitude),0.0); + vec3 sh = vec3(1.0); #ifdef OVERWORLD_SHADER vec3 spPos = start.xyz + dV*d; @@ -318,27 +332,33 @@ vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, } #ifdef VL_CLOUDS_SHADOWS - sh *= GetCloudShadow(progressW, WsunVec); + sh *= GetCloudShadow(progressW, WsunVec * lightCol.a); #endif #endif float bubble = exp2(-10.0 * clamp(1.0 - length(d*dVWorld) / 16.0, 0.0,1.0)); - float caustics = mix(max(max(waterCaustics(progressW, WsunVec), phase*0.5) * mix(0.5, 200.0, bubble), phase), 1.0, lowlightlevel); + // float caustics = mix(max(max(waterCaustics(progressW, WsunVec), phase*0.5) * mix(0.5, 200.0, bubble), phase), 1.0, lowlightlevel); + // float caustics = max(max(waterCaustics(progressW, WsunVec), phase*0.5) * mix(0.5, 200.0, bubble), phase); + float caustics = max(max(waterCaustics(progressW, WsunVec), phase*0.5) * mix(0.5, 1.5, bubble), phase) ;//* abs(WsunVec.y); - vec3 Directlight = lightSource * sh * phase * caustics*abs(WsunVec.y) * lowlightlevel; - vec3 Indirectlight = ambient * lowlightlevel; - vec3 WaterAbsorbance = exp(-waterCoefs * rayLength * d); + vec3 sunAbsorbance = exp(-waterCoefs * (distanceFromWaterSurface/abs(WsunVec.y))); + vec3 WaterAbsorbance = exp(-waterCoefs * distanceFromWaterSurface); - vec3 light = (Indirectlight + Directlight) * WaterAbsorbance * scatterCoef; + vec3 Directlight = lightSource * sh * phase * caustics * sunAbsorbance; + vec3 Indirectlight = ambient * WaterAbsorbance; + + + vec3 light = (Indirectlight + Directlight) * scatterCoef; - vec3 volumeCoeff = exp(-waterCoefs * rayLength * dd); + vec3 volumeCoeff = exp(-waterCoefs * length(dd*dVWorld)); vL += (light - light * volumeCoeff) / waterCoefs * absorbance; absorbance *= volumeCoeff; } - return vL; + + return vec4(vL, dot(absorbance,vec3(0.335))); } vec4 blueNoise(vec2 coord){ @@ -370,127 +390,101 @@ float encodeVec2(vec2 a){ uniform int framemod8; #include "/lib/TAA_jitter.glsl" - - - -vec3 toClipSpace3Prev(vec3 viewSpacePosition) { - return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -} - -vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth) -{ - vec2 du = vec2(texelSize.x*2., 0.0); - vec2 dv = vec2(0.0, texelSize.y*2.); - - vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x); - vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x); - vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x); - vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x); - vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x); - - vec3 dmin = dmc; - dmin = dmin.z > dtr.z ? dtr : dmin; - dmin = dmin.z > dtl.z ? dtl : dmin; - dmin = dmin.z > dbl.z ? dbl : dmin; - dmin = dmin.z > dbr.z ? dbr : dmin; - - #ifdef TAA_UPSCALING - dmin.xy = dmin.xy/RENDER_SCALE; - #endif - - return dmin; -} - -vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) { - - #ifdef DISTANT_HORIZONS - mat4 projectionMatrix = depthCheck ? dhPreviousProjection : gbufferPreviousProjection; - return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; - #else - return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; - #endif -} - -vec3 toScreenSpace_DH_special(vec3 POS, bool depthCheck ) { - - vec4 viewPos = vec4(0.0); - vec3 feetPlayerPos = vec3(0.0); - vec4 iProjDiag = vec4(0.0); - - #ifdef DISTANT_HORIZONS - if (depthCheck) { - iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw); - - feetPlayerPos = POS * 2.0 - 1.0; - viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3]; - viewPos.xyz /= viewPos.w; - - } else { - #endif - iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - - feetPlayerPos = POS * 2.0 - 1.0; - viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3]; - viewPos.xyz /= viewPos.w; - - #ifdef DISTANT_HORIZONS - } - #endif - - return viewPos.xyz; -} -vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, vec4 color){ - vec2 texcoord = gl_FragCoord.xy * texelSize; - - vec2 VLtexCoord = texcoord/VL_RENDER_RESOLUTION; - - // vec3 closestToCamera = closestToCamera5taps(texcoord, depthtex0); - // vec3 viewPos_5tap = toScreenSpace(closestToCamera); - - // get previous frames position stuff for UV - vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); - vec3 previousPosition = mat3(gbufferPreviousModelView) * playerPos + gbufferPreviousModelView[3].xyz; - previousPosition = toClipSpace3Prev(previousPosition); - - vec2 velocity = previousPosition.xy - VLtexCoord/RENDER_SCALE; - previousPosition.xy = VLtexCoord + velocity; - - vec4 currentFrame = color; - if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return currentFrame; - - // vec4 col0 = currentFrame; // can use this because its the center sample. - // vec4 col1 = texture2D(colortex0, VLtexCoord + vec2( texelSize.x, texelSize.y)); - // vec4 col2 = texture2D(colortex0, VLtexCoord + vec2( texelSize.x, -texelSize.y)); - // vec4 col3 = texture2D(colortex0, VLtexCoord + vec2(-texelSize.x, -texelSize.y)); - // vec4 col4 = texture2D(colortex0, VLtexCoord + vec2(-texelSize.x, texelSize.y)); - // vec4 col5 = texture2D(colortex0, VLtexCoord + vec2( 0.0, texelSize.y)); - // vec4 col6 = texture2D(colortex0, VLtexCoord + vec2( 0.0, -texelSize.y)); - // vec4 col7 = texture2D(colortex0, VLtexCoord + vec2(-texelSize.x, 0.0)); - // vec4 col8 = texture2D(colortex0, VLtexCoord + vec2( texelSize.x, 0.0)); - - // vec4 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8)))))))); - // vec4 colMin = min(col0,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8)))))))); - - // // colMin = 0.5 * (colMin + min(col0,min(col5,min(col6,min(col7,col8))))); - // // colMax = 0.5 * (colMax + max(col0,max(col5,max(col6,max(col7,col8))))); - - vec4 frameHistory = texture2D(colortex10, previousPosition.xy*VL_RENDER_RESOLUTION); - vec4 clampedFrameHistory = frameHistory; - // vec4 clampedFrameHistory = clamp(frameHistory, colMin, colMax); - - float blendFactor = 0.25; - blendFactor = clamp(length(velocity/texelSize),blendFactor,0.2); - - // if(min(frameHistory.a,rejection) > 0.0) blendFactor = 1.0; - - return mix(clampedFrameHistory, currentFrame, blendFactor); -} - float convertHandDepth(float depth) { float ndcDepth = depth * 2.0 - 1.0; ndcDepth /= MC_HAND_DEPTH; return ndcDepth * 0.5 + 0.5; } + + +vec3 alterCoords(in vec3 coords, bool lighting){ + + float theDistance = length(coords + (lighting ? vec3(0.0) : cameraPosition)); + + coords.x = max(coords.x,0.0); + + coords.y = coords.y; + + coords.z = coords.z/3; + + return coords; +} +vec4 raymarchTest( + in vec3 viewPosition, + in vec2 dither +){ + + vec3 color = vec3(0.0); + float totalAbsorbance = 1.0; + float expFactor = 16.0; + + float minHeight = 250.0; + float maxHeight = minHeight + 100.0; + + #if defined DISTANT_HORIZONS + float maxdist = dhFarPlane - 16.0; + #else + float maxdist = far*4; + #endif + + float referenceDistance = length(viewPosition) < maxdist ? length(viewPosition) - 1.0 : 100000000.0; + + int SAMPLECOUNT = 8; + + //project pixel position into projected shadowmap space + vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz; + vec3 dVWorld = wpos - gbufferModelViewInverse[3].xyz; + vec3 dVWorldN = normalize(dVWorld); + + // dVWorld *= dVWorldN/abs(dVWorldN.y); + // float maxLength = min(length(dVWorld), 16 * 8)/length(dVWorld); + // dVWorld *= maxLength; + + // float cloudRange = max(minHeight - cameraPosition.y,0.0); + float cloudRange = max(minHeight - cameraPosition.y, 0.0); + + vec3 rayDirection = dVWorldN.xyz * ( (maxHeight - minHeight) / length(alterCoords(dVWorldN, false)) / SAMPLECOUNT); + + // float cloudRange = mix(max(cameraPosition.y - maxHeight,0.0), max(minHeight - cameraPosition.y,0.0), clamp(rayDirection.y,0.0,1.0)); + + + vec3 rayProgress = rayDirection*dither.x + cameraPosition + (rayDirection / length(alterCoords(rayDirection, false))) * 200; + + float dL = length(rayDirection); + + // vec3 rayDirection = dVWorldN.xyz * ( (maxHeight - minHeight) / abs(dVWorldN.y) / SAMPLECOUNT); + // float flip = mix(max(cameraPosition.y - maxHeight,0.0), max(minHeight - cameraPosition.y,0.0), clamp(rayDirection.y,0.0,1.0)); + // vec3 rayProgress = rayDirection*dither.x + cameraPosition + (rayDirection / abs(rayDirection.y)) *flip; + // float dL = length(rayDirection); + + + for (int i = 0; i < SAMPLECOUNT; i++) { + + if(length(rayProgress - cameraPosition) > referenceDistance) break; + + float d = (pow(expFactor, float(i + dither.x)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); + float dd = pow(expFactor, float(i + dither.y)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); + + float theDistance = length(alterCoords(rayProgress-cameraPosition, true)); + + float fogDensity = min(max(texture2D(noisetex, rayProgress.xz/2048).b-0.5,0.0)*2.0,1.0) * clamp((minHeight+50) - theDistance, 0.0, clamp(theDistance-minHeight,0,1)); + + float fogVolumeCoeff = exp(-fogDensity*dd*dL); + + // vec3 lighting = vec3(1.0) * (1.0-clamp((minHeight-50) - theDistance,0,1)); + + vec3 lighting = vec3(1.0) * clamp(minHeight - theDistance/1.2,0,1); + + color += (lighting - lighting * fogVolumeCoeff) * totalAbsorbance; + + totalAbsorbance *= fogVolumeCoeff; + + rayProgress += rayDirection; + + } + return vec4(color, totalAbsorbance); +} + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -529,13 +523,14 @@ void main() { #endif vec3 viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0); + vec3 viewPos0_water = toScreenSpace(vec3(tc/RENDER_SCALE, z0)); vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos0 + gbufferModelViewInverse[3].xyz; vec3 playerPos_normalized = normalize(playerPos); float dirtAmount = Dirt_Amount; vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; + vec3 totEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; vec3 directLightColor = lightCol.rgb / 2400.0; @@ -575,11 +570,18 @@ void main() { #endif if (isEyeInWater == 1){ - vec3 underWaterFog = waterVolumetrics(vec3(0.0), viewPos0, length(viewPos0), BN, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor , dot(normalize(viewPos0), normalize(sunVec* lightCol.a ) )); + // vec3 underWaterFog = waterVolumetrics(vec3(0.0), viewPos0, length(viewPos0), BN, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor , dot(normalize(viewPos0), normalize(sunVec* lightCol.a ) )); + // VolumetricFog = vec4(underWaterFog, 1.0); + + vec4 underWaterFog = waterVolumetrics(vec3(0.0), viewPos0_water, length(viewPos0_water), BN, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor , dot(normalize(viewPos0_water), normalize(sunVec* lightCol.a ) )); - VolumetricFog = vec4(underWaterFog, 1.0); + // VolumetricFog.rgb = underWaterFog.rgb; + VolumetricFog = vec4(underWaterFog.rgb, 1.0); } + + // VolumetricFog = raymarchTest(viewPos0, BN); + gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0); diff --git a/shaders/dimensions/composite2.vsh b/shaders/dimensions/composite2.vsh index b7de7d9..b482ef1 100644 --- a/shaders/dimensions/composite2.vsh +++ b/shaders/dimensions/composite2.vsh @@ -82,7 +82,7 @@ void main() { lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) ; - refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333); + refractedSunVec = refract(lightCol.a*WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333); #if defined LPV_VL_FOG_ILLUMINATION && defined IS_LPV_ENABLED exposure = texelFetch2D(colortex4,ivec2(10,37),0).r; diff --git a/shaders/dimensions/composite3.fsh b/shaders/dimensions/composite3.fsh index 30ac926..b02dd7b 100644 --- a/shaders/dimensions/composite3.fsh +++ b/shaders/dimensions/composite3.fsh @@ -389,9 +389,7 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){ vec2 velocity = previousPosition.xy - texcoord/RENDER_SCALE; previousPosition.xy = texcoord + velocity; - // vec4 currentFrame = texture2D_bicubic(colortex0, VLtexCoord); - vec4 currentFrame = texture2D(colortex0, VLtexCoord ); - // vec4 currentFrame = texelFetch2D(colortex0, ivec2(VLtexCoord/texelSize),0); + vec4 currentFrame = texture2D(colortex0, VLtexCoord); if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return currentFrame; @@ -406,29 +404,13 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){ vec4 colMax = max(currentFrame,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8)))))))); vec4 colMin = min(currentFrame,min(col1,min(col2,min(col3, min(col4, min(col5, min(col6, min(col7, col8)))))))); - - // colMin = 0.5 * (colMin + min(currentFrame,min(col5,min(col6,min(col7,col8))))); - // colMax = 0.5 * (colMax + max(currentFrame,max(col5,max(col6,max(col7,col8))))); - - // vec4 col0 = texture(colortex0, VLtexCoord + vec2( texelSize.x, 0.0)); - // vec4 col1 = texture(colortex0, VLtexCoord + vec2( 0.0, texelSize.y)); - // vec4 col2 = texture(colortex0, VLtexCoord + vec2(-texelSize.x, 0.0)); - // vec4 col3 = texture(colortex0, VLtexCoord + vec2( 0.0, -texelSize.y)); - - // vec4 colMin = min(currentFrame, min(col0, min(col1, min(col2, col3)))); - // vec4 colMax = max(currentFrame, max(col0, max(col1, max(col2, col3)))); vec4 frameHistory = texture2D(colortex10, previousPosition.xy); vec4 clampedFrameHistory = clamp(frameHistory, colMin, colMax); float blendingFactor = 0.1; - // if((min(max(clampedFrameHistory.a - frameHistory.a,0.0) / 0.0000001, 1.0)) > 0.0) blendingFactor = 1.0; - - // if(abs(clampedFrameHistory.a-frameHistory.a) > 0.1 && abs(currentFrame.a-frameHistory.a) > 0.1) blendingFactor = 1.0; - // if(abs(currentFrame.a - frameHistory.a) > 0.6) blendingFactor = 1.0; if(abs(clampedFrameHistory.a - frameHistory.a) > 0.1) blendingFactor = 1.0; - // blendingFactor = clamp(blendingFactor + abs(clampedFrameHistory.a - frameHistory.a),0.0,1.0); // DEBUG = abs(clampedFrameHistory.a - frameHistory.a) > 0.1 ? 0. : 1.0; // DEBUG = clamp(abs(clampedFrameHistory.a - frameHistory.a),0.0,1.0); @@ -436,6 +418,8 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){ return clamp(mix(clampedFrameHistory, currentFrame, blendingFactor),0.0,65000.0); } +uniform float waterEnteredAltitude; + void main() { /* RENDERTARGETS:7,3,10 */ @@ -468,9 +452,13 @@ void main() { vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth0); vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + vec3 playerPos_normalized = normVec(playerPos); vec3 playerPos222 = mat3(gbufferModelViewInverse) * toScreenSpace_DH(texcoord/RENDER_SCALE, 1.0,1.0) + gbufferModelViewInverse[3].xyz ; + vec3 viewPos_alt = toScreenSpace(vec3(texcoord/RENDER_SCALE, z2)); + vec3 playerPos_alt = mat3(gbufferModelViewInverse) * viewPos_alt + gbufferModelViewInverse[3].xyz; + float linearDistance = length(playerPos); float linearDistance_cylinder = length(playerPos.xz); @@ -484,10 +472,14 @@ void main() { ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// vec4 data = texelFetch2D(colortex11,ivec2(texcoord/texelSize),0).rgba; vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; - vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; + vec4 unpack1 = vec4(decodeVec2(data.b),decodeVec2(data.a)) ; vec4 albedo = vec4(unpack0.ba,unpack1.rg); vec2 tangentNormals = unpack0.xy*2.0-1.0; + + bool nameTagMask = abs(unpack1.a - 0.1) < 0.01; + float nametagbackground = nameTagMask ? 0.25 : 1.0; + if(albedo.a < 0.01) tangentNormals = vec2(0.0); @@ -522,7 +514,7 @@ void main() { // #endif // vec4 temporallyFilteredVL = vl; - // vec4 temporallyFilteredVL = texture2D(colortex10, texcoord*VL_RENDER_RESOLUTION); + // temporallyFilteredVL = texture2D(colortex0, texcoord*VL_RENDER_RESOLUTION); float bloomyFogMult = 1.0; @@ -542,11 +534,11 @@ void main() { vec4 TranslucentShader = texture2D(colortex2, texcoord); // color = vec3(texcoord-0.5,0.0) * mat3(gbufferModelViewInverse); // apply block breaking effect. - if(albedo.a > 0.01 && !isWater && TranslucentShader.a <= 0.0 && !isEntity) color = mix(color*6.0, color, luma(albedo.rgb)) * albedo.rgb; + // if(albedo.a > 0.01 && !isWater && TranslucentShader.a <= 0.0 && !isEntity) color = mix(color*6.0, color, luma(albedo.rgb)) * albedo.rgb; ////// --------------- BLEND TRANSLUCENT GBUFFERS //////////// and do border fog on opaque and translucents - + #if defined BorderFog #ifdef DISTANT_HORIZONS float fog = smoothstep(1.0, 0.0, min(max(1.0 - linearDistance_cylinder / dhRenderDistance,0.0)*3.0,1.0) ); @@ -571,17 +563,20 @@ void main() { float fog = 0.0; #endif + + if (TranslucentShader.a > 0.0){ #ifdef Glass_Tint - if(!isWater) color *= mix(normalize(albedo.rgb+1e-7), vec3(1.0), max(fog, min(max(0.1-albedo.a,0.0) * 10.0,1.0))) ; + // if(!isWater) color *= mix(normalize(albedo.rgb+1e-7), vec3(1.0), max(fog, min(max(0.1-albedo.a,0.0) * 10.0,1.0))) ; #endif - #ifdef BorderFog - TranslucentShader = mix(TranslucentShader, vec4(0.0), fog); - #endif - + // #ifdef BorderFog + // TranslucentShader = mix(TranslucentShader, vec4(0.0), fog); + // #endif + + color *= (1.0-TranslucentShader.a); - color += TranslucentShader.rgb*10.0; + color += TranslucentShader.rgb*10.0 ; } ////// --------------- VARIOUS FOG EFFECTS (behind volumetric fog) @@ -611,36 +606,40 @@ void main() { ////// --------------- underwater fog if (isEyeInWater == 1){ - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; + // float dirtAmount = Dirt_Amount; + // vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); + // vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); + vec3 totEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);// dirtEpsilon*dirtAmount + waterEpsilon; + vec3 scatterCoef = Dirt_Amount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; - vec3 absorption = exp(-2.0 * totEpsilon * linearDistance); - vec3 fixedAbsorption = exp(-30.0 * totEpsilon) ; - vec3 finalAbsorption = (absorption + fixedAbsorption * 5.0 * (1.0 + nightVision*10)); - // vec3 finalAbsorption = absorption; + float distanceFromWaterSurface = normalize(playerPos).y + 1.0 + (cameraPosition.y - waterEnteredAltitude)/waterEnteredAltitude; + distanceFromWaterSurface = clamp(distanceFromWaterSurface, 0.0,1.0); - linearDistance = length(vec3(playerPos.x,max(-playerPos.y,0.0),playerPos.z)); + vec3 transmittance = exp(-totEpsilon * linearDistance); + color.rgb *= transmittance; - // in vanilla, the water fog has a max distance of ~7 chunks - float fogfade = max(1.0 - linearDistance / min(far, 16.0*7.0), 0.0); - fogfade *= fogfade; - // fogfade = exp(-5.0* (1.0-fogfade)); + vec3 transmittance2 = exp(-totEpsilon * 25.0); + float fogfade = 1.0 - max((1.0 - linearDistance / min(far, 16.0*7.0) ),0); + color.rgb += (transmittance2 * scatterCoef) * fogfade; - color.rgb = mix(fixedAbsorption, color.rgb * finalAbsorption, fogfade); - // color.rgb = color.rgb * finalAbsorption; - - bloomyFogMult *= 0.4; + + bloomyFogMult *= 0.5; } ////// --------------- BLEND FOG INTO SCENE //////////// apply VL fog over opaque and translucents bloomyFogMult *= temporallyFilteredVL.a; - color *= temporallyFilteredVL.a; - color += temporallyFilteredVL.rgb; + + #if defined IS_IRIS + color *= min(temporallyFilteredVL.a + (1-nametagbackground),1.0); + color += temporallyFilteredVL.rgb * nametagbackground; + #else + color *= temporallyFilteredVL.a ; + color += temporallyFilteredVL.rgb ; + #endif + + // color.rgb = vec3(nameTagMask); ////// --------------- VARIOUS FOG EFFECTS (in front of volumetric fog) //////////// blindness, nightvision, liquid fogs and misc fogs @@ -690,6 +689,7 @@ void main() { // color.rgb = vec3(DEBUG); gl_FragData[0].r = bloomyFogMult; // pass fog alpha so bloom can do bloomy fog gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0); + // gl_FragData[1].rgb = vec3(tangentNormals.xy,0.0) * 0.1 ; // gl_FragData[1].rgb = vec3(1.0) * ld( (data.a > 0.0 ? data.a : texture2D(depthtex0, texcoord).x ) ) ; // gl_FragData[1].rgb = gl_FragData[1].rgb * (1.0-TranslucentShader.a) + TranslucentShader.rgb*10.0; diff --git a/shaders/dimensions/composite5.fsh b/shaders/dimensions/composite5.fsh index d060192..2195335 100644 --- a/shaders/dimensions/composite5.fsh +++ b/shaders/dimensions/composite5.fsh @@ -419,8 +419,7 @@ vec4 computeTAA(vec2 texcoord, bool hand){ if(hand) blendingFactor = clamp(length(velocity/texelSize),blendingFactor,1.0); ////// Increases blending factor when far from AABB, reduces ghosting - // blendingFactor = min(blendingFactor + luma(min(max(clampedframeHistory-frameHistory,0.0) / frameHistory, 1.0)),1.0); - // blendingFactor = min(blendingFactor + luma(abs(clampedframeHistory - frameHistory)/clampedframeHistory) ,1.0); + blendingFactor = clamp(blendingFactor + luma(abs(clampedframeHistory - frameHistory)/clampedframeHistory),0.0,1.0); // if(luma(abs(clampedframeHistory - frameHistory)) > 0.01) blendingFactor = 1.0; diff --git a/shaders/dimensions/deferred.fsh b/shaders/dimensions/deferred.fsh index a65ccea..2e8de45 100644 --- a/shaders/dimensions/deferred.fsh +++ b/shaders/dimensions/deferred.fsh @@ -44,8 +44,9 @@ uniform vec3 sunPosition; uniform vec3 cameraPosition; // uniform float far; uniform ivec2 eyeBrightnessSmooth; +// uniform ivec2 eyeBrightness; uniform float caveDetection; - +uniform int isEyeInWater; vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.); @@ -53,6 +54,7 @@ vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.); #include "/lib/ROBOBO_sky.glsl" #include "/lib/sky_gradient.glsl" #include "/lib/Shadow_Params.glsl" +#include "/lib/waterBump.glsl" vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; // vec3 WsunVec = normalize(LightDir); @@ -95,6 +97,7 @@ uniform float near; uniform float dhFarPlane; uniform float dhNearPlane; + #include "/lib/DistantHorizons_projections.glsl" vec3 DH_toScreenSpace(vec3 p) { diff --git a/shaders/dimensions/fogBehindTranslucent_pass.fsh b/shaders/dimensions/fogBehindTranslucent_pass.fsh index 51cad85..2b29633 100644 --- a/shaders/dimensions/fogBehindTranslucent_pass.fsh +++ b/shaders/dimensions/fogBehindTranslucent_pass.fsh @@ -207,7 +207,7 @@ float fogPhase2(float lightPoint){ return exponential; } -vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL, float lightleakFix){ +vec4 waterVolumetrics( vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL, float lightleakFix){ int spCount = rayMarchSampleCount; vec3 start = toShadowSpaceProjected(rayStart); @@ -238,8 +238,16 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float vec3 absorbance = vec3(1.0); vec3 vL = vec3(0.0); - ambient = max(ambient * (normalize(wpos).y*0.3+0.7),0.0); + // ambient = max(ambient * (normalize(wpos).y*0.3+0.7),0.0); float expFactor = 11.0; + + vec3 sh = vec3(1.0); + + // do this outside raymarch loop, masking the water surface is good enough + #if defined VL_CLOUDS_SHADOWS && defined OVERWORLD_SHADER + sh *= GetCloudShadow(wpos+cameraPosition, WsunVec); + #endif + for (int i=0;i= 1.0) lightmap.y = 0.99; @@ -438,17 +432,9 @@ void main() { lightmap.y = 1.0; #endif - // float Vdiff = distance(viewPos1, viewPos0) * 2.0; - // float VdotU = playerPos.y; - // float estimatedDepth = Vdiff * abs(VdotU); //assuming water plane - float Vdiff = distance(viewPos1, viewPos0); float estimatedDepth = Vdiff * abs(normalize(playerPos).y); - float estimatedSunDepth = (Vdiff * 0.5) / abs(WsunVec.y); //assuming water plane - Vdiff *= 2.0; - - // Vdiff = Vdiff * (1.0 - clamp(exp(-Vdiff),0.0,1.0)) + max(estimatedDepth - 1.0,0.0); - // estimatedDepth = max(estimatedDepth - 1.0,0.0); + float estimatedSunDepth = Vdiff / abs(WsunVec.y); //assuming water plane indirectLightColor_dynamic *= ambient_brightness * lightmap.y*lightmap.y; @@ -461,24 +447,17 @@ void main() { if(!iswater){ #ifdef OVERWORLD_SHADER vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WsunVec, directLightColor, indirectLightColor); - float atmosphereAlpha = 1.0; vec4 VolumetricFog = GetVolumetricFog(viewPos1, vec2(noise_1, noise_2), directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb); - finalVolumetrics = VolumetricClouds; - - // VolumetricClouds.a *= atmosphereAlpha; + finalVolumetrics.rgb += VolumetricClouds.rgb; #endif #if defined NETHER_SHADER || defined END_SHADER vec4 VolumetricFog = GetVolumetricFog(viewPos1, noise_1, noise_2); #endif - // #if defined OVERWORLD_SHADER - // vec4 VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a); - // #endif - finalVolumetrics.rgb = finalVolumetrics.rgb * VolumetricFog.a + VolumetricFog.rgb; finalVolumetrics.a *= VolumetricFog.a; } @@ -486,9 +465,8 @@ void main() { vec4 underwaterVlFog = vec4(0,0,0,1); float lightleakfix = clamp(lightmap.y + (1-caveDetection),0.0,1.0); - if(iswater && isEyeInWater != 1) underwaterVlFog = waterVolumetrics_test(viewPos0, viewPos1, estimatedDepth, estimatedSunDepth, Vdiff, noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor, dot(normalize(viewPos1), normalize(sunVec*lightCol.a)) ,lightleakfix); - - finalVolumetrics.rgb += underwaterVlFog.rgb; + + if(iswater && isEyeInWater != 1) finalVolumetrics = waterVolumetrics(viewPos0, viewPos1, estimatedDepth, estimatedSunDepth, Vdiff, noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor, dot(normalize(viewPos1), normalize(sunVec*lightCol.a)) ,lightleakfix); gl_FragData[0] = clamp(finalVolumetrics, 0.0, 65000.0); } diff --git a/shaders/entity.properties b/shaders/entity.properties index cc4f665..04086cd 100644 --- a/shaders/entity.properties +++ b/shaders/entity.properties @@ -1,3 +1,6 @@ +entity.1599 = minecraft:entity_shadow +entity.1600=minecraft:name_tag + entity.1601=player entity.1602=minecraft:lightning_bolt weather2:lightning_bolt diff --git a/shaders/lang/en_us.lang b/shaders/lang/en_us.lang index 63564b5..0fd323f 100644 --- a/shaders/lang/en_us.lang +++ b/shaders/lang/en_us.lang @@ -510,7 +510,10 @@ option.AEROCHROME_MODE.comment = Infrared Film. Google "Aerochrome" to get an id option.AEROCHROME_PINKNESS.comment = Higher = Pink. Lower = Red option.AEROCHROME_WOOL_ENABLED.comment = Technically wool things should be affected but it ruins a lot of builds. Enable to be more technically correct. - +value.DIMENSION_FALLBACK_SHADER.0 = overworld shader as fallback +value.DIMENSION_FALLBACK_SHADER.1 = nether shader as fallback +value.DIMENSION_FALLBACK_SHADER.2 = end shader as fallback +value.DIMENSION_FALLBACK_SHADER.3 = no shader as fallback diff --git a/shaders/lib/Shadows.glsl b/shaders/lib/Shadows.glsl index c5cf4d5..74d649d 100644 --- a/shaders/lib/Shadows.glsl +++ b/shaders/lib/Shadows.glsl @@ -23,7 +23,7 @@ void GriAndEminShadowFix( // stop lightleaking by zooming up, centered on blocks vec2 scale = vec2(0.5); scale.y *= 0.5; vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y*0.1); - if(SkyLightmap < 0.1 && isEyeInWater != 1 && VanillaAO > 0.0) Bias = zoomShadow; + if(SkyLightmap < 0.1 && isEyeInWater != 1) Bias = zoomShadow; WorldPos += Bias; } \ No newline at end of file diff --git a/shaders/lib/indirect_lighting_effects.glsl b/shaders/lib/indirect_lighting_effects.glsl index f128ca1..12a889d 100644 --- a/shaders/lib/indirect_lighting_effects.glsl +++ b/shaders/lib/indirect_lighting_effects.glsl @@ -92,50 +92,6 @@ vec4 BilateralUpscale_SSAO(sampler2D tex, sampler2D depth, vec2 coord, float ref return RESULT / SUM; } -float ScreenSpace_SSS( - vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise -){ - if(hand) return 0.0; - int samples = 7; - float occlusion = 0.0; - float sss = 0.0; - - - float dist = 1.0 + clamp(viewPos.z*viewPos.z/50.0,0,5); // shrink sample size as distance increases - float mulfov2 = gbufferProjection[1][1]/(3 * dist); - - float maxR2_2 = viewPos.z*viewPos.z*mulfov2*2.*2./50.0; - - float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1); - if(leaves) maxR2_2 = mix(10, maxR2_2, dist3); - - - vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ; - - int n = 0; - for (int i = 0; i < samples; i++) { - - vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2; - - ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE); - - if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) { - vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize, texelFetch2D(depthtex1, offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) ); - vec3 vec = (t0.xyz - viewPos); - float dsquared = dot(vec, vec); - - if (dsquared > 1e-5){ - if(dsquared > maxR2_2){ - float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.); - sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0); - } - n += 1; - } - } - } - return max(1.0 - sss/n, 0.0); -} - //////////////////////////////////////////////////////////////////// ///////////////////////////// RTAO/SSGI //////////////////////// //////////////////////////////////////////////////////////////////// @@ -177,51 +133,7 @@ vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ } return vec3(1.1); } -// vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ -// vec3 clipPosition = toClipSpace3(position); -// float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? -// (-near -position.z) / dir.z : far*sqrt(3.); -// vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space -// direction.xy = normalize(direction.xy); - -// //get at which length the ray intersects with the edge of the screen -// vec3 maxLengths = (step(0.0,direction)-clipPosition) / direction; -// float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z); - -// vec3 stepv = (direction * mult) / quality*vec3(RENDER_SCALE,1.0); -// vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0); - -// spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE ; - -// spos += stepv*dither; - -// float minZ = spos.z; -// float maxZ = spos.z; - -// for(int i = 0; i < int(quality); i++){ -// if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1); - -// #ifdef UseQuarterResDepth -// float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0)); -// #else -// float sp = texelFetch2D(depthtex1,ivec2(spos.xy/ texelSize),0).r; -// #endif - -// float currZ = linZ(spos.z); -// float nextZ = linZ(sp); - -// if(nextZ < currZ && (sp <= max(minZ,maxZ) && sp >= min(minZ,maxZ))) return vec3(spos.xy/RENDER_SCALE,sp); - -// float biasamount = 0.00005; - -// minZ = maxZ - biasamount / currZ; -// maxZ += stepv.z; - -// spos += stepv; -// } -// return vec3(1.1); -// } float convertHandDepth_3(in float depth, bool hand) { if(!hand) return depth; @@ -229,6 +141,7 @@ float convertHandDepth_3(in float depth, bool hand) { ndcDepth /= MC_HAND_DEPTH; return ndcDepth * 0.5 + 0.5; } + vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes, bool hand){ float dist = 1.0 + clamp(position.z*position.z,0,2); // shrink sample size as distance increases @@ -305,9 +218,13 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(noise-0.5); spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE; + float ascribeAmount = 255.0 * 1.0 * (1.0 / viewHeight) * gbufferProjectionInverse[1].y; + float minZ = spos.z; float maxZ = spos.z; CURVE = 0.0; + + bool intersected = false; for(int i = 0; i < iterations; i++){ if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1); @@ -324,11 +241,11 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha float biasamount = 0.00005; - minZ = maxZ-biasamount / currZ; + minZ = maxZ; maxZ += stepv.z; spos += stepv; - + CURVE += 1.0/iterations; } return vec3(1.1); @@ -384,7 +301,7 @@ vec3 ApplySSRT( #endif #else #ifdef OVERWORLD_SHADER - skycontribution = unchangedIndirect * (max(rayDir.y,pow(1.0-lightmap,2))*0.95+0.05); + skycontribution = unchangedIndirect;// * (max(rayDir.y,pow(1.0-lightmap,2))*0.95+0.05); #endif #endif diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 9e71e35..b7453f8 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -11,15 +11,15 @@ #define WATER_WAVE_SPEED 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0] #define Dirt_Amount 0.14 // [0.0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1.0 1.04 1.08 1.12 1.16 1.2 1.24 1.28 1.32 1.36 1.4 1.44 1.48 1.52 1.56 1.6 1.64 1.68 1.72 1.76 1.8 1.84 1.88 1.92 1.96 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0] -#define Dirt_Scatter_R 0.6 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] -#define Dirt_Scatter_G 0.9 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] -#define Dirt_Scatter_B 0.9 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] +#define Dirt_Scatter_R 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] +#define Dirt_Scatter_G 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] +#define Dirt_Scatter_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ] #define Dirt_Absorb_R 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] #define Dirt_Absorb_G 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] #define Dirt_Absorb_B 1.0 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] -#define Water_Absorb_R 0.25 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ] -#define Water_Absorb_G 0.05 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ] -#define Water_Absorb_B 0.01 // [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ] +#define Water_Absorb_R 0.392389 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] +#define Water_Absorb_G 0.108329 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] +#define Water_Absorb_B 0.0660636 // [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ] #define MINIMUM_WATER_ABSORBANCE -1 // [-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 60 70 80 90 100] #define rayMarchSampleCount 2 // [1 2 3 4 6 8 12 16 32 64] @@ -209,7 +209,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0. #undef DISTANT_HORIZONS #endif -#define SEA_LEVEL 70 // [0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190] +#define SEA_LEVEL 62 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200] ////////////////////////////////////////////////////// // ----- BIOME SPECIFIC ENVIORNMENTS SETTINGS ----- // @@ -714,6 +714,10 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) // #define PLANET_CURVATURE #define CURVATURE_AMOUNT 1.0 // [-10.0 -9.0 -8.0 -7.0 -6.0 -5.0 -4.0 -3.0 -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0] +// #define OLD_INDIRECT_SSS + +#define DIMENSION_FALLBACK_SHADER 0 // [0 1 2 3] + /////////////////////////////////////////// // ----- DISTANT HORIZONS SETTINGS ----- // /////////////////////////////////////////// diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index 9f490ed..714a09b 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -1,31 +1,3 @@ -// uniform int framemod8; - -// const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), -// vec2(-1.,3.)/8., -// vec2(5.0,1.)/8., -// vec2(-3,-5.)/8., -// vec2(-5.,5.)/8., -// vec2(-7.,-1.)/8., -// vec2(3,7.)/8., -// vec2(7.,-7.)/8.); - -vec3 lerp(vec3 X, vec3 Y, float A){ - return X * (1.0 - A) + Y * A; -} - -float lerp(float X, float Y, float A){ - return X * (1.0 - A) + Y * A; -} - -float square(float x){ - return x*x; -} - - - -// vec3 toClipSpace3(vec3 viewSpacePosition) { -// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -// } float invLinZ (float lindepth){ return -((2.0*near/lindepth)-far-near)/(far-near); } @@ -120,22 +92,10 @@ float shlickFresnelRoughness(float XdotN, float roughness){ float shlickFresnel = clamp(1.0 + XdotN,0.0,1.0); - // shlickFresnel = pow(1.0-pow(1.0-shlickFresnel, mix(1.0,2.1,roughness)), mix(5.0,3.0,roughness)); - // shlickFresnel = mix(0.0, mix(1.0,0.065,1-pow(1-roughness,3.5)), shlickFresnel); - - - // float curves = 1.0-exp(-1.3*roughness); - // float brightness = 1.0-exp(-4.0*roughness); - float curves = exp(-4.0*pow(1-(roughness),2.5)); float brightness = exp(-3.0*pow(1-sqrt(roughness),3.50)); - shlickFresnel = pow(1.0-pow(1.0-shlickFresnel, mix(1.0, 1.9, curves)),mix(5.0, 2.6, curves)); - - - - shlickFresnel = mix(0.0, mix(1.0,0.065, brightness) , clamp(shlickFresnel,0.0,1.0)); return shlickFresnel; @@ -159,15 +119,13 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(dither-0.5); - #ifndef FORWARD_SPECULAR + #ifdef DEFERRED_SPECULAR spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; #endif float minZ = spos.z; float maxZ = spos.z; - - for (int i = 0; i <= int(quality); i++) { float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0)); @@ -344,14 +302,6 @@ vec3 specularReflections( bool isMetal = f0 > 229.5/255.0; - // #ifndef FORWARD_SPECULAR - // // underwater, convert from f0 air, to ior, then back to f0 water - // if(!isMetal || isWater){ - // f0 = 2.0 / (1.0 - sqrt(f0)) - 1.0; - // f0 = clamp(pow((1.33 - f0) / (1.33 + f0), 2.0),0.0,1.0); - // } - // #endif - // get reflected vector mat3 basis = CoordBase(normal); vec3 viewDir = -playerPos*basis; @@ -397,6 +347,8 @@ vec3 specularReflections( vec3 backgroundReflection = volumetricsFromTex(reflectedVector_L, colortex4, roughness).rgb / 1200.0; #else vec3 backgroundReflection = skyCloudsFromTex(reflectedVector_L, colortex4).rgb / 1200.0; + + if(isEyeInWater == 1) backgroundReflection *= exp(-vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B) * 15.0)*2; #endif #endif @@ -411,6 +363,7 @@ vec3 specularReflections( // composite all the different reflections together #if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION + specularReflections = mix(DarkenedDiffuseLighting, backgroundReflection, lightmap); #endif @@ -431,155 +384,4 @@ vec3 specularReflections( #endif return specularReflections; -} -/* -void DoSpecularReflections( - inout vec3 Output, - - vec3 FragPos, // toScreenspace(vec3(screenUV, depth) - vec3 WorldPos, - vec3 LightPos, // should be in world space - vec2 Noise, // x = bluenoise z = interleaved gradient noise - - vec3 Normal, // normals in world space - float Roughness, // red channel of specular texture _S - float F0, // green channel of specular texture _S - - vec3 Albedo, - vec3 Diffuse, // should contain the light color and NdotL. and maybe shadows. - - float Lightmap, // in anything other than world0, this should be 1.0; - bool Hand // mask for the hand -){ - vec3 Final_Reflection = Output; - vec3 Background_Reflection = Output; - vec3 Lightsource_Reflection = vec3(0.0); - vec4 SS_Reflections = vec4(0.0); - float reflectLength = 0.0; - - Lightmap = clamp((Lightmap-0.8)*7.0, 0.0,1.0); - - Roughness = 1.0 - Roughness; Roughness *= Roughness; - F0 = F0 == 0.0 ? 0.02 : F0; - - // F0 = 230.0/255.0; - // Roughness = 0.0; - - // F0 = 230.0/255.0; - bool isMetal = F0 > 229.5/255.0; - - // underwater, convert from f0 air, to ior, then back to f0 water - // if(!isMetal){ - // F0 = 2.0 / (1.0 - sqrt(F0)) - 1.0; - // F0 = clamp(pow((1.33 - F0) / (1.33 + F0), 2.0),0.0,1.0); - // } - // Roughness = 0.0; - - mat3 Basis = CoordBase(Normal); - vec3 ViewDir = -WorldPos*Basis; - - #ifdef Rough_reflections - vec3 SamplePoints = SampleVNDFGGX(ViewDir, Roughness, Noise.xy); - // vec3 SamplePoints = SampleVNDFGGX(ViewDir, vec2(0.1), Noise.x); - if(Hand) SamplePoints = vec3(0.0,0.0,1.0); - #else - vec3 SamplePoints = vec3(0.0,0.0,1.0); - #endif - - - vec3 Ln = reflect(-ViewDir, SamplePoints); - vec3 L = Basis * Ln; - - float Fresnel = pow(clamp(1.0 + dot(-Ln, SamplePoints),0.0,1.0),5.0); // Schlick's approximation - // F0 < 230 dialectrics - // F0 >= 230 hardcoded metal f0 - // F0 == 255 use albedo for f0 - Albedo = F0 == 1.0 ? sqrt(Albedo) : Albedo; - - vec3 metalAlbedoTint = isMetal ? Albedo : vec3(1.0); - // metalAlbedoTint = vec3(1.0); - // get F0 values for hardcoded metals. - vec3 hardCodedMetalsF0 = F0 == 1.0 ? Albedo : HCM_F0[int(max(F0*255.0 - 229.5,0.0))]; - - vec3 reflectance = isMetal ? hardCodedMetalsF0 : vec3(F0); - - vec3 f0 = (reflectance + (1.0-reflectance) * Fresnel) * metalAlbedoTint; - - // reflectance = mix(vec3(F0), vec3(1.0), Fresnel); - - // vec3 reflectance = mix(R0, vec3(1.0), Fresnel); // ensure that when the angle is 0 that the correct F0 is used. - - // #ifdef Rough_reflections - // if(Hand) Fresnel = Fresnel * pow(1.0-Roughness,F0 > 229.5/255.0 ? 1.0 : 3.0); - // #else - // Fresnel = Fresnel * pow(1.0-Roughness,3.0); - // #endif - - bool hasReflections = Roughness_Threshold == 1.0 ? true : F0 * (1.0 - Roughness * Roughness_Threshold) > 0.01; - - // mulitply all reflections by the albedo if it is a metal. - // vec3 Metals = F0 > 229.5/255.0 ? normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3) : vec3(1.0); - // vec3 Metals = F0 > 229.5/255.0 ? Albedo : vec3(1.0); - - // --------------- BACKGROUND REFLECTIONS - // apply background reflections to the final color. make sure it does not exist based on the lightmap - #ifdef Sky_reflection - - #ifdef OVERWORLD_SHADER - if(hasReflections) Background_Reflection = (skyCloudsFromTex(L, colortex4).rgb / 1200.0) ; - #else - if(hasReflections) Background_Reflection = (volumetricsFromTex(L, colortex4, sqrt(Roughness) * 6.0).rgb / 1200.0) ; - #endif - - // take fresnel and lightmap levels into account and write to the final color - // the minimum color being the output is for when the background reflection color is close to dark, it will fallback to a dimmed diffuse - // Final_Reflection = mix(Output, Background_Reflection, Lightmap * reflectance); - Final_Reflection = mix(Output, mix(isMetal ? vec3(0.0) : Output, Background_Reflection, f0 * Lightmap), Lightmap); - // Final_Reflection = Background_Reflection * reflectance; - #endif - - // --------------- SCREENSPACE REFLECTIONS - // apply screenspace reflections to the final color and mask out background reflections. - #ifdef Screen_Space_Reflections - if(hasReflections){ - - float SSR_Quality =reflection_quality;// mix(6.0, reflection_quality, Fresnel); // Scale quality with fresnel - - vec3 RaytracePos = rayTraceSpeculars(mat3(gbufferModelView) * L, FragPos, Noise.y, float(SSR_Quality), Hand, reflectLength); - float LOD = clamp(pow(reflectLength, pow(1.0-sqrt(Roughness),5.0) * 3.0) * 6.0, 0.0, 6.0); // use higher LOD as the reflection goes on, to blur it. this helps denoise a little. - // float LOD = clamp((1-pow(clamp(1.0-reflectLength,0,1),5.0)) * 6.0, 0.0, 6.0); // use higher LOD as the reflection goes on, to blur it. this helps denoise a little. - - if(Roughness <= 0.0) LOD = 0.0; - - // LOD = 0.0; - - if (RaytracePos.z < 1.0){ - vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(RaytracePos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; - previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; - previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; - - if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) { - SS_Reflections.a = 1.0; - SS_Reflections.rgb = texture2DLod(colortex5, previousPosition.xy, LOD).rgb; - } - } - // make sure it takes the fresnel into account for SSR. - SS_Reflections.rgb = mix(isMetal ? vec3(0.0) : Output, SS_Reflections.rgb, f0); - - // occlude the background with the SSR and write to the final color. - Final_Reflection = mix(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a); - } - #endif - - // --------------- LIGHTSOURCE REFLECTIONS - // slap the main lightsource reflections to the final color. - #ifdef LIGHTSOURCE_REFLECTION - Lightsource_Reflection = Diffuse * GGX(Normal, -WorldPos, LightPos, Roughness, reflectance, metalAlbedoTint) * Sun_specular_Strength; - Final_Reflection += Lightsource_Reflection; - #endif - - Output = Final_Reflection; - - // Output = exp(-100 * (reflectLength*reflectLength*reflectLength)) * vec3(1.0); -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index 4909d38..7c9b514 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -351,11 +351,14 @@ vec3 getRayOrigin( float minHeight, float maxHeight ){ + + vec3 cloudDist = vec3(1.0); cloudDist.xz = vec2(25.0); // allow passing through/above/below the plane without limits float flip = mix(max(cameraPos.y - maxHeight,0.0), max(minHeight - cameraPos.y,0.0), clamp(rayStartPos.y,0.0,1.0)); // orient the ray to be a flat plane facing up/down - vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/abs(rayStartPos.y)) * flip; + // vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/abs(rayStartPos.y)) * flip; + vec3 position = rayStartPos*dither + cameraPos + (rayStartPos/length(rayStartPos/cloudDist)) * flip; return position; } @@ -382,7 +385,7 @@ vec4 GetVolumetricClouds( float heightRelativeToClouds = clamp(1.0 - max(cameraPosition.y - minHeight,0.0) / 100.0 ,0.0,1.0); #if defined DISTANT_HORIZONS - float maxdist = dhFarPlane; + float maxdist = dhFarPlane - 16.0; #else float maxdist = far + 16.0*5.0; #endif @@ -402,7 +405,9 @@ vec4 GetVolumetricClouds( // int samples = 30; ///------- setup the ray - vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples); + vec3 cloudDist = vec3(1.0); cloudDist.xz *= 25.0; + // vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples); + vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples); vec3 rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight); ///------- do color stuff outside of the raymarcher loop @@ -419,6 +424,8 @@ vec4 GetVolumetricClouds( // sunScattering *= rayleighScatter; float distanceFade = 1.0 - clamp(exp2(pow(abs(distanceEstimation.y),1.5) * -100.0),0.0,1.0)*heightRelativeToClouds; + distanceFade = 1.0; + // - pow(1.0-clamp(signedSunVec.y,0.0,1.0),5.0) skyScattering *= mix(1.0, 2.0, distanceFade); sunScattering *= distanceFade; @@ -439,7 +446,7 @@ vec4 GetVolumetricClouds( minHeight = CloudLayer1_height; maxHeight = cloudheight + minHeight; - rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples); + rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples); rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight); if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM); @@ -453,7 +460,7 @@ vec4 GetVolumetricClouds( minHeight = CloudLayer2_height; maxHeight = cloudheight + minHeight; - rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)); + rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)); rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight); if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM); diff --git a/shaders/shaders.properties b/shaders/shaders.properties index bc97f73..cc62380 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -347,9 +347,9 @@ SHADER_VERSION_LABEL \ ######## MISC SETTINGS - screen.Misc_Settings = [EXPERIMENTAL_STUFF] DEBUG_VIEW [the_end_orb] display_LUT WhiteWorld SSS_view ambientLight_only LIGHTNING_FLASH DISABLE_ENCHANT_GLINT DISABLE_VANILLA_EMISSIVES PARTICLE_RENDERING_FIX TRANSLUCENT_ENTITIES LIGHTING_EFFECTS_BLUR_FILTER [selection_box_outline] + screen.Misc_Settings = [EXPERIMENTAL_STUFF] DEBUG_VIEW [the_end_orb] display_LUT WhiteWorld SSS_view ambientLight_only LIGHTNING_FLASH DISABLE_ENCHANT_GLINT DISABLE_VANILLA_EMISSIVES PARTICLE_RENDERING_FIX TRANSLUCENT_ENTITIES LIGHTING_EFFECTS_BLUR_FILTER [selection_box_outline] DIMENSION_FALLBACK_SHADER - screen.EXPERIMENTAL_STUFF = CLOUDS_INTERSECT_TERRAIN BLOOMY_PARTICLES ORIGINAL_CHOCAPIC_SKY BIOME_TINT_WATER HYPER_DETAILED_WAVES OLD_BLOOM PLANET_GROUND_BRIGHTNESS LIT_PARTICLE_BRIGHTNESS WATER_CAUSTICS_BRIGHTNESS OLD_CAVE_DETECTION FORCE_TRANSLUCENT_GLASS LARGE_WAVE_DISPLACEMENT + screen.EXPERIMENTAL_STUFF = CLOUDS_INTERSECT_TERRAIN BLOOMY_PARTICLES ORIGINAL_CHOCAPIC_SKY BIOME_TINT_WATER HYPER_DETAILED_WAVES OLD_BLOOM PLANET_GROUND_BRIGHTNESS LIT_PARTICLE_BRIGHTNESS WATER_CAUSTICS_BRIGHTNESS OLD_CAVE_DETECTION FORCE_TRANSLUCENT_GLASS LARGE_WAVE_DISPLACEMENT OLD_INDIRECT_SSS screen.the_end_orb.columns = 1 screen.the_end_orb = THE_ORB ORB_X ORB_Y ORB_Z ORB_ColMult ORB_R ORB_G ORB_B @@ -513,7 +513,16 @@ uniform.bool.worldTimeChangeCheck = abs(smooth(sunAngle, 1.0, 1.0) - sunAngle) #endif -uniform.float.wetnessAmount = smooth(if(rainStrength>0.01, 3.0, 0.0), 100.0, 100.0) +uniform.float.wetnessAmount = smooth(if(rainStrength > 0.01, 3.0, 0.0), 100.0, 100.0) + +# the idea is to record the altitude at which you entered a body of water. +# using the smooth() function to interpolate to the newest value of eyeAltitude over time, i can make it take a very long time to interpolate. essentially freezing/unfreezing the value in place at any time i need to. + +# force water surface level to a fixed height if you entered the water from an area in low light levels (caves). if youre above the hardcoded y level, allow it use the current height +variable.float.waterEnteredLowLight = if(eyeBrightness.y < 0.004, max(eyeAltitude - 0.1, SEA_LEVEL), eyeAltitude - 0.1) + +variable.float.freezeTranstion = if(isEyeInWater == 1, 100000000000000.0, 0.0) +uniform.float.waterEnteredAltitude = smooth(eyeAltitude, freezeTranstion, freezeTranstion) # photon stuff uniform.vec2.view_res = vec2(viewWidth, viewHeight) @@ -524,7 +533,7 @@ texture.composite.colortex6 = texture/blueNoise.png variable.float.texelSizeX = 1.0/viewWidth variable.float.texelSizeY = 1.0/viewHeight -uniform.vec2.texelSize = vec2(texelSizeX,texelSizeY) +uniform.vec2.texelSize = vec2(texelSizeX,texelSizeY) #if defined RESPONSIVE_TAA uniform.int.framemod8 = frameCounter%4