From 62be2ab09780e6a3723c90222dcd988e8aa849f5 Mon Sep 17 00:00:00 2001 From: MikiP98 <79966387+MikiP98@users.noreply.github.com> Date: Sat, 16 Nov 2024 21:39:26 +0100 Subject: [PATCH] Revert "intial changes for commit #495" This reverts commit 4869877f770434bcf79509ebf6ddb87af7393d4d. --- shaders/dimensions/DH_generic.fsh | 50 - shaders/dimensions/DH_generic.vsh | 52 - shaders/dimensions/DH_solid.fsh | 57 +- shaders/dimensions/DH_solid.vsh | 38 +- shaders/dimensions/DH_translucent.fsh | 65 +- shaders/dimensions/DH_translucent.vsh | 28 +- shaders/dimensions/all_particles.fsh | 37 +- shaders/dimensions/all_particles.vsh | 14 +- shaders/dimensions/all_solid.fsh | 99 +- shaders/dimensions/all_solid.vsh | 18 +- shaders/dimensions/all_translucent.fsh | 358 ++++--- shaders/dimensions/all_translucent.vsh | 17 +- shaders/dimensions/all_vanilla_emissives.fsh | 8 +- shaders/dimensions/composite.fsh | 218 ++-- shaders/dimensions/composite.vsh | 6 - shaders/dimensions/composite1.fsh | 766 +++++--------- shaders/dimensions/composite1.vsh | 15 +- shaders/dimensions/composite10.fsh | 2 +- shaders/dimensions/composite11.fsh | 129 +-- shaders/dimensions/composite12.fsh | 37 +- shaders/dimensions/composite2.fsh | 356 ++----- shaders/dimensions/composite2.vsh | 22 +- shaders/dimensions/composite3.fsh | 404 ++------ shaders/dimensions/composite3.vsh | 2 +- shaders/dimensions/composite5.fsh | 80 +- shaders/dimensions/deferred.fsh | 97 +- shaders/dimensions/deferred.vsh | 65 +- shaders/dimensions/deferred2.fsh | 12 +- shaders/dimensions/deferred2.vsh | 14 +- shaders/dimensions/final.fsh | 79 +- .../dimensions/fogBehindTranslucent_pass.fsh | 202 +--- .../dimensions/fogBehindTranslucent_pass.vsh | 19 +- shaders/lang/en_us.lang | 12 +- shaders/lang/pt_br.lang | 4 +- shaders/lang/ru_RU.lang | 4 +- shaders/lang/zh_cn.lang | 4 +- shaders/lib/ROBOBO_sky.glsl | 8 +- shaders/lib/Shadows.glsl | 15 +- shaders/lib/TAA_jitter.glsl | 71 +- shaders/lib/climate_settings.glsl | 7 +- shaders/lib/color_transforms.glsl | 12 +- shaders/lib/diffuse_lighting.glsl | 31 +- shaders/lib/end_fog.glsl | 37 +- shaders/lib/indirect_lighting_effects.glsl | 187 ++-- shaders/lib/lpv_render.glsl | 13 +- shaders/lib/nether_fog.glsl | 10 +- shaders/lib/overworld_fog.glsl | 352 ++++++- shaders/lib/settings.glsl | 96 +- shaders/lib/sky_gradient.glsl | 64 +- shaders/lib/specular.glsl | 502 ++-------- shaders/lib/volumetricClouds.glsl | 938 +++++++++++------- shaders/shaders.properties | 63 +- shaders/world0/dh_generic.fsh | 5 - shaders/world0/dh_generic.vsh | 5 - shaders/world0/shadow.fsh | 11 +- shaders/world0/shadow.vsh | 17 +- 56 files changed, 2279 insertions(+), 3555 deletions(-) delete mode 100644 shaders/dimensions/DH_generic.fsh delete mode 100644 shaders/dimensions/DH_generic.vsh delete mode 100644 shaders/world0/dh_generic.fsh delete mode 100644 shaders/world0/dh_generic.vsh diff --git a/shaders/dimensions/DH_generic.fsh b/shaders/dimensions/DH_generic.fsh deleted file mode 100644 index c737d31..0000000 --- a/shaders/dimensions/DH_generic.fsh +++ /dev/null @@ -1,50 +0,0 @@ -#include "/lib/settings.glsl" - -varying vec4 pos; -varying vec4 gcolor; - -uniform vec2 texelSize; -uniform vec3 cameraPosition; -uniform sampler2D depthtex1; - -uniform mat4 gbufferModelViewInverse; -uniform float far; -uniform int frameCounter; - -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif -} -/* RENDERTARGETS:2 */ -void main() { -if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) { - - vec3 viewPos = pos.xyz; - vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; - - float falloff = exp(-10.0 * (1.0-clamp(1.0 - playerPos.y/5000.0,0.0,1.0))); - - - #ifdef DH_OVERDRAW_PREVENTION - #if OVERDRAW_MAX_DISTANCE == 0 - float maxOverdrawDistance = far; - #else - float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE; - #endif - - if(length(playerPos) < clamp(far-16*4, 16, maxOverdrawDistance) || texture2D(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){ discard; return;} - #endif - - - vec3 Albedo = toLinear(gcolor.rgb) ; - - gl_FragData[0] = vec4(Albedo * Emissive_Brightness * 0.1, gcolor.a); -} -} \ No newline at end of file diff --git a/shaders/dimensions/DH_generic.vsh b/shaders/dimensions/DH_generic.vsh deleted file mode 100644 index 1c1d4f2..0000000 --- a/shaders/dimensions/DH_generic.vsh +++ /dev/null @@ -1,52 +0,0 @@ -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - -varying vec4 pos; -varying vec4 gcolor; - -uniform vec2 texelSize; -uniform int framemod8; - -#if DOF_QUALITY == 5 - uniform int hideGUI; - uniform int frameCounter; - uniform float aspectRatio; - uniform float screenBrightness; - uniform float far; - #include "/lib/bokeh.glsl" -#endif - -#include "/lib/TAA_jitter.glsl" - - -void main() { - gl_Position = ftransform(); - - #ifdef TAA_UPSCALING - gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; - #endif - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif - - pos = gl_ModelViewMatrix * gl_Vertex; - gcolor = gl_Color; - - #if DOF_QUALITY == 5 - vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0); - jitter = rotate(radians(float(frameCounter))) * jitter; - jitter.y *= aspectRatio; - jitter.x *= DOF_ANAMORPHIC_RATIO; - - #if MANUAL_FOCUS == -2 - float focusMul = 0; - #elif MANUAL_FOCUS == -1 - float focusMul = gl_Position.z + (far / 3.0) - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); - #else - float focusMul = gl_Position.z + (far / 3.0) - MANUAL_FOCUS; - #endif - - vec2 totalOffset = (jitter * JITTER_STRENGTH) * focusMul * 1e-2; - gl_Position.xy += hideGUI >= 1 ? totalOffset : vec2(0); - #endif -} \ No newline at end of file diff --git a/shaders/dimensions/DH_solid.fsh b/shaders/dimensions/DH_solid.fsh index 5aeba68..ad1136c 100644 --- a/shaders/dimensions/DH_solid.fsh +++ b/shaders/dimensions/DH_solid.fsh @@ -2,7 +2,6 @@ varying vec4 pos; -varying vec4 localPos; varying vec4 gcolor; varying vec2 lightmapCoords; varying vec4 normals_and_materials; @@ -11,7 +10,6 @@ flat varying float EMISSIVE; flat varying int dh_material_id; uniform float far; -uniform float nightVision; // uniform int hideGUI; uniform mat4 gbufferModelView; uniform mat4 gbufferModelViewInverse; @@ -55,7 +53,6 @@ float encodeVec2(float x,float y){ uniform mat4 gbufferProjection; uniform mat4 gbufferProjectionInverse; -uniform vec3 cameraPosition; vec3 toScreenSpace(vec3 p) { vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); @@ -98,48 +95,7 @@ float densityAtPos(in vec3 pos){ return mix(xy.r,xy.g, f.y); } - -// https://gitlab.com/jeseibel/distant-horizons-core/-/blob/main/core/src/main/resources/shaders/flat_shaded.frag?ref_type=heads -// Property of Distant Horizons [mod] - -const int noiseSteps = 4; -const float noiseIntensity = 10.0; -const int noiseDropoff = 1024; - -float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); } -float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } -float rand(vec3 co) { return rand(co.xy + rand(co.z)); } - -vec3 quantize(const in vec3 val, const in int stepSize) { - return floor(val * stepSize) / stepSize; -} - -vec4 applyNoise(in vec4 fragColor, const in vec3 viewPos, const in float viewDist) { - // vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz))); - // // This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable - // vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001; - - float noiseAmplification = noiseIntensity * 0.01; - float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0; - noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1 - noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects - - // Random value for each position - float randomValue = rand(quantize(viewPos, noiseSteps)) - * 2.0 * noiseAmplification - noiseAmplification; - - // Modifies the color - // A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color - vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue; - newCol = clamp(newCol, 0.0, 1.0); - - if (noiseDropoff != 0) { - float distF = min(viewDist / noiseDropoff, 1.0); - newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied - } - - return vec4(newCol,1.0); -} +uniform vec3 cameraPosition; /* RENDERTARGETS:1,7,8 */ void main() { @@ -151,7 +107,7 @@ void main() { float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE; #endif - if(clamp(1.0-length(localPos.xyz)/clamp(far - 32.0,32.0,maxOverdrawDistance),0.0,1.0) > 0.0 ){ + if(clamp(1.0-length(pos.xyz)/clamp(far - 32.0,32.0,maxOverdrawDistance),0.0,1.0) > 0.0 ){ discard; return; } @@ -164,14 +120,11 @@ void main() { // PackLightmaps.y *= 1.05; PackLightmaps = min(max(PackLightmaps,0.0)*1.05,1.0); - vec4 data1 = clamp( encode(viewToWorld(normals), PackLightmaps), 0.0, 1.0); + vec4 data1 = clamp( encode(normals, PackLightmaps), 0.0, 1.0); // alpha is material masks, set it to 0.65 to make a DH LODs mask. - #ifdef DH_NOISE_TEXTURE - vec4 Albedo = applyNoise(gcolor, localPos.rgb+cameraPosition, length(localPos.xyz)); - #else - vec4 Albedo = vec4(gcolor.rgb, 1.0); - #endif + vec4 Albedo = vec4(gcolor.rgb, 1.0); + // vec3 worldPos = mat3(gbufferModelViewInverse)*pos.xyz + cameraPosition; // worldPos = (worldPos*vec3(1.0,1./48.,1.0)/4) ; // worldPos = floor(worldPos * 4.0 + 0.001) / 32.0; diff --git a/shaders/dimensions/DH_solid.vsh b/shaders/dimensions/DH_solid.vsh index 38e1e37..bab0fb9 100644 --- a/shaders/dimensions/DH_solid.vsh +++ b/shaders/dimensions/DH_solid.vsh @@ -2,14 +2,12 @@ #include "/lib/res_params.glsl" varying vec4 pos; -varying vec4 localPos; varying vec4 gcolor; varying vec2 lightmapCoords; varying vec4 normals_and_materials; flat varying float SSSAMOUNT; flat varying float EMISSIVE; flat varying int dh_material_id; -uniform float nightVision; uniform vec2 texelSize; uniform int framemod8; @@ -27,9 +25,9 @@ uniform float far; +/* uniform mat4 gbufferModelViewInverse; uniform mat4 gbufferModelView; - uniform float far; uniform mat4 dhProjection; uniform vec3 cameraPosition; @@ -39,45 +37,38 @@ uniform vec3 cameraPosition; vec4 toClipSpace3(vec3 viewSpacePosition) { return vec4(projMAD(dhProjection, viewSpacePosition),-viewSpacePosition.z); } +*/ #define SEASONS_VSH #define DH_SEASONS #include "/lib/climate_settings.glsl" void main() { + gl_Position = ftransform(); - // vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - // vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; - // #ifdef PLANET_CURVATURE - // float curvature = length(worldpos) / (16*8); - // worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; - // #endif - // position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; + /* + vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; + vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; - // gl_Position = toClipSpace3(position); - - vec4 vPos = gl_Vertex; - - vec3 cameraOffset = fract(cameraPosition); - vPos.xyz = floor(vPos.xyz + cameraOffset + 0.5) - cameraOffset; - - vec4 viewPos = gl_ModelViewMatrix * vPos; - localPos = gbufferModelViewInverse * viewPos; - gl_Position = dhProjection * viewPos; + float cellSize = 32*2; + vec3 modulusWorldPos = vec3(worldpos.x,worldpos.y,worldpos.z) + fract(cameraPosition/cellSize)*cellSize - cellSize*0.5; + worldpos.y -= (clamp(1.0-length(modulusWorldPos)/max(far-32,0.0),0.0,1.0)) * 50.0; + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; + gl_Position = toClipSpace3(position); + */ #ifdef TAA_UPSCALING gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; #endif - #ifdef TAA gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; #endif - lightmapCoords = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; + lightmapCoords = gl_MultiTexCoord1.xy; // is this even correct? lol' gcolor = gl_Color; - + pos = gl_ModelViewMatrix * gl_Vertex; EMISSIVE = 0.0; if(dhMaterialId == DH_BLOCK_ILLUMINATED || gl_MultiTexCoord1.x >= 0.95) EMISSIVE = 0.5; @@ -94,6 +85,7 @@ void main() { normals_and_materials = vec4(normalize(gl_NormalMatrix * gl_Normal), MATERIALS); dh_material_id = dhMaterialId; + #if defined Seasons && defined OVERWORLD_SHADER YearCycleColor(gcolor.rgb, gl_Color.rgb, dhMaterialId == DH_BLOCK_LEAVES, dhMaterialId == DH_BLOCK_GRASS); #endif diff --git a/shaders/dimensions/DH_translucent.fsh b/shaders/dimensions/DH_translucent.fsh index 0f9533f..950b54a 100644 --- a/shaders/dimensions/DH_translucent.fsh +++ b/shaders/dimensions/DH_translucent.fsh @@ -117,22 +117,10 @@ uniform int isEyeInWater; uniform float rainStrength; #ifdef OVERWORLD_SHADER - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - #define CLOUDSHADOWSONLY #include "/lib/volumetricClouds.glsl" #endif -#ifndef OVERWORLD_SHADER -#undef WATER_SUN_SPECULAR -#endif float GGX(vec3 n, vec3 v, vec3 l, float r, float f0) { r = max(pow(r,2.5), 0.0001); @@ -212,30 +200,16 @@ vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater) return vec3(1.1); } - -float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif -} -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += + (frameCounter%40000) * 2.0; - #endif - + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha.x * coord.x + alpha.y * coord.y ) ; } - +float interleaved_gradientNoise(){ + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; + float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715) ) ); + return noise ; +} vec3 viewToWorld(vec3 viewPos) { vec4 pos; pos.xyz = viewPos; @@ -272,10 +246,6 @@ vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ return normalize(bump*tbnMatrix); } -#define FORWARD_SPECULAR -#define FORWARD_ENVIORNMENT_REFLECTION -#define FORWARD_BACKGROUND_REFLECTION -#define FORWARD_ROUGH_REFLECTION /* RENDERTARGETS:2,7 */ void main() { @@ -340,7 +310,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 Direct_lighting = vec3(0.0); #ifdef OVERWORLD_SHADER - vec3 DirectLightColor = lightCol.rgb/2400.0; + vec3 DirectLightColor = lightCol.rgb/80.0; float NdotL = clamp(dot(normals, normalize(WsunVec2)),0.0,1.0); NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); @@ -372,14 +342,13 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) Shadows = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x; } #endif - - #ifdef CLOUDS_SHADOWS - Shadows *= GetCloudShadow(playerPos + cameraPosition, WsunVec); - #endif + #ifdef CLOUDS_SHADOWS + Shadows *= pow(GetCloudShadow(playerPos),3); + #endif Direct_lighting = DirectLightColor * NdotL * Shadows; - vec3 AmbientLightColor = averageSkyCol_Clouds/900.0; + vec3 AmbientLightColor = averageSkyCol_Clouds/30.0; vec3 ambientcoefs = normals_and_materials.xyz / dot(abs(normals_and_materials.xyz), vec3(1.0)); float SkylightDir = ambientcoefs.y*1.5; @@ -397,7 +366,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo; // specular - #ifdef FORWARD_SPECULAR + #ifdef WATER_REFLECTIONS vec3 Reflections_Final = vec3(0.0); vec4 Reflections = vec4(0.0); vec3 BackgroundReflection = FinalColor; @@ -417,8 +386,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #ifdef SNELLS_WINDOW if(isEyeInWater == 1) fresnel = pow(clamp(1.5 + normalDotEye,0.0,1.0), 25.0); #endif - #if defined FORWARD_ENVIORNMENT_REFLECTION && defined DH_SCREENSPACE_REFLECTIONS - vec3 rtPos = rayTrace(reflectedVector, viewPos, interleaved_gradientNoise_temporal(), fresnel, false); + #if defined SCREENSPACE_REFLECTIONS && defined DH_SCREENSPACE_REFLECTIONS + vec3 rtPos = rayTrace(reflectedVector, viewPos, interleaved_gradientNoise(), fresnel, false); if (rtPos.z < 1.){ vec3 previousPosition = mat3(gbufferModelViewInverse) * DH_toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; @@ -429,11 +398,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) } } #endif - #ifdef FORWARD_BACKGROUND_REFLECTION - BackgroundReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 1200.0; + #ifdef WATER_BACKGROUND_SPECULAR + BackgroundReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0; #endif #ifdef WATER_SUN_SPECULAR - SunReflection = (DirectLightColor * Shadows) * GGX(normalize(normals), -normalize(viewPos), normalize(WsunVec2), roughness, f0) * (1.0-Reflections.a); + SunReflection = Direct_lighting * GGX(normalize(normals), -normalize(viewPos), normalize(WsunVec2), roughness, f0) * (1.0-Reflections.a); #endif Reflections_Final = mix(BackgroundReflection, Reflections.rgb, Reflections.a) * fresnel; diff --git a/shaders/dimensions/DH_translucent.vsh b/shaders/dimensions/DH_translucent.vsh index 4d9372f..458b070 100644 --- a/shaders/dimensions/DH_translucent.vsh +++ b/shaders/dimensions/DH_translucent.vsh @@ -14,7 +14,7 @@ flat varying vec3 averageSkyCol_Clouds; flat varying vec4 lightCol; #ifdef OVERWORLD_SHADER - #ifdef Daily_Weather + #if defined Daily_Weather flat varying vec4 dailyWeatherParams0; flat varying vec4 dailyWeatherParams1; #endif @@ -56,26 +56,11 @@ vec4 toClipSpace3(vec3 viewSpacePosition) { } void main() { - gl_Position = dhProjection * gl_ModelViewMatrix * gl_Vertex; + gl_Position = ftransform(); vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - - vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; - - // worldpos.y -= length(worldpos)/(16*2); - - #ifdef PLANET_CURVATURE - float curvature = length(worldpos) / (16*8); - worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; - #endif - position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; - - gl_Position = toClipSpace3(position); pos = gl_ModelViewMatrix * gl_Vertex; - - // vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - isWater = 0; @@ -83,13 +68,13 @@ void main() { isWater = 1; // offset water to not look like a full cube - // vec3 worldpos = mat3(gbufferModelViewInverse) * position;// + gbufferModelViewInverse[3].xyz ; - // worldpos.y -= 1.8/16.0; - // position = mat3(gbufferModelView) * worldpos;// + gbufferModelView[3].xyz; + vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz ; + worldpos.y -= 1.8/16.0; + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; } - // gl_Position = toClipSpace3(position); + gl_Position = toClipSpace3(position); normals_and_materials = vec4(normalize(gl_Normal), 1.0); @@ -98,6 +83,7 @@ void main() { + lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index 2bc5656..2a497d7 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -62,25 +62,17 @@ uniform vec2 texelSize; uniform ivec2 eyeBrightnessSmooth; uniform float rainStrength; -uniform float nightVision; - flat varying float HELD_ITEM_BRIGHTNESS; - +#ifndef OVERWORLD_SHADER + uniform float nightVision; +#endif #include "/lib/util.glsl" #ifdef OVERWORLD_SHADER - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - - #define CLOUDSHADOWSONLY + #define CLOUDSHADOWSONLY #include "/lib/volumetricClouds.glsl" #endif @@ -231,8 +223,8 @@ vec3 toClipSpace3(vec3 viewSpacePosition) { } flat varying vec3 WsunVec2; - const float mincoord = 1.0/4096.0; - const float maxcoord = 1.0-mincoord; +const float mincoord = 1.0/4096.0; +const float maxcoord = 1.0-mincoord; uniform sampler2D normals; varying vec4 tangent; @@ -381,12 +373,7 @@ void main() { #else vec3 playerCamPos = cameraPosition; #endif - // lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length((feetPlayerPos+cameraPosition) - playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0)); - if(HELD_ITEM_BRIGHTNESS > 0.0){ - float pointLight = clamp(1.0-length((feetPlayerPos+cameraPosition)-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0,1.0); - lightmap.x = mix(lightmap.x, HELD_ITEM_BRIGHTNESS, pointLight*pointLight); - } - + lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length((feetPlayerPos+cameraPosition) - playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0)); #endif #ifdef WEATHER @@ -415,7 +402,7 @@ void main() { if(lightmap.x >= 0.9) Torch_Color *= LIT_PARTICLE_BRIGHTNESS; #ifdef OVERWORLD_SHADER - directLightColor = lightCol.rgb/2400.0; + directLightColor = lightCol.rgb/80.0; float Shadows = 1.0; vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; @@ -430,7 +417,7 @@ void main() { Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2); #ifdef CLOUDS_SHADOWS - Shadows *= GetCloudShadow(feetPlayerPos+cameraPosition, WsunVec); + Shadows *= GetCloudShadow(feetPlayerPos); #endif Direct_lighting = directLightColor * Shadows; @@ -439,7 +426,7 @@ void main() { Direct_lighting *= phaseg(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), 0.65)*2 + 0.5; #endif - AmbientLightColor = averageSkyCol_Clouds / 900.0; + AmbientLightColor = averageSkyCol_Clouds / 30.0; #ifdef IS_IRIS AmbientLightColor *= 2.5; @@ -451,11 +438,11 @@ void main() { #endif #ifdef NETHER_SHADER - Indirect_lighting = volumetricsFromTex(vec3(0.0,1.0,0.0), colortex4, 6).rgb / 1200.0; + Indirect_lighting = skyCloudsFromTexLOD2(vec3(0.0,1.0,0.0), colortex4, 6).rgb / 30.0; #endif #ifdef END_SHADER - Indirect_lighting = vec3(0.3,0.6,1.0) * 0.1; + Indirect_lighting = vec3(0.3,0.6,1.0) * 0.5; #endif ///////////////////////// BLOCKLIGHT LIGHTING OR LPV LIGHTING OR FLOODFILL COLORED LIGHTING diff --git a/shaders/dimensions/all_particles.vsh b/shaders/dimensions/all_particles.vsh index 115f358..20114e5 100644 --- a/shaders/dimensions/all_particles.vsh +++ b/shaders/dimensions/all_particles.vsh @@ -23,12 +23,10 @@ flat varying float exposure; flat varying vec3 averageSkyCol_Clouds; flat varying vec4 lightCol; flat varying vec3 WsunVec; - - #ifdef Daily_Weather + #if defined Daily_Weather flat varying vec4 dailyWeatherParams0; flat varying vec4 dailyWeatherParams1; #endif - #endif @@ -108,12 +106,12 @@ void main() { vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; - bool istopv = worldpos.y > cameraPosition.y + 5.0 && lmtexcoord.w > 0.99; + bool istopv = worldpos.y > cameraPosition.y + 5.0 && lmtexcoord.w > 0.94; if(!istopv){ - worldpos.xyz -= cameraPosition - vec3(2.0,0.0,2.0) * min(max(eyeBrightnessSmooth.y/240.0-0.95,0.0)*11.0,1.0); + worldpos.xyz -= cameraPosition; }else{ - worldpos.xyz -= cameraPosition ; + worldpos.xyz -= cameraPosition + vec3(2.0,0.0,2.0); } position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; @@ -142,8 +140,8 @@ void main() { WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0) / 2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0) / 2.0, 0.0); #endif #endif diff --git a/shaders/dimensions/all_solid.fsh b/shaders/dimensions/all_solid.fsh index 096f728..5fcaa59 100644 --- a/shaders/dimensions/all_solid.fsh +++ b/shaders/dimensions/all_solid.fsh @@ -94,40 +94,25 @@ flat varying int SIGN; flat varying float HELD_ITEM_BRIGHTNESS; uniform float noPuddleAreas; -uniform float nightVision; + // float interleaved_gradientNoise(){ // return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); // } - float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); } float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); return noise; } -float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += + (frameCounter%40000) * 2.0; - #endif - - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * coord.x + alpha.y * coord.y ) ; -} float blueNoise(){ - #ifdef TAA - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); - #else - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887); - #endif + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); +} +float R2_dither(){ + vec2 alpha = vec2(0.75487765, 0.56984026); + return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; } mat3 inverseMatrix(mat3 m) { @@ -326,8 +311,7 @@ void main() { vec2 tempOffset = offsets[framemod8]; vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 playerpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; - vec3 worldpos = playerpos + cameraPosition; + vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition; float torchlightmap = lmtexcoord.z; @@ -338,11 +322,8 @@ void main() { vec3 playerCamPos = cameraPosition; #endif - // if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0)); - if(HELD_ITEM_BRIGHTNESS > 0.0){ - float pointLight = clamp(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0,1.0); - torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, pointLight*pointLight); - } + if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0)); + #ifdef HAND torchlightmap *= 0.9; #endif @@ -350,17 +331,17 @@ void main() { float lightmap = clamp( (lmtexcoord.w-0.9) * 10.0,0.,1.); - // float rainfall = 1.0; - // float Puddle_shape = 0.0; + float rainfall = 0.0; + float Puddle_shape = 0.0; - // #if defined Puddles && defined WORLD && !defined ENTITIES && !defined HAND - // // rainfall = rainStrength * noPuddleAreas * lightmap; + #if defined Puddles && defined WORLD && !defined ENTITIES && !defined HAND + rainfall = rainStrength * noPuddleAreas * lightmap; - // // Puddle_shape = clamp(lightmap - exp(-15.0 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b,5.0)),0.0,1.0); - // // Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5,0.0,1.0); - // // Puddle_shape *= rainStrength * noPuddleAreas ; + Puddle_shape = clamp(lightmap - exp(-15.0 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b,5.0)),0.0,1.0); + Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5,0.0,1.0); + Puddle_shape *= rainStrength * noPuddleAreas ; - // #endif + #endif vec2 adjustedTexCoord = lmtexcoord.xy; @@ -370,38 +351,31 @@ void main() { adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st; // vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); vec3 viewVector = normalize(tbnMatrix*fragpos); - float dist = length(playerpos); - - float falloff = min(max(1.0-dist/MAX_OCCLUSION_DISTANCE,0.0) * 2.0,1.0); - - falloff = pow(1.0-pow(1.0-falloff,1.0),2.0); - - // falloff = 1; + float dist = length(fragpos); float maxdist = MAX_OCCLUSION_DISTANCE; if(!ifPOM) maxdist = 0.0; gl_FragDepth = gl_FragCoord.z; - if (falloff > 0.0) { + if (dist < maxdist) { float depthmap = readNormal(vtexcoord.st).a; float used_POM_DEPTH = 1.0; - float pomdepth = POM_DEPTH*falloff; if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { float noise = blueNoise(); #ifdef Adaptive_Step_length - vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * pomdepth) * clamp(1.0-pow(depthmap,2),0.1,1.0); + vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0); used_POM_DEPTH = 1.0; #else - vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*pomdepth; + vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH; #endif vec3 coord = vec3(vtexcoord.st , 1.0); coord += interval * noise * used_POM_DEPTH; float sumVec = noise; - for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - pomdepth + pomdepth * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { + for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { coord = coord + interval * used_POM_DEPTH; sumVec += used_POM_DEPTH; } @@ -429,7 +403,7 @@ void main() { //////////////////////////////// //////////////////////////////// float textureLOD = bias(); vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color; - // Albedo.rgb = vec3(1.0) * min(max(exp(-15.0 * pow(1.0-luma(Albedo.rgb),3.0)) - 0.2,0.0)*5.0,1.0); + #if defined HAND if (Albedo.a < 0.1) discard; #endif @@ -509,7 +483,7 @@ void main() { NormalTex.xy = NormalTex.xy * 2.0-1.0; NormalTex.z = sqrt(max(1.0 - dot(NormalTex.xy, NormalTex.xy), 0.0)); - normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); + normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0-Puddle_shape); #endif //////////////////////////////// //////////////////////////////// @@ -519,8 +493,8 @@ void main() { #ifdef WORLD vec4 SpecularTex = texture2D_POMSwitch(specular, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM,textureLOD); - // SpecularTex.r = max(SpecularTex.r, rainfall); - // SpecularTex.g = max(SpecularTex.g, max(Puddle_shape*0.02,0.02)); + SpecularTex.r = max(SpecularTex.r, rainfall); + SpecularTex.g = max(SpecularTex.g, max(Puddle_shape*0.02,0.02)); gl_FragData[1].rg = SpecularTex.rg; @@ -569,23 +543,24 @@ void main() { //////////////////////////////// //////////////////////////////// #ifdef WORLD - // #ifdef Puddles - // float porosity = 0.4; + #ifdef Puddles + float porosity = 0.4; - // #ifdef Porosity - // porosity = SpecularTex.z >= 64.5/255.0 ? 0.0 : (SpecularTex.z*255.0/64.0)*0.65; - // #endif + #ifdef Porosity + porosity = SpecularTex.z >= 64.5/255.0 ? 0.0 : (SpecularTex.z*255.0/64.0)*0.65; + #endif - // // if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity); - // #endif + if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity); + #endif // apply noise to lightmaps to reduce banding. vec2 PackLightmaps = vec2(torchlightmap, lmtexcoord.w); + vec4 data1 = clamp( encode(viewToWorld(normal), PackLightmaps), 0.0, 1.0); - + gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w)); - gl_FragData[2] = vec4(viewToWorld(FlatNormals) * 0.5 + 0.5, VanillaAO); + gl_FragData[2] = vec4(FlatNormals * 0.5 + 0.5, VanillaAO); #endif } \ No newline at end of file diff --git a/shaders/dimensions/all_solid.vsh b/shaders/dimensions/all_solid.vsh index 32f8074..89abca9 100644 --- a/shaders/dimensions/all_solid.vsh +++ b/shaders/dimensions/all_solid.vsh @@ -83,7 +83,7 @@ flat varying int SIGN; // in vec3 at_velocity; // out vec3 velocity; -uniform float nightVision; + uniform mat4 gbufferModelView; uniform mat4 gbufferModelViewInverse; @@ -198,8 +198,6 @@ void main() { VanillaAO = 1.0 - clamp(color.a,0,1); if (color.a < 0.3) color.a = 1.0; // fix vanilla ao on some custom block models. - - /////// ----- RANDOM STUFF ----- /////// // gl_TextureMatrix[0] for animated things like charged creepers @@ -243,7 +241,6 @@ void main() { NameTags = 0; #ifdef ENTITIES - // disallow POM to work on item frames. if(entityId == ENTITY_ITEM_FRAME) SIGN = 1; @@ -300,7 +297,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.75; } // low #ifdef MISC_BLOCK_SSS @@ -331,7 +328,6 @@ void main() { #endif - vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; #ifdef WAVY_PLANTS // also use normal, so up/down facing geometry does not get detatched from its model parts. @@ -350,24 +346,18 @@ void main() { ) && abs(position.z) < 64.0 ){ + vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; vec3 UnalteredWorldpos = worldpos; // apply displacement for waving plant blocks worldpos += calcMovePlants(worldpos + cameraPosition) * max(lmtexcoord.w,0.5); - // apply displacement for waving leaf blocks specifically, overwriting the other waving mode. these wave off of the air. they wave uniformly if(mc_Entity.x == BLOCK_AIR_WAVING) worldpos = UnalteredWorldpos + calcMoveLeaves(worldpos + cameraPosition, 0.0040, 0.0064, 0.0043, 0.0035, 0.0037, 0.0041, vec3(1.0,0.2,1.0), vec3(0.5,0.1,0.5))*lmtexcoord.w; + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; } #endif - - #ifdef PLANET_CURVATURE - float curvature = length(worldpos) / (16*8); - worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; - #endif - - position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; gl_Position = toClipSpace3(position); #endif diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index b987a77..8d7910a 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -36,6 +36,7 @@ uniform vec4 entityColor; flat varying float HELD_ITEM_BRIGHTNESS; +const bool colortex4MipmapEnabled = true; uniform sampler2D noisetex; uniform sampler2D depthtex1; uniform sampler2D depthtex0; @@ -83,15 +84,11 @@ uniform float rainStrength; uniform float skyIntensityNight; uniform float skyIntensity; uniform ivec2 eyeBrightnessSmooth; -uniform float nightVision; - uniform int frameCounter; uniform float frameTimeCounter; uniform vec2 texelSize; uniform int framemod8; -uniform float viewWidth; -uniform float viewHeight; uniform mat4 gbufferPreviousModelView; uniform vec3 previousCameraPosition; @@ -113,18 +110,11 @@ uniform vec3 nsunColor; #ifdef OVERWORLD_SHADER flat varying float Flashing; #include "/lib/lightning_stuff.glsl" - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - + #define CLOUDSHADOWSONLY #include "/lib/volumetricClouds.glsl" - +#else + uniform float nightVision; #endif #ifdef END_SHADER @@ -142,12 +132,14 @@ uniform vec3 nsunColor; #include "/lib/diffuse_lighting.glsl" +float blueNoise(){ + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); +} +vec4 blueNoise(vec2 coord){ + return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; +} float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); } float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; @@ -155,27 +147,20 @@ float interleaved_gradientNoise(){ return noise; } float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += + (frameCounter%40000) * 2.0; - #endif - + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha.x * coord.x + alpha.y * coord.y ) ; } -float blueNoise(){ - #ifdef TAA - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); - #else - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887); - #endif -} - #include "/lib/TAA_jitter.glsl" + + + + + + #define PW_DEPTH 1.5 //[0.5 1.0 1.5 2.0 2.5 3.0] #define PW_POINTS 2 //[2 4 6 8 16 32] @@ -254,10 +239,91 @@ float encodeVec2(float x,float y){ } +float invLinZ (float lindepth){ + return -((2.0*near/lindepth)-far-near)/(far-near); +} float ld(float dist) { return (2.0 * near) / (far + near - dist * (far - near)); } +vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater, inout float reflectLength){ + + float quality = mix(15,SSR_STEPS,fresnel); + + // quality = SSR_STEPS; + + 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.,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) + stepv*dither; + float minZ = clipPosition.z; + float maxZ = spos.z+stepv.z*0.5; + + spos.xy += offsets[framemod8]*texelSize*0.5/RENDER_SCALE; + + float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases + for (int i = 0; i <= int(quality); i++) { + + // decode depth buffer + // float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); + + float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0); + sp = invLinZ(sp); + + if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp); + + + + + spos += stepv; + //small bias + if(inwater) { + minZ = maxZ-0.00035/ld(spos.z); + }else{ + minZ = maxZ-0.0001/max(ld(spos.z), (0.0 + position.z*position.z*0.001)); + } + maxZ += stepv.z; + + + reflectLength += 1.0 / quality; // for shit + } + + return vec3(1.1); +} + +float GGX(vec3 n, vec3 v, vec3 l, float r, float f0) { + r = max(pow(r,2.5), 0.0001); + + vec3 h = l + v; + float hn = inversesqrt(dot(h, h)); + + float dotLH = clamp(dot(h,l)*hn,0.,1.); + float dotNH = clamp(dot(h,n)*hn,0.,1.) ; + float dotNL = clamp(dot(n,l),0.,1.); + float dotNHsq = dotNH*dotNH; + + float denom = dotNHsq * r - dotNHsq + 1.; + float D = r / (3.141592653589793 * denom * denom); + + float F = f0 + (1. - f0) * exp2((-5.55473*dotLH-6.98316)*dotLH); + float k2 = .25 * r; + + return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2); +} + + + uniform float dhFarPlane; #include "/lib/DistantHorizons_projections.glsl" @@ -360,19 +426,12 @@ void Emission( float Emission, float exposure ){ - // float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); - if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why + float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); + if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * Emissive_Brightness * autoBrightnessAdjust * 0.1, pow(Emission, Emissive_Curve)); // old method.... idk why } uniform vec3 eyePosition; -#define FORWARD_SPECULAR -#define FORWARD_ENVIORNMENT_REFLECTION -#define FORWARD_BACKGROUND_REFLECTION -#define FORWARD_ROUGH_REFLECTION - -#include "/lib/specular.glsl" - //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -427,9 +486,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; float UnchangedAlpha = gl_FragData[0].a; - - // gl_FragData[0].a = pow(gl_FragData[0].a,3); - + #ifdef WhiteWorld gl_FragData[0].rgb = vec3(0.5); gl_FragData[0].a = 1.0; @@ -475,6 +532,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 worldSpaceNormal = viewToWorld(normal).xyz; vec2 TangentNormal = vec2(0); // for refractions + + vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w); mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x, tangent.y, tangent2.y, normal.y, @@ -482,14 +541,17 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 NormalTex = vec3(texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).xy,0.0); NormalTex.xy = NormalTex.xy*2.0-1.0; - NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0); - + NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; + + // tangent space normals for refraction + TangentNormal = NormalTex.xy*0.5+0.5; + #ifndef HAND if (isWater){ vec3 posxz = (mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz) + cameraPosition; // make the waves flow in the direction the water faces, except for perfectly up facing parts. - if(abs(worldSpaceNormal.y) < 0.9995) posxz.xz -= posxz.y + normalize(worldSpaceNormal.xz*10.0) * frameTimeCounter * 3.0 * WATER_WAVE_SPEED; + if(abs(worldSpaceNormal.y) < 0.9995) posxz.xz -= (posxz.y + frameTimeCounter*3 * WATER_WAVE_SPEED) * normalize(worldSpaceNormal.xz) ; posxz.xyz = getParallaxDisplacement(posxz); vec3 bump = normalize(getWaveNormal(posxz, false)); @@ -498,24 +560,22 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); NormalTex.xyz = bump; + + // tangent space normals for refraction + TangentNormal = (bump.xy/3.0)*0.5+0.5; } #endif - // tangent space normals for refraction - TangentNormal = NormalTex.xy; - normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); - // TangentNormal = clamp(TangentNormal + (blueNoise()*2.0-1.0)*0.005,-1.0,1.0); - - gl_FragData[2] = vec4(encodeVec2(TangentNormal*0.5+0.5), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), 1.0); + gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), 1.0); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// SPECULARS ///////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// - vec3 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rga; + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// DIFFUSE LIGHTING ////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -534,12 +594,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #else vec3 playerCamPos = cameraPosition; #endif - - if(HELD_ITEM_BRIGHTNESS > 0.0){ - float pointLight = clamp(1.0-length((feetPlayerPos+cameraPosition)-playerCamPos)/HANDHELD_LIGHT_RANGE,0.0,1.0); - lightmap.x = mix(lightmap.x , HELD_ITEM_BRIGHTNESS, pointLight*pointLight); - } - + lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS*clamp( pow(max(1.0-length((feetPlayerPos+cameraPosition) - playerCamPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0)); #endif vec3 Indirect_lighting = vec3(0.0); @@ -549,7 +604,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 Direct_lighting = vec3(0.0); #ifdef OVERWORLD_SHADER - vec3 DirectLightColor = lightCol.rgb/2400.0; + vec3 DirectLightColor = lightCol.rgb/80.0; 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; @@ -564,13 +619,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2); - #ifdef CLOUDS_SHADOWS - Shadows *= GetCloudShadow(feetPlayerPos+cameraPosition, WsunVec); - #endif + Shadows *= pow(GetCloudShadow(feetPlayerPos),3); Direct_lighting = DirectLightColor * NdotL * Shadows; - vec3 AmbientLightColor = averageSkyCol_Clouds/900.0; + vec3 AmbientLightColor = averageSkyCol_Clouds/30.0; vec3 ambientcoefs = worldSpaceNormal / dot(abs(worldSpaceNormal), vec3(1.0)); float SkylightDir = ambientcoefs.y*1.5; @@ -582,41 +635,26 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #endif #ifdef NETHER_SHADER - Indirect_lighting = volumetricsFromTex(normalize(worldSpaceNormal), colortex4, 0).rgb / 1200.0 / 1.5; + Indirect_lighting = skyCloudsFromTexLOD2(worldSpaceNormal, colortex4, 6).rgb / 30.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); + 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); - float end_NdotL = clamp(dot(worldSpaceNormal, normalize(-lightPos))*0.5+0.5,0.0,1.0); - end_NdotL *= end_NdotL; + NdotL *= NdotL; - float fogShadow = GetEndFogShadow(feetPlayerPos+cameraPosition, lightPos); - float endPhase = endFogPhase(lightPos); + Direct_lighting = lightColors * endFogPhase(lightPos) * NdotL; - Direct_lighting += lightColors * endPhase * end_NdotL * fogShadow; - - vec3 AmbientLightColor = vec3(0.3,0.6,1.0) ; + vec3 AmbientLightColor = vec3(0.3,0.6,1.0) * 0.5; Indirect_lighting = AmbientLightColor + 0.7 * AmbientLightColor * dot(worldSpaceNormal, normalize(feetPlayerPos)); - Indirect_lighting *= 0.1; #endif ///////////////////////// BLOCKLIGHT LIGHTING OR LPV LIGHTING OR FLOODFILL COLORED LIGHTING @@ -642,66 +680,136 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo; - #if EMISSIVE_TYPE == 2 || EMISSIVE_TYPE == 3 - Emission(FinalColor, Albedo, SpecularTex.b, exposure); - #endif - //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// SPECULAR LIGHTING ///////////////////////////// //////////////////////////////////////////////////////////////////////////////// #ifdef DAMAGE_BLOCK_EFFECT - #undef FORWARD_SPECULAR + #undef WATER_REFLECTIONS #endif - #ifdef FORWARD_SPECULAR + #ifndef OVERWORLD_SHADER + #undef WATER_SUN_SPECULAR + #endif - float harcodedF0 = 0.02; + #ifdef WATER_REFLECTIONS + // vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg; // if nothing is chosen, no smoothness and no reflectance vec2 specularValues = vec2(1.0, 0.0); - + // hardcode specular values for select blocks like glass, water, and slime - if(isReflective) specularValues = vec2(1.0, harcodedF0); + if(isReflective) specularValues = vec2(1.0, 0.02); // detect if the specular texture is used, if it is, overwrite hardcoded values if(SpecularTex.r > 0.0 && SpecularTex.g <= 1.0) specularValues = SpecularTex.rg; - float f0 = isReflective ? max(specularValues.g, harcodedF0) : specularValues.g; + float roughness = pow(1.0-specularValues.r,2.0); + float f0 = isReflective ? max(specularValues.g, 0.02) : specularValues.g; #ifdef HAND - f0 = max(specularValues.g, harcodedF0); + f0 = max(specularValues.g, 0.02); #endif - - float roughness = specularValues.r; - + + // f0 = SpecularTex.g; + // roughness = pow(1.0-specularValues.r,2.0); + // f0 = 0.9; + // roughness = 0.0; + + 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); + + // make sure zero alpha is not forced to be full alpha by fresnel on items with funny normal padding if(UnchangedAlpha <= 0.0 && !isReflective) f0 = 0.0; - + if (f0 > 0.0){ - if(isReflective) f0 = max(f0, harcodedF0); - - float reflectance = 0.0; - #if !defined OVERWORLD_SHADER - - vec3 WsunVec = vec3(0.0); - vec3 DirectLightColor = WsunVec; - float Shadows = 0.0; + if(isReflective) f0 = max(f0, 0.02); + + vec3 Reflections_Final = vec3(0.0); + vec4 Reflections = vec4(0.0); + vec3 BackgroundReflection = FinalColor; + vec3 SunReflection = vec3(0.0); + float indoors = pow(1.0-pow(1.0-min(max(lightmap.y-0.6,0.0)*3.0,1.0),0.5),2.0); + + vec3 reflectedVector = reflect(normalize(viewPos), normal); + float normalDotEye = dot(normal, normalize(viewPos)); + + float fresnel = pow(clamp(1.0 + normalDotEye, 0.0, 1.0),5.0); + + /* + int seed = (frameCounter%40000) + frameCounter*2; + float noise = fract(R2_samples(seed).y + (1-blueNoise())); + mat3 Basis = CoordBase(viewToWorld(normal)); + vec3 ViewDir = -normalize(feetPlayerPos)*Basis; + vec3 SamplePoints = SampleVNDFGGX(ViewDir, vec2(roughness), noise); + vec3 Ln = reflect(-ViewDir, SamplePoints); + vec3 L = Basis * Ln; + fresnel = pow(clamp(1.0 + dot(-Ln, SamplePoints),0.0,1.0), 5.0); + */ + + #ifdef SNELLS_WINDOW + // snells window looking thing + if(isEyeInWater == 1) fresnel = pow(clamp(1.5 + normalDotEye,0.0,1.0), 25.0); #endif - vec3 specularReflections = specularReflections(viewPos, normalize(feetPlayerPos), WsunVec, vec3(blueNoise(), vec2(interleaved_gradientNoise_temporal())), viewToWorld(normal), roughness, f0, Albedo, FinalColor*gl_FragData[0].a, DirectLightColor * Shadows, lightmap.y, false, reflectance); - - gl_FragData[0].a = gl_FragData[0].a + (1.0-gl_FragData[0].a) * reflectance; - - // invert the alpha blending darkening on the color so you can interpolate between diffuse and specular and keep buffer blending - gl_FragData[0].rgb = clamp(specularReflections / gl_FragData[0].a * 0.1,0.0,65000.0); - - }else{ - gl_FragData[0].rgb = clamp(FinalColor * 0.1,0.0,65000.0); + fresnel = mix(f0, 1.0, fresnel); + + // Sun, Sky, and screen-space reflections + #ifdef OVERWORLD_SHADER + #ifdef WATER_SUN_SPECULAR + SunReflection = Direct_lighting * GGX(normal, -normalize(viewPos), WsunVec*mat3(gbufferModelViewInverse), max(roughness,0.035), f0) * Metals; + #endif + #ifdef WATER_BACKGROUND_SPECULAR + if(isEyeInWater == 0 && !isReflectiveEntity) BackgroundReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0 * Metals; + #endif + + if(isEyeInWater == 1 && isWater) BackgroundReflection.rgb = exp(-8.0 * vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B)) * clamp(WsunVec.y*lightCol.a,0,1); + #else + #ifdef WATER_BACKGROUND_SPECULAR + if(isEyeInWater == 0) BackgroundReflection = skyCloudsFromTexLOD2(mat3(gbufferModelViewInverse) * reflectedVector, colortex4, 0).rgb / 30.0 * Metals; + #endif + #endif + + #ifdef SCREENSPACE_REFLECTIONS + float reflectLength = 0.0; + vec3 rtPos = rayTrace(reflectedVector, viewPos.xyz, interleaved_gradientNoise_temporal(), fresnel, isEyeInWater == 1,reflectLength); + if (rtPos.z < 1.0){ + vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + 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) { + Reflections.a = 1.0; + Reflections.rgb = texture2D(colortex5, previousPosition.xy).rgb * Metals; + } + } + #endif + + float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1); + + Reflections_Final = mix(mix(FinalColor, BackgroundReflection, indoors), Reflections.rgb, Reflections.a) * fresnel * visibilityFactor; + 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); + + if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.0); + + } else { + gl_FragData[0].rgb = FinalColor*0.1; } + #else gl_FragData[0].rgb = FinalColor*0.1; #endif + + #if EMISSIVE_TYPE == 2 || EMISSIVE_TYPE == 3 + Emission(gl_FragData[0].rgb, Albedo, SpecularTex.b, exposure); + #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; @@ -716,20 +824,16 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) if(gl_FragCoord.x*texelSize.x < 0.47) gl_FragData[0] = vec4(0.0); #endif #if DEBUG_VIEW == debug_NORMALS - gl_FragData[0].rgb = viewToWorld(normalize(normal.xyz)) * 0.1; - gl_FragData[0].a = 1; + gl_FragData[0].rgb = normalize(normal.xyz) * 0.1; #endif #if DEBUG_VIEW == debug_INDIRECT - gl_FragData[0].rgb = Indirect_lighting * 0.1; + gl_FragData[0].rgb = Indirect_lighting* 0.1; #endif #if DEBUG_VIEW == debug_DIRECT gl_FragData[0].rgb = Direct_lighting * 0.1; #endif - // gl_FragData[3].a = clamp(lightmap.y,0.0,1.0); - - gl_FragData[3] = vec4(encodeVec2(lightmap.x, lightmap.y), 1, 1, 1); - + gl_FragData[3].a = clamp(lightmap.y,0.0,1.0); } } \ No newline at end of file diff --git a/shaders/dimensions/all_translucent.vsh b/shaders/dimensions/all_translucent.vsh index fb10c20..db0fdf6 100644 --- a/shaders/dimensions/all_translucent.vsh +++ b/shaders/dimensions/all_translucent.vsh @@ -25,11 +25,10 @@ flat varying float exposure; flat varying vec4 lightCol; flat varying vec3 WsunVec; - #ifdef Daily_Weather + #if defined Daily_Weather flat varying vec4 dailyWeatherParams0; flat varying vec4 dailyWeatherParams1; #endif - #endif varying vec4 normalMat; @@ -133,15 +132,6 @@ void main() { position = mat3(gbufferModelView) * (displacedPos - cameraPosition) + gbufferModelView[3].xyz; } #endif - - // vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; - #ifdef PLANET_CURVATURE - float curvature = length(worldpos) / (16*8); - worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; - #endif - position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; - gl_Position = toClipSpace3(position); HELD_ITEM_BRIGHTNESS = 0.0; @@ -159,6 +149,7 @@ void main() { // water mask if(mc_Entity.x == 8.0) { mat = 1.0; + gl_Position.z -= 1e-4; } // translucent entities @@ -202,8 +193,8 @@ void main() { // WsunVec = normalize(LightDir); #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0); #endif #endif diff --git a/shaders/dimensions/all_vanilla_emissives.fsh b/shaders/dimensions/all_vanilla_emissives.fsh index 925a79c..e3f4828 100644 --- a/shaders/dimensions/all_vanilla_emissives.fsh +++ b/shaders/dimensions/all_vanilla_emissives.fsh @@ -69,20 +69,20 @@ void main() { minimumBrightness = 10.0; #endif - // float autoBrightnessAdjust = mix(minimumBrightness, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); + float autoBrightnessAdjust = mix(minimumBrightness, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); #ifdef DISABLE_VANILLA_EMISSIVES vec3 emissiveColor = vec3(0.0); Albedo.a = 0.0; #else - vec3 emissiveColor = Albedo.rgb * color.a ;//* autoBrightnessAdjust; + vec3 emissiveColor = Albedo.rgb * color.a * autoBrightnessAdjust; #endif gl_FragData[0] = vec4(emissiveColor*0.1, Albedo.a * sqrt(color.a)); #endif #ifdef ENCHANT_GLINT - // float autoBrightnessAdjust = mix(0.1, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); + float autoBrightnessAdjust = mix(0.1, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); Albedo.rgb = clamp(Albedo.rgb ,0.0,1.0); // for safety @@ -90,7 +90,7 @@ void main() { vec3 GlintColor = vec3(0.0); Albedo.a = 0.0; #else - vec3 GlintColor = Albedo.rgb * Emissive_Brightness; + vec3 GlintColor = Albedo.rgb * autoBrightnessAdjust * Emissive_Brightness; #endif diff --git a/shaders/dimensions/composite.fsh b/shaders/dimensions/composite.fsh index 87e83b7..ebe5d79 100644 --- a/shaders/dimensions/composite.fsh +++ b/shaders/dimensions/composite.fsh @@ -21,14 +21,11 @@ uniform sampler2D depthtex1; uniform sampler2D colortex1; uniform sampler2D colortex3; // Noise uniform sampler2D colortex6; // Noise -uniform sampler2D colortex7; // Noise uniform sampler2D colortex8; // Noise uniform sampler2D colortex14; // Noise -uniform sampler2D colortex10; // Noise uniform sampler2D colortex12; // Noise -uniform sampler2D colortex13; // Noise uniform sampler2D colortex15; // Noise -uniform int isEyeInWater; + uniform sampler2D shadow; #ifdef TRANSLUCENT_COLORED_SHADOWS @@ -124,39 +121,30 @@ vec2 decodeVec2(float a){ } -float interleaved_gradientNoise_temporal(){ - vec2 coord = gl_FragCoord.xy; - - #ifdef TAA - coord += (frameCounter*9)%40000; - #endif - return fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); +float interleaved_gradientNoise_temporal(){ + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); } float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); return noise; } -float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - #ifdef TAA - coord += (frameCounter*2)%40000; +float R2_dither(){ + #ifdef TAA + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; + #else + vec2 coord = gl_FragCoord.xy; #endif - vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha.x * coord.x + alpha.y * coord.y ) ; } float blueNoise(){ - #ifdef TAA - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); - #else - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887); - #endif + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; + return texelFetch2D(colortex6, ivec2(coord )%512 , 0); } vec2 R2_samples(int n){ vec2 alpha = vec2(0.75487765, 0.56984026); @@ -248,53 +236,63 @@ float convertHandDepth_2(in float depth, bool hand) { ndcDepth /= MC_HAND_DEPTH; return ndcDepth * 0.5 + 0.5; } - vec2 SSAO( vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise ){ + // if(hand) return vec2(1.0,0.0); int samples = 7; float occlusion = 0.0; float sss = 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 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 = viewPos.z*viewPos.z*mulfov2*2.0 * 5.0 / mix(4.0, 50.0, clamp(viewPos.z*viewPos.z - 0.1,0,1)); + + #ifdef Ambient_SSS + float maxR2_2 = viewPos.z;//*viewPos.z*mulfov2*2.*2./4.0; + + float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1); + // if(leaves) maxR2_2 = 0.1; + // if(leaves) maxR2_2 = mix(10, maxR2_2, dist3); + #endif + + vec2 acc = -(TAA_Offset*(texelSize/2.0))*RENDER_SCALE ; - float leaf = leaves ? -0.5 : 0.0; + // vec2 BLUENOISE = blueNoise(gl_FragCoord.xy).rg; int n = 0; + + float leaf = leaves ? -0.5 : 0.0; + for (int i = 0; i < samples; i++) { - vec2 offsets = CleanSample(i, samples - 1, noise) / distanceScale; + // vec2 sampleOffset = (SpiralSample(i, 7, 8 , noise)) * mulfov2 * clamp(0.05 + i*0.095, 0.0,0.3) ; + vec2 sampleOffset = CleanSample(i, samples - 1, noise) * mulfov2 * 0.3 ; - 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 = convertHandDepth_2(texelFetch2D(depthtex1, offsetUV, 0).x, hand); + 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 ) { #ifdef DISTANT_HORIZONS - float sampleDHDepth = texelFetch2D(dhDepthTex1, offsetUV, 0).x; - vec3 offsetViewPos = toScreenSpace_DH((offsetUV*texelSize - jitterOffsets) * (1.0/RENDER_SCALE), sampleDepth, sampleDHDepth); + float dhdepth = texelFetch2D(dhDepthTex1, offset,0).x; #else - vec3 offsetViewPos = toScreenSpace(vec3((offsetUV*texelSize - jitterOffsets) * (1.0/RENDER_SCALE), sampleDepth)); + float dhdepth = 0.0; #endif - vec3 viewPosDiff = offsetViewPos - viewPos; - float viewPosDiffSquared = dot(viewPosDiff, viewPosDiff); + vec3 t0 = toScreenSpace_DH((offset*texelSize+acc+0.5*texelSize) * (1.0/RENDER_SCALE), convertHandDepth_2(texelFetch2D(depthtex1, offset,0).x, hand), dhdepth); + + vec3 vec = (t0.xyz - viewPos); + float dsquared = dot(vec, vec); - 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); - } + if (dsquared > 1e-5){ + if( dsquared < maxR2){ + float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.); + occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0); + } + #ifdef Ambient_SSS - sss += clamp(0.0 - dot(viewPosDiff, normalizedNormals),0.0,1.0) * exp(-10.0 * occlusion); + sss += clamp(leaf - dot(vec, normalize(normal)),0.0,1.0); #endif n += 1; @@ -304,52 +302,6 @@ vec2 SSAO( return max(1.0 - vec2(occlusion*AO_Strength, sss)/n, 0.0); } -float ScreenSpace_SSS( - vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise -){ - int samples = 7; - float occlusion = 0.0; - float sss = 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 leaf = leaves ? -0.5 : 0.0; - - 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 = convertHandDepth_2(texelFetch2D(depthtex1, offsetUV, 0).x, hand); - - #ifdef DISTANT_HORIZONS - float sampleDHDepth = texelFetch2D(dhDepthTex1, offsetUV, 0).x; - vec3 offsetViewPos = toScreenSpace_DH((offsetUV*texelSize - jitterOffsets) * (1.0/RENDER_SCALE), sampleDepth, sampleDHDepth); - #else - vec3 offsetViewPos = toScreenSpace(vec3((offsetUV*texelSize - jitterOffsets) * (1.0/RENDER_SCALE), sampleDepth)); - #endif - - vec3 viewPosDiff = offsetViewPos - viewPos; - float viewPosDiffSquared = dot(viewPosDiff, viewPosDiff); - - if (viewPosDiffSquared > 1e-5){ - sss += clamp(leaf - dot(viewPosDiff, normalizedNormals),0.0,1.0); - n += 1; - } - } - } - return max(1.0 - sss/n, 0.0); -} - 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; @@ -414,59 +366,14 @@ float sampleDepth(sampler2D depthTex, vec2 texcoord, bool hand){ return convertHandDepth_2(texture2D(depthTex, texcoord).r, hand); } -flat varying vec3 zMults; - -vec4 BilateralUpscale_VLFOG(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){ - ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION); - ivec2 posDepth = ivec2(coord*VL_RENDER_RESOLUTION) * scaling; - ivec2 posColor = ivec2(coord*VL_RENDER_RESOLUTION); - ivec2 pos = ivec2(gl_FragCoord.xy*texelSize + 1); - - ivec2 getRadius[5] = ivec2[]( - ivec2(-1,-1), - ivec2( 1, 1), - ivec2(-1, 1), - ivec2( 1,-1), - ivec2( 0, 0) - ); - - #ifdef DISTANT_HORIZONS - float diffThreshold = 0.01; - #else - float diffThreshold = zMults.x; - #endif - - vec4 RESULT = vec4(0.0); - float SUM = 0.0; - - for (int i = 0; i < 4; i++) { - - ivec2 radius = getRadius[i]; - - #ifdef DISTANT_HORIZONS - float offsetDepth = sqrt(texelFetch2D(depth, posDepth + radius * scaling + pos * scaling,0).a/65000.0); - #else - float offsetDepth = ld(texelFetch2D(depth, posDepth + radius * scaling + pos * scaling, 0).r); - #endif - - float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5; - - RESULT += texelFetch2D(tex, posColor + radius + pos, 0) * EDGES; - - SUM += EDGES; - } - - return RESULT / SUM; -} -#include "/lib/sky_gradient.glsl" - -/* RENDERTARGETS:3,14,12,10*/ +/* RENDERTARGETS:3,14,12*/ void main() { float noise = R2_dither(); + vec2 texcoord = gl_FragCoord.xy*texelSize; float z = texture2D(depthtex1,texcoord).x; @@ -482,7 +389,7 @@ void main() { vec4 SHADOWDATA = vec4(0.0); - vec4 data = texelFetch2D(colortex1,ivec2(gl_FragCoord.xy),0); + vec4 data = texture2D(colortex1,texcoord); vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); vec3 normal = mat3(gbufferModelViewInverse) * clamp(worldToView( decode(dataUnpacked0.yw) ),-1.,1.); @@ -530,11 +437,13 @@ void main() { gl_FragData[2] = vec4(vec3(0.0), 65000.0); - vec3 FlatNormals = normalize(texture2D(colortex15,texcoord).rgb * 2.0 - 1.0); - if(z >= 1.0) FlatNormals = normal; + vec3 FlatNormals = texture2D(colortex15,texcoord).rgb * 2.0 - 1.0; + + if(z >= 1.0){ + FlatNormals = normal; + } - - vec2 SSAO_SSS = SSAO(viewPos, worldToView(FlatNormals), hand, isLeaf, noise); + vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise); if(swappedDepth >= 1.0) SSAO_SSS = vec2(1.0,0.0); @@ -544,21 +453,6 @@ void main() { #endif - - /*------------- VOLUMETRICS BEHIND TRANSLUCENTS PASS-THROUGH -------------*/ - // colortex10 is the history buffer used in reprojection of volumetrics, i can just hijack that. - gl_FragData[3] = texture2D(colortex10, texcoord); - - // if(texture2D(colortex7,texcoord).a > 0.0) { - // vec4 VL = BilateralUpscale_VLFOG(colortex13, depthtex1, gl_FragCoord.xy - 1.5, ld(z)); - - // // gl_FragData[3].rgb += VL.rgb * gl_FragData[3].a; - // // gl_FragData[3].a *= VL.a; - // } - - - - #ifdef OVERWORLD_SHADER float SpecularTex = texture2D(colortex8,texcoord).z; float LabSSS = clamp((-64.0 + SpecularTex * 255.0) / 191.0 ,0.0,1.0); @@ -569,7 +463,9 @@ void main() { float minshadowfilt = Min_Shadow_Filter_Radius; float maxshadowfilt = Max_Shadow_Filter_Radius; - if(lightmap.y < 0.1) maxshadowfilt = min(maxshadowfilt, minshadowfilt); + // if(lightmap.y < 0.1 && !entities){ + // maxshadowfilt = mix(minshadowfilt, maxshadowfilt, vanillAO); + // } #ifdef BASIC_SHADOW_FILTER if (LabSSS > 0.0 && NdotL < 0.001){ diff --git a/shaders/dimensions/composite.vsh b/shaders/dimensions/composite.vsh index 524b7ba..785dc42 100644 --- a/shaders/dimensions/composite.vsh +++ b/shaders/dimensions/composite.vsh @@ -12,10 +12,6 @@ uniform vec3 sunPosition; uniform mat4 gbufferModelViewInverse; -flat varying vec3 zMults; - -uniform float far; -uniform float near; #include "/lib/util.glsl" #include "/lib/res_params.glsl" @@ -30,8 +26,6 @@ void main() { WsunVec = (float(sunElevation > 1e-5)*2-1.)*normalize(mat3(gbufferModelViewInverse) * sunPosition); - zMults = vec3(1.0/(far * near),far+near,far-near); - #ifdef TAA TAA_Offset = offsets[framemod8]; #else diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index e87d11b..3bbc665 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -17,7 +17,6 @@ #define projMAD_old(m, v) (diagonal3_old(m) * (v) + (m)[3].xyz) const bool colortex5MipmapEnabled = true; -uniform float nightVision; #ifdef OVERWORLD_SHADER const bool shadowHardwareFiltering = true; @@ -40,16 +39,18 @@ uniform float nightVision; #endif #ifdef NETHER_SHADER + uniform float nightVision; const bool colortex4MipmapEnabled = true; uniform vec3 lightningEffect; - #undef LIGHTSOURCE_REFLECTION + // #define LIGHTSOURCE_REFLECTION #endif #ifdef END_SHADER + uniform float nightVision; uniform vec3 lightningEffect; flat varying float Flashing; - #undef LIGHTSOURCE_REFLECTION + // #define LIGHTSOURCE_REFLECTION #endif uniform int hideGUI; @@ -87,18 +88,18 @@ uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha) #endif -// uniform mat4 shadowModelView; -// uniform mat4 shadowModelViewInverse; -// uniform mat4 shadowProjection; -// uniform mat4 shadowProjectionInverse; -// uniform mat4 gbufferProjection; -// uniform mat4 gbufferProjectionInverse; -// uniform mat4 gbufferModelView; -// uniform mat4 gbufferModelViewInverse; -// uniform mat4 gbufferPreviousProjection; +uniform mat4 shadowModelView; +uniform mat4 shadowModelViewInverse; +uniform mat4 shadowProjection; +uniform mat4 shadowProjectionInverse; +uniform mat4 gbufferProjection; +uniform mat4 gbufferProjectionInverse; +uniform mat4 gbufferModelView; +uniform mat4 gbufferModelViewInverse; +uniform mat4 gbufferPreviousProjection; uniform mat4 gbufferPreviousModelView; -// uniform vec3 cameraPosition; +uniform vec3 cameraPosition; uniform vec3 previousCameraPosition; // uniform float far; @@ -148,14 +149,12 @@ float convertHandDepth_2(in float depth, bool hand) { return ndcDepth * 0.5 + 0.5; } -#include "/lib/projections.glsl" - -// vec3 toScreenSpace(vec3 p) { -// vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); -// vec3 feetPlayerPos = p * 2. - 1.; -// vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3]; -// return viewPos.xyz / viewPos.w; -// } +vec3 toScreenSpace(vec3 p) { + vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); + vec3 feetPlayerPos = p * 2. - 1.; + vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3]; + return viewPos.xyz / viewPos.w; +} @@ -169,15 +168,7 @@ float convertHandDepth_2(in float depth, bool hand) { #include "/lib/stars.glsl" #ifdef OVERWORLD_SHADER - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - + #define CLOUDSHADOWSONLY #include "/lib/volumetricClouds.glsl" #define CLOUDS_INTERSECT_TERRAIN @@ -213,13 +204,6 @@ vec2 decodeVec2(float a){ #include "/lib/end_fog.glsl" - - -#define DEFERRED_SPECULAR -#define DEFERRED_ENVIORNMENT_REFLECTION -#define DEFERRED_BACKGROUND_REFLECTION -#define DEFERRED_ROUGH_REFLECTION - #include "/lib/specular.glsl" @@ -291,60 +275,33 @@ vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth, return vec3(sampled.x,sampled.yz/sampled.w); } - -float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif -} float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; + float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715) ) ); + return noise ; } float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += (frameCounter%40000) * 2.0; - #endif - - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * coord.x + alpha.y * coord.y ) ; -} -float R2_dither2(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += (frameCounter*8)%40000; - #endif - + vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha.x * coord.x + alpha.y * coord.y ) ; } float blueNoise(){ - #ifdef TAA - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); - #else - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887); - #endif + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } vec4 blueNoise(vec2 coord){ return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; } -// vec3 toShadowSpaceProjected(vec3 feetPlayerPos){ +vec3 toShadowSpaceProjected(vec3 feetPlayerPos){ -// mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection); + mat4 DH_shadowProjection = DH_shadowProjectionTweak(shadowProjection); -// feetPlayerPos = mat3(gbufferModelViewInverse) * feetPlayerPos + gbufferModelViewInverse[3].xyz; -// feetPlayerPos = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz; -// feetPlayerPos = diagonal3_old(DH_shadowProjection) * feetPlayerPos + DH_shadowProjection[3].xyz; + feetPlayerPos = mat3(gbufferModelViewInverse) * feetPlayerPos + gbufferModelViewInverse[3].xyz; + feetPlayerPos = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz; + feetPlayerPos = diagonal3_old(DH_shadowProjection) * feetPlayerPos + DH_shadowProjection[3].xyz; -// return feetPlayerPos; -// } + return feetPlayerPos; +} vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0) { @@ -384,7 +341,7 @@ vec2 CleanSample( // for every sample, the sample position must change its distance from the origin. // otherwise, you will just have a circle. - float spiralShape = sqrt(variedSamples / (totalSamples + variance)); + float spiralShape = pow(variedSamples / (totalSamples + variance),0.5); float shape = 2.26; // this is very important. 2.26 is very specific float theta = variedSamples * (PI * shape); @@ -431,7 +388,7 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo _far = dhFarPlane; } - vec3 worldpos = mat3(gbufferModelViewInverse) * viewPos ; + vec3 worldpos = mat3(gbufferModelViewInverse) * viewPos; float dist = 1.0 + length(worldpos)/(_far/2.0); // step length as distance increases vec3 clipPosition = toClipSpace3_DH(viewPos, depthCheck); @@ -484,8 +441,8 @@ void Emission( float Emission, float exposure ){ - // float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); - if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why + float autoBrightnessAdjust = mix(5.0, 100.0, clamp(exp(-10.0*exposure),0.0,1.0)); + if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * Emissive_Brightness * autoBrightnessAdjust, pow(Emission, Emissive_Curve)); // old method.... idk why // if( Emission < 254.5/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve); } @@ -588,10 +545,6 @@ void BilateralUpscale_REUSE_Z(sampler2D tex1, sampler2D tex2, sampler2D depth, v ivec2( 1,-1), ivec2( 1, 1), ivec2(-1, 1) - // ivec2( 0, 1), - // ivec2( 0,-1), - // ivec2(-1, 0), - // ivec2( 1, 0) ); #ifdef DISTANT_HORIZONS @@ -743,59 +696,6 @@ float ComputeShadowMap(in vec3 projectedShadowPosition, float distortFactor, flo // return mix(1.0, shadowmap / samples, maxDistFade); } - - -vec3 ComputeShadowMap_COLOR(in vec3 projectedShadowPosition, float distortFactor, float noise, float shadowBlockerDepth, float NdotL, float maxDistFade, vec3 directLightColor, inout float FUNNYSHADOW, inout vec3 tintedSunlight, bool isSSS){ - - // if(maxDistFade <= 0.0) return 1.0; - float backface = NdotL <= 0.0 ? 1.0 : 0.0; - - vec3 shadowColor = vec3(0.0); - vec3 translucentTint = vec3(0.0); - - #ifdef BASIC_SHADOW_FILTER - int samples = SHADOW_FILTER_SAMPLE_COUNT; - float rdMul = (shadowBlockerDepth*distortFactor*d0*k/shadowMapResolution) * 0.3; - - for(int i = 0; i < samples; i++){ - vec2 offsetS = CleanSample(i, samples - 1, noise) * rdMul; - projectedShadowPosition.xy += offsetS; - #else - int samples = 1; - #endif - - #ifdef TRANSLUCENT_COLORED_SHADOWS - float opaqueShadow = shadow2D(shadowtex0, projectedShadowPosition).x; - float opaqueShadowT = shadow2D(shadowtex1, projectedShadowPosition).x; - vec4 translucentShadow = texture2D(shadowcolor0, projectedShadowPosition.xy); - - float shadowAlpha = pow(1.0-pow(1.0-translucentShadow.a,2.0),5.0); - translucentShadow.rgb = normalize(translucentShadow.rgb*translucentShadow.rgb + 0.0001) * (1.0-shadowAlpha); - - // translucentTint += mix(translucentShadow.rgb * mix(opaqueShadowT, 1.0, backface), vec3(1.0), max(opaqueShadow, backface * (shadowAlpha < 1.0 ? 0.0 : 1.0))); - - shadowColor += directLightColor * mix(translucentShadow.rgb * opaqueShadowT, vec3(1.0), opaqueShadow); - - translucentTint += mix(translucentShadow.rgb, vec3(1.0), max(opaqueShadow, backface * (shadowAlpha < 1.0 ? 0.0 : 1.0))); - FUNNYSHADOW += ((1.0-shadowAlpha) * opaqueShadowT)/samples; - #else - shadowColor += directLightColor * shadow2D(shadow, projectedShadowPosition).x; - #endif - - #ifdef BASIC_SHADOW_FILTER - } - #endif - - // #ifdef TRANSLUCENT_COLORED_SHADOWS - // directLightColor *= mix(vec3(1.0), translucentTint.rgb / samples, maxDistFade); - tintedSunlight *= translucentTint.rgb / samples; - // #endif - - return mix(directLightColor, shadowColor.rgb / samples, maxDistFade); - // return 1.0; - // return mix(1.0, shadow / samples, maxDistFade); -} - #endif float CustomPhase(float LightPos){ @@ -809,143 +709,44 @@ float CustomPhase(float LightPos){ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, float lightPos, float shadows, float distantSSS){ - // Scattering *= sss_density_multiplier; + Scattering *= sss_density_multiplier; - // float density = 0.0001 + Density*2.0; + float density = 0.0001 + Density*2.0; - // 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 - // scatterDepth = max(scatterDepth, pow(shadows, 0.5 + (1.0-Density) * 2.0) ); - // #else - // scatterDepth = exp(-7.0 * pow(1.0-shadows,3.0))*min(2.0-sss_density_multiplier,1.0); - // #endif - - // // PBR at its finest :clueless: - // vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(20.0 - 19*scatterDepth) * sss_absorbance_multiplier); - - // vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve); - - // scatter *= 1.0 + CustomPhase(lightPos)*6.0; // ~10x brighter at the peak - - // return scatter; - - - // Scattering *= sss_density_multiplier; - - float density = 1e-6 + Density * 2.0; - - // float scatterDepth = Scattering;//max(1.0 - Scattering/density,0.0); - - float scatterDepth = max(1.0 - Scattering/density, 0.0); - 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); + float scatterDepth = max(1.0 - Scattering/density,0.0); + scatterDepth = exp((1.0-scatterDepth) * -7.0); scatterDepth = mix(exp(Scattering * -10.0), scatterDepth, distantSSS); - vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve);// * vec3(1.0); - - - scatter *= 1.0 + CustomPhase(lightPos)*6.0; // ~10x brighter at the peak - - return scatter; -} - -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; + // this is for SSS when there is no shadow blocker depth + #if defined BASIC_SHADOW_FILTER && defined Variable_Penumbra_Shadows + scatterDepth = max(scatterDepth, pow(shadows, 0.5 + (1.0-Density) * 2.0) ); + #else + scatterDepth = exp(-7.0 * pow(1.0-shadows,3.0))*min(2.0-sss_density_multiplier,1.0); + #endif // 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 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(20.0 - 19*scatterDepth) * sss_absorbance_multiplier); vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve); + scatter *= 1.0 + CustomPhase(lightPos)*6.0; // ~10x brighter at the peak + return scatter; } - - -vec3 blurredAlbedo( float noise, float lineardistance){ - - int samples = 7; - vec3 blurredColor = vec3(0.0); - - for (int i = 0; i < samples; i++) { - - vec2 offsets = CleanSample(i, samples - 1, noise)*0.02 / lineardistance; - - ivec2 offsetUV = ivec2(gl_FragCoord.xy + offsets*vec2(viewWidth, viewHeight*aspectRatio)*RENDER_SCALE); - - vec3 SAMPLE = texelFetch2D(colortex1, offsetUV, 0).xyz; - - blurredColor += toLinear(vec3(decodeVec2(SAMPLE.x).x, decodeVec2(SAMPLE.y).x, decodeVec2(SAMPLE.z).x)); - - } - - return blurredColor/samples; -} -uniform float wetnessAmount; -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 -){ - - float halfWet = min(wetnessAmount,1.0); - float fullWet = clamp(wetnessAmount - 2.0,0.0,1.0); - // halfWet = 1.0; - // fullWet = 0.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); - 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; +vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){ - 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)); - -} - -vec2 smoothfilterUV(in vec2 uv) -{ - vec2 textureResolution = vec2(viewWidth,viewHeight); - uv = uv*textureResolution + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - - #ifndef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + (fuv*fuv)*(3.0-2.0*fuv); - #endif - #ifdef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0); - #endif - - uv = (uv - 0.5)/textureResolution; + Scattering *= sss_density_multiplier; - return uv; + float scatterDepth = 1.0 - pow(Scattering, 0.5 + Density * 2.5); + + // PBR at its finest :clueless: + vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(15.0 - 10.0*scatterDepth) * sss_absorbance_multiplier * 0.01); + + vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve); + + return scatter; } void main() { @@ -953,18 +754,12 @@ void main() { vec3 DEBUG = vec3(1.0); ////// --------------- SETUP STUFF --------------- ////// - vec2 texcoord = (gl_FragCoord.xy*texelSize); + vec2 texcoord = gl_FragCoord.xy*texelSize; + vec2 bnoise = blueNoise(gl_FragCoord.xy).rg; + int seed = (frameCounter%40000) + frameCounter*2; + float noise = fract(R2_samples(seed).y + bnoise.y); float noise_2 = R2_dither(); - vec2 bnoise = blueNoise(gl_FragCoord.xy ).rg; - // #ifdef TAA - int seed = (frameCounter*5)%40000; - vec2 r2_sequence = R2_samples(seed).xy; - vec2 BN = fract(r2_sequence + bnoise); - float noise = BN.y; - // #else - // float noise = fract(R2_samples(3).y + bnoise.y); - // #endif float z0 = texture2D(depthtex0,texcoord).x; float z = texture2D(depthtex1,texcoord).x; @@ -1001,7 +796,7 @@ void main() { ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - vec4 data = texelFetch2D(colortex1, ivec2(gl_FragCoord.xy), 0); + vec4 data = texture2D(colortex1,texcoord); vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps @@ -1010,7 +805,7 @@ void main() { vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x)); vec3 normal = decode(dataUnpacked0.yw); vec2 lightmap = dataUnpacked1.yz; - + lightmap.xy = min(max(lightmap.xy - 0.05,0.0)*1.06,1.0); // small offset to hide flickering from precision error in the encoding/decoding on values close to 1.0 or 0.0 #if !defined OVERWORLD_SHADER @@ -1023,11 +818,11 @@ void main() { ////// --------------- UNPACK MISC --------------- ////// - vec4 SpecularTex = texelFetch2D(colortex8, ivec2(gl_FragCoord.xy), 0); + vec4 SpecularTex = texture2D(colortex8,texcoord); float LabSSS = clamp((-65.0 + SpecularTex.z * 255.0) / 190.0 ,0.0,1.0); vec4 normalAndAO = texture2D(colortex15,texcoord); - vec3 FlatNormals = normalize(normalAndAO.rgb * 2.0 - 1.0); + vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; vec3 slopednormal = normal; float vanilla_AO = z < 1.0 ? clamp(normalAndAO.a,0,1) : 0.0; @@ -1035,6 +830,7 @@ void main() { if(isDHrange){ FlatNormals = normal; + normal = viewToWorld(normal); slopednormal = normal; } @@ -1072,9 +868,9 @@ void main() { } #ifdef DISTANT_HORIZONS - vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5, z, DH_depth1); + vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z, DH_depth1); #else - vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5, z)); + vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z)); #endif vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos; @@ -1088,48 +884,38 @@ void main() { #endif ////// --------------- COLORS --------------- ////// - - float dirtAmount = Dirt_Amount; - // float dirtAmount = Dirt_Amount + 0.01; + 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 = dirtEpsilon*dirtAmount + waterEpsilon; vec3 Absorbtion = vec3(1.0); vec3 AmbientLightColor = vec3(0.0); vec3 MinimumLightColor = vec3(1.0); vec3 Indirect_lighting = vec3(0.0); vec3 Indirect_SSS = vec3(0.0); - vec2 SSAO_SSS = vec2(1.0); vec3 DirectLightColor = vec3(0.0); vec3 Direct_lighting = vec3(0.0); vec3 Direct_SSS = vec3(0.0); float cloudShadow = 1.0; float Shadows = 1.0; - - vec3 shadowColor = vec3(1.0); - vec3 SSSColor = vec3(1.0); - vec3 filteredShadow = vec3(Min_Shadow_Filter_Radius,1.0,0.0); - float NdotL = 1.0; float lightLeakFix = clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); #ifdef OVERWORLD_SHADER - DirectLightColor = lightCol.rgb / 2400.0;//mix(900.0, 2400.0, lightmap.y); - AmbientLightColor = averageSkyCol_Clouds / 900.0; - shadowColor = DirectLightColor; + DirectLightColor = lightCol.rgb / 80.0; + AmbientLightColor = averageSkyCol_Clouds / 30.0; - // #ifdef PER_BIOME_ENVIRONMENT - // // BiomeSunlightColor(DirectLightColor); - // vec3 biomeDirect = DirectLightColor; - // vec3 biomeIndirect = AmbientLightColor; - // float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect); + #ifdef PER_BIOME_ENVIRONMENT + // BiomeSunlightColor(DirectLightColor); + vec3 biomeDirect = DirectLightColor; + vec3 biomeIndirect = AmbientLightColor; + float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect); - // float maxDistance = inBiome * min(max(1.0 - length(feetPlayerPos)/(32*8),0.0)*2.0,1.0); - // DirectLightColor = mix(DirectLightColor, biomeDirect, maxDistance); - // #endif + float maxDistance = inBiome * min(max(1.0 - length(feetPlayerPos)/(32*8),0.0)*2.0,1.0); + DirectLightColor = mix(DirectLightColor, biomeDirect, maxDistance); + #endif bool inShadowmapBounds = false; #endif @@ -1139,93 +925,91 @@ void main() { //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////// START DRAW //////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// - - + if (swappedDepth >= 1.0) { + vec3 Background = vec3(0.0); - //////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// UNDER WATER SHADING //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////// + #ifdef OVERWORLD_SHADER + float atmosphereGround = 1.0 - exp2(-50.0 * pow(clamp(feetPlayerPos_normalized.y+0.025,0.0,1.0),2.0) ); // darken the ground in the sky. + + #if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0 || RESOURCEPACK_SKY == 3 + // vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2; + vec3 orbitstar = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE,1.0))); + float radiance = 2.39996 - (worldTime + worldDay*24000.0) / 24000.0; + // float radiance = 2.39996 + frameTimeCounter; + mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); + + orbitstar.xy *= rotationMatrix; - if ((isEyeInWater == 0 && isWater) || (isEyeInWater == 1 && !isWater)){ - - feetPlayerPos += gbufferModelViewInverse[3].xyz; - - #ifdef DISTANT_HORIZONS - vec3 playerPos0 = mat3(gbufferModelViewInverse) * toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z0, DH_depth0) + gbufferModelViewInverse[3].xyz; - #else - vec3 playerPos0 = mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)) + gbufferModelViewInverse[3].xyz; + Background += stars(orbitstar) * 10.0 * clamp(-unsigned_WsunVec.y*2.0,0.0,1.0); + + #if !defined ambientLight_only && (RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0) + Background += drawSun(dot(lightCol.a * WsunVec, feetPlayerPos_normalized),0, DirectLightColor,vec3(0.0)); + Background += drawMoon(feetPlayerPos_normalized, lightCol.a * WsunVec, DirectLightColor*20, Background); + #endif + + Background *= atmosphereGround; + #endif + + vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0 * Sky_Brightness; + Background += Sky; + #endif - 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)); + #if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 2 || RESOURCEPACK_SKY == 3 + vec3 resourcePackskyBox = toLinear(texture2D(colortex10, texcoord).rgb * 5.0) * 15.0 * clamp(unsigned_WsunVec.y*2.0,0.1,1.0); - // 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; + #ifdef SKY_GROUND + resourcePackskyBox *= atmosphereGround; + #endif + + Background += resourcePackskyBox; #endif - viewerWaterDepth += max(estimatedDepth - 1.0, minimumAbsorbance); + #if defined OVERWORLD_SHADER && defined VOLUMETRIC_CLOUDS && !defined CLOUDS_INTERSECT_TERRAIN + vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x); + Background = Background * Clouds.a + Clouds.rgb; + #endif - Absorbtion = exp( -2.0 * totEpsilon * viewerWaterDepth); + gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise_2)), 0.0, 65000.); - // 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; + } else { - if (isEyeInWater == 1){ - estimatedDepth = 1.0; - viewerWaterDepth = max(0.9-lightmap.y,0.0)*3.0; - Absorbtion = exp( -2.0 * totEpsilon * viewerWaterDepth); - - DirectLightColor *= Absorbtion; - } - - // 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)); - } - - - if (swappedDepth < 1.0) { - - // idk why this do feetPlayerPos += gbufferModelViewInverse[3].xyz; + //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////// FILTER STUFF ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// - + + vec3 filteredShadow = vec3(1.412,1.0,0.0); + vec2 SSAO_SSS = vec2(1.0); + #if defined DISTANT_HORIZONS && defined DH_AMBIENT_OCCLUSION BilateralUpscale_REUSE_Z(colortex3, colortex14, colortex12, gl_FragCoord.xy-1.5, DH_mixedLinearZ, SSAO_SSS, filteredShadow, hand); #else BilateralUpscale_REUSE_Z(colortex3, colortex14, depthtex0, gl_FragCoord.xy-1.5, ld(z0), SSAO_SSS, filteredShadow, hand); #endif - + float ShadowBlockerDepth = filteredShadow.y; + //////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// MAJOR LIGHTSOURCE STUFF //////////////////////// //////////////////////////////////////////////////////////////////////////////////// #ifdef OVERWORLD_SHADER - - float LM_shadowMapFallback = min(max(lightmap.y-0.8, 0.0) * 5.0,1.0); + float LM_shadowMapFallback = min(max(lightmap.y-0.8, 0.0) * 25,1.0); float LightningPhase = 0.0; vec3 LightningFlashLighting = Iris_Lightningflash(feetPlayerPos, lightningBoltPosition.xyz, slopednormal, LightningPhase) * pow(lightmap.y,10); NdotL = clamp((-15 + dot(slopednormal, WsunVec)*255.0) / 240.0 ,0.0,1.0); - // NdotL = 1; - float flatNormNdotL = clamp((-15 + dot((FlatNormals), WsunVec)*255.0) / 240.0 ,0.0,1.0); + float flatNormNdotL = clamp((-15 + dot(viewToWorld(FlatNormals), WsunVec)*255.0) / 240.0 ,0.0,1.0); - //////////////////////////////// SHADOWMAP //////////////////////////////// // setup shadow projection vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; - if(!hand) GriAndEminShadowFix(shadowPlayerPos, FlatNormals, vanilla_AO, lightmap.y); + if(!hand) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y); vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz; projectedShadowPosition = diagonal3_old(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; @@ -1248,9 +1032,6 @@ void main() { float shadowMapFalloff2 = shadowmapFade; #endif - // shadowMapFalloff = 1.0; - // shadowMapFalloff2 = 1.0; - // un-distort #ifdef DISTORT_SHADOWMAP float distortFactor = calcDistort(projectedShadowPosition.xy); @@ -1258,66 +1039,48 @@ void main() { #else float distortFactor = 1.0; #endif - + projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5) ; float ShadowAlpha = 0.0; // this is for subsurface scattering later. - vec3 tintedSunlight = DirectLightColor; // this is for subsurface scattering later. - - shadowColor = ComputeShadowMap_COLOR(projectedShadowPosition, distortFactor, noise_2, filteredShadow.x, flatNormNdotL, shadowMapFalloff, DirectLightColor, ShadowAlpha, tintedSunlight, LabSSS > 0.0); + Shadows = ComputeShadowMap(projectedShadowPosition, distortFactor, noise_2, filteredShadow.x, flatNormNdotL, shadowMapFalloff, DirectLightColor, ShadowAlpha, LabSSS > 0.0); - // transition to fallback lightmap shadow mask. - shadowColor *= mix(isWater ? lightLeakFix : LM_shadowMapFallback, 1.0, shadowMapFalloff2); + Shadows = mix(isWater ? lightLeakFix : LM_shadowMapFallback, Shadows, shadowMapFalloff); - // #ifdef OLD_LIGHTLEAK_FIX - // if (isEyeInWater == 0) Shadows *= lightLeakFix; // light leak fix - // #endif - - //////////////////////////////// SUN SSS //////////////////////////////// - #if SSS_TYPE != 0 - - float sunSSS_density = LabSSS; - float SSS_shadow = ShadowAlpha; - - #ifdef DISTANT_HORIZONS - shadowMapFalloff2 = smoothstep(0.0, 1.0, min(max(1.0 - length(feetPlayerPos) / min(shadowDistance, max(far-32.0,32.0)),0.0)*5.0,1.0)); - #endif - - #ifndef RENDER_ENTITY_SHADOWS - if(entities) sunSSS_density = 0.0; - #endif - - #ifdef SCREENSPACE_CONTACT_SHADOWS - vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise_temporal(), sunSSS_density > 0.0 && shadowMapFalloff2 < 1.0, hand); - - // combine shadowmap with a minumum shadow determined by the screenspace shadows. - shadowColor *= SS_directLight.r; - - // combine shadowmap blocker depth with a minumum determined by the screenspace shadows, starting after the shadowmap ends - ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff2); - #endif - #ifdef TRANSLUCENT_COLORED_SHADOWS - SSSColor = tintedSunlight; - #else - SSSColor = DirectLightColor; - #endif - - SSSColor *= SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), SSS_shadow, shadowMapFalloff2); - - if(isEyeInWater != 1)SSSColor *= lightLeakFix; - - #ifndef SCREENSPACE_CONTACT_SHADOWS - SSSColor = mix(vec3(0.0), SSSColor, shadowMapFalloff2); - #endif - - #ifdef CLOUDS_SHADOWS - float cloudShadows = GetCloudShadow(feetPlayerPos.xyz + cameraPosition, WsunVec); - shadowColor *= cloudShadows; - SSSColor *= cloudShadow*cloudShadows; - #endif + #ifdef OLD_LIGHTLEAK_FIX + if (isEyeInWater == 0) Shadows *= lightLeakFix; // light leak fix #endif #endif + + //////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////// UNDER WATER SHADING //////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////// + + if ((isEyeInWater == 0 && isWater) || (isEyeInWater == 1 && !isWater)){ + #ifdef DISTANT_HORIZONS + vec3 viewPos0 = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z0, DH_depth0); + #else + vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); + #endif + + float Vdiff = distance(viewPos, viewPos0)*mix(5.0,2.0,clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0)); + float estimatedDepth = Vdiff * abs(feetPlayerPos_normalized.y); //assuming water plane + + // make it such that the estimated depth flips to be correct when entering water. + if (isEyeInWater == 1){ + estimatedDepth = 40.0 * pow(max(1.0-lightmap.y,0.0),2.0); + MinimumLightColor = vec3(10.0); + } + + float depthfalloff = 1.0 - clamp(exp(-0.1*estimatedDepth),0.0,1.0); + + float estimatedSunDepth = Vdiff; //assuming water plane + Absorbtion = mix(exp(-2.0 * totEpsilon * estimatedDepth), exp(-8.0 * totEpsilon), depthfalloff); + + // 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)); + } #ifdef END_SHADER float vortexBounds = clamp(vortexBoundRange - length(feetPlayerPos+cameraPosition), 0.0,1.0); @@ -1329,10 +1092,11 @@ void main() { float end_NdotL = clamp(dot(slopednormal, normalize(-lightPos))*0.5+0.5,0.0,1.0); end_NdotL *= end_NdotL; - float fogShadow = GetEndFogShadow(feetPlayerPos+cameraPosition, lightPos); + float fogShadow = GetCloudShadow(feetPlayerPos+cameraPosition, lightPos); float endPhase = endFogPhase(lightPos); Direct_lighting += lightColors * endPhase * end_NdotL * fogShadow; + AmbientLightColor += lightColors * (endPhase*endPhase) * (1.0-exp(vec3(0.6,2.0,2) * -(endPhase*0.1))) ; #endif @@ -1347,7 +1111,7 @@ void main() { float SkylightDir = (slopednormal / dot(abs(slopednormal),vec3(1.0))).y*1.5; if(isGrass) SkylightDir = 1.5; - skylight = max(pow((FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.2 + (1-lightmap.y)*0.8); + skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.2 + (1-lightmap.y)*0.8); #if indirect_effect == 1 skylight = min(skylight, mix(0.95, 2.5, pow(1-pow(1-SSAO_SSS.x, 0.5),2.0) )); @@ -1363,30 +1127,27 @@ void main() { #endif #ifdef NETHER_SHADER - Indirect_lighting = volumetricsFromTex(normalize(normal), colortex4, 6).rgb / 1200.0; - vec3 up = volumetricsFromTex(vec3(0.0,1.0,0.0), colortex4, 6).rgb / 1200.0; + Indirect_lighting = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 30.0; + vec3 up = skyCloudsFromTexLOD2(vec3(0.0,1.0,0.0), colortex4, 6).rgb / 30.0; #if indirect_effect == 1 Indirect_lighting = mix(up, Indirect_lighting, clamp(pow(1.0-pow(1.0-SSAO_SSS.x, 0.5),2.0),0.0,1.0)); #endif - AmbientLightColor = Indirect_lighting; + AmbientLightColor = Indirect_lighting / 5.0; #endif #ifdef END_SHADER - Indirect_lighting = vec3(0.3,0.6,1.0); + Indirect_lighting = vec3(0.3,0.6,1.0) * 0.5; Indirect_lighting = Indirect_lighting + 0.7*mix(-Indirect_lighting, Indirect_lighting * dot(slopednormal, feetPlayerPos_normalized), clamp(pow(1.0-pow(1.0-SSAO_SSS.x, 0.5),2.0),0.0,1.0)); - Indirect_lighting *= 0.1; - - Indirect_lighting += lightColors * (endPhase*endPhase) * (1.0-exp(vec3(0.6,2.0,2.0) * -(endPhase*0.01))) /1000.0; #endif #ifdef IS_LPV_ENABLED vec3 normalOffset = vec3(0.0); if (any(greaterThan(abs(FlatNormals), vec3(1.0e-6)))) - normalOffset = 0.5*(FlatNormals); + normalOffset = 0.5*viewToWorld(FlatNormals); #if LPV_NORMAL_STRENGTH > 0 vec3 texNormalOffset = -normalOffset + slopednormal; @@ -1397,6 +1158,7 @@ void main() { #else const vec3 lpvPos = vec3(0.0); #endif + vec3 blockLightColor = doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos); Indirect_lighting += blockLightColor; @@ -1440,7 +1202,9 @@ void main() { if(!hand) Indirect_lighting = ApplySSRT(Indirect_lighting, blockLightColor, MinimumLightColor, viewPos, normal, vec3(bnoise, noise_2), lightmap.y, isGrass, isDHrange); #endif - + #if defined END_SHADER + Direct_lighting *= AO; + #endif //////////////////////////////////////////////////////////////////////////////// ///////////////////////// SUB SURFACE SCATTERING //////////////////////////// @@ -1449,10 +1213,11 @@ 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*2.5) * ambient_brightness; // 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*lightmap.y*lightmap.y; + Indirect_SSS *= AO; // apply to ambient light. Indirect_lighting = max(Indirect_lighting, Indirect_SSS * ambientColor * ambientsss_brightness); @@ -1463,6 +1228,49 @@ void main() { } #endif + //////////////////////////////// SUN SSS //////////////////////////////// + #if SSS_TYPE != 0 && defined OVERWORLD_SHADER + + float sunSSS_density = LabSSS; + float SSS_shadow = ShadowAlpha * Shadows; + + #ifdef DISTANT_HORIZONS + shadowMapFalloff2 = smoothstep(0.0, 1.0, min(max(1.0 - length(feetPlayerPos) / min(shadowDistance, max(far-32.0,32.0)),0.0)*5.0,1.0)); + #endif + + #ifndef RENDER_ENTITY_SHADOWS + if(entities) sunSSS_density = 0.0; + #endif + + #ifdef SCREENSPACE_CONTACT_SHADOWS + vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), sunSSS_density > 0.0 && shadowMapFalloff2 < 1.0, hand); + + // combine shadowmap with a minumum shadow determined by the screenspace shadows. + Shadows = min(Shadows, SS_directLight.r); + // Shadows = SS_directLight.r; + + // combine shadowmap blocker depth with a minumum determined by the screenspace shadows, starting after the shadowmap ends + ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff2); + // ShadowBlockerDepth = max( SS_directLight.g,0.0); + #endif + + + Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), SSS_shadow, shadowMapFalloff2); + + Direct_SSS *= lightLeakFix; + + #ifndef SCREENSPACE_CONTACT_SHADOWS + Direct_SSS = mix(vec3(0.0), Direct_SSS, shadowMapFalloff2); + #endif + + #ifdef CLOUDS_SHADOWS + cloudShadow = GetCloudShadow(feetPlayerPos); + Shadows *= cloudShadow; + Direct_SSS *= cloudShadow; + #endif + + #endif + ///////////////////////////////////////////////////////////////////////// ///////////////////////////// FINALIZE ///////////////////////////// ///////////////////////////////////////////////////////////////////////// @@ -1472,104 +1280,35 @@ void main() { albedo = vec3(1); NdotL = 0; #endif - #if defined END_SHADER - Direct_lighting *= AO; - #endif - #ifdef OVERWORLD_SHADER - // Direct_lighting = max(shadowColor*NdotL, SSSColor); - #ifdef AO_in_sunlight - Direct_lighting = shadowColor*NdotL*(AO*0.7+0.3) + SSSColor; - #else - Direct_lighting = shadowColor*NdotL + SSSColor; - #endif - #endif - - #if defined OVERWORLD_SHADER && defined DEFERRED_SPECULAR - if(!hand && !entities) applyPuddles(feetPlayerPos + cameraPosition, FlatNormals, lightmap.y, isWater, albedo, normal, SpecularTex.r, SpecularTex.g); - #endif - - vec3 FINAL_COLOR = (Indirect_lighting + Direct_lighting) * albedo; - - Emission(FINAL_COLOR, albedo, SpecularTex.a, exposure); - - if(lightningBolt) FINAL_COLOR = vec3(77.0, 153.0, 255.0); - - #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)); - #endif - - - gl_FragData[0].rgb = FINAL_COLOR; - // gl_FragData[0].rgb = vec3(1) * Absorbtion; - - - - - }else{ - vec3 Background = vec3(0.0); #ifdef OVERWORLD_SHADER - - float atmosphereGround = 1.0 - exp2(-50.0 * pow(clamp(feetPlayerPos_normalized.y+0.025,0.0,1.0),2.0) ); // darken the ground in the sky. - - #if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0 || RESOURCEPACK_SKY == 3 - // vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2; - vec3 orbitstar = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE,1.0))); - // float radiance = 2.39996 - (worldTime + worldDay*24000.0) / 24000.0; - float radiance = 2.39996 ; - // float radiance = 2.39996 + frameTimeCounter; - mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); - - orbitstar.xy *= rotationMatrix; - - Background += stars(orbitstar) * 10.0 * clamp(-unsigned_WsunVec.y*2.0,0.0,1.0); - - #if !defined ambientLight_only && (RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0) - Background += drawSun(dot(lightCol.a * WsunVec, feetPlayerPos_normalized),0, DirectLightColor,vec3(0.0)); - Background += drawMoon(feetPlayerPos_normalized, lightCol.a * WsunVec, DirectLightColor, Background); - #endif - - Background *= atmosphereGround; - #endif - - vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/1200.0 * Sky_Brightness; - Background += Sky; - + Direct_lighting = max(DirectLightColor * NdotL * Shadows, DirectLightColor * Direct_SSS); #endif - // #if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 2 || RESOURCEPACK_SKY == 3 - // vec3 resourcePackskyBox = toLinear(texture2D(colortex10, texcoord).rgb * 5.0) * 15.0 * clamp(unsigned_WsunVec.y*2.0,0.1,1.0); + gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo; - // #ifdef SKY_GROUND - // resourcePackskyBox *= atmosphereGround; - // #endif - - // Background += resourcePackskyBox; - // #endif - - #if defined OVERWORLD_SHADER && defined VOLUMETRIC_CLOUDS && !defined CLOUDS_INTERSECT_TERRAIN - vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x); - Background = Background * Clouds.a + Clouds.rgb; + #ifdef Specular_Reflections + vec2 specularNoises = vec2(noise, R2_dither()); + DoSpecularReflections(gl_FragData[0].rgb, viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*Shadows*NdotL, lightmap.y, hand); #endif + + Emission(gl_FragData[0].rgb, albedo, SpecularTex.a, exposure); + + if(lightningBolt) gl_FragData[0].rgb = vec3(77.0, 153.0, 255.0); - gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise_2)), 0.0, 65000.); + gl_FragData[0].rgb *= Absorbtion; } - - if(translucentMasks > 0.0 && isEyeInWater != 1){ - - // water absorbtion will impact ALL light coming up from terrain underwater. - gl_FragData[0].rgb *= Absorbtion; - - vec4 vlBehingTranslucents = BilateralUpscale_VLFOG(colortex13, depthtex1, gl_FragCoord.xy - 1.5, ld(z)); + if(translucentMasks > 0.0){ + #ifdef DISTANT_HORIZONS + vec4 vlBehingTranslucents = BilateralUpscale_VLFOG(colortex13, colortex12, gl_FragCoord.xy - 1.5, sqrt(texture2D(colortex12,texcoord).a/65000.0)); + #else + vec4 vlBehingTranslucents = BilateralUpscale_VLFOG(colortex13, depthtex1, gl_FragCoord.xy - 1.5, ld(z)); + #endif gl_FragData[0].rgb = gl_FragData[0].rgb * vlBehingTranslucents.a + vlBehingTranslucents.rgb; - } - + ////// DEBUG VIEW STUFF #if DEBUG_VIEW == debug_SHADOWMAP gl_FragData[0].rgb = vec3(0.5) + vec3(1.0) * Shadows * 30.0; @@ -1587,29 +1326,24 @@ void main() { gl_FragData[0].rgb = Indirect_lighting; #endif #if DEBUG_VIEW == debug_DIRECT - if(swappedDepth >= 1.0) Direct_lighting = vec3(1.0); - gl_FragData[0].rgb = Direct_lighting; + if(swappedDepth >= 1.0) Direct_lighting = vec3(15.0); + gl_FragData[0].rgb = Direct_lighting + 0.5; #endif #if DEBUG_VIEW == debug_VIEW_POSITION gl_FragData[0].rgb = viewPos * 0.001; #endif #if DEBUG_VIEW == debug_FILTERED_STUFF - - // 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); - // 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))); + // if(hideGUI == 1) gl_FragData[0].rgb = vec3(1) * (1.0 - SSAO_SSS.y); + // if(hideGUI == 0) gl_FragData[0].rgb = vec3(1) * (1.0 - SSAO_SSS.x); + 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; // gl_FragData[0].rgb = vec3(1) * Shadows; // if(swappedDepth >= 1.0) gl_FragData[0].rgb = vec3(0.1); - // gl_FragData[0].rgb = vec3(1) * ld(texture2D(depthtex1, texcoord).r); - // if(texcoord.x > 0.5 ) - - // gl_FragData[0].rgb = vec3(1) * filteredShadow.y; - // if(swappedDepth >= 1.0) gl_FragData[0].rgb += vec3(0.5); + // if(texcoord.x > 0.5 )gl_FragData[0].rgb = vec3(1) * ld(texture2D(depthtex0, texcoord).r); - /* RENDERTARGETS:3 */ + + + /* DRAWBUFFERS:3 */ } \ No newline at end of file diff --git a/shaders/dimensions/composite1.vsh b/shaders/dimensions/composite1.vsh index a77e3e9..39df506 100644 --- a/shaders/dimensions/composite1.vsh +++ b/shaders/dimensions/composite1.vsh @@ -5,11 +5,10 @@ flat varying float Flashing; #endif - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #endif - +#if defined Daily_Weather + flat varying vec4 dailyWeatherParams0; + flat varying vec4 dailyWeatherParams1; +#endif flat varying vec3 WsunVec; flat varying vec3 unsigned_WsunVec; @@ -54,14 +53,14 @@ void main() { averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) * sunPosition); unsigned_WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition); - WsunVec = lightCol.a*unsigned_WsunVec; exposure = texelFetch2D(colortex4,ivec2(10,37),0).r; #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0); #endif #ifdef TAA diff --git a/shaders/dimensions/composite10.fsh b/shaders/dimensions/composite10.fsh index 8f1de2b..8e5c48b 100644 --- a/shaders/dimensions/composite10.fsh +++ b/shaders/dimensions/composite10.fsh @@ -106,7 +106,7 @@ vec2 texcoord = ((gl_FragCoord.xy)*2.0 + 0.5)*texelSize; bloom += texture2D_bicubic(colortex6,texcoord/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb * weights[5]; //1/128 res bloom += texture2D_bicubic(colortex6,texcoord/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb * weights[6]; //1/256 res - gl_FragData[0].rgb = bloom * 2.0; + gl_FragData[0].rgb = bloom * 3.0; #endif gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); diff --git a/shaders/dimensions/composite11.fsh b/shaders/dimensions/composite11.fsh index 2e5ed7c..5c98b4d 100644 --- a/shaders/dimensions/composite11.fsh +++ b/shaders/dimensions/composite11.fsh @@ -14,7 +14,7 @@ uniform sampler2D colortex3; // uniform sampler2D colortex6; uniform sampler2D colortex7; // uniform sampler2D colortex8; // specular -uniform sampler2D colortex9; // specular +// uniform sampler2D colortex9; // specular uniform sampler2D depthtex0; uniform sampler2D depthtex1; uniform sampler2D noisetex; @@ -72,6 +72,12 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo return (near * far) / (depth * (near - far) + far); } + + + + + + float bloomWeight(){ float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 ); @@ -85,102 +91,9 @@ float bloomWeight(){ return result; } -vec3 invTonemap(vec3 col){ - return col/(1-luma(col)); -} + #define linear_to_srgb(x) (pow(x, vec3(1.0/2.2))) -uniform sampler2D colortex6; - - -float w0(float a) -{ - return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0); -} - -float w1(float a) -{ - return (1.0/6.0)*(a*a*(3.0*a - 6.0) + 4.0); -} - -float w2(float a) -{ - return (1.0/6.0)*(a*(a*(-3.0*a + 3.0) + 3.0) + 1.0); -} - -float w3(float a) -{ - return (1.0/6.0)*(a*a*a); -} - -float g0(float a) -{ - return w0(a) + w1(a); -} - -float g1(float a) -{ - return w2(a) + w3(a); -} - -float h0(float a) -{ - return -1.0 + w1(a) / (w0(a) + w1(a)); -} - -float h1(float a) -{ - return 1.0 + w3(a) / (w2(a) + w3(a)); -} - -vec4 texture2D_bicubic(sampler2D tex, vec2 uv) -{ - vec4 texelSize = vec4(texelSize,1.0/texelSize); - uv = uv*texelSize.zw; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - - float g0x = g0(fuv.x); - float g1x = g1(fuv.x); - float h0x = h0(fuv.x); - float h1x = h1(fuv.x); - float h0y = h0(fuv.y); - float h1y = h1(fuv.y); - - vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * texelSize.xy; - vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * texelSize.xy; - vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * texelSize.xy; - vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * texelSize.xy; - - return g0(fuv.y) * (g0x * texture2D(tex, p0) + - g1x * texture2D(tex, p1)) + - g1(fuv.y) * (g0x * texture2D(tex, p2) + - g1x * texture2D(tex, p3)); -} - -// vec3 lenseFlare(vec2 UV){ -// float noise = blueNoise(); - -// float vignetteLength = 0.2; -// float vignette = 0.5+length(texcoord-0.5);//min(max(length(texcoord-0.5) - vignetteLength,0.0) / (1.0/(1.0-vignetteLength)),1.0); - -// float aberrationStrength = vignette;//clamp(CHROMATIC_ABERRATION_STRENGTH * 0.01 * (1.0 - vignette),0.0,0.9) * vignette * 0.75; - -// vec2 centeredUV = texcoord - 0.5; - -// vec3 color = vec3(0.0); -// color = texture2D(colortex7, texcoord).rgb; - -// vec2 distortedUV = (centeredUV - (centeredUV ) * aberrationStrength) + 0.5; - -// color += texture2D(colortex7, distortedUV).rgb; -// // color.r = texture2D(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r; -// // color.g = texture2D(colortex7, texcoord).g; -// // color.b = texture2D(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b; - -// return color; -// } - void main() { /* DRAWBUFFERS:7 */ float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.); @@ -219,21 +132,16 @@ void main() { vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); - vec2 resScale = vec2(1920.,1080.)/clampedRes; - vec2 bloomTileUV = (((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0) / clampedRes*vec2(1920.,1080.); - vec3 bloomTile0 = texture2D_bicubic(colortex3, bloomTileUV/2.).rgb; //1/4 res - vec3 bloomTile1 = texture2D_bicubic(colortex6, bloomTileUV/4.).rgb; //1/8 res - vec3 bloomTile2 = texture2D_bicubic(colortex6, bloomTileUV/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res - vec3 bloomTile3 = texture2D_bicubic(colortex6, bloomTileUV/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res - vec3 bloomTile4 = texture2D_bicubic(colortex6, bloomTileUV/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb; //1/64 res - vec3 bloomTile5 = texture2D_bicubic(colortex6, bloomTileUV/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb; //1/128 res - vec3 bloomTile6 = texture2D_bicubic(colortex6, bloomTileUV/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb; //1/256 res - - float weights[7] = float[]( 1.0, 1.0/2.0, 1.0/3.0, 1.0/5.5, 1.0/8.0, 1.0/10.0, 1.0/12.0 ); - vec3 bloom = (bloomTile0*weights[0] + bloomTile1*weights[1] + bloomTile2*weights[2] + bloomTile3*weights[3] + bloomTile4*weights[4] + bloomTile5*weights[5] + bloomTile6*weights[6]) / bloomWeight(); - vec3 fogBloom = (bloomTile0 + bloomTile1 + bloomTile2 + bloomTile3 + bloomTile4 + bloomTile5 + bloomTile6) / 7.0; + #ifdef OLD_BLOOM + vec3 bloom = texture2D(colortex3, texcoord/clampedRes*vec2(1920.,1080.)*BLOOM_QUALITY ).rgb / 2.0 / 7.0; + float lightScat = clamp((BLOOM_STRENGTH+3) * 0.05 * pow(exposure.a, 0.2) ,0.0,1.0) * vignette; + #else + vec3 bloom = texture2D(colortex3, texcoord/clampedRes*vec2(1920.,1080.)*BLOOM_QUALITY ).rgb / 3.0 / bloomWeight(); + float lightScat = clamp(BLOOM_STRENGTH * 0.5 * pow(exposure.a, 0.2) ,0.0,1.0) * vignette; + #endif + float VL_abs = texture2D(colortex7, texcoord*RENDER_SCALE).r; #ifdef AUTO_EXPOSURE float purkinje = clamp(exposure.a*exposure.a,0.0,1.0) * clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*Purkinje_strength,0,1); @@ -241,12 +149,9 @@ void main() { float purkinje = clamp(rodExposureDepth.x/(1.0+rodExposureDepth.x)*Purkinje_strength,0,1); #endif - float lightScat = clamp(BLOOM_STRENGTH * 0.3,0.0,1.0) * vignette; - float VL_abs = texture2D(colortex7, texcoord*RENDER_SCALE).r; - VL_abs = clamp((1.0-VL_abs)*BLOOMY_FOG*0.75*(1.0+rainStrength) * (1.0-purkinje*0.3),0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0); - col = (mix(col, fogBloom, VL_abs) + bloom*lightScat) * exposure.rgb; + col = (mix(col, bloom, VL_abs) + bloom * lightScat) * exposure.rgb; float lum = dot(col, vec3(0.15,0.3,0.55)); float lum2 = dot(col, vec3(0.85,0.7,0.45)); diff --git a/shaders/dimensions/composite12.fsh b/shaders/dimensions/composite12.fsh index e163cf2..06a6e0a 100644 --- a/shaders/dimensions/composite12.fsh +++ b/shaders/dimensions/composite12.fsh @@ -13,7 +13,6 @@ uniform float viewWidth; uniform float aspectRatio; uniform float frameTimeCounter; -uniform int frameCounter; uniform int hideGUI; @@ -135,41 +134,11 @@ vec3 saturationAndCrosstalk(vec3 color){ return color; } -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} - -vec3 chromaticAberration(vec2 UV){ - float noise = blueNoise() - 0.5; - - vec2 centeredUV = (texcoord - 0.5); - // not stretched by aspect ratio; circular by choice :) it makes most the abberation on the left/right of the screen. - float vignette = 1.0 - clamp(1.0 - length(centeredUV * vec2(aspectRatio,1.0)) / 200.0,0.0,1.0); - - float aberrationStrength = CHROMATIC_ABERRATION_STRENGTH * vignette; - - vec3 color = vec3(0.0); - color.r = texture2D(colortex7, (centeredUV - (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).r; - color.g = texture2D(colortex7, texcoord).g; - color.b = texture2D(colortex7, (centeredUV + (centeredUV + centeredUV*noise) * aberrationStrength) + 0.5).b; - - return color; -} - void main() { /* DRAWBUFFERS:7 */ - - #ifdef CHROMATIC_ABERRATION - vec3 color = chromaticAberration(texcoord); - #else - vec3 color = texture2D(colortex7,texcoord).rgb; - #endif + + vec3 color = texture2D(colortex7,texcoord).rgb; #ifdef CONTRAST_ADAPTATIVE_SHARPENING color = contrastAdaptiveSharpening(color, texcoord); @@ -184,6 +153,6 @@ void main() { #ifdef COLOR_GRADING_ENABLED color = colorGrading(color); #endif - + gl_FragData[0].rgb = clamp(int8Dither(color, texcoord),0.0,1.0); } diff --git a/shaders/dimensions/composite2.fsh b/shaders/dimensions/composite2.fsh index c3c866d..0fad316 100644 --- a/shaders/dimensions/composite2.fsh +++ b/shaders/dimensions/composite2.fsh @@ -22,7 +22,6 @@ uniform sampler2D colortex3; // uniform sampler2D colortex4; uniform sampler2D colortex6; uniform sampler2D colortex7; -uniform sampler2D colortex10; flat varying vec3 WsunVec; uniform vec3 sunVec; @@ -33,21 +32,12 @@ uniform float near; uniform float dhFarPlane; uniform float dhNearPlane; -// uniform mat4 gbufferModelViewInverse; -// uniform mat4 gbufferModelView; -uniform mat4 gbufferPreviousModelView; -// uniform mat4 gbufferProjectionInverse; -// uniform mat4 gbufferProjection; -// uniform mat4 gbufferPreviousProjection; -// uniform vec3 cameraPosition; -uniform vec3 previousCameraPosition; - uniform int frameCounter; uniform float frameTimeCounter; // varying vec2 texcoord; uniform vec2 texelSize; -flat varying vec2 TAA_Offset; +// flat varying vec2 TAA_Offset; uniform int isEyeInWater; uniform float rainStrength; @@ -120,17 +110,17 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo float LpvFadeF = cubicRadius.x*cubicRadius.y*cubicRadius.z; if(LpvFadeF > 0.0){ - // if(length(lpvSample.xyz) > 1e-5){ - vec3 lighting = SampleLpvLinear(lpvPos).rgb * (LPV_VL_FOG_ILLUMINATION_BRIGHTNESS/100.0); - // float density = exp(-5.0 * clamp( 1.0 - length(lpvSample.xyz) / 16.0,0.0,1.0)) * (LPV_VL_FOG_ILLUMINATION_BRIGHTNESS/100.0) * LpvFadeF; - float density = exp(-5.0 * (1.0-length(lighting.xyz))) * LpvFadeF; - // float density = (1-exp(-1.0-clamp(length(lighting.rgb),0.0,1.0),25) )* LpvFadeF; + vec4 lpvSample = SampleLpvLinear(lpvPos); - // float density = 0.01 * LpvFadeF; + if(length(lpvSample.xyz) > 1e-5){ + vec3 LpvTorchLight = GetLpvBlockLight(lpvSample); + + vec3 lighting = LpvTorchLight; + float density = exp(-5.0 * clamp( 1.0 - length(lpvSample.xyz) / 16.0,0.0,1.0)) * (LPV_VL_FOG_ILLUMINATION_BRIGHTNESS/100.0) * LpvFadeF; color = lighting - lighting * exp(-density*dd*dL); - // } + } } return color; @@ -140,38 +130,21 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo float invLinZ (float lindepth){ return -((2.0*near/lindepth)-far-near)/(far-near); } - -uniform float nightVision; - #ifdef OVERWORLD_SHADER const bool shadowHardwareFiltering = true; uniform sampler2DShadow shadow; - #ifdef TRANSLUCENT_COLORED_SHADOWS uniform sampler2D shadowcolor0; uniform sampler2DShadow shadowtex0; uniform sampler2DShadow shadowtex1; #endif flat varying vec3 refractedSunVec; - - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - - + // uniform int dhRenderDistance; #define TIMEOFDAYFOG #include "/lib/lightning_stuff.glsl" - - // #define CLOUDS_INTERSECT_TERRAIN + #define CLOUDS_INTERSECT_TERRAIN #include "/lib/volumetricClouds.glsl" - - #include "/lib/climate_settings.glsl" #include "/lib/overworld_fog.glsl" #endif #ifdef NETHER_SHADER @@ -186,9 +159,7 @@ uniform sampler2D colortex4; #define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) float interleaved_gradientNoise_temporal(){ - vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); } float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; @@ -197,15 +168,15 @@ float interleaved_gradientNoise(){ } float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter ); + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a+ 1.0/1.6180339887 * frameCounter ); } float R2_dither(){ - // #ifdef TAA + #ifdef TAA vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; - // #else - // vec2 coord = gl_FragCoord.xy; - // #endif + #else + vec2 coord = gl_FragCoord.xy; + #endif vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha.x * coord.x + alpha.y * coord.y ) ; } @@ -255,7 +226,7 @@ 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){ +void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEyeDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ int spCount = 8; vec3 start = toShadowSpaceProjected(rayStart); @@ -265,29 +236,35 @@ vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, //limit ray length at 32 blocks for performance and reducing integration error //you can't see above this anyway float maxZ = min(rayLength,32.0)/(1e-8+rayLength); - dV *= maxZ; - rayLength *= maxZ; - vec3 dVWorld = mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; + rayLength *= maxZ; + float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; + vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; + + #ifdef OVERWORLD_SHADER + float phase = fogPhase(VdotL) * 5.0; + #endif + vec3 absorbance = vec3(1.0); vec3 vL = vec3(0.0); + float YFade = pow(normalize(dVWorld).y*0.3+0.7,1.5); + #ifdef OVERWORLD_SHADER - float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.1,1.0); - float phase = fogPhase(VdotL) * 5.0; + float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.1,1.0); #else - float lowlightlevel = 1.0; - float phase = 0.0; + float lowlightlevel = 1.0; #endif + // lowlightlevel = pow(lowlightlevel,0.5); float expFactor = 11.0; for (int i=0;i pos.z && sh.x < 1.0){ - vec4 translucentShadow = texture2D(shadowcolor0, pos.xy); - if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001); + sh = normalize(texture2D(shadowcolor0, pos.xy).rgb+0.0001); } #else sh = vec3(shadow2D(shadow, pos).x); @@ -318,28 +292,38 @@ vec3 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, } #ifdef VL_CLOUDS_SHADOWS - sh *= GetCloudShadow(progressW, WsunVec); + sh *= GetCloudShadow_VLFOG(progressW, WsunVec); #endif + + + // float bubble = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - length(d*dVWorld) / (16),0.0)*5.0,1.0),2.0),2.0); + float bubble = exp( -7.0 * clamp(1.0 - length(d*dVWorld) / 16.0, 0.0,1.0) ); + float bubble2 = max(pow(length(d*dVWorld)/24,5)*100.0,0.0) + 1; + + float sunCaustics = (waterCaustics(progressW, WsunVec)) * mix(0.25,10.0,bubble) + 0.75; + + vec3 sunMul = exp(-1 * d * waterCoefs * 1.1); + vec3 Directlight = ((lightSource* sh) * phase * sunMul * sunCaustics) * lowlightlevel * pow(abs(WsunVec.y),1); + #else + vec3 Directlight = vec3(0.0); #endif + vec3 ambientMul = exp(-1 * d * waterCoefs); + vec3 Indirectlight = ambient * ambientMul * YFade * lowlightlevel; - 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); + vec3 light = (Indirectlight + Directlight) * scatterCoef; - vec3 Directlight = lightSource * sh * phase * caustics*abs(WsunVec.y) * lowlightlevel; - vec3 Indirectlight = ambient * lowlightlevel; + vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs * absorbance; + absorbance *= exp(-waterCoefs * dd * rayLength); - vec3 WaterAbsorbance = exp(-waterCoefs * rayLength * d); - - vec3 light = (Indirectlight + Directlight) * WaterAbsorbance * scatterCoef; - - vec3 volumeCoeff = exp(-waterCoefs * rayLength * dd); - vL += (light - light * volumeCoeff) / waterCoefs * absorbance; - absorbance *= volumeCoeff; + #if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT + vL += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, 1.0); + #endif } - return vL; + inColor += vL; } +// #endif vec4 blueNoise(vec2 coord){ return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; @@ -367,130 +351,9 @@ float encodeVec2(vec2 a){ -uniform int framemod8; -#include "/lib/TAA_jitter.glsl" +// 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; -} //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -499,95 +362,88 @@ float convertHandDepth(float depth) { void main() { - +#if defined OVERWORLD_SHADER && defined CLOUDS_INTERSECT_TERRAIN + /* RENDERTARGETS:0,14 */ +#else /* RENDERTARGETS:0 */ +#endif - float noise_2 = blueNoise(); float noise_1 = max(1.0 - R2_dither(),0.0015); - // float noise_2 = interleaved_gradientNoise_temporal(); - vec2 bnoise = blueNoise(gl_FragCoord.xy ).rg; - - int seed = (frameCounter*5)%40000; - vec2 r2_sequence = R2_samples(seed).xy; - vec2 BN = fract(r2_sequence + bnoise); - - // vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize + texelSize*0.5; - vec2 tc = gl_FragCoord.xy/VL_RENDER_RESOLUTION*texelSize;// + texelSize*0.5; + float noise_2 = blueNoise(); + + vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize + texelSize*0.5; bool iswater = texture2D(colortex7,tc).a > 0.99; - vec2 jitter = TAA_Offset/VL_RENDER_RESOLUTION*texelSize*0.5; - - float depth = texture2D(depthtex0, tc + jitter).x; + float z0 = texture2D(depthtex0, tc).x; - float z0 = depth < 0.56 ? convertHandDepth(depth) : depth; - #ifdef DISTANT_HORIZONS float DH_z0 = texture2D(dhDepthTex,tc).x; #else float DH_z0 = 0.0; #endif - vec3 viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0); - vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos0 + gbufferModelViewInverse[3].xyz; - vec3 playerPos_normalized = normalize(playerPos); + vec3 viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE , z0, DH_z0); + vec3 playerPos_normalized = normalize(mat3(gbufferModelViewInverse) * viewPos0 + gbufferModelViewInverse[3].xyz); - 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 directLightColor = lightCol.rgb / 2400.0; - vec3 indirectLightColor = averageSkyCol / 1200.0; - vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 1200.0; - - // indirectLightColor_dynamic += MIN_LIGHT_AMOUNT * 0.02 * 0.2 + nightVision*0.02; + vec3 directLightColor = lightCol.rgb/80.0; + vec3 indirectLightColor = averageSkyCol/30.0; + vec3 indirectLightColor_dynamic = averageSkyCol_Clouds/30.0; - #if defined OVERWORLD_SHADER - // z0 = texture2D(depthtex0, tc + jitter/VL_RENDER_RESOLUTION).x; - // viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0); - vec4 VolumetricClouds = GetVolumetricClouds(viewPos0, BN, WsunVec, directLightColor, indirectLightColor); + vec3 cloudDepth = vec3(0.0); + vec3 fogDepth = vec3(0.0); + + #if defined OVERWORLD_SHADER && defined CLOUDS_INTERSECT_TERRAIN + vec4 VolumetricClouds = renderClouds(viewPos0, vec2(noise_1,noise_2), directLightColor, indirectLightColor, cloudDepth); #ifdef CAVE_FOG - - float skyhole = pow(clamp(1.0-pow(max(playerPos_normalized.y - 0.6,0.0)*5.0,2.0),0.0,1.0),2)* caveDetection; - VolumetricClouds.rgb *= 1.0-skyhole; - VolumetricClouds.a = mix(VolumetricClouds.a, 1.0, skyhole); + float skyhole = (1.0-pow(clamp(1.0-pow(max(playerPos_normalized.y - 0.6,0.0)*5.0,2.0),0.0,1.0),2)* caveDetection) ; + VolumetricClouds.rgb *= skyhole; + VolumetricClouds.a = mix(VolumetricClouds.a, 1.0, (1.0-skyhole) * caveDetection); #endif #endif #ifdef OVERWORLD_SHADER float atmosphereAlpha = 1.0; - - vec3 sceneColor = texelFetch2D(colortex3,ivec2(tc/texelSize),0).rgb * VolumetricClouds.a + VolumetricClouds.rgb; - vec4 VolumetricFog = GetVolumetricFog(viewPos0, BN, directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb); - + vec4 VolumetricFog = GetVolumetricFog(viewPos0, vec2(noise_2,noise_1), directLightColor, indirectLightColor, averageSkyCol_Clouds/30.0, atmosphereAlpha); + VolumetricClouds.a *= atmosphereAlpha; #endif #if defined NETHER_SHADER || defined END_SHADER - vec4 VolumetricFog = GetVolumetricFog(viewPos0, BN.x, BN.y); + vec4 VolumetricFog = GetVolumetricFog(viewPos0, noise_1, noise_2); #endif - - #if defined OVERWORLD_SHADER - VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a); - // VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a); + + #if defined OVERWORLD_SHADER && defined CLOUDS_INTERSECT_TERRAIN + VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a * atmosphereAlpha + VolumetricFog.rgb, VolumetricFog.a); #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 ) )); - - VolumetricFog = vec4(underWaterFog, 1.0); - } - gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0); - - // vec4 currentFrame = VolumetricFog; - // vec4 previousFrame = texture2D(colortex10, gl_FragCoord.xy * texelSize); - // vec4 temporallyFilteredVL = VLTemporalFiltering(viewPos0, z0 >= 1.0, VolumetricFog); + if (isEyeInWater == 1){ - // gl_FragData[1] = temporallyFilteredVL; + float estEyeDepth = clamp(eyeBrightnessSmooth.y/240.0,0.,1.0); + // estEyeDepth = pow(estEyeDepth,3.0) * 32.0; + estEyeDepth = 0.0; + // vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); + + vec3 vl = vec3(0.0); + waterVolumetrics(vl, vec3(0.0), viewPos0, estEyeDepth, estEyeDepth, length(viewPos0), noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor , dot(normalize(viewPos0), normalize(sunVec* lightCol.a ) )); + + gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.); + + } + + #if defined OVERWORLD_SHADER && defined CLOUDS_INTERSECT_TERRAIN + gl_FragData[1] = vec4(VolumetricClouds.a,0.0,0.0,0.0); + #endif } \ No newline at end of file diff --git a/shaders/dimensions/composite2.vsh b/shaders/dimensions/composite2.vsh index b7de7d9..3f1c92f 100644 --- a/shaders/dimensions/composite2.vsh +++ b/shaders/dimensions/composite2.vsh @@ -10,11 +10,10 @@ flat varying vec3 averageSkyCol_Clouds; flat varying float exposure; #endif - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #endif - +#if defined Daily_Weather + flat varying vec4 dailyWeatherParams0; + flat varying vec4 dailyWeatherParams1; +#endif @@ -50,7 +49,6 @@ void main() { gl_Position = ftransform(); gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0; - #ifdef OVERWORLD_SHADER lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; @@ -58,11 +56,11 @@ void main() { averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0); - dailyWeatherParams0.a = texelFetch2D(colortex4,ivec2(3,1),0).x/1500.0; - dailyWeatherParams1.a = texelFetch2D(colortex4,ivec2(3,1),0).y/1500.0; + dailyWeatherParams0.a = (texelFetch2D(colortex4,ivec2(3,1),0).x/150.0)/2.0; + dailyWeatherParams1.a = (texelFetch2D(colortex4,ivec2(3,1),0).y/150.0)/2.0; #endif #endif @@ -70,7 +68,7 @@ void main() { #ifdef NETHER_SHADER lightCol.rgb = vec3(0.0); averageSkyCol = vec3(0.0); - averageSkyCol_Clouds = vec3(0.0); + averageSkyCol_Clouds = vec3(2.0, 1.0, 0.5) * 10.0; #endif #ifdef END_SHADER @@ -80,7 +78,7 @@ void main() { #endif lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; - WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) ; + WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333); diff --git a/shaders/dimensions/composite3.fsh b/shaders/dimensions/composite3.fsh index 30ac926..b5bdc22 100644 --- a/shaders/dimensions/composite3.fsh +++ b/shaders/dimensions/composite3.fsh @@ -13,7 +13,6 @@ uniform sampler2D noisetex; uniform sampler2D depthtex0; uniform sampler2D depthtex1; - // const bool colortex4MipmapEnabled = true; #ifdef DISTANT_HORIZONS uniform sampler2D dhDepthTex; uniform sampler2D dhDepthTex1; @@ -37,9 +36,8 @@ uniform sampler2D colortex15; uniform vec2 texelSize; uniform sampler2D colortex4; -uniform float viewHeight; -uniform float viewWidth; -uniform float nightVision; + + uniform vec3 sunVec; uniform float frameTimeCounter; uniform int frameCounter; @@ -58,8 +56,6 @@ uniform mat4 gbufferPreviousProjection; uniform vec3 cameraPosition; uniform vec3 previousCameraPosition; -uniform int hideGUI; -uniform int dhRenderDistance; uniform int isEyeInWater; uniform ivec2 eyeBrightnessSmooth; uniform ivec2 eyeBrightness; @@ -73,12 +69,14 @@ uniform float caveDetection; #include "/lib/res_params.glsl" #ifdef OVERWORLD_SHADER + #include "/lib/sky_gradient.glsl" + #include "/lib/lightning_stuff.glsl" #include "/lib/climate_settings.glsl" + #define CLOUDS_INTERSECT_TERRAIN + // #define CLOUDSHADOWSONLY + // #include "/lib/volumetricClouds.glsl" #endif -#include "/lib/sky_gradient.glsl" - -uniform float eyeAltitude; #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) @@ -95,49 +93,28 @@ vec3 toLinear(vec3 sRGB){ } vec3 toScreenSpace(vec3 p) { vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 playerPos = p * 2. - 1.; - vec4 fragposition = iProjDiag * playerPos.xyzz + gbufferProjectionInverse[3]; + vec3 p3 = p * 2. - 1.; + vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; return fragposition.xyz / fragposition.w; } #include "/lib/DistantHorizons_projections.glsl" - -float interleaved_gradientNoise_temporal(){ - #ifdef TAA - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887 * frameCounter); - #else - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y ) + 1.0/1.6180339887); - #endif +float blueNoise(){ + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } +vec4 blueNoise(vec2 coord){ + return texelFetch2D(colortex6, ivec2(coord )%512 , 0); +} +vec3 normVec (vec3 vec){ + return vec*inversesqrt(dot(vec,vec)); +} + float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); return noise; } -float R2_dither(){ - vec2 coord = gl_FragCoord.xy ; - - #ifdef TAA - coord += (frameCounter%40000) * 2.0; - #endif - - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * coord.x + alpha.y * coord.y ) ; -} -float blueNoise(){ - #ifdef TAA - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); - #else - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887); - #endif -} -vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; -} -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} float DH_ld(float dist) { return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane)); @@ -239,8 +216,7 @@ void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, float lineardista float refractionStrength = isTranslucentEntity ? 0.25 : 1.0 ; // Texcoord = abs(Texcoord + (TangentNormals * clamp((ld(depths.x) - ld(depths.y)) * 0.5,0.0,0.15)) * RENDER_SCALE * refractionStrength ); - // Texcoord = abs(Texcoord + (TangentNormals * mix(0.01, 0.1, pow(clamp(1.0-lineardistance/(32*4),0.0,1.0),2))) * RENDER_SCALE * refractionStrength ); - Texcoord = abs(Texcoord + TangentNormals * RENDER_SCALE * 0.1 ); + Texcoord = abs(Texcoord + (TangentNormals * mix(0.01, 0.1, pow(clamp(1.0-lineardistance/(32*4),0.0,1.0),2))) * RENDER_SCALE * refractionStrength ); float DistortedAlpha = decodeVec2(texture2D(colortex11,Texcoord).b).g; // float DistortedAlpha = decodeVec2(texelFetch2D(colortex11,ivec2(Texcoord/texelSize),0).b).g; @@ -249,201 +225,17 @@ void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, float lineardista Texcoord = mix(Texcoord, UnalteredTexcoord, min(max(0.1-DistortedAlpha,0.0) * 1000.0,1.0)); // remove distortion on non-translucents } -vec3 doRefractionEffect( inout vec2 texcoord, vec2 normal, float linearDistance){ - - // make the tangent space normals match the directions of the texcoord UV, this greatly improves the refraction effect. - vec2 UVNormal = vec2(normal.x,-normal.y); - - float refractionMult = 0.3 / (1.0 + linearDistance); - float diffractionMult = 0.035; - float smudgeMult = 1.0; - - // for diffraction, i wanted to know *when* normals were at an angle, not what the - float clampValue = 0.2; - vec2 abberationOffset = (clamp(UVNormal,-clampValue, clampValue)/clampValue) * diffractionMult; - - // return vec3(abs(abberationOffset), 0.0); - - #ifdef REFRACTION_SMUDGE - vec2 directionalSmudge = abberationOffset * (blueNoise()-0.5) * smudgeMult; - #else - vec2 directionalSmudge = vec2(0.0); - #endif - - vec2 refractedUV = texcoord - (UVNormal + directionalSmudge)*refractionMult; - - // a max bound around screen edges and edges of the refracted screen - vec2 vignetteSides = clamp(min((1.0 - refractedUV)/0.05, refractedUV/0.05)+0.5,0.0,1.0); - float vignette = vignetteSides.x*vignetteSides.y; - - refractionMult *= decodeVec2(texelFetch2D(colortex11, ivec2(refractedUV/texelSize),0).b).g > 0.0 ? 1.0 : 0.0; - - vec3 color = vec3(0.0); - - #ifdef FAKE_DISPERSION_EFFECT - //// RED - refractedUV = clamp(texcoord - ((UVNormal + abberationOffset) + directionalSmudge)*refractionMult ,0.0,1.0); - color.r = texelFetch2D(colortex3, ivec2(refractedUV/texelSize),0).r; - //// GREEN - refractedUV = clamp(texcoord - (UVNormal + directionalSmudge)*refractionMult ,0,1); - color.g = texelFetch2D(colortex3, ivec2(refractedUV/texelSize),0).g; - //// BLUE - refractedUV = clamp(texcoord - ((UVNormal - abberationOffset) + directionalSmudge)*refractionMult ,0.0,1.0); - color.b = texelFetch2D(colortex3, ivec2(refractedUV/texelSize),0).b; - - #else - refractedUV = clamp(texcoord - UVNormal,0.0,1.0); - color = texture2D(colortex3, refractedUV).rgb; - #endif - - // texcoord = texcoord - (UVNormal+directionalSmudge)*refractionMult*vignette; - return color; -} - -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; -} -vec3 tonemap(vec3 col){ - return col/(1+luma(col)); -} -vec3 invTonemap(vec3 col){ - return col/(1-luma(col)); -} - -vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){ - vec2 texcoord = ((gl_FragCoord.xy)*2.0 + 0.5)*texelSize/2.0; - - 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 - 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); - - if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return currentFrame; - - 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(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); - - return clamp(mix(clampedFrameHistory, currentFrame, blendingFactor),0.0,65000.0); -} +uniform int dhRenderDistance; +uniform float eyeAltitude; void main() { - /* RENDERTARGETS:7,3,10 */ + /* DRAWBUFFERS:73 */ ////// --------------- SETUP STUFF --------------- ////// vec2 texcoord = gl_FragCoord.xy*texelSize; - float z = texture2D(depthtex0, texcoord).x; - float z2 = texture2D(depthtex1, texcoord).x; + float z = texture2D(depthtex0,texcoord).x; + float z2 = texture2D(depthtex1,texcoord).x; float frDepth = ld(z); float swappedDepth = z; @@ -466,13 +258,19 @@ void main() { float DH_depth0 = 0.0; #endif - 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 fragpos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z, DH_depth0); + + // vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5,z)); + vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; + vec3 np3 = normVec(p3); + + float linearDistance = length(p3); + float linearDistance_cylinder = length(p3.xz); + + // vec3 fragpos_NODH = toScreenSpace(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z); + + // float linearDistance_NODH = length(p3); - float linearDistance = length(playerPos); - float linearDistance_cylinder = length(playerPos.xz); float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); float lightleakfixfast = clamp(eyeBrightness.y/240.,0.0,1.0); @@ -482,7 +280,7 @@ void main() { // bool isOpaque_entity = abs(opaqueMasks-0.45) < 0.01; ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// - vec4 data = texelFetch2D(colortex11,ivec2(texcoord/texelSize),0).rgba; + vec4 data = texture2D(colortex11,texcoord).rgba; vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; @@ -490,6 +288,7 @@ void main() { vec2 tangentNormals = unpack0.xy*2.0-1.0; if(albedo.a < 0.01) tangentNormals = vec2(0.0); + vec4 TranslucentShader = texture2D(colortex2, texcoord); ////// --------------- UNPACK MISC --------------- ////// // 1.0 = water mask @@ -511,36 +310,25 @@ void main() { #else float cloudAlpha = 1.0; #endif - float DEBUG = 0.0; - vec4 temporallyFilteredVL = VLTemporalFiltering(viewPos, z >= 1.0,DEBUG); - gl_FragData[2] = temporallyFilteredVL; - - // #ifdef DISTANT_HORIZONS - // vec4 vl = BilateralUpscale(colortex0, colortex14, colortex12, gl_FragCoord.xy - 1.5, sqrt(texture2D(colortex12,texcoord).a/65000.0), cloudAlpha); - // #else - // vec4 vl = BilateralUpscale(colortex0, colortex14, depthtex0, gl_FragCoord.xy - 1.5, frDepth,cloudAlpha); - // #endif - // vec4 temporallyFilteredVL = vl; - - // vec4 temporallyFilteredVL = texture2D(colortex10, texcoord*VL_RENDER_RESOLUTION); + #ifdef DISTANT_HORIZONS + vec4 vl = BilateralUpscale(colortex0, colortex14, colortex12, gl_FragCoord.xy - 1.5, sqrt(texture2D(colortex12,texcoord).a/65000.0), cloudAlpha); + #else + vec4 vl = BilateralUpscale(colortex0, colortex14, depthtex0, gl_FragCoord.xy - 1.5, frDepth,cloudAlpha); + #endif float bloomyFogMult = 1.0; ////// --------------- distort texcoords as a refraction effect vec2 refractedCoord = texcoord; - ////// --------------- MAIN COLOR BUFFER - #ifdef FAKE_REFRACTION_EFFECT - // ApplyDistortion(refractedCoord, tangentNormals, linearDistance, isEntity); - // vec3 color = texture2D(colortex3, refractedCoord).rgb; - vec3 color = doRefractionEffect(refractedCoord, tangentNormals.xy, linearDistance); - #else - // vec3 color = texture2D(colortex3, refractedCoord).rgb; - vec3 color = texelFetch2D(colortex3, ivec2(refractedCoord/texelSize),0).rgb; + #ifdef Refraction + ApplyDistortion(refractedCoord, tangentNormals, linearDistance, isEntity); #endif - vec4 TranslucentShader = texture2D(colortex2, texcoord); - // color = vec3(texcoord-0.5,0.0) * mat3(gbufferModelViewInverse); + + ////// --------------- MAIN COLOR BUFFER + vec3 color = texture2D(colortex3, refractedCoord).rgb; + // 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; @@ -554,7 +342,7 @@ void main() { float fog = smoothstep(1.0, 0.0, min(max(1.0 - linearDistance_cylinder / far,0.0)*3.0,1.0) ); #endif - fog *= exp(-10.0 * pow(clamp(playerPos_normalized.y,0.0,1.0)*4.0,2.0)); + fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0)); fog *= (1.0-caveDetection); @@ -563,7 +351,7 @@ void main() { #ifdef SKY_GROUND vec3 borderFogColor = skyGroundColor; #else - vec3 borderFogColor = skyFromTex(playerPos_normalized, colortex4)/30.0; + vec3 borderFogColor = skyFromTex(np3, colortex4)/30.0; #endif color.rgb = mix(color.rgb, borderFogColor, fog); @@ -573,7 +361,7 @@ void main() { 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+0.0001)*0.9+0.1, vec3(1.0), max(fog, min(max(0.1-albedo.a,0.0) * 1000.0,1.0))) ; #endif #ifdef BorderFog @@ -597,50 +385,58 @@ void main() { #endif cavefogCol *= 1.0-pow(1.0-pow(1.0 - max(1.0 - linearDistance/far,0.0),2.0),CaveFogFallOff); - cavefogCol *= exp(-7.0*clamp(normalize(playerPos_normalized).y*0.5+0.5,0.0,1.0)) * 0.999 + 0.001; + cavefogCol *= exp(-7.0*clamp(normalize(np3).y*0.5+0.5,0.0,1.0)) * 0.999 + 0.001; - cavefogCol *= 0.3; - - float skyhole = pow(clamp(1.0-pow(max(playerPos_normalized.y - 0.6,0.0)*5.0,2.0),0.0,1.0),2); + float skyhole = pow(clamp(1.0-pow(max(np3.y - 0.6,0.0)*5.0,2.0),0.0,1.0),2); color.rgb = mix(color.rgb + cavefogCol * caveDetection, cavefogCol, z >= 1.0 ? skyhole * caveDetection : 0.0); - } #endif +#ifdef END_SHADER + // create a point that "glows" but in worldspace. + + // this is not correct but whatever + float CenterdotV = dot(normalize(vec3(0.0,400.0,0.0) - cameraPosition), normalize(p3 + cameraPosition)); + + float distanceFadeOff = pow(min(max(length(cameraPosition)-300.0,0.0)/100.0,1.0),2.0); + + color.rgb += vec3(0.1,0.5,1.0) * (exp2(-10.0 * max(-CenterdotV*0.5+0.5,0.0)) + exp(-150.0 * max(-CenterdotV*0.5+0.5,0.0))) * distanceFadeOff; +#endif + ////// --------------- underwater fog if (isEyeInWater == 1){ - 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 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; - - linearDistance = length(vec3(playerPos.x,max(-playerPos.y,0.0),playerPos.z)); - - // 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)); - - color.rgb = mix(fixedAbsorption, color.rgb * finalAbsorption, fogfade); - // color.rgb = color.rgb * finalAbsorption; + vec3 absorbColor = exp(-totEpsilon*linearDistance); + vec3 maxAbsorb = exp(-8.0 * totEpsilon); + #ifdef OVERWORLD_SHADER + + linearDistance = length(vec3(p3.x,max(-p3.y,0.0),p3.z)); + float fogfade = exp(-0.001*(linearDistance*linearDistance)); + vec3 thresholdAbsorbedColor = mix(maxAbsorb, absorbColor, clamp(dot(absorbColor,vec3(0.33333)),0.0,1.0)); + color.rgb = mix(vec3(1.0) * clamp(WsunVec.y,0,1) * pow(normalize(np3).y*0.3+0.7,1.5) * maxAbsorb, color.rgb * thresholdAbsorbedColor, clamp(fogfade,0.0,1.0)); + + #else + + color.rgb *= absorbColor; + + #endif + bloomyFogMult *= 0.4; } ////// --------------- BLEND FOG INTO SCENE //////////// apply VL fog over opaque and translucents - bloomyFogMult *= temporallyFilteredVL.a; - color *= temporallyFilteredVL.a; - color += temporallyFilteredVL.rgb; + color *= vl.a*cloudAlpha ; + color += vl.rgb; + bloomyFogMult *= mix(vl.a,vl.a*0.5 + 0.5, rainStrength); ////// --------------- VARIOUS FOG EFFECTS (in front of volumetric fog) //////////// blindness, nightvision, liquid fogs and misc fogs @@ -653,13 +449,12 @@ void main() { ////// --------------- lava. if (isEyeInWater == 2){ - color.rgb = mix(color.rgb, vec3(0.1,0.0,0.0), 1.0-exp(-10.0*clamp(linearDistance*0.5,0.,1.))*0.5 ); - bloomyFogMult = 0.0; + color.rgb = vec3(4.0,0.5,0.1); } ///////// --------------- powdered snow if (isEyeInWater == 3){ - color.rgb = mix(color.rgb,vec3(0.5,0.75,1.0),clamp(linearDistance*0.5,0.,1.)); + color.rgb = mix(color.rgb,vec3(10,15,20),clamp(linearDistance*0.5,0.,1.)); bloomyFogMult = 0.0; } @@ -667,30 +462,23 @@ void main() { color.rgb *= mix(1.0,clamp( exp(pow(linearDistance*(blindness*0.2),2) * -5),0.,1.) , blindness); //////// --------------- darkness effect - color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(viewPos)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); + color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); ////// --------------- FINALIZE #ifdef display_LUT + vec3 thingy = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb / 30; - // if(hideGUI == 0){ - vec3 thingy = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy/150),0).rgb /1200.0; - - if(luma(thingy) > 0.0){ - color.rgb = thingy; - // // vl.a = 1.0; - } - // } - #if defined OVERWORLD_SHADER - - if( hideGUI == 1) color.rgb = skyCloudsFromTex(playerPos_normalized, colortex4).rgb/1200.0; - #else - if( hideGUI == 1) color.rgb = volumetricsFromTex(playerPos_normalized, colortex4, 0.0).rgb/1200.0; - #endif + if(luma(thingy) > 0.0){ + color.rgb = thingy; + vl.a = 1.0; + } #endif -// color.rgb = vec3(DEBUG); + + // if(texcoord.x > 0.5 )color.rgb = skyCloudsFromTex(np3, colortex4).rgb/30.0; + 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(tangentNormals.xy,0.0) ; // 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; // gl_FragData[1].rgb = 1-(texcoord.x > 0.5 ? vec3(TranslucentShader.a) : vec3(data.a)); diff --git a/shaders/dimensions/composite3.vsh b/shaders/dimensions/composite3.vsh index 2b4c566..3b7d4d0 100644 --- a/shaders/dimensions/composite3.vsh +++ b/shaders/dimensions/composite3.vsh @@ -37,7 +37,7 @@ void main() { #ifdef OVERWORLD_SHADER #ifdef BorderFog - skyGroundColor = texelFetch2D(colortex4,ivec2(1,37),0).rgb / 1200.0 * Sky_Brightness; + skyGroundColor = texelFetch2D(colortex4,ivec2(1,37),0).rgb / 30.0 * Sky_Brightness; #endif WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition); #endif diff --git a/shaders/dimensions/composite5.fsh b/shaders/dimensions/composite5.fsh index d060192..a9d9a1a 100644 --- a/shaders/dimensions/composite5.fsh +++ b/shaders/dimensions/composite5.fsh @@ -11,7 +11,7 @@ const int colortex6Format = R11F_G11F_B10F; // additionnal buffer for bloom (c const int colortex7Format = RGBA8; // Final output, transparencies id (gbuffer->composite4) const int colortex8Format = RGBA8; // Specular Texture const int colortex9Format = RGBA8; // rain in alpha -const int colortex10Format = RGBA16F; // resourcepack Skies +const int colortex10Format = RGBA16; // resourcepack Skies const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals const int colortex12Format = RGBA16F; // DISTANT HORIZONS + VANILLA MIXED DEPTHs @@ -31,7 +31,7 @@ const bool colortex6Clear = false; const bool colortex7Clear = false; const bool colortex8Clear = false; const bool colortex9Clear = true; -const bool colortex10Clear = false; +const bool colortex10Clear = true; const bool colortex11Clear = true; const bool colortex12Clear = false; const bool colortex13Clear = false; @@ -41,11 +41,11 @@ const bool colortex15Clear = false; #ifdef SCREENSHOT_MODE /* - const int colortex5Format = RGBA32F; //TAA buffer (everything) + const int colortex5Format = RGBA32F;// TAA buffer (everything) */ #else /* - const int colortex5Format = RGBA16F; //TAA buffer (everything) + const int colortex5Format = R11F_G11F_B10F; // TAA buffer (everything) */ #endif @@ -67,7 +67,6 @@ uniform vec2 texelSize; uniform float frameTimeCounter; uniform float viewHeight; uniform float viewWidth; - uniform vec3 previousCameraPosition; uniform mat4 gbufferPreviousModelView; @@ -214,24 +213,6 @@ vec4 smoothfilter(in sampler2D tex, in vec2 uv) return texture2D(tex, uv); } -vec2 smoothfilterUV(in vec2 uv) -{ - vec2 textureResolution = vec2(viewWidth,viewHeight); - uv = uv*textureResolution + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - - #ifndef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + (fuv*fuv)*(3.0-2.0*fuv); - #endif - #ifdef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0); - #endif - - uv = (uv - 0.5)/textureResolution; - - return uv; -} //approximation from SMAA presentation from siggraph 2016 vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount) { @@ -250,14 +231,15 @@ vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float shar vec2 w12 = w1 + w2; vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12); vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb; + vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0); vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0); - vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) + + vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) + vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) + vec4(centerColor, 1.0) * (w12.x * w12.y) + vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) + vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y ); - + return color.rgb/color.a; } @@ -332,24 +314,6 @@ vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth, return dmin; } -vec3 RGB2YCoCg(vec3 RGB) -{ - vec3 o; - o.x = 0.25*RGB.r + 0.5*RGB.g + 0.25*RGB.b; - o.y = 0.5*RGB.r - 0.5*RGB.b; - o.z = -0.25*RGB.r + 0.5*RGB.g - 0.25*RGB.b; - return o; -} - -vec3 YCoCg2RGB(vec3 YCoCg) -{ - vec3 o; - o.r = YCoCg.x + YCoCg.y - YCoCg.z; - o.g = YCoCg.x + YCoCg.z; - o.b = YCoCg.x - YCoCg.y - YCoCg.z; - return o; -} - vec4 computeTAA(vec2 texcoord, bool hand){ vec2 jitter = offsets[framemod8]*texelSize*0.5; @@ -376,9 +340,9 @@ vec4 computeTAA(vec2 texcoord, bool hand){ vec2 velocity = previousPosition.xy - closestToCamera.xy; previousPosition.xy = texcoord + velocity; + // sample current frame, and make sure it is de-jittered - // vec3 currentFrame = smoothfilter(colortex3, adjTC + jitter).rgb; - vec3 currentFrame = texelFetch2D(colortex3, ivec2((adjTC + jitter)/texelSize), 0).rgb; + vec3 currentFrame = smoothfilter(colortex3, adjTC + jitter).rgb; //reject history if off-screen and early exit if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return vec4(currentFrame, 1.0); @@ -402,13 +366,14 @@ vec4 computeTAA(vec2 texcoord, bool hand){ vec3 colMax = max(col0,max(col1,max(col2,max(col3, max(col4, max(col5, max(col6, max(col7, col8)))))))); vec3 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))))); + vec3 colMax5 = max(col0,max(col5,max(col6,max(col7,col8)))); + vec3 colMin5 = min(col0,min(col5,min(col6,min(col7,col8)))); + colMin = 0.5 * (colMin + colMin5); + colMax = 0.5 * (colMax + colMax5); #endif - #ifdef DAMAGE_TAKEN_EFFECT - ////// when this triggers, use current frame UV to sample history, for a funny trailing effect. + // when this triggers, use current frame UV to sample history, for a funny trailing effect. if(CriticalDamageTaken > 0.01) previousPosition.xy = texcoord; #endif @@ -418,17 +383,14 @@ vec4 computeTAA(vec2 texcoord, bool hand){ float blendingFactor = BLEND_FACTOR; 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); + //Increases blending factor when far from AABB, reduces ghosting + blendingFactor = min(blendingFactor + luma(min(max(clampedframeHistory - frameHistory,0.0) / frameHistory, 1.0)),1.0); - // if(luma(abs(clampedframeHistory - frameHistory)) > 0.01) blendingFactor = 1.0; - - ////// Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering + // Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering vec3 finalResult = invTonemap(mix(tonemap(clampedframeHistory), tonemap(currentFrame), blendingFactor)); #ifdef DAMAGE_TAKEN_EFFECT - ////// when this triggers, do a funny trailing effect. + // when this triggers, do a funny trailing effect. if(CriticalDamageTaken > 0.01) finalResult = mix(finalResult, frameHistory, sqrt(CriticalDamageTaken)*0.8); #endif #ifdef SCREENSHOT_MODE @@ -456,10 +418,14 @@ void main() { // vec4 color = TAA_hq(hand); - vec4 color = computeTAA(smoothfilterUV(texcoord), hand); + vec4 color = computeTAA(texcoord, hand); // gl_FragData[0] = clamp(color, 0.0, 65000.0); + #if DEBUG_VIEW == debug_TEMPORAL_REPROJECTION + color.rgb = texture2D(colortex3, taauTC).rgb; + #endif + #ifdef SCREENSHOT_MODE gl_FragData[0] = clamp(color, 0.0, 65000.0); #else diff --git a/shaders/dimensions/deferred.fsh b/shaders/dimensions/deferred.fsh index a65ccea..84b8232 100644 --- a/shaders/dimensions/deferred.fsh +++ b/shaders/dimensions/deferred.fsh @@ -64,18 +64,11 @@ vec3 toShadowSpaceProjected(vec3 p3){ return p3; } -float interleaved_gradientNoise_temporal(){ - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y) + 1.0/1.6180339887 * frameCounter); -} float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); + float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+frameCounter/1.6180339887); return noise; } -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; -} float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } @@ -130,7 +123,6 @@ float invLinZ (float lindepth){ } #ifdef OVERWORLD_SHADER - uniform sampler2D colortex4; // uniform sampler2D colortex12; // const bool shadowHardwareFiltering = true; uniform sampler2DShadow shadow; @@ -143,27 +135,11 @@ float invLinZ (float lindepth){ uniform sampler2DShadow shadowtex1; #endif - // #define TEST + #define TEST #define TIMEOFDAYFOG #include "/lib/lightning_stuff.glsl" - - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - - flat varying vec4 CurrentFrame_dailyWeatherParams0; - flat varying vec4 CurrentFrame_dailyWeatherParams1; - - - #define VL_CLOUDS_DEFERRED - + #include "/lib/volumetricClouds.glsl" - #include "/lib/climate_settings.glsl" #include "/lib/overworld_fog.glsl" #endif @@ -189,16 +165,23 @@ vec2 R2_samples(float n){ return fract(alpha * n); } -uniform float dayChangeSmooth; -uniform bool worldTimeChangeCheck; - void main() { /* DRAWBUFFERS:4 */ gl_FragData[0] = vec4(0.0); - float mixhistory = 0.06; +float accumuteSpeed = texelFetch2D(colortex4, ivec2(5,5), 0).r/150.0; + +vec2 pixelPos6 = vec2(5,5); + +if (gl_FragCoord.x > pixelPos6.x && gl_FragCoord.x < pixelPos6.x + 1 && gl_FragCoord.y > pixelPos6.y && gl_FragCoord.y < pixelPos6.y + 1){ + mixhistory = 0.1; + gl_FragData[0] = vec4(1,0,0,1); +} + + + #ifdef OVERWORLD_SHADER @@ -211,12 +194,12 @@ float mixhistory = 0.06; #ifdef Daily_Weather ivec2 pixelPos = ivec2(0,0); if (gl_FragCoord.x > 1 && gl_FragCoord.x < 4 && gl_FragCoord.y > 1 && gl_FragCoord.y < 2){ - - mixhistory = clamp(dayChangeSmooth*dayChangeSmooth*dayChangeSmooth*0.1, frameTime*0.1, 1.0); - if(gl_FragCoord.x < 2) gl_FragData[0] = vec4(CurrentFrame_dailyWeatherParams0.rgb * 10.0,1.0); - if(gl_FragCoord.x > 2) gl_FragData[0] = vec4(CurrentFrame_dailyWeatherParams1.rgb * 10.0,1.0); - if(gl_FragCoord.x > 3) gl_FragData[0] = vec4(CurrentFrame_dailyWeatherParams0.a * 10.0, CurrentFrame_dailyWeatherParams1.a * 10.0, 0.0, 1.0); + mixhistory = 0.005; + + if(gl_FragCoord.x < 2) gl_FragData[0] = vec4(dailyWeatherParams0.rgb * 2.0,1.0); + if(gl_FragCoord.x > 2) gl_FragData[0] = vec4(dailyWeatherParams1.rgb * 2.0,1.0); + if(gl_FragCoord.x > 3) gl_FragData[0] = vec4(dailyWeatherParams0.a * 2.0, dailyWeatherParams1.a * 2.0, 0.0, 1.0); } #endif @@ -284,9 +267,7 @@ if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){ sky *= vec3(0.0, 0.18, 0.35); #endif - gl_FragData[0] = vec4(sky / 4000.0 , 1.0); - - if(worldTimeChangeCheck) mixhistory = 1.0; + gl_FragData[0] = vec4(sky / 4000.0, 1.0); } /// --- Sky + clouds + fog @@ -294,31 +275,27 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+ vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); vec3 viewVector = cartToSphere(p); - vec3 viewPos = mat3(gbufferModelView)*viewVector*1024.0; - float noise = interleaved_gradientNoise_temporal(); - - WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition + gbufferModelViewInverse[3].xyz) ;// * ( float(sunElevation > 1e-5)*2.0-1.0 ); + WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) ;// * ( float(sunElevation > 1e-5)*2.0-1.0 ); vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150.0; - sky = mix(averageSkyCol_Clouds * AmbientLightTint * 0.25, sky, pow(clamp(viewVector.y+1.0,0.0,1.0),5.0)); + sky = mix(dot(sky, vec3(0.333)) * vec3(0.5), sky, pow(clamp(viewVector.y+1.0,0.0,1.0),5)); vec3 suncol = lightSourceColor; - #ifdef ambientLight_only suncol = vec3(0.0); #endif - float rejection = 1.0; - vec4 volumetricClouds = GetVolumetricClouds(viewPos, vec2(noise, 1.0-noise), WsunVec, suncol*2.5, skyGroundCol/30.0); - + + vec3 cloudDepth = vec3(0.0); + vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*2.0, skyGroundCol/30.0, cloudDepth); + float atmosphereAlpha = 1.0; - vec4 volumetricFog = GetVolumetricFog(viewPos, vec2(noise, 1.0-noise), suncol*2.5, skyGroundCol/30.0, averageSkyCol_Clouds*5.0, atmosphereAlpha, volumetricClouds.rgb); + vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*2.0, skyGroundCol/30.0, averageSkyCol_Clouds*5.0, atmosphereAlpha); - sky = sky * volumetricClouds.a + volumetricClouds.rgb / 5.0; - sky = sky * volumetricFog.a + volumetricFog.rgb / 5.0; + sky = sky*clouds.a + clouds.rgb / 5.0; + sky *= atmosphereAlpha; + sky = sky * VL_Fog.a + VL_Fog.rgb / 5.0; gl_FragData[0] = vec4(sky,1.0); - - if(worldTimeChangeCheck) mixhistory = 1.0; } #endif @@ -329,15 +306,14 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+ if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){ vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2); vec3 viewVector = cartToSphere(p); - float noise = interleaved_gradientNoise_temporal(); vec3 BackgroundColor = vec3(0.0); - vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., noise, 1.0-noise); + vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887)); - BackgroundColor += VL_Fog.rgb; + BackgroundColor += VL_Fog.rgb/5.0; - gl_FragData[0] = vec4(BackgroundColor*8.0, 1.0); + gl_FragData[0] = vec4(BackgroundColor, 1.0); } #endif @@ -395,11 +371,12 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+ //Temporally accumulate sky and light values -vec3 frameHistory = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb; -vec3 currentFrame = gl_FragData[0].rgb*150.; +vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb; +vec3 curr = gl_FragData[0].rgb*150.; +if(accumuteSpeed < 1.0) mixhistory = 1.0; -gl_FragData[0].rgb = clamp(mix(frameHistory, currentFrame, mixhistory),0.0,65000.); +gl_FragData[0].rgb = clamp(mix(temp, curr, mixhistory),0.0,65000.); //Exposure values if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) diff --git a/shaders/dimensions/deferred.vsh b/shaders/dimensions/deferred.vsh index 5378d88..02bf6ec 100644 --- a/shaders/dimensions/deferred.vsh +++ b/shaders/dimensions/deferred.vsh @@ -23,13 +23,8 @@ flat varying float rodExposure; flat varying float avgL2; flat varying float centerDepth; -#ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; -#endif -uniform int hideGUI; -flat varying vec4 CurrentFrame_dailyWeatherParams0; -flat varying vec4 CurrentFrame_dailyWeatherParams1; +flat varying vec4 dailyWeatherParams0; +flat varying vec4 dailyWeatherParams1; uniform sampler2D colortex4; uniform sampler2D colortex6; @@ -151,13 +146,10 @@ void main() { } // maximum control of color and luminance + vec3 minimumlight = vec3(0.5,0.75,1.0) * (min(MIN_LIGHT_AMOUNT,0.0025) + nightVision); // vec3 minimumlight = vec3(0.5,0.75,1.0) * nightVision; - // averageSkyCol_Clouds = max( normalize(averageSkyCol_Clouds) * min(luma(averageSkyCol_Clouds) * 3.0,2.5) * (1.0-rainStrength*0.7), minimumlight); - - - vec3 minimumlight = vec3(0.02) * 0.2 * MIN_LIGHT_AMOUNT + nightVision * 0.05; - averageSkyCol_Clouds = max(normalize(averageSkyCol_Clouds + 1e-6) * min(luma(averageSkyCol_Clouds) * 3.0,2.5),0.0); - averageSkyCol = max(averageSkyCol * PLANET_GROUND_BRIGHTNESS,0.0) + max(minimumlight, 0.02 * 0.2); + averageSkyCol_Clouds = max( normalize(averageSkyCol_Clouds) * min(luma(averageSkyCol_Clouds) * 3.0,2.5) * (1.0-rainStrength*0.7), minimumlight); + averageSkyCol = max(averageSkyCol * PLANET_GROUND_BRIGHTNESS, minimumlight); //////////////////////////////////////// /// --- SUNLIGHT/MOONLIGHT STUFF --- /// @@ -173,8 +165,7 @@ void main() { sunColor = sunColorBase/4000.0 * skyAbsorb; moonColor = moonColorBase/4000.0; - // lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis; - lightSourceColor = sunColor * sunVis + moonColor * moonVis; + lightSourceColor = (sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis) ; #endif @@ -222,39 +213,8 @@ void main() { vec4(DAY9_l0_density, DAY9_l1_density, DAY9_l2_density, DAY9_cfog_density) ); - - - CurrentFrame_dailyWeatherParams0 = weatherParameters_A[dayCounter]; - CurrentFrame_dailyWeatherParams1 = weatherParameters_B[dayCounter]; - - vec4 rainyWeatherParameters_A[3] = vec4[]( - // vec4(DAY0_l0_coverage, DAY0_l1_coverage, DAY0_l2_coverage, DAY0_ufog_density), - vec4(1.3,0.0,0.0,0.0), - vec4(0.5,0.0,0.0,0.0), - vec4(0.0,0.0,0.0,0.0) - ); - vec4 rainyWeatherParameters_B[3] = vec4[]( - // vec4(DAY7_l0_density, DAY7_l1_density, DAY7_l2_density, DAY7_cfog_density), - vec4(0.1,0.0,0.0,0.0), - vec4(0.1,0.0,0.0,0.0), - vec4(0.0,0.0,0.0,0.0) - ); - - // if(hideGUI == 1){ - // CurrentFrame_dailyWeatherParams0 = rainyWeatherParameters_A[worldDay%2]; - // CurrentFrame_dailyWeatherParams1 = rainyWeatherParameters_B[worldDay%2]; - // } else { - // CurrentFrame_dailyWeatherParams0 = vec4(0.5,0.0,0.0,0.0); - // CurrentFrame_dailyWeatherParams1 = vec4(0.1,0.5,0.0,0.0); - // } - - #if defined Daily_Weather - dailyWeatherParams0 = vec4(sqrt(texelFetch2D(colortex4,ivec2(1,1),0).rgb/ 1500.0), 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); - - dailyWeatherParams0.a = texelFetch2D(colortex4,ivec2(3,1),0).x/1500.0; - dailyWeatherParams1.a = texelFetch2D(colortex4,ivec2(3,1),0).y/1500.0; - #endif + dailyWeatherParams0 = weatherParameters_A[dayCounter]; + dailyWeatherParams1 = weatherParameters_B[dayCounter]; #endif @@ -275,7 +235,7 @@ void main() { vec2 ij = R2_samples((frameCounter%2000)*maxITexp+i); vec2 tc = 0.5 + (ij-0.5) * 0.7; vec3 sp = texture2D(colortex6, tc/16. * resScale+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; - avgExp += log(sqrt(luma(sp))); + avgExp += log(luma(sp)); avgB += log(min(dot(sp,vec3(0.07,0.22,0.71)),8e-2)); } @@ -287,16 +247,13 @@ void main() { float L = max(avgBrightness,1e-8); float keyVal = 1.03-2.0/(log(L*4000/150.*8./3.0+1.0)/log(10.0)+2.0); float expFunc = 0.5+0.5*tanh(log(L)); - - float targetExposure = 1.0/log(L+1.05); - // float targetExposure = 0.35/log(L+1.05); - // float targetExposure = 0.18/log2(L*2.5+1.045)*0.62; + float targetExposure = 0.18/log2(L*2.5+1.045)*0.62; avgL2 = clamp(mix(avgB,texelFetch2D(colortex4,ivec2(10,37),0).b,0.985),0.00003051757,65000.0); float targetrodExposure = max(0.012/log2(avgL2+1.002)-0.1,0.0)*1.2; - exposure = max(targetExposure, 0.0); + exposure = max(targetExposure*EXPOSURE_MULTIPLIER, 0.0); // exposure = mix(0.0, 1.0, min(targetExposure,1.0)); // exposure = 1; diff --git a/shaders/dimensions/deferred2.fsh b/shaders/dimensions/deferred2.fsh index 60c584b..b2d8c55 100644 --- a/shaders/dimensions/deferred2.fsh +++ b/shaders/dimensions/deferred2.fsh @@ -100,17 +100,6 @@ uniform int dhRenderDistance; #define CLOUDS_INTERSECT_TERRAIN uniform float eyeAltitude; - - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - - #include "/lib/volumetricClouds.glsl" @@ -127,6 +116,7 @@ uniform float eyeAltitude; void main() { +/* DRAWBUFFERS:0 */ diff --git a/shaders/dimensions/deferred2.vsh b/shaders/dimensions/deferred2.vsh index 8dd15ea..cc7f26b 100644 --- a/shaders/dimensions/deferred2.vsh +++ b/shaders/dimensions/deferred2.vsh @@ -1,12 +1,10 @@ #include "/lib/settings.glsl" // uniform int dhRenderDistance; - - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #endif - +#if defined Daily_Weather + flat varying vec4 dailyWeatherParams0; + flat varying vec4 dailyWeatherParams1; +#endif flat varying vec3 averageSkyCol; flat varying vec3 sunColor; @@ -34,8 +32,8 @@ void main() { gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(CLOUDS_QUALITY+0.01,0.0,1.0)*2.0-1.0; #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0); #endif averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; diff --git a/shaders/dimensions/final.fsh b/shaders/dimensions/final.fsh index b97b76e..12d3420 100644 --- a/shaders/dimensions/final.fsh +++ b/shaders/dimensions/final.fsh @@ -1,18 +1,14 @@ #include "/lib/settings.glsl" uniform sampler2D colortex7; -uniform sampler2D colortex5; -uniform sampler2D colortex6; uniform sampler2D colortex14; uniform sampler2D depthtex0; -uniform sampler2D depthtex1; uniform sampler2D depthtex2; uniform sampler2D noisetex; varying vec2 texcoord; uniform vec2 texelSize; uniform float frameTimeCounter; -uniform int frameCounter; uniform float viewHeight; uniform float viewWidth; uniform float aspectRatio; @@ -23,19 +19,12 @@ uniform int hideGUI; #include "/lib/color_dither.glsl" #include "/lib/res_params.glsl" -uniform float near; -uniform float far; -float ld(float dist) { - return (2.0 * near) / (far + near - dist * (far - near)); -} + float interleaved_gradientNoise(){ vec2 coord = gl_FragCoord.xy; float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); return noise; } -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} #include "/lib/gameplay_effects.glsl" @@ -64,20 +53,14 @@ uniform mat4 gbufferPreviousModelView; #include "/lib/util.glsl" #include "/lib/projections.glsl" -vec3 tonemap(vec3 col){ - return col/(1+luma(col)); -} -vec3 invTonemap(vec3 col){ - return col/(1-luma(col)); -} -vec3 doMotionBlur(vec2 texcoord, float depth, float noise, bool hand){ +vec3 doMotionBlur(vec2 texcoord, float depth, float noise){ float samples = 4.0; vec3 color = vec3(0.0); float blurMult = 1.0; - if(hand) blurMult = 0.0; + if(depth < 0.56) blurMult = 0.0; vec3 viewPos = toScreenSpace(vec3(texcoord, depth)); viewPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); @@ -88,9 +71,8 @@ vec3 doMotionBlur(vec2 texcoord, float depth, float noise, bool hand){ vec2 velocity = texcoord - previousPosition.xy; // thank you Capt Tatsu for letting me use these - velocity = (velocity / (1.0 + length(velocity)) ) * 0.05 * blurMult * MOTION_BLUR_STRENGTH; + velocity = (velocity / (1.0 + length(velocity))) * 0.05 * blurMult * MOTION_BLUR_STRENGTH; texcoord = texcoord - velocity*(samples*0.5 + noise); - vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight); for (int i = 0; i < int(samples); i++) { @@ -99,53 +81,23 @@ vec3 doMotionBlur(vec2 texcoord, float depth, float noise, bool hand){ color += texture2D(colortex7, clamp(texcoord, screenEdges, 1.0-screenEdges)).rgb; } - + // return vec3(texcoord,0.0); return color / samples; } -float convertHandDepth_2(in float depth, bool hand) { - if(!hand) return depth; - - float ndcDepth = depth * 2.0 - 1.0; - ndcDepth /= MC_HAND_DEPTH; - return ndcDepth * 0.5 + 0.5; -} - uniform sampler2D shadowcolor1; -float doVignette( in vec2 texcoord, in float noise){ - - float vignette = 1.0-clamp(1.0-length(texcoord-0.5),0.0,1.0); - - // vignette = pow(1.0-pow(1.0-vignette,3),5); - vignette *= vignette*vignette; - vignette = 1.0-vignette; - vignette *= vignette*vignette*vignette*vignette; - - // stop banding - vignette = vignette + vignette*(noise-0.5)*0.01; - - return mix(1.0, vignette, VIGNETTE_STRENGTH); -} - void main() { - float noise = blueNoise(); + float depth = texture2D(depthtex0,texcoord*RENDER_SCALE).r; + float noise = interleaved_gradientNoise(); #ifdef MOTION_BLUR - float depth = texture2D(depthtex0, texcoord*RENDER_SCALE).r; - bool hand = depth < 0.56; - float depth2 = convertHandDepth_2(depth, hand); - - vec3 COLOR = doMotionBlur(texcoord, depth2, noise, hand); + vec3 COLOR = doMotionBlur(texcoord, depth, noise); #else vec3 COLOR = texture2D(colortex7,texcoord).rgb; #endif - - #ifdef VIGNETTE - COLOR *= doVignette(texcoord, noise); - #endif - + #if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT || defined WATER_ON_CAMERA_EFFECT // for making the fun, more fun applyGameplayEffects(COLOR, texcoord, noise); @@ -156,19 +108,10 @@ void main() { #endif #if DEBUG_VIEW == debug_SHADOWMAP - vec2 shadowUV = texcoord * vec2(2.0, 1.0) ; - // shadowUV -= vec2(0.5,0.0); - // float zoom = 0.1; - // shadowUV = ((shadowUV-0.5) - (shadowUV-0.5)*zoom) + 0.5; + vec2 shadowUV = texcoord * vec2(2.0, 1.0); - if(shadowUV.x < 1.0 && shadowUV.y < 1.0 && hideGUI == 1) COLOR = texture2D(shadowcolor1,shadowUV).rgb; - #endif - #if DEBUG_VIEW == debug_DEPTHTEX0 - COLOR = vec3(ld(texture2D(depthtex0, texcoord*RENDER_SCALE).r)); - #endif - #if DEBUG_VIEW == debug_DEPTHTEX1 - COLOR = vec3(ld(texture2D(depthtex1, texcoord*RENDER_SCALE).r)); + if(shadowUV.x < 1.0 && shadowUV.y < 1.0 && hideGUI == 1)COLOR = texture2D(shadowcolor1,shadowUV).rgb; #endif diff --git a/shaders/dimensions/fogBehindTranslucent_pass.fsh b/shaders/dimensions/fogBehindTranslucent_pass.fsh index 51cad85..87ceb60 100644 --- a/shaders/dimensions/fogBehindTranslucent_pass.fsh +++ b/shaders/dimensions/fogBehindTranslucent_pass.fsh @@ -2,7 +2,9 @@ // #if defined END_SHADER || defined NETHER_SHADER #undef IS_LPV_ENABLED // #endif +#ifndef OVERWORLD_SHADER uniform float nightVision; +#endif flat varying vec4 lightCol; flat varying vec3 averageSkyCol; @@ -88,33 +90,14 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo flat varying vec3 refractedSunVec; - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #else - vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); - vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); - #endif - - #define TIMEOFDAYFOG #include "/lib/lightning_stuff.glsl" #define CLOUDS_INTERSECT_TERRAIN // #define CLOUDSHADOWSONLY #include "/lib/volumetricClouds.glsl" - #include "/lib/climate_settings.glsl" #include "/lib/overworld_fog.glsl" - -// float fogPhase(float lightPoint){ -// float linear = 1.0 - clamp(lightPoint*0.5+0.5,0.0,1.0); -// float linear2 = 1.0 - clamp(lightPoint,0.0,1.0); -// float exponential = exp2(pow(linear,0.3) * -15.0 ) * 1.5; -// exponential += sqrt(exp2(sqrt(linear) * -12.5)); - -// return exponential; -// } #endif #ifdef NETHER_SHADER uniform sampler2D colortex4; @@ -207,7 +190,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_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ int spCount = rayMarchSampleCount; vec3 start = toShadowSpaceProjected(rayStart); @@ -224,12 +207,8 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz; vec3 dVWorld = (wpos - gbufferModelViewInverse[3].xyz); - - // vec3 dVWorld = -mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; - // vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; - - + vec3 newabsorbance = exp(-rayLength * waterCoefs); // No need to take the integrated value #ifdef OVERWORLD_SHADER float phase = fogPhase(VdotL) * 5.0; #else @@ -239,14 +218,13 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float vec3 vL = vec3(0.0); ambient = max(ambient * (normalize(wpos).y*0.3+0.7),0.0); + float expFactor = 11.0; for (int i=0;i 0.99; - - bool iswater = alpha > 0.99; ////////////////////////////////////////////////////////// ///////////////// BEHIND OF TRANSLUCENTS ///////////////// ////////////////////////////////////////////////////////// - if(blendedAlpha > 0.0 || iswater){ + if(texture2D(colortex2, tc).a > 0.0 || iswater){ float noise_1 = R2_dither(); float noise_2 = blueNoise(); @@ -390,106 +322,78 @@ void main() { // vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); - float dirtAmount = Dirt_Amount ; + float dirtAmount = Dirt_Amount + 0.1; // 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 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; #ifdef BIOME_TINT_WATER // yoink the biome tint written in this buffer for water only. if(iswater){ - vec2 translucentdata = texelFetch2D(colortex11,ivec2(tc/texelSize),0).gb; + vec2 translucentdata = texture2D(colortex11,tc).gb; vec3 wateralbedo = normalize(vec3(decodeVec2(translucentdata.x),decodeVec2(translucentdata.y).x)+0.00001) * 0.5 + 0.5; scatterCoef = dirtAmount * wateralbedo / 3.14; } #endif - // vec3 directLightColor = lightCol.rgb / 2400.0; - // vec3 indirectLightColor = averageSkyCol / 1500.0; - // vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 900.0; - - vec3 directLightColor = lightCol.rgb / 2400.0; - vec3 indirectLightColor = averageSkyCol / 1200.0; - vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 900.0; - + vec3 directLightColor = lightCol.rgb/80.0; + vec3 indirectLightColor = averageSkyCol/30.0; + vec3 indirectLightColor_dynamic = averageSkyCol_Clouds/30.0; vec3 viewPos1 = toScreenSpace_DH(tc/RENDER_SCALE, z, DH_z); vec3 viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0); - - vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos1; - vec3 playerPos0 = mat3(gbufferModelViewInverse) * viewPos0; + vec3 playerPos = normalize(mat3(gbufferModelViewInverse) * viewPos1); #ifdef OVERWORLD_SHADER // vec2 lightmap = decodeVec2(texture2D(colortex14, tc).a); - // vec2 lightmap = vec2(0.0,texture2D(colortex14, tc).a); - - vec2 lightmap = decodeVec2(texelFetch2D(colortex14,ivec2(tc/texelSize),0).x); - - + vec2 lightmap = vec2(0.0,texture2D(colortex14, tc).a); #ifdef DISTANT_HORIZONS if(z >= 1.0) lightmap.y = 0.99; #endif #else - vec2 lightmap = decodeVec2(texelFetch2D(colortex14,ivec2(tc/texelSize),0).a); + vec2 lightmap = decodeVec2(texture2D(colortex14, tc).a); 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) * 2.0; + float VdotU = playerPos.y; + float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane + float estimatedSunDepth = estimatedDepth / abs(WsunVec.y); //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; + indirectLightColor_dynamic *= ambient_brightness * pow(1.0-pow(1.0-lightmap.y,0.5),3.0) ; + // float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) ; + // indirectLightColor_dynamic += vec3(TORCH_R,TORCH_G,TORCH_B) * TorchBrightness_autoAdjust * pow(1.0-sqrt(1.0-clamp(lightmap.x,0.0,1.0)),2.0) * 2.0; + + vec3 cloudDepth = vec3(0.0); + vec4 VolumetricFog2 = vec4(0,0,0,1); + vec4 VolumetricClouds = vec4(0,0,0,1); - // Vdiff = Vdiff * (1.0 - clamp(exp(-Vdiff),0.0,1.0)) + max(estimatedDepth - 1.0,0.0); - // estimatedDepth = max(estimatedDepth - 1.0,0.0); - - indirectLightColor_dynamic *= ambient_brightness * lightmap.y*lightmap.y; + #ifdef OVERWORLD_SHADER + if(!iswater){ - indirectLightColor_dynamic += MIN_LIGHT_AMOUNT * 0.02 * 0.2 + nightVision*0.02; - - indirectLightColor_dynamic += vec3(TORCH_R,TORCH_G,TORCH_B) * pow(1.0-sqrt(1.0-clamp(lightmap.x,0.0,1.0)),2.0) ; - - vec4 finalVolumetrics = vec4(0.0,0.0,0.0,1.0); - - if(!iswater){ - #ifdef OVERWORLD_SHADER - vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WsunVec, directLightColor, indirectLightColor); - + #if defined CLOUDS_INTERSECT_TERRAIN + VolumetricClouds = renderClouds(viewPos1, vec2(noise_1,noise_2), directLightColor, indirectLightColor, cloudDepth); + #endif 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; - #endif + VolumetricFog2 = GetVolumetricFog(viewPos1, vec2(noise_1, noise_2), directLightColor, indirectLightColor,indirectLightColor_dynamic, atmosphereAlpha); + VolumetricClouds.a *= atmosphereAlpha; - #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; - } + #if defined CLOUDS_INTERSECT_TERRAIN + VolumetricFog2 = vec4(VolumetricClouds.rgb * VolumetricFog2.a * atmosphereAlpha + VolumetricFog2.rgb, VolumetricFog2.a*VolumetricClouds.a); + #endif + } + #endif vec4 underwaterVlFog = vec4(0,0,0,1); + if(iswater) underwaterVlFog = waterVolumetrics_test(viewPos0, viewPos1, estimatedDepth, estimatedSunDepth, Vdiff, noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic, directLightColor* (1.0-caveDetection), dot(normalize(viewPos1), normalize(sunVec*lightCol.a)) ); - 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; + vec4 fogFinal = vec4(underwaterVlFog.rgb * VolumetricFog2.a + VolumetricFog2.rgb, VolumetricFog2.a * underwaterVlFog.a); - gl_FragData[0] = clamp(finalVolumetrics, 0.0, 65000.0); + gl_FragData[0] = clamp(fogFinal, 0.0, 65000.0); } } \ No newline at end of file diff --git a/shaders/dimensions/fogBehindTranslucent_pass.vsh b/shaders/dimensions/fogBehindTranslucent_pass.vsh index d74ae93..1b6f513 100644 --- a/shaders/dimensions/fogBehindTranslucent_pass.vsh +++ b/shaders/dimensions/fogBehindTranslucent_pass.vsh @@ -6,11 +6,10 @@ flat varying vec4 lightCol; flat varying vec3 averageSkyCol; flat varying vec3 averageSkyCol_Clouds; - #ifdef Daily_Weather - flat varying vec4 dailyWeatherParams0; - flat varying vec4 dailyWeatherParams1; - #endif - +#if defined Daily_Weather + flat varying vec4 dailyWeatherParams0; + flat varying vec4 dailyWeatherParams1; +#endif flat varying vec3 WsunVec; flat varying vec3 refractedSunVec; @@ -57,11 +56,11 @@ void main() { averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; #if defined Daily_Weather - dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb / 1500.0, 0.0); - dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb / 1500.0, 0.0); + dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0); + dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0); - dailyWeatherParams0.a = texelFetch2D(colortex4,ivec2(3,1),0).x/1500.0; - dailyWeatherParams1.a = texelFetch2D(colortex4,ivec2(3,1),0).y/1500.0; + dailyWeatherParams0.a = (texelFetch2D(colortex4,ivec2(3,1),0).x/150.0)/2.0; + dailyWeatherParams1.a = (texelFetch2D(colortex4,ivec2(3,1),0).y/150.0)/2.0; #endif #endif @@ -69,7 +68,7 @@ void main() { #ifdef NETHER_SHADER lightCol.rgb = vec3(0.0); averageSkyCol = vec3(0.0); - averageSkyCol_Clouds = volumetricsFromTex(vec3(0.0,1.0,0.0), colortex4, 6).rgb; + averageSkyCol_Clouds = vec3(2.0, 1.0, 0.5) * 5.0; #endif #ifdef END_SHADER diff --git a/shaders/lang/en_us.lang b/shaders/lang/en_us.lang index 63564b5..54ba5b5 100644 --- a/shaders/lang/en_us.lang +++ b/shaders/lang/en_us.lang @@ -389,14 +389,12 @@ screen.World = World option.SSR_STEPS = SSR Quality option.WATER_SUN_SPECULAR = Sun/Moon Reflections option.WATER_BACKGROUND_SPECULAR = Sky/Fog Reflections - option.FAKE_REFRACTION_EFFECT = Refraction In Water/Glass + option.Refraction = Refraction In Water/Glass option.Dirt_Amount = Dirt Amount option.Water_Top_Layer = Ocean Y coordinate option.WATER_WAVE_STRENGTH = Wave Strength option.SNELLS_WINDOW = Snell's Window - option.MINIMUM_WATER_ABSORBANCE = Minimum Water Absorbance - value.MINIMUM_WATER_ABSORBANCE.-1 = AUTO - + screen.Water_fog_color = Water Fog Settings option.Dirt_Scatter_R = Scatter Red (dirt) option.Dirt_Scatter_G = Scatter Green (dirt) @@ -419,7 +417,6 @@ screen.Post_Processing = Post Processing screen.TAA_OPTIONS = Anti-Aliasing Settings option.SCREENSHOT_MODE = Screenshot Mode option.TAA = TAA - option.RESPONSIVE_TAA = Responsive TAA §a(SET BLEND FACTOR TO 0.25 WHEN THIS IS ENABLED) option.BLEND_FACTOR = Blend Factor option.TAA_UPSCALING = Temporal Upscaling option.SCALE_FACTOR = Scale Factor @@ -630,7 +627,7 @@ screen.World.comment = Configure settings for various things that happen in the option.SSR_STEPS.comment = Configure the quality of the screen-space reflections on translucent things. §aPERFORMANCE COST:§r medium to high option.WATER_SUN_SPECULAR.comment = Toggle the sun and moon reflections on translucent things. §aPERFORMANCE COST:§r low option.WATER_BACKGROUND_SPECULAR.comment = Toggle the sky and fog reflections on translucent things. §aPERFORMANCE COST:§r low to medium - option.FAKE_REFRACTION_EFFECT.comment = Toggle refraction on translucent things. §bWhat is this?§r If you look at water, you can see the light refracting distorts what is in it. §aPERFORMANCE COST:§r low + option.Refraction.comment = Toggle refraction on translucent things. §bWhat is this?§r If you look at water, you can see the light refracting distorts what is in it. §aPERFORMANCE COST:§r low option.Dirt_Amount.comment = Configure how much dirt is in water. This controls how much fog is within water. option.Water_Top_Layer.comment = Configure the Y coordinate at which the ocean should be in the world. @@ -738,5 +735,4 @@ option.DISTANT_HORIZONS_SHADOWMAP.comment = §cTHIS SETTING WILL DESTROY PERFOR option.TOGGLE_VL_FOG = Toggle Volumetric Fog option.TOGGLE_VL_FOG.comment = one big button to just turn all the fog off. -option.TRANSLUCENT_COLORED_SHADOWS.comment = §bWhat is this?§r This effect allows translucent things like stained glass to color the sunlight as it passes through it. §aPERFORMANCE COST:§r medium -option.MINIMUM_WATER_ABSORBANCE.comment = §bWhat is this?§r This controls how "clear" the water is in shallow areas. AUTO allows water to be clear outdoors, but adjust to be at a minimum value of 7 when indoors, to make it clearly visible. §dTHIS SETTING DOES NOT IMPACT UNDER-WATER VISUALS. \ No newline at end of file +option.TRANSLUCENT_COLORED_SHADOWS.comment = §bWhat is this?§r This effect allows translucent things like stained glass to color the sunlight as it passes through it. §aPERFORMANCE COST:§r medium \ No newline at end of file diff --git a/shaders/lang/pt_br.lang b/shaders/lang/pt_br.lang index d204370..ef7718c 100644 --- a/shaders/lang/pt_br.lang +++ b/shaders/lang/pt_br.lang @@ -216,7 +216,7 @@ screen.World = Mundo option.SSR_STEPS = Qualidade do SSR option.WATER_SUN_SPECULAR = Reflexos do Sol/Lua option.WATER_BACKGROUND_SPECULAR = Reflexos do Céu/Névoa - option.FAKE_REFRACTION_EFFECT = Refração na Água/Vidro + option.Refraction = Refração na Água/Vidro option.Dirt_Amount = Quantidade de Sujeira option.Water_Top_Layer = Coordenada Y do Oceano @@ -451,7 +451,7 @@ screen.World.comment = Ajuste configurações para váriadas coisas que acontece option.SSR_STEPS.comment = Ajuste a qualiade dos reflexos em coisas translúcidas. §aCUSTO DE PERFORMANCE:§r Médio pra Alto option.WATER_SUN_SPECULAR.comment = Habilita reflexos da lua e do sol em coisas translúcidas. §aCUSTO DE PERFORMANCE:§r Baixo option.WATER_BACKGROUND_SPECULAR.comment = Habilita reflexos do céu e névoa em coisas translúcidas. §aCUSTO DE PERFORMANCE:§r Baixo para Médio - option.FAKE_REFRACTION_EFFECT.comment = Habilita refração em coisas translúcidas. §bO Que é Isso?§r Olhe para a água e você vai perceber a refração da luz distorcendo as coisas dentro dela. §aCUSTO DE PERFORMANCE:§r Baixo + option.Refraction.comment = Habilita refração em coisas translúcidas. §bO Que é Isso?§r Olhe para a água e você vai perceber a refração da luz distorcendo as coisas dentro dela. §aCUSTO DE PERFORMANCE:§r Baixo option.Dirt_Amount.comment = Ajusta quanta sujeira tem na água. Isso controla quanta névoa tem dentro da água. option.Water_Top_Layer.comment = Ajusta a coordenada Y que oceano deve estar no mundo. diff --git a/shaders/lang/ru_RU.lang b/shaders/lang/ru_RU.lang index 7a15d6c..d612ebd 100644 --- a/shaders/lang/ru_RU.lang +++ b/shaders/lang/ru_RU.lang @@ -363,7 +363,7 @@ screen.World = Мир option.SSR_STEPS = Качество SSR option.WATER_SUN_SPECULAR = Отражения солнца/луны option.WATER_BACKGROUND_SPECULAR = Отражения неба/тумана - option.FAKE_REFRACTION_EFFECT = Преломление в воде/стекле + option.Refraction = Преломление в воде/стекле option.Dirt_Amount = Количество грязи option.Water_Top_Layer = Координата океана Y option.WATER_WAVE_STRENGTH = Сила волны @@ -653,7 +653,7 @@ screen.World.comment = Настраивайте параметры для раз option.SSR_STEPS.comment = Настройте качество отражения в пространстве экрана на полупрозрачных объектах. §aНАГРУЗКА:§r от средней до высокой option.WATER_SUN_SPECULAR.comment = Переключайте отражения солнца и луны на полупрозрачных объектах. §aНАГРУЗКА:§r низкая option.WATER_BACKGROUND_SPECULAR.comment = Переключайте отражения неба и тумана на полупрозрачных объектах. §aНАГРУЗКА:§r от низкой до средней - option.FAKE_REFRACTION_EFFECT.comment = Переключите преломление на полупрозрачных объектах. §bЧто это?§r Если вы посмотрите на воду, то увидите, что преломление света искажает то, что в ней находится. §aНАГРУЗКА:§r низкая + option.Refraction.comment = Переключите преломление на полупрозрачных объектах. §bЧто это?§r Если вы посмотрите на воду, то увидите, что преломление света искажает то, что в ней находится. §aНАГРУЗКА:§r низкая option.Dirt_Amount.comment = Настройте количество грязи в воде. Это определяет количество тумана в воде option.Water_Top_Layer.comment = Настройте координату Y, в которой должен находиться океан в мире diff --git a/shaders/lang/zh_cn.lang b/shaders/lang/zh_cn.lang index b2b4def..148158f 100644 --- a/shaders/lang/zh_cn.lang +++ b/shaders/lang/zh_cn.lang @@ -373,7 +373,7 @@ screen.World = 世界 option.SSR_STEPS = SSR 采样值 option.WATER_SUN_SPECULAR = 日月反射 option.WATER_BACKGROUND_SPECULAR = 天空/雾气反射 - option.FAKE_REFRACTION_EFFECT = 折射 (水体/玻璃) + option.Refraction = 折射 (水体/玻璃) option.Dirt_Amount = 水体浑浊程度 option.Water_Top_Layer = 海平面 Y 轴坐标 option.WATER_WAVE_STRENGTH = 水波强度 @@ -599,7 +599,7 @@ screen.World.comment = 配置多种会在主世界发生的效果, 从摇摆植 option.SSR_STEPS.comment = 配置半透明方块的屏幕空间反射质量. §a性能消耗水平:§r 中偏高. option.WATER_SUN_SPECULAR.comment = 半透明方块的日月反射开关. §a性能消耗水平:§r 低. option.WATER_BACKGROUND_SPECULAR.comment = 半透明方块的天空和雾气反射开关. §a性能消耗水平:§r 低偏中. - option.FAKE_REFRACTION_EFFECT.comment = 半透明折射开关. §b这啥?§r 如果你观察水体, 可以看到光的折射会扭曲了水中的内容. §a性能消耗水平:§r 低. + option.Refraction.comment = 半透明折射开关. §b这啥?§r 如果你观察水体, 可以看到光的折射会扭曲了水中的内容. §a性能消耗水平:§r 低. option.Dirt_Amount.comment = 配置水中污物含量. 这可以控制水雾量. option.Water_Top_Layer.comment = 配置海平面在世界中的 Y 坐标. diff --git a/shaders/lib/ROBOBO_sky.glsl b/shaders/lib/ROBOBO_sky.glsl index e5f23f6..d7e9c0b 100644 --- a/shaders/lib/ROBOBO_sky.glsl +++ b/shaders/lib/ROBOBO_sky.glsl @@ -119,7 +119,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s position += increment * (0.34*noise); vec2 phaseSun = sky_phase(dot(viewVector, sunVector), 0.8); - vec2 phaseMoon = sky_phase(dot(viewVector, moonVector), 0.8) ; + vec2 phaseMoon = sky_phase(dot(viewVector, moonVector), 0.8); vec3 scatteringSun = vec3(0.0); vec3 scatteringMoon = vec3(0.0); @@ -128,7 +128,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s transmittance = vec3(1.0); float high_sun = clamp(pow(sunVector.y+0.6,5),0.0,1.0) * 3.0; // make sunrise less blue, and allow sunset to be bluer - float low_sun = clamp(((1.0-abs(sunVector.y))*3.) - high_sun,1.0,2.0) ; + float low_sun = clamp(((1.0-abs(sunVector.y))*3.) - high_sun,1.0,1.8) ; for (int i = 0; i < iSteps; ++i, position += increment) { @@ -144,7 +144,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s #ifdef ORIGINAL_CHOCAPIC_SKY scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun) * stepScatteringVisible * sky_transmittance(position, sunVector, jSteps) * planetGround; #else - scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun) * stepScatteringVisible * sky_transmittance(position, sunVector, jSteps) * planetGround; + scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps) * planetGround; #endif scatteringMoon += sky_coefficientsScattering * (stepAirmass.xy * phaseMoon) * stepScatteringVisible * sky_transmittance(position, moonVector, jSteps) * planetGround; @@ -159,7 +159,7 @@ vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 s transmittance *= stepTransmittance; } - vec3 scattering = scatteringAmbient * background + scatteringSun * sunColorBase + scatteringMoon*moonColorBase * 0.5; + vec3 scattering = scatteringSun * sunColorBase + scatteringAmbient * background + scatteringMoon*moonColorBase ; return scattering; } diff --git a/shaders/lib/Shadows.glsl b/shaders/lib/Shadows.glsl index c5cf4d5..07cb5a7 100644 --- a/shaders/lib/Shadows.glsl +++ b/shaders/lib/Shadows.glsl @@ -11,19 +11,16 @@ void GriAndEminShadowFix( float MinimumValue = 0.05; // give a tiny boost to the distance mulitplier when shadowmap resolution is below 2048.0 - // float ResMultiplier = 1.0 + (shadowDistance/8.0)*(1.0 - min(shadowMapResolution,2048)/2048.0)*0.3; + float ResMultiplier = 1.0 + (shadowDistance/8.0)*(1.0 - min(shadowMapResolution,2048)/2048.0)*0.3; - // float DistanceMultiplier = max(1.0 - max(1.0 - length(WorldPos) / shadowDistance, 0.0), MinimumValue) * ResMultiplier; - float theDistance = max(1.0 - length(WorldPos) / shadowDistance,0.0); - float DistanceMultiplier = mix(0.5, 0.05, theDistance); - float DistanceMultiplier2 = mix(1.0, 0.02, theDistance); - - vec3 Bias = (FlatNormal * DistanceMultiplier + WsunVec * DistanceMultiplier2); + float DistanceMultiplier = max(1.0 - max(1.0 - length(WorldPos) / shadowDistance, 0.0), MinimumValue) * ResMultiplier; + + vec3 Bias = FlatNormal * DistanceMultiplier; // 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; + vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y); + if(SkyLightmap < 0.1) Bias = zoomShadow; WorldPos += Bias; } \ No newline at end of file diff --git a/shaders/lib/TAA_jitter.glsl b/shaders/lib/TAA_jitter.glsl index ff5c988..6e36ea9 100644 --- a/shaders/lib/TAA_jitter.glsl +++ b/shaders/lib/TAA_jitter.glsl @@ -1,40 +1,33 @@ -// swap out jitter pattern to be a 4 frame pattern instead of an 8 frame halton sequence -#ifdef RESPONSIVE_TAA - const vec2[4] offsets = vec2[4]( +const vec2[8] offsets = vec2[8]( + vec2( 1.0, -3.0)/8.0, + vec2(-1.0, 3.0)/8.0, + vec2( 5.0, 1.0)/8.0, + vec2(-3.0, -5.0)/8.0, + vec2(-5.0, 5.0)/8.0, + vec2(-7.0, -1.0)/8.0, + vec2( 3.0, 7.0)/8.0, + vec2( 7.0, 7.0)/8.0 +); - // vec2( 0.0, -1.0), - // vec2( 1.0, 0.0), - // vec2( 0.0, 1.0), - // vec2(-1.0, 0.0) - - // vec2(-1.0, -7.0)/8.0, - // vec2( 7.0, -1.0)/8.0, - // vec2( 1.0, 7.0)/8.0, - // vec2(-7.0, 1.0)/8.0 - - vec2(-0.125, -0.875), - vec2( 0.875, -0.125), - vec2( 0.125, 0.875), - vec2(-0.875, 0.125) - - - // vec2(-7.0, 1.0)/8.0, - // vec2( 7.0, -1.0)/8.0, - // vec2( 1.0, 7.0)/8.0, - // vec2(-1.0, -7.0)/8.0 - - ); -#else - - const vec2[8] offsets = vec2[8]( - vec2( 1.0, -3.0)/8.0, - vec2(-1.0, 3.0)/8.0, - vec2( 5.0, 1.0)/8.0, - vec2(-3.0, -5.0)/8.0, - vec2(-5.0, 5.0)/8.0, - vec2(-7.0, -1.0)/8.0, - vec2( 3.0, 7.0)/8.0, - vec2( 7.0, 7.0)/8.0 - ); - -#endif \ No newline at end of file +// const vec2[4] offsets = vec2[4]( +// vec2( 0.0, -1.0), // right bottom +// vec2( 1.0, 0.0), // left top +// vec2( 0.0, 1.0), // right top +// vec2(-1.0, 0.0) // left bottom +// ); +// const vec2[4] offsets = vec2[4]( +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0) +// ); +// const vec2[8] offsets = vec2[8]( +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0), +// vec2(0.0) +// ); \ No newline at end of file diff --git a/shaders/lib/climate_settings.glsl b/shaders/lib/climate_settings.glsl index 2121437..d952f5b 100644 --- a/shaders/lib/climate_settings.glsl +++ b/shaders/lib/climate_settings.glsl @@ -122,6 +122,7 @@ ///////////////////////////// BIOME SPECIFICS ///////////////////////////////// /////////////////////////////////////////////////////////////////////////////// + uniform float nightVision; uniform float isJungles; uniform float isSwamps; @@ -143,7 +144,7 @@ BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0; // insure the biome colors are locked to the fog shape and lighting, but not its orignal color. - BiomeColors *= max(dot(FinalFogColor,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025); + BiomeColors *= max(dot(FinalFogColor,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); // these range 0.0-1.0. they will never overlap. float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; @@ -183,8 +184,8 @@ // DirectLightCol = BiomeColors * max(dot(DirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); // IndirectLightCol = BiomeColors * max(dot(IndirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); - DirectLightCol = BiomeColors * max(dot(DirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 ); - IndirectLightCol = BiomeColors * max(dot(IndirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 ); + DirectLightCol = BiomeColors * max(dot(DirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); + IndirectLightCol = BiomeColors * max(dot(IndirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); // these range 0.0-1.0. they will never overlap. float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; diff --git a/shaders/lib/color_transforms.glsl b/shaders/lib/color_transforms.glsl index 42224f6..99c5370 100644 --- a/shaders/lib/color_transforms.glsl +++ b/shaders/lib/color_transforms.glsl @@ -70,17 +70,11 @@ return x/(1.0+x); vec3 ACESFilm( vec3 x ) { x*=0.9; - // float a = 2.51f; - // float b = 0.03f; - // float c = 2.43f; - // float d = 0.59f; - // float e = 0.14f; - // slower rate to bright color float a = 2.51f; float b = 0.03f; float c = 2.43f; - float d = 0.95f; - float e = 0.12f; + float d = 0.59f; + float e = 0.14f; return (x*(a*x+b))/(x*(c*x+d)+e); } @@ -247,7 +241,7 @@ vec3 agxLook(vec3 val) { vec3 slope = vec3(1.0); vec3 power = vec3(1.0); float sat = 1.25; - + // ASC CDL val = pow(val * slope + offset, power); return luma + sat * (val - luma); diff --git a/shaders/lib/diffuse_lighting.glsl b/shaders/lib/diffuse_lighting.glsl index 94140a7..6044852 100644 --- a/shaders/lib/diffuse_lighting.glsl +++ b/shaders/lib/diffuse_lighting.glsl @@ -25,29 +25,13 @@ vec3 doBlockLightLighting( vec3 lightColor, float lightmap, float exposureValue, vec3 playerPos, vec3 lpvPos ){ - lightmap = clamp(lightmap,0.0,1.0); - float lightmapBrightspot = min(max(lightmap-0.7,0.0)*3.3333,1.0); - lightmapBrightspot *= lightmapBrightspot*lightmapBrightspot; - - float lightmapLight = 1.0-sqrt(1.0-lightmap); - lightmapLight *= lightmapLight; - - float lightmapCurve = mix(lightmapLight, 2.0, lightmapBrightspot); - - // lightmapCurve = lightmap*lightmap; - - // float lightmapCurve = (exp(-15.0 * (1.0-lightmap))*10.0 + lightmap*pow(1.0-pow(1.0-lightmap,2.0),2.0))*0.5; - // float lightmapCurve = (pow(min(max(lightmap-0.6, 0.0) * 2.5,1.0),4.0) * 10.0 + lightmap*pow(1.0-pow(1.0-lightmap,2.0),2.0))*0.5; - // float lightmapCurve = pow(1.0-pow(1.0-lightmap,2.0),2.0); + float lightmapCurve = pow(1.0-sqrt(1.0-clamp(lightmap,0.0,1.0)),2.0) * 2.0; - vec3 blockLight = lightColor * lightmapCurve; + vec3 blockLight = lightColor * lightmapCurve; //; #if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store vec4 lpvSample = SampleLpvLinear(lpvPos); - #ifdef VANILLA_LIGHTMAP_MASK - lpvSample.rgb *= lightmapCurve; - #endif vec3 lpvBlockLight = GetLpvBlockLight(lpvSample); // create a smooth falloff at the edges of the voxel volume. @@ -57,7 +41,7 @@ vec3 doBlockLightLighting( voxelRangeFalloff = 1.0 - pow(1.0-pow(voxelRangeFalloff,1.5),3.0); // outside the voxel volume, lerp to vanilla lighting as a fallback - blockLight = mix(blockLight, lpvSample.rgb, voxelRangeFalloff); + blockLight = mix(blockLight, lpvBlockLight/5.0, voxelRangeFalloff); #ifdef Hand_Held_lights // create handheld lightsources @@ -72,8 +56,8 @@ vec3 doBlockLightLighting( #endif // try to make blocklight have consistent visiblity in different light levels. - // float autoBrightness = mix(0.5, 1.0, clamp(exp(-10.0*exposureValue),0.0,1.0)); - // blockLight *= autoBrightness; + float autoBrightness = mix(1.0, 30.0, clamp(exp(-10.0*exposureValue),0.0,1.0)); + blockLight *= autoBrightness; return blockLight * TORCH_AMOUNT; } @@ -82,14 +66,11 @@ vec3 doIndirectLighting( vec3 lightColor, vec3 minimumLightColor, float lightmap ){ - // float lightmapCurve = pow(1.0-pow(1.0-lightmap,2.0),2.0); - // float lightmapCurve = lightmap*lightmap; float lightmapCurve = (pow(lightmap,15.0)*2.0 + pow(lightmap,2.5))*0.5; vec3 indirectLight = lightColor * lightmapCurve * ambient_brightness * 0.7; - // indirectLight = max(indirectLight, minimumLightColor * (MIN_LIGHT_AMOUNT * 0.02 * 0.2 + nightVision)); - indirectLight += minimumLightColor * (MIN_LIGHT_AMOUNT * 0.02 * 0.2 + nightVision*0.02); + indirectLight += minimumLightColor * max(MIN_LIGHT_AMOUNT*0.01, nightVision * 0.1); return indirectLight; } \ No newline at end of file diff --git a/shaders/lib/end_fog.glsl b/shaders/lib/end_fog.glsl index 9840e56..d076c63 100644 --- a/shaders/lib/end_fog.glsl +++ b/shaders/lib/end_fog.glsl @@ -168,15 +168,12 @@ float fogShape(in vec3 pos){ float endFogPhase(vec3 LightPos){ - // float mie = exp(length(LightPos) / -150); - // mie *= mie; - // mie *= mie; - // mie *= 100; + float mie = exp(length(LightPos) / -150); + mie *= mie; + mie *= mie; + mie *= 100; - // float mie = 1.0 - clamp(1.0 - length(LightPos) / 100.0,0.0,1.0); - float mie = exp(length(LightPos) / -50.0); - - return (mie*10.0)*(mie*10.0); + return mie; } vec3 LightSourceColors(float vortexBounds, float lightningflash){ @@ -200,13 +197,13 @@ vec3 LightSourceLighting(vec3 startPos, vec3 lightPos, float noise, float densit float shadow = 0.0; for (int j = 0; j < 3; j++){ - vec3 shadowSamplePos = startPos - lightPos * (0.05 + j * (0.25 + 0*0.15)); + vec3 shadowSamplePos = startPos - lightPos * (0.05 + j * (0.25 + noise*0.15)); shadow += fogShape(shadowSamplePos); } + vec3 finalLighting = lightColor * phase * exp(shadow * -10.0); - vec3 finalLighting = lightColor * phase * exp(-7.0 * shadow) ; - finalLighting += lightColor * phase*phase * (1.0 - exp( -shadow * vec3(0.6,2.0,2))) * (1.0 - exp(-density*density)); + finalLighting += lightColor * phase*phase * (1.0-exp((shadow*shadow*shadow) * vec3(0.6,2.0,2) * -1)) * (1.0 - exp(-density*density)); return finalLighting; } @@ -249,9 +246,9 @@ vec4 GetVolumetricFog( // float phsething = phaseEND(CenterdotV, 0.35) + phaseEND(CenterdotV, 0.85) ; - float skyPhase = (0.5 + pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0) * 0.1; + float skyPhase = 0.5 + pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0; - vec3 hazeColor = normalize(gl_Fog.color.rgb + 1e-6) * 0.1; + vec3 hazeColor = normalize(gl_Fog.color.rgb) * 0.1; float lightningflash = texelFetch2D(colortex4,ivec2(1,1),0).x/150.0; @@ -261,7 +258,7 @@ vec4 GetVolumetricFog( for (int i = 0; i < SAMPLECOUNT; i++) { float d = (pow(expFactor, float(i+dither)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); - float dd = pow(expFactor, float(i+dither2)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); + float dd = pow(expFactor, float(i+dither)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld; @@ -271,7 +268,7 @@ vec4 GetVolumetricFog( // determine where the vortex area ends and chaotic lightning area begins. float vortexBounds = clamp(vortexBoundRange - length(progressW), 0.0,1.0); vec3 lightPosition = LightSourcePosition(progressW, cameraPosition, vortexBounds); - vec3 lightColors = LightSourceColors(vortexBounds, lightningflash) * 0.25; + vec3 lightColors = LightSourceColors(vortexBounds, lightningflash); float volumeDensity = fogShape(progressW); @@ -284,9 +281,9 @@ vec4 GetVolumetricFog( float volumeCoeff = exp(-stormDensity*dd*dL); - vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither, volumeDensity, lightColors, vortexBounds); - vec3 indirect = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1) * 0.1; - + + vec3 lightsources = LightSourceLighting(progressW, lightPosition, dither2, volumeDensity, lightColors, vortexBounds); + vec3 indirect = vec3(0.5,0.75,1.0) * 0.2 * (exp((volumeDensity*volumeDensity) * -50) * 0.9 + 0.1); vec3 stormLighting = indirect + lightsources; color += (stormLighting - stormLighting*volumeCoeff) * absorbance; @@ -340,7 +337,7 @@ vec4 GetVolumetricFog( return vec4(color, absorbance); } -float GetEndFogShadow(vec3 WorldPos, vec3 LightPos){ +float GetCloudShadow(vec3 WorldPos, vec3 LightPos){ float Shadow = 0.0; for (int i=0; i < 3; i++){ @@ -350,5 +347,5 @@ float GetEndFogShadow(vec3 WorldPos, vec3 LightPos){ Shadow += fogShape(shadowSamplePos)*END_STORM_DENSTIY; } - return clamp(exp2(Shadow * -10.0),0.0,1.0); + return clamp(exp2(Shadow * -5.0),0.0,1.0); } \ No newline at end of file diff --git a/shaders/lib/indirect_lighting_effects.glsl b/shaders/lib/indirect_lighting_effects.glsl index f128ca1..de824bf 100644 --- a/shaders/lib/indirect_lighting_effects.glsl +++ b/shaders/lib/indirect_lighting_effects.glsl @@ -13,7 +13,7 @@ vec3 cosineHemisphereSample(vec2 Xi){ return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.))); } -vec3 TangentToWorld(vec3 N, vec3 H){ +vec3 TangentToWorld(vec3 N, vec3 H, float roughness){ vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 T = normalize(cross(UpVector, N)); vec3 B = cross(N, T); @@ -92,6 +92,67 @@ vec4 BilateralUpscale_SSAO(sampler2D tex, sampler2D depth, vec2 coord, float ref return RESULT / SUM; } +vec2 SSAO( + vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise +){ + if(hand) return vec2(1.0,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 = viewPos.z*viewPos.z*mulfov2*2.*5/50.0; + + #ifdef Ambient_SSS + 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); + #endif + + 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; + + vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * clamp(0.05 + i*0.095, 0.0,0.3) * 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 ) { + #ifdef DISTANT_HORIZONS + float dhdepth = texelFetch2D(dhDepthTex1, offset,0).x; + #else + float dhdepth = 0.0; + #endif + + vec3 t0 = toScreenSpace_DH((offset*texelSize+acc+0.5*texelSize) * (1.0/RENDER_SCALE), texelFetch2D(depthtex1, offset,0).x, dhdepth); + vec3 vec = (t0.xyz - viewPos); + float dsquared = dot(vec, vec); + + if (dsquared > 1e-5){ + if (dsquared < maxR2){ + float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.); + occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0); + } + + #ifdef Ambient_SSS + 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); + } + #endif + + n += 1; + } + } + } + return max(1.0 - vec2(occlusion, sss)/n, 0.0); +} float ScreenSpace_SSS( vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise ){ @@ -149,79 +210,40 @@ vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ direction.xy = normalize(direction.xy); //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - float mult = maxLengths.y; + 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) ; + vec3 stepv = (direction * mult) / quality*vec3(RENDER_SCALE,1.0); + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*dither; - spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; + spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE ; - spos += stepv*dither; - - float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases + float minZ = spos.z; + float maxZ = spos.z; for(int i = 0; i < int(quality); i++){ - #ifdef UseQuarterResDepth - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); - #else - float sp = linZ(texelFetch2D(depthtex1,ivec2(spos.xy/ texelSize),0).r); - #endif - float currZ = linZ(spos.z); + 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; - if( sp < currZ) { - float dist = abs(sp-currZ)/currZ; - if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); - } spos += stepv; } 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; @@ -279,7 +301,7 @@ vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes, bool hand){ return vec3(1.1); } -vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool hand, inout float CURVE ){ +vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool hand){ vec3 worldpos = mat3(gbufferModelViewInverse) * position; @@ -302,12 +324,12 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha int iterations = min(int(min(len, mult*len)-2), maxSteps); - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(noise-0.5); + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0);// + stepv*noise; spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE; - + float minZ = spos.z; float maxZ = spos.z; - CURVE = 0.0; + 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); @@ -327,9 +349,8 @@ vec3 RT_alternate(vec3 dir, vec3 position, float noise, float stepsizes, bool ha minZ = maxZ-biasamount / currZ; maxZ += stepv.z; - spos += stepv; - - CURVE += 1.0/iterations; + spos += stepv*(noise*0.25+0.75); + } return vec3(1.1); } @@ -357,30 +378,24 @@ vec3 ApplySSRT( vec3 radiance2 = vec3(0.0); vec3 occlusion2 = vec3(0.0); vec3 skycontribution2 = unchangedIndirect; - float CURVE = 1.0; + vec3 bouncedLight = vec3(0.0); for (int i = 0; i < nrays; i++){ int seed = (frameCounter%40000)*nrays+i; vec2 ij = fract(R2_samples(seed) + noise.xy); - vec3 rayDir = TangentToWorld(normal, normalize(cosineHemisphereSample(ij))); + vec3 rayDir = TangentToWorld(normal, normalize(cosineHemisphereSample(ij)), lightmap); #ifdef HQ_SSGI vec3 rayHit = rayTrace_GI( mat3(gbufferModelView) * rayDir, viewPos, noise.z, 50.); // ssr rt #else - vec3 rayHit = RT_alternate(mat3(gbufferModelView)*rayDir, viewPos, noise.z, 10., isLOD, CURVE); // choc sspt - - - /// RAAAAAAAAAAAAAAAAAAAAAAAAGHH - // CURVE = (1.0-exp(-5.0*(1.0-CURVE))); - CURVE = 1.0-pow(1.0-pow(1.0-CURVE,2.0),5.0); + vec3 rayHit = RT_alternate(mat3(gbufferModelView)*rayDir, viewPos, noise.z, 10., isLOD); // choc sspt #endif #ifdef SKY_CONTRIBUTION_IN_SSRT #ifdef OVERWORLD_SHADER - // skycontribution = doIndirectLighting(pow(skyCloudsFromTexLOD(rayDir, colortex4, 0).rgb/1200.0, vec3(0.7)) * 2.5, minimumLightColor, lightmap) + blockLightColor; - skycontribution = doIndirectLighting(skyCloudsFromTex(rayDir, colortex4).rgb/1200.0, minimumLightColor, lightmap) + blockLightColor; + skycontribution = doIndirectLighting(pow(skyCloudsFromTexLOD(rayDir, colortex4, 0).rgb/30.0, vec3(0.7)) * 2.5, minimumLightColor, lightmap) + blockLightColor; #else - skycontribution = volumetricsFromTex(rayDir, colortex4, 6).rgb / 1200.0 + blockLightColor; + skycontribution = pow(skyCloudsFromTexLOD2(rayDir, colortex4, 6).rgb / 30.0, vec3(0.7)) + blockLightColor; #endif #else #ifdef OVERWORLD_SHADER @@ -398,18 +413,18 @@ vec3 ApplySSRT( 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){ - bouncedLight = texture2D(colortex5, previousPosition.xy).rgb * GI_Strength * CURVE; + bouncedLight = texture2D(colortex5, previousPosition.xy).rgb * GI_Strength; radiance += bouncedLight; radiance2 += bouncedLight; } #endif - occlusion += skycontribution * CURVE; - occlusion2 += skycontribution2 * CURVE; + occlusion += skycontribution; + occlusion2 += skycontribution2; } } - // return unchangedIndirect * CURVE; + if(isLOD) return max(radiance/nrays, 0.0); #ifdef SKY_CONTRIBUTION_IN_SSRT diff --git a/shaders/lib/lpv_render.glsl b/shaders/lib/lpv_render.glsl index a1d4a05..d5d127b 100644 --- a/shaders/lib/lpv_render.glsl +++ b/shaders/lib/lpv_render.glsl @@ -1,13 +1,10 @@ -// LPV block brightness scale. just 1.0/15.0 -const float LpvBlockBrightness = 0.066666; +// LPV block brightness scale +const float LpvBlockBrightness = 1.0; float lpvCurve(float values) { - #ifdef VANILLA_LIGHTMAP_MASK - return sqrt(values); - #else - return values*values; - #endif + // return values; + return pow(1.0 - sqrt(1.0-values), 2.0); } vec4 SampleLpvLinear(const in vec3 lpvPos) { @@ -20,8 +17,6 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) { vec3 hsv = RgbToHsv(lpvSample.rgb); hsv.z = lpvCurve(hsv.b) * LpvBlockSkyRange.x; lpvSample.rgb = HsvToRgb(hsv); - - lpvSample.rgb = clamp(lpvSample.rgb/15.0,0.0,1.0); return lpvSample; } diff --git a/shaders/lib/nether_fog.glsl b/shaders/lib/nether_fog.glsl index 2e88ef2..aa3f0a1 100644 --- a/shaders/lib/nether_fog.glsl +++ b/shaders/lib/nether_fog.glsl @@ -43,7 +43,7 @@ vec4 GetVolumetricFog( /// ------------- RAYMARCHING STUFF ------------- \\\ - int SAMPLECOUNT = 16; + int SAMPLECOUNT = 10; vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz; vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); @@ -62,14 +62,14 @@ vec4 GetVolumetricFog( vec3 color = vec3(0.0); float absorbance = 1.0; - vec3 hazeColor = normalize(gl_Fog.color.rgb + 1e-6) * 0.25; + vec3 hazeColor = normalize(gl_Fog.color.rgb); #if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*exposure),0.0,1.0)) / 5.0; #endif for (int i = 0; i < SAMPLECOUNT; i++) { - float d = (pow(expFactor, float(i+dither2)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); + float d = (pow(expFactor, float(i+dither)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); float dd = pow(expFactor, float(i+dither)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld; @@ -80,7 +80,7 @@ vec4 GetVolumetricFog( float plumeDensity = min(densityVol * pow(min(max(100.0-progressW.y,0.0)/30.0,1.0),4.0), pow(clamp(1.0 - length(progressW-cameraPosition)/far,0.0,1.0),5.0) * NETHER_PLUME_DENSITY); float plumeVolumeCoeff = exp(-plumeDensity*dd*dL); - vec3 lighting = vec3(1.0,0.4,0.2)*0.25 * exp(-15.0*densityVol); + vec3 lighting = vec3(1.0,0.4,0.2) * exp(-15.0*densityVol); color += (lighting - lighting * plumeVolumeCoeff) * absorbance; absorbance *= plumeVolumeCoeff; @@ -98,7 +98,7 @@ vec4 GetVolumetricFog( float ceilingSmokeDensity = 0.001 * pow(min(max(progressW.y-40.0,0.0)/50.0,1.0),3.0); float ceilingSmokeVolumeCoeff = exp(-ceilingSmokeDensity*dd*dL); - vec3 ceilingSmoke = vec3(0.1); + vec3 ceilingSmoke = vec3(1.0); color += (ceilingSmoke - ceilingSmoke*ceilingSmokeVolumeCoeff) * (absorbance*0.5+0.5); absorbance *= ceilingSmokeVolumeCoeff; diff --git a/shaders/lib/overworld_fog.glsl b/shaders/lib/overworld_fog.glsl index f468c48..5a3159b 100644 --- a/shaders/lib/overworld_fog.glsl +++ b/shaders/lib/overworld_fog.glsl @@ -44,7 +44,7 @@ float cloudVol(in vec3 pos, float maxDistance ){ FogDensities(medium_gradientFog, cloudyFog, rainyFog, maxDistance, dailyWeatherParams0.a, dailyWeatherParams1.a); - return uniformFog + medium_gradientFog + cloudyFog; + return uniformFog + medium_gradientFog + cloudyFog + rainyFog; } float phaseRayleigh(float cosTheta) { @@ -52,29 +52,23 @@ float phaseRayleigh(float cosTheta) { return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation } float fogPhase(float lightPoint){ - float linear = clamp(-lightPoint*0.5+0.5,0.0,1.0); + float linear = 1.0 - clamp(lightPoint*0.5+0.5,0.0,1.0); float linear2 = 1.0 - clamp(lightPoint,0.0,1.0); float exponential = exp2(pow(linear,0.3) * -15.0 ) * 1.5; exponential += sqrt(exp2(sqrt(linear) * -12.5)); - // float exponential = 1.0 / (linear * 10.0 + 0.05); - return exponential; } -float phaseCloudFog(float x, float g){ - float gg = g * g; - return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14; -} + uniform ivec2 eyeBrightness; vec4 GetVolumetricFog( - in vec3 viewPosition, - in vec2 dither, - in vec3 LightColor, - in vec3 AmbientColor, - in vec3 AveragedAmbientColor, - inout float atmosphereAlpha, - inout vec3 sceneColor + vec3 viewPosition, + vec2 dither, + vec3 LightColor, + vec3 AmbientColor, + vec3 AveragedAmbientColor, + inout float atmosphereAlpha ){ #ifndef TOGGLE_VL_FOG return vec4(0.0,0.0,0.0,1.0); @@ -107,7 +101,8 @@ vec4 GetVolumetricFog( dV *= maxLength; dVWorld *= maxLength; - float dL = length(dVWorld)/8.0; + float dL_alternate = length(dVWorld); + float dL = dL_alternate/8.0; vec3 progress = start.xyz; vec3 progressW = vec3(0.0); @@ -116,23 +111,17 @@ vec4 GetVolumetricFog( /// ------------- COLOR/LIGHTING STUFF ------------- \\\ vec3 color = vec3(0.0); - vec3 finalAbsorbance = vec3(1.0); - - // float totalAbsorbance = 1.0; - vec3 totalAbsorbance = vec3(1.0); - + float totalAbsorbance = 1.0; float fogAbsorbance = 1.0; - // float atmosphereAbsorbance = 1.0; - vec3 atmosphereAbsorbance = vec3(1.0); + float atmosphereAbsorbance = 1.0; vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec; float SdotV = dot(sunVec, normalize(viewPosition))*lightCol.a; ///// ----- fog lighting //Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx) - float sunPhase = fogPhase(SdotV)*5.0;// phaseCloudFog(SdotV, 0.9) + phaseCloudFog(SdotV, 0.85) + phaseCloudFog(SdotV, 0.5) * 5.0; - float sunPhase2 = (phaseCloudFog(SdotV, 0.85) + phaseCloudFog(SdotV, 0.5)) * 5.0; - float skyPhase = 2.0 + pow(1.0-pow(1.0-clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),2.0),5.0)*2.0 ;//pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0; + float sunPhase = fogPhase(SdotV) * 5.0; + float skyPhase = pow(clamp(normalize(wpos).y*0.5+0.5,0.0,1.0),4.0)*5.0; float rayL = phaseRayleigh(SdotV); vec3 rC = vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5) ; @@ -141,7 +130,7 @@ vec4 GetVolumetricFog( vec3 skyLightPhased = AmbientColor; vec3 LightSourcePhased = LightColor; - skyLightPhased *= skyPhase; + skyLightPhased *= 1.0 + skyPhase; LightSourcePhased *= sunPhase; #ifdef ambientLight_only @@ -154,6 +143,12 @@ vec4 GetVolumetricFog( float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect); #endif + #ifdef DISTANT_HORIZONS + float atmosphereMult = 1.0; + #else + float atmosphereMult = 1.5; + #endif + #ifdef RAYMARCH_CLOUDS_WITH_FOG vec3 SkyLightColor = AmbientColor; vec3 LightSourceColor = LightColor; @@ -179,16 +174,14 @@ vec4 GetVolumetricFog( float lightLevelZero = pow(clamp(eyeBrightnessSmooth.y/240.0 ,0.0,1.0),3.0); // SkyLightColor *= lightLevelZero*0.9 + 0.1; - vec3 finalsceneColor = vec3(0.0); for (int i = 0; i < SAMPLECOUNT; i++) { 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 dd = pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0); progress = start.xyz + d*dV; progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld; - // if(length(progressW-cameraPosition) > cloudDepth) break; //------------------------------------ //------ SAMPLE SHADOWS FOR FOG EFFECTS //------------------------------------ @@ -219,7 +212,7 @@ vec4 GetVolumetricFog( #endif #ifdef VL_CLOUDS_SHADOWS - sh *= GetCloudShadow(progressW, WsunVec*lightCol.a); + sh *= GetCloudShadow_VLFOG(progressW, WsunVec * lightCol.a); #endif #ifdef PER_BIOME_ENVIRONMENT @@ -244,9 +237,10 @@ vec4 GetVolumetricFog( #endif vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz); - vec3 lighting = DirectLight + indirectLight;// * (lightLevelZero*0.99 + 0.01) + Lightning; - - color += (lighting - lighting * fogVolumeCoeff) * totalAbsorbance; + vec3 lighting = DirectLight + indirectLight * (lightLevelZero*0.99 + 0.01) + Lightning; + + color += (lighting - lighting * fogVolumeCoeff) * fogAbsorbance; + fogAbsorbance *= fogVolumeCoeff; // kill fog absorbance when in caves. totalAbsorbance *= mix(1.0, fogVolumeCoeff, lightLevelZero); @@ -258,32 +252,26 @@ vec4 GetVolumetricFog( #else float cloudPlaneCutoff = 1.0; #endif - // maximum range for atmosphere haze, basically. - float planetVolume = 1.0 - exp(clamp(1.0 - length(progressW-cameraPosition) / (16*150), 0.0,1.0) * -10); // just air - vec2 airCoef = (exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 192.0 * Haze_amount) * cloudPlaneCutoff * planetVolume; + vec2 airCoef = exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * (24.0 * atmosphereMult) * Haze_amount * cloudPlaneCutoff; // Pbr for air, yolo mix between mie and rayleigh for water droplets vec3 rL = rC*airCoef.x; vec3 m = mC*(airCoef.y+densityVol*300.0); // calculate the atmosphere haze seperately and purely additive to color, do not contribute to absorbtion. - vec3 atmosphereVolumeCoeff = exp(-(rL+m)*dd*dL); - // vec3 Atmosphere = LightSourcePhased * sh * (rayL*rL + sunPhase*m) + AveragedAmbientColor * (rL+m); + vec3 atmosphereVolumeCoeff = exp(-(rL+m)*dd*dL_alternate); + vec3 Atmosphere = (LightSourcePhased * sh * (rayL*rL + sunPhase*m) + AveragedAmbientColor * (rL+m) * (lightLevelZero*0.99 + 0.01)) * inACave; - color += (Atmosphere - Atmosphere * atmosphereVolumeCoeff) / (rL+m+1e-6) * atmosphereAbsorbance; + color += (Atmosphere - Atmosphere * atmosphereVolumeCoeff) / (rL+m+1e-6) * atmosphereAbsorbance * totalAbsorbance; + atmosphereAbsorbance *= dot(atmosphereVolumeCoeff, vec3(0.33333)); - // finalsceneColor = sceneColor * totalAbsorbance; - - atmosphereAbsorbance *= atmosphereVolumeCoeff*fogVolumeCoeff; - - //------------------------------------ //------ LPV FOG EFFECT //------------------------------------ #if defined LPV_VL_FOG_ILLUMINATION && defined EXCLUDE_WRITE_TO_LUT - color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * totalAbsorbance; + color += LPV_FOG_ILLUMINATION(progressW-cameraPosition, dd, dL) * TorchBrightness_autoAdjust * totalAbsorbance; #endif //------------------------------------ //------ STUPID RENDER CLOUDS AS FOG EFFECT @@ -345,13 +333,271 @@ vec4 GetVolumetricFog( } } #else - // if (totalAbsorbance < 1e-5) break; + if (totalAbsorbance < 1e-5) break; #endif } - - // sceneColor = finalsceneColor; - - // atmosphereAlpha = atmosphereAbsorbance; - + atmosphereAlpha = atmosphereAbsorbance; return vec4(color, totalAbsorbance); -} \ No newline at end of file +} + + + + + + + + + + + + + + + + + + + +// vec4 GetVolumetricFog( +// vec3 viewPosition, +// vec2 dither, +// vec3 LightColor, +// vec3 AmbientColor +// ){ + +// #ifndef TOGGLE_VL_FOG +// return vec4(0.0,0.0,0.0,1.0); +// #endif +// int SAMPLECOUNT = VL_SAMPLES; +// /// ------------- RAYMARCHING STUFF ------------- \\\ + +// //project pixel position into projected shadowmap space + +// vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz; +// vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz; +// fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz; + +// //project view origin into projected shadowmap space +// vec3 start = toShadowSpaceProjected(vec3(0.0)); + +// //rayvector into projected shadow map space +// //we can use a projected vector because its orthographic projection +// //however we still have to send it to curved shadow map space every step +// vec3 dV = fragposition - start; +// vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); + +// #ifdef DISTANT_HORIZONS +// float maxLength = min(length(dVWorld), max(dhFarPlane-1000,0.0))/length(dVWorld); +// SAMPLECOUNT += SAMPLECOUNT; +// #else +// float maxLength = min(length(dVWorld), far)/length(dVWorld); +// #endif + +// dV *= maxLength; +// dVWorld *= maxLength; + +// float dL = length(dVWorld); +// float mult = length(dVWorld)/25; + +// vec3 progress = start.xyz; +// vec3 progressW = gbufferModelViewInverse[3].xyz + cameraPosition; + +// vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a; +// float SdotV = dot(sunVec,normalize(viewPosition))*lightCol.a; + + +// /// ------------- COLOR/LIGHTING STUFF ------------- \\\ + +// vec3 color = vec3(0.0); +// vec3 absorbance = vec3(1.0); + +// ///// ----- fog lighting +// //Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx) +// float mie = fogPhase(SdotV) * 5.0; +// float rayL = phaseRayleigh(SdotV); + +// vec3 rC = vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5); +// vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6); + +// vec3 skyLightPhased = AmbientColor; +// vec3 LightSourcePhased = LightColor; + +// #ifdef ambientLight_only +// LightSourcePhased = vec3(0.0); +// #endif +// #ifdef PER_BIOME_ENVIRONMENT +// vec3 biomeDirect = LightSourcePhased; +// vec3 biomeIndirect = skyLightPhased; +// float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect); +// #endif + +// skyLightPhased = max(skyLightPhased + skyLightPhased*(normalize(wpos).y*0.9+0.1),0.0); +// LightSourcePhased *= mie; + +// // float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); + +// float lightleakfix = 1.0 - caveDetection; + +// #ifdef RAYMARCH_CLOUDS_WITH_FOG +// vec3 SkyLightColor = AmbientColor; +// vec3 LightSourceColor = LightColor; + +// #ifdef ambientLight_only +// LightSourceColor = vec3(0.0); +// #endif + +// float shadowStep = 200.0; + +// vec3 dV_Sun = WsunVec*shadowStep; + +// float mieDay = phaseg(SdotV, 0.75); +// float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ; + +// vec3 directScattering = LightSourceColor * mieDay * 3.14; +// vec3 directMultiScattering = LightSourceColor * mieDayMulti * 3.14; + +// vec3 sunIndirectScattering = LightSourceColor * phaseg(dot(mat3(gbufferModelView)*vec3(0,1,0),normalize(viewPosition)), 0.5) * 3.14; +// #endif + + +// #ifdef DISTANT_HORIZONS +// float atmosphereMult = 1.0; +// #else +// float atmosphereMult = 1.5; +// #endif + +// float expFactor = 11.0; +// for (int i=0;i pos.z && sh.x < 1.0){ +// vec4 translucentShadow = texture2D(shadowcolor0, pos.xy); +// if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001); +// } +// #else +// sh = vec3(shadow2D(shadow, pos).x); +// #endif + +// } +// vec3 sh2 = sh; + +// #ifdef VL_CLOUDS_SHADOWS +// // if(clamp(progressW.y - CloudLayer1_height,0.0,1.0) < 1.0 && clamp(progressW.y-50,0.0,1.0) > 0.0) +// sh *= GetCloudShadow_VLFOG(progressW, WsunVec); +// #endif + + +// #ifdef PER_BIOME_ENVIRONMENT +// float maxDistance = inBiome * min(max(1.0 - length(d*dVWorld.xz)/(32*8),0.0)*2.0,1.0); +// float densityVol = cloudVol(progressW, maxDistance) * lightleakfix; +// #else +// float densityVol = cloudVol(progressW, 0.0) * lightleakfix; +// #endif + +// //Water droplets(fog) +// float density = densityVol*300.0; + +// ///// ----- main fog lighting + +// //Just air +// vec2 airCoef = exp(-max(progressW.y - SEA_LEVEL, 0.0) / vec2(8.0e3, 1.2e3) * vec2(6.,7.0)) * (atmosphereMult * 24.0) * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-50),0),0.0,1.0); + +// //Pbr for air, yolo mix between mie and rayleigh for water droplets +// vec3 rL = rC*airCoef.x; +// vec3 m = (airCoef.y+density) * mC; + +// #ifdef PER_BIOME_ENVIRONMENT +// vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL + m); // not pbr so just make the atmosphere also dense fog heh +// vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * (rL*rayL + m); +// #else +// vec3 Atmosphere = skyLightPhased * (rL + m); // not pbr so just make the atmosphere also dense fog heh +// vec3 DirectLight = LightSourcePhased * sh * (rL*rayL + m); +// #endif +// vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m); + +// vec3 foglighting = (Atmosphere + DirectLight + Lightning) * lightleakfix; + + + +// color += (foglighting - foglighting * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance; +// absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0); + +// #ifdef RAYMARCH_CLOUDS_WITH_FOG +// ////////////////////////////////////////// +// ///// ----- cloud part +// ////////////////////////////////////////// +// // curvature = clamp(1.0 - length(progressW - cameraPosition)/(32*128),0.0,1.0); + + +// float otherlayer = max(progressW.y - (CloudLayer0_height+99.5), 0.0) > 0.0 ? 0.0 : 1.0; + +// float DUAL_MIN_HEIGHT = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height; +// float DUAL_MAX_HEIGHT = DUAL_MIN_HEIGHT + 100.0; + +// float DUAL_DENSITY = otherlayer > 0.0 ? CloudLayer0_density : CloudLayer1_density; + +// if(clamp(progressW.y - DUAL_MAX_HEIGHT,0.0,1.0) < 1.0 && clamp(progressW.y - DUAL_MIN_HEIGHT,0.0,1.0) > 0.0){ + +// float DUAL_MIN_HEIGHT_2 = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height; +// float DUAL_MAX_HEIGHT_2 = DUAL_MIN_HEIGHT + 100.0; + +// float cumulus = GetCumulusDensity(-1, progressW, 1, CloudLayer0_height, CloudLayer1_height); +// float fadedDensity = DUAL_DENSITY * clamp(exp( (progressW.y - (DUAL_MAX_HEIGHT - 75)) / 9.0 ),0.0,1.0); + +// float muE = cumulus*fadedDensity; +// float directLight = 0.0; +// for (int j=0; j < 3; j++){ +// vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05)); +// float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * DUAL_DENSITY; + +// directLight += shadow; +// } + +// /// shadows cast from one layer to another +// /// large cumulus -> small cumulus +// #if defined CloudLayer1 && defined CloudLayer0 +// if(otherlayer > 0.0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, progressW + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither.y) - progressW.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT); +// #endif +// // // altostratus -> cumulus +// // #ifdef CloudLayer2 +// // vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0); +// // float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density; +// // directLight += HighAlt_shadow; +// // #endif + + +// float skyScatter = clamp(((DUAL_MAX_HEIGHT - 20 - progressW.y) / 275.0) * (0.5+DUAL_DENSITY),0.0,1.0); +// float distantfade = 1- exp( -10*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*65),0.0,1.0),2)); +// vec3 cloudlighting = DoCloudLighting(cloudDensity * cumulus, SkyLightColor, skyScatter, directLight, directScattering*sh2, directMultiScattering*sh2, 1); + +// color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL),0.0) * absorbance; +// absorbance *= max(exp(-muE*dd*dL),0.0); +// } + +// #endif + +// if (min(dot(absorbance,vec3(0.335)),1.0) < 1e-5) break; +// } +// return vec4(color, min(dot(absorbance,vec3(0.335)),1.0)); +// } \ No newline at end of file diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 1eabc33..79d19f4 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -9,28 +9,31 @@ // #define Vanilla_like_water #define WATER_WAVE_STRENGTH 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 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_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 ] -#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_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 Dirt_Scatter_R 0.7 // [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.7 // [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.7 // [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 0.65 // [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 0.85 // [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.05 // [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.2629 // [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.0565 // [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.01011 // [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 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] #define Water_Top_Layer 62.90 // [0.90 1.90 2.90 3.90 4.90 5.90 6.90 7.90 8.90 9.90 10.90 11.90 12.90 13.90 14.90 15.90 16.90 17.90 18.90 19.90 20.90 21.90 22.90 23.90 24.90 25.90 26.90 27.90 28.90 29.90 30.90 31.90 32.90 33.90 34.90 35.90 36.90 37.90 38.90 39.90 40.90 41.90 42.90 43.90 44.90 45.90 46.90 47.90 48.90 49.90 50.90 51.90 52.90 53.90 54.90 55.90 56.90 57.90 58.90 59.90 60.90 61.90 62.90 63.90 64.90 65.90 66.90 67.90 68.90 69.90 70.90 71.90 72.90 73.90 74.90 75.90 76.90 77.90 78.90 79.90 80.90 81.90 82.90 83.90 84.90 85.90 86.90 87.90 88.90 89.90 90.90 91.90 92.90 93.90 94.90 95.90 96.90 97.90 98.90 99.90 100.90 101.90 102.90 103.90 104.90 105.90 106.90 107.90 108.90 109.90 110.90 111.90 112.90 113.90 114.90 115.90 116.90 117.90 118.90 119.90 120.90 121.90 122.90 123.90 124.90 125.90 126.90 127.90 128.90 129.90 130.90 131.90 132.90 133.90 134.90 135.90 136.90 137.90 138.90 139.90 140.90 141.90 142.90 143.90 144.90 145.90 146.90 147.90 148.90 149.90 150.90 151.90 152.90 153.90 154.90 155.90 156.90 157.90 158.90 159.90 160.90 161.90 162.90 163.90 164.90 165.90 166.90 167.90 168.90 169.90 170.90 171.90 172.90 173.90 174.90 175.90 176.90 177.90 178.90 179.90 180.90 181.90 182.90 183.90 184.90 185.90 186.90 187.90 188.90 189.90 190.90 191.90 192.90 193.90 194.90 195.90 196.90 197.90 198.90 199.90] -#define FAKE_REFRACTION_EFFECT -#define FAKE_DISPERSION_EFFECT -#define REFRACTION_SMUDGE +#define Refraction #define SSR_STEPS 30 // [10 15 20 25 30 35 40 50 100 200 400] #define USE_QUARTER_RES_DEPTH +#define WATER_REFLECTIONS +#define WATER_BACKGROUND_SPECULAR +#define WATER_SUN_SPECULAR +#define SCREENSPACE_REFLECTIONS +// #define WATER_HQ_SMOOTHNESS + #define SNELLS_WINDOW //////////////////////////////////////// @@ -77,7 +80,7 @@ // ----- INDIRECT LIGHT RELATED SETTINGS ----- // ///////////////////////////////////////////////// -#define MIN_LIGHT_AMOUNT 0.5 // [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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.0 ] +#define MIN_LIGHT_AMOUNT 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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.0 ] #define ambient_brightness 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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] #define AmbientLight_R 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] @@ -91,11 +94,11 @@ #define TORCH_B 0.65 // [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 1.0] #define Hand_Held_lights -#define HANDHELD_LIGHT_RANGE 16 // [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 205 210 215 220 225 230 235 240 245 250 255] +#define HANDHELD_LIGHT_RANGE 10 // [1 2 3 4 5 6 7 8 9 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 205 210 215 220 225 230 235 240 245 250 255] #define indirect_effect 1 // [0 1 2 3 4] -// #define AO_in_sunlight +#define AO_in_sunlight #define AO_Strength 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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0] // #define SKY_CONTRIBUTION_IN_SSRT @@ -142,7 +145,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0. #define VPS_Search_Samples 4 // [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] #define Min_Shadow_Filter_Radius 5.0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 ] #define Max_Shadow_Filter_Radius 30.0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 ] -#define Max_Filter_Depth 15.0 // [0.1 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 220.0] +#define Max_Filter_Depth 35.0 // [0.1 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 220.0] #define BASIC_SHADOW_FILTER #define SHADOW_FILTER_SAMPLE_COUNT 13 // [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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 ] @@ -188,7 +191,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0. #define RainFog_amount 0.1 // [0.0 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 1.0] -#define BLOOMY_FOG 1.0 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0] +#define BLOOMY_FOG 1.5 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0] #define BLOOM_STRENGTH 1.0 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0] #define CAVE_FOG @@ -257,9 +260,14 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0. // ----- LABPBR MATERIALS RELATED SETTINGS ----- // /////////////////////////////////////////////////// +// #define Specular_Reflections +// #define Screen_Space_Reflections +// #define Sky_reflection +// #define Rough_reflections +#define Dynamic_SSR_quality #define Sun_specular_Strength 1 // [0 1 2 3 4 5 6 7 8 9 10] #define reflection_quality 30 // [6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 55.0 60.0 65.0 70.0 75.0 80.0 85.0 90.0 95.0 100.0 ] -#define Roughness_Threshold 0.3 // [0.0 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 1.00] +#define Roughness_Threshold 1.5 // [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] #ifdef Specular_Reflections #define LIGHTSOURCE_REFLECTION @@ -318,7 +326,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0. #define sunColorG 0.91 // [0.0 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 1.0 ] #define sunColorB 0.81 // [0.0 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 1.0 ] -#define moon_illuminance 600.0 //[0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 150.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 1000.0 2000.0 3000.0 4000.0 5000.0 6000.0 7000.0 8000.0 9000.0 10000.0 11000.0 12000.0 13000.0 14000.0 15000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 150000.0 200000.0 250000.0 300000.0 400000.0 500000.0] +#define moon_illuminance 50.0 //[0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 150.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 1000.0 2000.0 3000.0 4000.0 5000.0 6000.0 7000.0 8000.0 9000.0 10000.0 11000.0 12000.0 13000.0 14000.0 15000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 150000.0 200000.0 250000.0 300000.0 400000.0 500000.0] #define Moon_temp 15000 // [1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 4500 5600 5700 5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800 6900 7000 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 15000 20000 25000 50000] #define moonColorR 0.9080 //[0.0 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 1.0 ] #define moonColorG 0.9121 //[0.0 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 1.0 ] @@ -504,14 +512,12 @@ uniform int moonPhase; ////////////////////////////////////// #define TAA -// #define RESPONSIVE_TAA -// #define TAA_UPSCALING // #define SCREENSHOT_MODE -#ifdef SCREENSHOT_MODE - #undef RESPONSIVE_TAA -#endif +// #define TAA_UPSCALING +#define BLEND_FACTOR 0.12 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00] +#define CLOSEST_VELOCITY +//#define NO_CLIP -#define BLEND_FACTOR 0.125 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.125 0.14 0.16 0.18 0.20 0.25 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00] ///////////////////////////////////////////////// @@ -576,9 +582,6 @@ const vec3 HIGHLIGHTS_TARGET = length(vec3(HIGHLIGHTS_GRADE_R, HIGHLIGHTS_GRADE_ #define Manual_exposure_value 1.0 // [0.000553 0.000581 0.000611 0.000642 0.000675 0.000710 0.000746 0.000784 0.000825 0.000867 0.000911 0.000958 0.001007 0.001059 0.001113 0.001170 0.001230 0.001294 0.001360 0.001430 0.001503 0.001580 0.001661 0.001746 0.001836 0.001930 0.002029 0.002133 0.002242 0.002357 0.002478 0.002605 0.002739 0.002879 0.003027 0.003182 0.003345 0.003517 0.003697 0.003887 0.004086 0.004296 0.004516 0.004748 0.004991 0.005247 0.005516 0.005799 0.006096 0.006409 0.006737 0.007083 0.007446 0.007828 0.008229 0.008651 0.009095 0.009561 0.010051 0.010567 0.011108 0.011678 0.012277 0.012906 0.013568 0.014264 0.014995 0.015764 0.016572 0.017422 0.018315 0.019254 0.020241 0.021279 0.022370 0.023517 0.024723 0.025991 0.027323 0.028724 0.030197 0.031745 0.033373 0.035084 0.036883 0.038774 0.040762 0.042852 0.045049 0.047358 0.049787 0.052339 0.055023 0.057844 0.060810 0.063927 0.067205 0.070651 0.074273 0.078081 0.082084 0.086293 0.090717 0.095369 0.100258 0.105399 0.110803 0.116484 0.122456 0.128734 0.135335 0.142274 0.149568 0.157237 0.165298 0.173773 0.182683 0.192049 0.201896 0.212247 0.223130 0.234570 0.246596 0.259240 0.272531 0.286504 0.301194 0.316636 0.332871 0.349937 0.367879 0.386741 0.406569 0.427414 0.449328 0.472366 0.496585 0.522045 0.548811 0.576949 0.606530 0.637628 0.670320 0.704688 0.740818 0.778800 0.818730 0.860707 0.904837 0.951229 1.0 1.051271 1.105170 1.161834 1.221402 1.284025 1.349858 1.419067 1.491824 1.568312 1.648721 1.733253 1.822118 1.915540 2.013752 2.117000 2.225540 2.339646 2.459603 2.585709 2.718281 2.857651 3.004166 3.158192 3.320116 3.490342 3.669296 3.857425 4.055199 4.263114 4.481689 4.711470 4.953032 5.206979 5.473947 5.754602 6.049647 6.359819 6.685894 7.028687 7.389056 7.767901 8.166169 8.584858 9.025013 9.487735 9.974182 10.48556 11.02317 11.58834 12.18249 ] #define Exposure_Speed 1.0 // [0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 4.0 5.0] -#define MINUMUM_EXPOSURE 0.1 // [0.0 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 1.0] -#define MAXIMUM_EXPOSURE 0.1 // [0.0 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 1.0] - #define Fake_purkinje #define Purkinje_strength 1.0 // [0.0 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 1.0] #define Purkinje_R 0.4 // [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 1.0] @@ -590,19 +593,12 @@ const vec3 HIGHLIGHTS_TARGET = length(vec3(HIGHLIGHTS_GRADE_R, HIGHLIGHTS_GRADE_ // #define AEROCHROME_WOOL_ENABLED // Technically wool things should be affected but it affects a lot of builds and stuff #define AEROCHROME_PINKNESS 0.3 // How pink it is from red [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0] const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS); + // #define CAMERA_GRIDLINES - - // #define MOTION_BLUR #define MOTION_BLUR_STRENGTH 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 3.0 4.0 5.0] -// #define CHROMATIC_ABERRATION -#define CHROMATIC_ABERRATION_STRENGTH 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 3.0 4.0 5.0] - -// #define VIGNETTE -#define VIGNETTE_STRENGTH 0.5 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0] - /////////////////////////////////////////////////////// // ----- GAMEPLAY POST EFFECT RELATED SETTINGS ----- // /////////////////////////////////////////////////////// @@ -703,10 +699,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #define SELECT_BOX_COL_B 0.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0] #define OLD_CAVE_DETECTION -#define FORCE_TRANSLUCENT_GLASS - -// #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] /////////////////////////////////////////// // ----- DISTANT HORIZONS SETTINGS ----- // @@ -716,7 +708,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #define DISTORT_SHADOWMAP // #define DISTANT_HORIZONS_SHADOWMAP #ifdef DISTANT_HORIZONS_SHADOWMAP - #undef DISTORT_SHADOWMAP + // #undef DISTORT_SHADOWMAP const float shadowNearPlane = -1.0; const float shadowFarPlane = -1.0; @@ -724,12 +716,11 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) // #define DH_SHADOWPROJECTIONTWEAK #define DH_OVERDRAW_PREVENTION -#define OVERDRAW_MAX_DISTANCE 128 // [0 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256] +#define OVERDRAW_MAX_DISTANCE 0 // [0 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256] #define DH_AMBIENT_OCCLUSION #define DH_SUBSURFACE_SCATTERING #define DH_SCREENSPACE_REFLECTIONS -#define DH_NOISE_TEXTURE /////////////////////////////////////////// // ----- FLOODFILL [LPV] SETTINGS ----- // @@ -737,7 +728,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) //#define LPV_ENABLED #define LPV_SIZE 7 // [6 7 8] -#define LPV_SATURATION 50 // [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] +#define LPV_SATURATION 100 // [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] #define LPV_TINT_SATURATION 100 // [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] #define LPV_NORMAL_STRENGTH 50 // [0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100] #define LPV_NORMAL_OFFSET @@ -758,8 +749,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #endif #endif -// ruining parts of the effect to make it more like vanilla floodfill -// #define VANILLA_LIGHTMAP_MASK //////////////////////////////// // ----- DEBUG SETTINGS ----- // @@ -774,13 +763,10 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #define debug_VIEW_POSITION 6 #define debug_DH_WATER_BLENDING 7 #define debug_FILTERED_STUFF 8 -#define debug_DEPTHTEX0 9 -#define debug_DEPTHTEX1 10 -#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING debug_FILTERED_STUFF debug_DEPTHTEX0 debug_DEPTHTEX1] +#define debug_TEMPORAL_REPROJECTION 9 +#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING debug_FILTERED_STUFF debug_TEMPORAL_REPROJECTION] + -#if DEBUG_VIEW == debug_DEPTHTEX0 || DEBUG_VIEW == debug_DEPTHTEX1 - #undef TAA -#endif // fix settings #ifdef DH_SCREENSPACE_REFLECTIONS #endif @@ -807,6 +793,4 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #ifdef LPV_VL_FOG_ILLUMINATION #endif #ifdef OLD_CAVE_DETECTION -#endif -#ifdef FORCE_TRANSLUCENT_GLASS #endif \ No newline at end of file diff --git a/shaders/lib/sky_gradient.glsl b/shaders/lib/sky_gradient.glsl index 6429948..2656274 100644 --- a/shaders/lib/sky_gradient.glsl +++ b/shaders/lib/sky_gradient.glsl @@ -28,7 +28,7 @@ vec3 drawMoon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeSt vec3 LightDir = phase[moonPhase]; - return Shape * pow(clamp(dot(sunNormal,LightDir)/5,0.0,1.5),5) * Color * 10.0 + clamp(Shape * 4.0 * pow(shape2/200,2.0),0.0,1.0)*0.004; + return Shape * pow(clamp(dot(sunNormal,LightDir)/5,0.0,1.5),5) * Color + clamp(Shape * 4.0 * pow(shape2/200,2.0),0.0,1.0)*0.004; } const float pi = 3.141592653589793238462643383279502884197169; @@ -134,73 +134,27 @@ vec4 texture2D_bicubic_offset(sampler2D tex, vec2 uv, float noise, float scale) vec2 sphereToCarte(vec3 dir) { float lonlat = clamp(atan(-dir.x, -dir.z), -pi, pi); - return vec2(lonlat * (0.5/pi) +0.5, 0.5*dir.y+0.5); + return vec2(lonlat * (0.5/pi) +0.5,0.5*dir.y+0.5); } vec3 skyFromTex(vec3 pos,sampler2D sampler){ - vec2 p = sphereToCarte(pos); - - vec2 clampUV = vec2(1.0); - p = clamp(p*2.0-1.0, -clampUV, clampUV)*0.5+0.5; - return texture2D(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize).rgb; } vec3 skyFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ vec2 p = sphereToCarte(pos); - return texture2DLod(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize,LOD).rgb; } - vec4 skyCloudsFromTex(vec3 pos,sampler2D sampler){ - vec2 p = sphereToCarte(pos); - - vec2 uv = clamp(p, 0.0, 1.0) * texelSize*256. + vec2(18.5+257.,1.5)*texelSize; - - return texture2D(sampler, uv); + return texture2D(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize); +} +vec4 skyCloudsFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ + vec2 p = sphereToCarte(pos); + return texture2DLod(sampler,p*texelSize*256. + vec2(18.5 + 257., 1.5)*texelSize,LOD); } -vec4 skyCloudsFromTexBLUR(vec3 pos,sampler2D sampler, float scaler){ - +vec4 skyCloudsFromTexLOD2(vec3 pos,sampler2D sampler, float LOD){ vec2 p = sphereToCarte(pos); - vec2 scaleA = texelSize*256.; - vec2 scaleB = vec2(18.5+257.,1.5)*texelSize; - vec2 posi = p; - - vec2 uv = clamp(posi, 0.0, 1.0)*scaleA + scaleB; - - - vec4 color = texture2D(sampler, uv); - - return color; -} - -vec4 skyCloudsFromTexLOD(vec3 pos,sampler2D sampler, float roughness){ - vec2 p = sphereToCarte(pos); - - roughness = (1-pow(1-roughness,3)); - - float Y = min(max(p.y-0.5,0)*50.0,1); - p = mix(p, ((p-0.5) - (p-0.5)*roughness) + 0.5, Y); - - // p = ((p-0.5) - (p-0.5)*roughness) + 0.5; - - vec2 clampUV = vec2(1.0); - p = clamp(p*2.0-1.0, -clampUV, clampUV)*0.5+0.5; - - vec2 uv = p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize; - - return texture2D(sampler, uv); -} - - -vec4 volumetricsFromTex(vec3 pos,sampler2D sampler, float LOD){ - vec2 p = sphereToCarte(pos); - - p = clamp(p, 0.0, 1.0); - - vec2 uv = p*texelSize*256. + vec2(256.0 - 256.0*0.12,1.5)*texelSize; - - return texture2DLod(sampler, uv, LOD); + return texture2DLod(sampler,p*texelSize*256. + vec2(256.0 - 256.0*0.12,1.5)*texelSize,LOD); } \ No newline at end of file diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index ba3ab89..ee44e96 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -1,13 +1,13 @@ -// uniform int framemod8; +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.); +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; @@ -23,9 +23,9 @@ float square(float x){ -// vec3 toClipSpace3(vec3 viewSpacePosition) { -// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -// } +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); } @@ -61,89 +61,7 @@ vec2 R2_Sample(int n){ return fract(alpha * n); } -float fma(float a,float b,float c){ - return a * b + c; -} - -vec3 SampleVNDFGGX( - vec3 viewerDirection, // Direction pointing towards the viewer, oriented such that +Z corresponds to the surface normal - float alpha, // Roughness parameter along X and Y of the distribution - vec2 xy // Pair of uniformly distributed numbers in [0, 1) -) { - - // Transform viewer direction to the hemisphere configuration - viewerDirection = normalize(vec3( alpha * 0.5 * viewerDirection.xy, viewerDirection.z)); - - // Sample a reflection direction off the hemisphere - const float tau = 6.2831853; // 2 * pi - float phi = tau * xy.x; - - float cosTheta = fma(1.0 - xy.y, 1.0 + viewerDirection.z, -viewerDirection.z); - float sinTheta = sqrt(clamp(1.0 - cosTheta * cosTheta, 0.0, 1.0)); - - sinTheta = clamp(sinTheta,0.0,1.0); - cosTheta = clamp(cosTheta,sinTheta*0.5,1.0); - - - vec3 reflected = vec3(vec2(cos(phi), sin(phi)) * sinTheta, cosTheta); - - // Evaluate halfway direction - // This gives the normal on the hemisphere - vec3 halfway = reflected + viewerDirection; - - // Transform the halfway direction back to hemiellispoid configuation - // This gives the final sampled normal - return normalize(vec3(alpha * halfway.xy, halfway.z)); -} - -vec3 GGX(vec3 n, vec3 v, vec3 l, float r, vec3 f0, vec3 metalAlbedoTint) { - r = max(pow(r,2.5), 0.0001); - - vec3 h = normalize(l + v); - float hn = inversesqrt(dot(h, h)); - - float dotLH = clamp(dot(h,l)*hn,0.,1.); - float dotNH = clamp(dot(h,n)*hn,0.,1.) ; - float dotNL = clamp(dot(n,l),0.,1.); - float dotNHsq = dotNH*dotNH; - - float denom = dotNHsq * r - dotNHsq + 1.; - float D = r / (3.141592653589793 * denom * denom); - - vec3 F = (f0 + (1. - f0) * exp2((-5.55473*dotLH-6.98316)*dotLH)) * metalAlbedoTint; - float k2 = .25 * r; - - return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2); -} - -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; -} - -vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, bool hand, inout float reflectionLength, float fresnel){ - - float biasAmount = 0.00005;//mix(0.00035, 0.00005, pow(fresnel,0.01)); +vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, bool hand, inout float reflectLength){ vec3 clipPosition = toClipSpace3(position); float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? @@ -157,282 +75,108 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0); - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*(dither-0.5); - - #ifndef FORWARD_SPECULAR - spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; - #endif + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*dither; float minZ = spos.z; float maxZ = spos.z; + spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; + float depthcancleoffset = pow(1.0-(quality/reflection_quality),1.0); - + float dist = 1.0 + clamp(position.z*position.z/50.0,0.0,2.0); // shrink sample size as distance increases for (int i = 0; i <= int(quality); i++) { + // float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0)); + + // if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp); + + // spos += stepv; + + // //small bias + // float biasamount = (0.0002 + 0.0015*pow(depthcancleoffset,5) ) / dist; + + // if(hand) biasamount = 0.00035; + + // minZ = maxZ-biasamount / ld(spos.z); + // maxZ += stepv.z; + + float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0)); float currZ = linZ(spos.z); float nextZ = linZ(sp); - // if(abs(nextZ-currZ) < mix(0.005,0.5,currZ*currZ) && sp < max(minZ,maxZ) && sp > min(minZ,maxZ)) return vec3(spos.xy/RENDER_SCALE,sp); - if(sp < max(minZ,maxZ) && sp > min(minZ,maxZ)) return vec3(spos.xy/RENDER_SCALE,sp); - - minZ = maxZ-biasAmount / currZ; + // if(nextZ < currZ) { + if(abs(nextZ-currZ)/currZ < 0.15 && sp <= max(minZ,maxZ) && sp >= min(minZ,maxZ)) return vec3(spos.xy/RENDER_SCALE,sp); + // } + float biasamount = 0.005; + minZ = maxZ-biasamount / linZ(spos.z); maxZ += stepv.z; spos += stepv; - reflectionLength += 1.0 / quality; - + reflectLength += 1.0 / quality; // for shit } return vec3(1.1); } -vec4 screenSpaceReflections( - vec3 reflectedVector, - vec3 viewPos, - float noise, - - bool isHand, - float roughness, - float fresnel - -){ - vec4 reflection = vec4(0.0); - - float reflectionLength = 0.0; - float quality = 30.0f;//mix(10.0f, 30.0f, fresnel); - - vec3 raytracePos = rayTraceSpeculars(reflectedVector, viewPos, noise, quality, isHand, reflectionLength, fresnel); - - if (raytracePos.z >= 1.0) return reflection; - - // use higher LOD as the reflection goes on, to blur it. this helps denoise a little. - - float value = 0.1; - reflectionLength = min(max(reflectionLength - value, 0.0)/(1.0-value), 1.0); - - float LOD = mix(0.0, 6.0*(1.0-exp(-15.0*sqrt(roughness))), 1.0-pow(1.0-reflectionLength,5.0)); - // float LOD = mix(0.0, 6.0*pow(roughness,0.1), 1.0-pow(1.0-reflectionLength,5.0)); - - // float LOD = clamp(pow(reflectionLength, pow(1.0-sqrt(roughness),5.0) * 3.0) * 6.0, 0.0, 6.0*pow(roughness,0.1)); - - - 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) { - reflection.a = 1.0; - - #ifdef FORWARD_RENDERED_SPECULAR - // vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); - // vec2 resScale = vec2(1920.,1080.)/clampedRes; - // vec2 bloomTileUV = (((previousPosition.xy/texelSize)*2.0 + 0.5)*texelSize/2.0) / clampedRes*vec2(1920.,1080.); - // reflection.rgb = texture2D(colortex6, bloomTileUV / 4.0).rgb; - reflection.rgb = texture2D(colortex5, previousPosition.xy).rgb; - #else - reflection.rgb = texture2DLod(colortex5, previousPosition.xy, LOD).rgb; - #endif - - } - - // reflection.rgb = vec3(LOD/6); - -// vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); -// vec2 resScale = vec2(1920.,1080.)/clampedRes; -// vec2 bloomTileUV = (((previousPosition.xy/texelSize)*2.0 + 0.5)*texelSize/2.0) / clampedRes*vec2(1920.,1080.); - -// vec2 bloomTileoffsetUV[6] = vec2[]( -// bloomTileUV / 4., -// bloomTileUV / 8. + vec2(0.25*resScale.x+2.5*texelSize.x, .0), -// bloomTileUV / 16. + vec2(0.375*resScale.x+4.5*texelSize.x, .0), -// bloomTileUV / 32. + vec2(0.4375*resScale.x+6.5*texelSize.x, .0), -// bloomTileUV / 64. + vec2(0.46875*resScale.x+8.5*texelSize.x, .0), -// bloomTileUV / 128. + vec2(0.484375*resScale.x+10.5*texelSize.x, .0) -// ); -// // reflectLength = pow(1-pow(1-reflectLength,2),5) * 6; -// reflectLength = (exp(-4*(1-reflectLength))) * 6; -// Reflections.rgb = texture2D(colortex6, bloomTileoffsetUV[0]).rgb; - - return reflection; +float fma(float a,float b,float c){ + return a * b + c; } -float getReflectionVisibility(float f0, float roughness){ +//// thank you Zombye | the paper: https://ggx-research.github.io/publication/2023/06/09/publication-ggx.html +vec3 SampleVNDFGGX( + vec3 viewerDirection, // Direction pointing towards the viewer, oriented such that +Z corresponds to the surface normal + vec2 alpha, // Roughness parameter along X and Y of the distribution + float xy // Pair of uniformly distributed numbers in [0, 1) +) { + // alpha *= alpha; + // Transform viewer direction to the hemisphere configuration + viewerDirection = normalize(vec3(alpha * viewerDirection.xy, viewerDirection.z)); - // the goal is to determine if the reflection is even visible. - // if it reaches a point in smoothness or reflectance where it is not visible, allow it to interpolate to diffuse lighting. - float thresholdValue = Roughness_Threshold; + // Sample a reflection direction off the hemisphere + const float tau = 6.2831853; // 2 * pi + float phi = tau * xy; - if(thresholdValue < 0.01) return 0.0; + float cosTheta = fma(1.0 - xy, 1.0 + viewerDirection.z, -viewerDirection.z) ; + float sinTheta = sqrt(clamp(1.0 - cosTheta * cosTheta, 0.0, 1.0)); - // the visibility gradient should only happen for dialectric materials. because metal is always shiny i guess or something - float dialectrics = max(f0*255.0 - 26.0,0.0)/229.0; - float value = 0.35; // so to a value you think is good enough. - float thresholdA = min(max( (1.0-dialectrics) - value, 0.0)/value, 1.0); + // xonk note, i dont know what im doing but this kinda does what i want so whatever + float attemptTailClamp = clamp(sinTheta,max(cosTheta-0.25,0), cosTheta); + float attemptTailClamp2 = clamp(cosTheta,max(sinTheta-0.25,0), sinTheta); - // use perceptual smoothness instead of linear roughness. it just works better i guess - float smoothness = 1.0-sqrt(roughness); - value = thresholdValue; // this one is typically want you want to scale. - float thresholdB = min(max(smoothness - value, 0.0)/value, 1.0); - - // preserve super smooth reflections. if thresholdB's value is really high, then fully smooth, low f0 materials would be removed (like water). - value = 0.1; // super low so only the smoothest of materials are includes. - float thresholdC = 1.0-min(max(value - (1.0-smoothness), 0.0)/value, 1.0); - - float visibilityGradient = max(thresholdA*thresholdC - thresholdB,0.0); + vec3 reflected = vec3(vec2(cos(phi), sin(phi)) * attemptTailClamp2, attemptTailClamp); + // vec3 reflected = vec3(vec2(cos(phi), sin(phi)) * sinTheta, cosTheta); - // a curve to make the gradient look smooth/nonlinear. just preference - visibilityGradient = 1.0-visibilityGradient; - visibilityGradient *=visibilityGradient; - visibilityGradient = 1.0-visibilityGradient; - visibilityGradient *=visibilityGradient; + // Evaluate halfway direction + // This gives the normal on the hemisphere + vec3 halfway = reflected + viewerDirection; - return visibilityGradient; + // Transform the halfway direction back to hemiellispoid configuation + // This gives the final sampled normal + return normalize(vec3(alpha * halfway.xy, halfway.z)); } -// derived from N and K from labPBR wiki https://shaderlabs.org/wiki/LabPBR_Material_Standard -// using ((1.0 - N)^2 + K^2) / ((1.0 + N)^2 + K^2) -vec3 HCM_F0 [8] = vec3[]( - vec3(0.531228825312, 0.51235724246, 0.495828545714),// iron - vec3(0.944229966045, 0.77610211732, 0.373402004593),// gold - vec3(0.912298031535, 0.91385063144, 0.919680580954),// Aluminum - vec3(0.55559681715, 0.55453707574, 0.554779427513),// Chrome - vec3(0.925952196272, 0.72090163805, 0.504154241735),// Copper - vec3(0.632483812932, 0.62593707362, 0.641478899539),// Lead - vec3(0.678849234658, 0.64240055565, 0.588409633571),// Platinum - vec3(0.961999998804, 0.94946811207, 0.922115710997) // Silver -); +float GGX(vec3 n, vec3 v, vec3 l, float r, float f0) { + r = max(pow(r,2.5), 0.0001); -vec3 specularReflections( + vec3 h = l + v; + float hn = inversesqrt(dot(h, h)); - in vec3 viewPos, // toScreenspace(vec3(screenUV, depth) - in vec3 playerPos, // normalized - in vec3 lightPos, // should be in world space - in vec3 noise, // x = bluenoise y = interleaved gradient noise + float dotLH = clamp(dot(h,l)*hn,0.,1.); + float dotNH = clamp(dot(h,n)*hn,0.,1.) ; + float dotNL = clamp(dot(n,l),0.,1.); + float dotNHsq = dotNH*dotNH; - in vec3 normal, // normals in world space - in float roughness, // red channel of specular texture _S - in float f0, // green channel of specular texture _S - in vec3 albedo, - in vec3 diffuseLighting, - in vec3 lightColor, // should contain the light's color and shadows. + float denom = dotNHsq * r - dotNHsq + 1.; + float D = r / (3.141592653589793 * denom * denom); - in float lightmap, // in anything other than world0, this should be 1.0; - in bool isHand // mask for the hand + float F = f0 + (1. - f0) * exp2((-5.55473*dotLH-6.98316)*dotLH); + float k2 = .25 * r; - #ifdef FORWARD_SPECULAR - , inout float reflectanceForAlpha - #else - , bool isWater - #endif -){ - #ifdef FORWARD_RENDERED_SPECULAR - lightmap = pow(min(max(lightmap-0.6,0.0)*2.5,1.0),2.0); - #else - lightmap = clamp((lightmap-0.8)*7.0, 0.0,1.0); - #endif - - roughness = 1.0 - roughness; - roughness *= roughness; - - f0 = f0 == 0.0 ? 0.02 : f0; - - // f0 = 0.9; - // roughness = 0.0; - - bool isMetal = f0 > 229.5/255.0; - - // #ifndef FORWARD_RENDERED_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; - - #if defined FORWARD_ROUGH_REFLECTION || defined DEFERRED_ROUGH_REFLECTION - vec3 samplePoints = SampleVNDFGGX(viewDir, roughness, noise.xy); - vec3 reflectedVector_L = basis * reflect(-normalize(viewDir), samplePoints); - - // get reflectance and f0/HCM values - // float shlickFresnel = pow(clamp(1.0 + dot(-reflectedVector, samplePoints),0.0,1.0),5.0); - #else - vec3 reflectedVector_L = reflect(playerPos, normal); - #endif - - float shlickFresnel = shlickFresnelRoughness(dot(-normalize(viewDir), vec3(0.0,0.0,1.0)), roughness); - - // #if defined FORWARD_RENDERED_SPECULAR && defined SNELLS_WINDOW - // if(isEyeInWater == 1) shlickFresnel = mix(shlickFresnel, 1.0, min(max(0.97 - (1-shlickFresnel),0.0)/(1-0.97),1.0)); - // #endif - - // 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); - // get F0 values for hardcoded metals. - vec3 hardCodedMetalsF0 = f0 == 1.0 ? albedo : HCM_F0[int(clamp(f0*255.0 - 229.5,0.0,7.0))]; - vec3 reflectance = isMetal ? hardCodedMetalsF0 : vec3(f0); - vec3 F0 = (reflectance + (1.0-reflectance) * shlickFresnel) * metalAlbedoTint; - - #if defined FORWARD_SPECULAR - reflectanceForAlpha = clamp(dot(F0, vec3(0.3333333)), 0.0,1.0); - #endif - - vec3 specularReflections = diffuseLighting; - - float reflectionVisibilty = getReflectionVisibility(f0, roughness); - - #if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION || defined DEFERRED_ENVIORNMENT_REFLECTION || defined FORWARD_ENVIORNMENT_REFLECTION - if(reflectionVisibilty < 1.0){ - #if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION - #if !defined OVERWORLD_SHADER && !defined FORWARD_SPECULAR - vec3 backgroundReflection = volumetricsFromTex(reflectedVector_L, colortex4, roughness).rgb / 1200.0; - #else - vec3 backgroundReflection = skyCloudsFromTex(reflectedVector_L, colortex4).rgb / 1200.0; - #endif - #endif - - #if defined DEFERRED_ENVIORNMENT_REFLECTION || defined FORWARD_ENVIORNMENT_REFLECTION - vec4 enviornmentReflection = screenSpaceReflections(mat3(gbufferModelView) * reflectedVector_L, viewPos, noise.y, isHand, roughness, shlickFresnel); - // darkening for metals. - vec3 DarkenedDiffuseLighting = isMetal ? diffuseLighting * (1.0-enviornmentReflection.a) * (1.0-lightmap) : diffuseLighting; - #else - // darkening for metals. - vec3 DarkenedDiffuseLighting = isMetal ? diffuseLighting * (1.0-lightmap) : diffuseLighting; - #endif - - // composite all the different reflections together - #if defined DEFERRED_BACKGROUND_REFLECTION || defined FORWARD_BACKGROUND_REFLECTION - specularReflections = mix(DarkenedDiffuseLighting, backgroundReflection, lightmap); - #endif - - #if defined DEFERRED_ENVIORNMENT_REFLECTION || defined FORWARD_ENVIORNMENT_REFLECTION - specularReflections = mix(specularReflections, enviornmentReflection.rgb, enviornmentReflection.a); - #endif - - specularReflections = mix(DarkenedDiffuseLighting, specularReflections, F0); - - // lerp back to diffuse lighting if the reflection has not been deemed visible enough - specularReflections = mix(specularReflections, diffuseLighting, reflectionVisibilty); - } - #endif - - #if defined OVERWORLD_SHADER - vec3 lightSourceReflection = Sun_specular_Strength * lightColor * GGX(normal, -playerPos, lightPos, roughness, reflectance, metalAlbedoTint); - specularReflections += lightSourceReflection; - #endif - - return specularReflections; + return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2); } -/* + void DoSpecularReflections( inout vec3 Output, @@ -455,70 +199,43 @@ void DoSpecularReflections( 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; + // F0 = 0.9; 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); + vec3 SamplePoints = SampleVNDFGGX(ViewDir, vec2(Roughness), 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; + float Fresnel = pow(clamp(1.0 + dot(-Ln, SamplePoints),0.0,1.0), 5.0); // Schlick's approximation - 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))]; + float RayContribution = lerp(F0, 1.0, Fresnel); // ensure that when the angle is 0 that the correct F0 is used. - 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 + #ifdef Rough_reflections + if(Hand) RayContribution = RayContribution * pow(1.0-Roughness,F0 > 229.5/255.0 ? 1.0 : 3.0); + #else + RayContribution = RayContribution * 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 ? lerp(normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3), vec3(1.0), Fresnel * pow(1.0-Roughness,25.0)) : vec3(1.0); + 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 @@ -526,33 +243,31 @@ void DoSpecularReflections( #ifdef Sky_reflection #ifdef OVERWORLD_SHADER - if(hasReflections) Background_Reflection = (skyCloudsFromTex(L, colortex4).rgb / 1200.0) ; + if(hasReflections) Background_Reflection = (skyCloudsFromTex(L, colortex4).rgb / 30.0) * Metals ; #else - if(hasReflections) Background_Reflection = (volumetricsFromTex(L, colortex4, sqrt(Roughness) * 6.0).rgb / 1200.0) ; + if(hasReflections) Background_Reflection = (skyCloudsFromTexLOD2(L, colortex4, sqrt(Roughness) * 6.0).rgb / 30.0) * Metals; #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; + Final_Reflection = lerp(Output, Background_Reflection, Lightmap * RayContribution); #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 + #ifdef Dynamic_SSR_quality + float SSR_Quality = lerp(reflection_quality, 6.0, RayContribution); // Scale quality with ray contribution + #else + float SSR_Quality = reflection_quality; + #endif + float reflectLength = 0.0; 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; @@ -560,26 +275,25 @@ void DoSpecularReflections( 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; + SS_Reflections.rgb = texture2DLod(colortex5, previousPosition.xy, LOD).rgb * Metals; } } // make sure it takes the fresnel into account for SSR. - SS_Reflections.rgb = mix(isMetal ? vec3(0.0) : Output, SS_Reflections.rgb, f0); + SS_Reflections.rgb = lerp(Output, SS_Reflections.rgb, RayContribution); // occlude the background with the SSR and write to the final color. - Final_Reflection = mix(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a); + Final_Reflection = lerp(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a); } #endif + // Final_Reflection = mix(mix(Output,Background_Reflection,Lightmap), SS_Reflections.rgb, SS_Reflections.a) * RayContribution; + // --------------- 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; + Lightsource_Reflection = Diffuse * GGX(Normal, -WorldPos, LightPos, Roughness, F0) * Metals; + Final_Reflection += Lightsource_Reflection * Sun_specular_Strength ; #endif - - Output = Final_Reflection; - // Output = exp(-100 * (reflectLength*reflectLength*reflectLength)) * vec3(1.0); -} -*/ \ No newline at end of file + Output = Final_Reflection; +} \ No newline at end of file diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index a90c8b9..901aea5 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -1,11 +1,56 @@ -#define ALTOSTRATUS_LAYER 2 -#define LARGECUMULUS_LAYER 1 -#define SMALLCUMULUS_LAYER 0 +#ifdef HQ_CLOUDS + int maxIT_clouds = minRayMarchSteps; + int maxIT = maxRayMarchSteps; + + const int cloudLoD = cloud_LevelOfDetail; + const int cloudShadowLoD = cloud_ShadowLevelOfDetail; +#else + int maxIT_clouds = minRayMarchStepsLQ; + int maxIT = maxRayMarchStepsLQ; + + const int cloudLoD = cloud_LevelOfDetailLQ; + const int cloudShadowLoD = cloud_ShadowLevelOfDetailLQ; +#endif + +uniform int worldTime; +#define WEATHERCLOUDS +#include "/lib/climate_settings.glsl" + +#if defined Daily_Weather + flat varying vec4 dailyWeatherParams0; + flat varying vec4 dailyWeatherParams1; +#else + vec4 dailyWeatherParams0 = vec4(CloudLayer0_coverage, CloudLayer1_coverage, CloudLayer2_coverage, 0.0); + vec4 dailyWeatherParams1 = vec4(CloudLayer0_density, CloudLayer1_density, CloudLayer2_density, 0.0); +#endif + +float LAYER0_width = 100.0; +float LAYER0_minHEIGHT = CloudLayer0_height; +float LAYER0_maxHEIGHT = LAYER0_width + LAYER0_minHEIGHT; + +float LAYER1_width = 100.0; +float LAYER1_minHEIGHT = max(CloudLayer1_height, LAYER0_maxHEIGHT); +float LAYER1_maxHEIGHT = LAYER1_width + LAYER1_minHEIGHT; + +float LAYER2_HEIGHT = max(CloudLayer2_height, LAYER1_maxHEIGHT); + +// float LAYER0_COVERAGE = mix(pow(dailyWeatherParams0.x*2.0,0.2), 0.9, rainStrength); +// float LAYER1_COVERAGE = mix(pow(dailyWeatherParams0.y*2.0,0.2), 0.8, rainStrength); +// float LAYER2_COVERAGE = mix(pow(dailyWeatherParams0.z*2.0,0.2), 1.3, rainStrength); + +float LAYER0_COVERAGE = mix(dailyWeatherParams0.x, 0.95, rainStrength); +float LAYER1_COVERAGE = mix(dailyWeatherParams0.y, 0.0, rainStrength); +float LAYER2_COVERAGE = mix(dailyWeatherParams0.z, 1.5, rainStrength); + +float LAYER0_DENSITY = mix(dailyWeatherParams1.x,1.0,rainStrength); +float LAYER1_DENSITY = mix(dailyWeatherParams1.y,0.0,rainStrength); +float LAYER2_DENSITY = mix(dailyWeatherParams1.z,0.05,rainStrength); uniform int worldDay; -uniform int worldTime; + float cloud_movement = (worldTime + mod(worldDay,100)*24000.0) / 24.0 * Cloud_Speed; +//3D noise from 2d texture float densityAtPos(in vec3 pos){ pos /= 18.; pos.xz *= 0.5; @@ -20,331 +65,341 @@ float densityAtPos(in vec3 pos){ return mix(xy.r,xy.g, f.y); } -float getCloudShape(int LayerIndex, int LOD, in vec3 position, float minHeight, float maxHeight){ - vec3 samplePos = position*vec3(1.0, 1.0/48.0, 1.0)/4.0; +float GetAltostratusDensity(vec3 pos){ + + float large = 1.0 - texture2D(noisetex, (pos.xz + cloud_movement)/100000.).b; + large = max(large + LAYER2_COVERAGE - 0.7, 0.0); + float medium = 1.0 - texture2D(noisetex, (pos.xz - cloud_movement)/7500. + vec2(-large,1.0-large)/5.0).b; + + float shape = max(large - medium*0.4 * clamp(1.5-large,0.0,1.0),0.0); + + return shape*shape; +} + +float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float maxHeight){ + float FinalCloudCoverage = 0.0; float coverage = 0.0; - float shape = 0.0; - float largeCloud = 0.0; - float smallCloud = 0.0; + float Topshape = 0.0; + float Baseshape = 0.0; - if(LayerIndex == ALTOSTRATUS_LAYER){ - - coverage = dailyWeatherParams0.z; + float LAYER0_minHEIGHT_FOG = CloudLayer0_height; + float LAYER0_maxHEIGHT_FOG = 100 + LAYER0_minHEIGHT_FOG; + LAYER0_minHEIGHT_FOG = LAYER0_minHEIGHT; + LAYER0_maxHEIGHT_FOG = LAYER0_maxHEIGHT; - largeCloud = texture2D(noisetex, (position.xz + cloud_movement)/100000.).b; - smallCloud = 1.0 - texture2D(noisetex, (position.xz - cloud_movement)/7500. - vec2(1.0-largeCloud, -largeCloud)/5.0).b; + float LAYER1_minHEIGHT_FOG = max(CloudLayer1_height, LAYER0_maxHEIGHT); + float LAYER1_maxHEIGHT_FOG = 100 + LAYER1_minHEIGHT_FOG; + LAYER1_minHEIGHT_FOG = LAYER1_minHEIGHT; + LAYER1_maxHEIGHT_FOG = LAYER1_maxHEIGHT; - smallCloud = largeCloud + smallCloud * 0.4 * clamp(1.5-largeCloud,0.0,1.0); - - float val = coverage; - shape = min(max(val - smallCloud,0.0)/sqrt(val),1.0); - shape *= shape; - return shape; - } - if(LayerIndex == LARGECUMULUS_LAYER){ - coverage = dailyWeatherParams0.y; - - largeCloud = texture2D(noisetex, (samplePos.zx + cloud_movement*2.0)/10000.0).b; - smallCloud = texture2D(noisetex, (samplePos.zx - cloud_movement*2.0)/2500.0).b; - - smallCloud = abs(largeCloud* -0.7) + smallCloud; + vec2 SampleCoords0 = vec2(0.0); vec2 SampleCoords1 = vec2(0.0); - float val = coverage; - shape = min(max(val - smallCloud,0.0)/sqrt(val),1.0) ; - - - } - if(LayerIndex == SMALLCUMULUS_LAYER){ - coverage = dailyWeatherParams0.x; - - largeCloud = texture2D(noisetex, (samplePos.xz + cloud_movement)/5000.0).b; - smallCloud = 1.0-texture2D(noisetex, (samplePos.xz - cloud_movement)/500.0).r; - - smallCloud = abs(largeCloud-0.6) + smallCloud*smallCloud; - - float val = coverage; - shape = min(max(val - smallCloud,0.0)/sqrt(val),1.0) ; - - // shape = abs(largeCloud*2.0 - 1.2)*0.5 - (1.0-smallCloud); + float CloudSmall = 0.0; + if(layer == 0){ + SampleCoords0 = (samplePos.xz + cloud_movement) / 5000 ; + SampleCoords1 = (samplePos.xz - cloud_movement) / 500 ; + CloudSmall = texture2D(noisetex, SampleCoords1 ).r; } - // clamp density of the cloud within its upper/lower bounds - shape = min(min(shape, clamp(maxHeight - position.y,0,1)), 1.0 - clamp(minHeight - position.y,0,1)); + if(layer == 1){ + SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 10000); + SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 2500); + CloudSmall = texture2D(noisetex, SampleCoords1 ).b; + } - // carve out the upper part of clouds. make sure it rounds out at its upper bound - float topShape = min(max(maxHeight-position.y,0.0) / max(maxHeight-minHeight,1.0),1.0); - topShape = min(exp(-0.5 * (1.0-topShape)), 1.0-pow(1.0-topShape,5.0)); - - // round out the bottom part slightly - float bottomShape = 1.0-pow(1.0-min(max(position.y-minHeight,0.0) / 25.0, 1.0), 5.0); - shape = max((shape - 1.0) + topShape * bottomShape,0.0); - - /// erosion noise - if(shape > 0.001){ - - float erodeAmount = 0.5; - // shrink the coverage slightly so it is a similar shape to clouds with erosion. this helps cloud lighting and cloud shadows. - if (LOD < 1) return max(shape - 0.27*erodeAmount,0.0); - - samplePos.xz -= cloud_movement/4.0; - - // da wind - // if(LayerIndex == SMALLCUMULUS_LAYER) - samplePos.xz += pow( max(position.y - (minHeight+20.0), 0.0) / (max(maxHeight-minHeight,1.0)*0.20), 1.5); - - float erosion = 0.0; - - if(LayerIndex == SMALLCUMULUS_LAYER){ - erosion += (1.0-densityAtPos(samplePos * 200.0)) * sqrt(1.0-shape); - - float falloff = 1.0 - clamp((maxHeight - position.y)/100.0,0.0,1.0); - erosion += abs(densityAtPos(samplePos * 600.0) - falloff) * 0.75 * (1.0-shape) * (1.0-falloff*0.25); - - erosion = erosion*erosion*erosion*erosion; + if(layer == -1){ + float otherlayer = max(pos.y - (LAYER0_minHEIGHT_FOG+99.5), 0.0) > 0 ? 0.0 : 1.0; + if(otherlayer > 0.0){ + SampleCoords0 = (samplePos.xz + cloud_movement) / 5000 ; + SampleCoords1 = (samplePos.xz - cloud_movement) / 500 ; + CloudSmall = texture2D(noisetex, SampleCoords1 ).r; + }else{ + SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 10000); + SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 2500); + CloudSmall = texture2D(noisetex, SampleCoords1 ).b; } - if(LayerIndex == LARGECUMULUS_LAYER){ - erosion += (1.0 - densityAtPos(samplePos * 100.0)) * sqrt(1.0-shape); + } - float falloff = 1.0 - clamp((maxHeight - position.y)/200.0,0.0,1.0); - erosion += abs(densityAtPos(samplePos * 450.0) - falloff) * 0.75 * (1.0-shape) * (1.0-falloff*0.5); + float CloudLarge = texture2D(noisetex, SampleCoords0).b; - erosion = erosion*erosion*erosion*erosion; - } + if(layer == 0){ + coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall); - return max(shape - erosion*erodeAmount,0.0); + float layer0 = min(min(coverage + LAYER0_COVERAGE, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1)); + Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.0; + Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 15.0; + Baseshape = max(LAYER0_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0; + + FinalCloudCoverage = max(layer0 - Topshape - Baseshape * (1.0-rainStrength),0.0); + } + + if(layer == 1){ + + coverage = abs(CloudLarge-0.8) - CloudSmall; + + float layer1 = min(min(coverage + LAYER1_COVERAGE - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1)); + + Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75),0.0) / 200.0; + Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10), 0.0) / 15.0; + Baseshape = max(LAYER1_minHEIGHT_FOG + 15.5 - pos.y, 0.0) / 50.0; + + FinalCloudCoverage = max(layer1 - Topshape*Topshape - Baseshape * (1.0-rainStrength), 0.0); + } + + + if(layer == -1){ + + #ifdef CloudLayer0 + float layer0_coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall); + float layer0 = min(min(layer0_coverage + LAYER0_COVERAGE, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1)); + + Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.0; + Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 15.0; + Baseshape = max(LAYER0_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0; + + FinalCloudCoverage = max(layer0 - Topshape - Baseshape * (1.0-rainStrength),0.0); + #endif + + #ifdef CloudLayer1 + float layer1_coverage = abs(CloudLarge-0.8) - CloudSmall; + float layer1 = min(min(layer1_coverage + LAYER1_COVERAGE - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1)); + + Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75), 0.0) / 200; + Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10 ), 0.0) / 50; + Baseshape = max(LAYER1_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0; + + FinalCloudCoverage += max(layer1 - Topshape*Topshape - Baseshape * (1.0-rainStrength), 0.0); + #endif + } + + return FinalCloudCoverage; +} + +//Erode cloud with 3d Perlin-worley noise, actual cloud value +float cloudVol(int layer, in vec3 pos, in vec3 samplePos, in float cov, in int LoD, float minHeight, float maxHeight){ + + // float curvature = 1-exp(-25*pow(clamp(1.0 - length(pos - cameraPosition)/(32*80),0.0,1.0),2)); + // curvature = clamp(1.0 - length(pos - cameraPosition)/(32*128),0.0,1.0); + + float otherlayer = max(pos.y - (CloudLayer0_height+99.5), 0.0) > 0 ? 0.0 : 1.0; + float upperPlane = otherlayer; + + float noise = 0.0 ; + float totalWeights = 0.0; + float pw = log(fbmPower1); + float pw2 = log(fbmPower2); + + samplePos.xz -= cloud_movement/4; + + samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) ; + + noise += (1.0-densityAtPos(samplePos * mix(100.0,200.0,upperPlane)) ) * sqrt(1.0-cov); + + if (LoD > 0){ + noise += abs( densityAtPos(samplePos * mix(450.0,600.0,upperPlane) ) - (1.0-clamp(((maxHeight - pos.y) / 100.0),0.0,1.0))) * 0.75 * (1.0-cov); + } + + noise = noise*noise; + float cloud = max(cov - noise*noise*fbmAmount,0.0); + + return cloud; +} + +float GetCumulusDensity(int layer, in vec3 pos, in int LoD, float minHeight, float maxHeight){ + + vec3 samplePos = pos*vec3(1.0,1./48.,1.0)/4; + + float coverageSP = cloudCov(layer, pos,samplePos, minHeight, maxHeight); + + // return coverageSP; + if (coverageSP > 0.001) { + if (LoD < 0) return max(coverageSP - 0.27*fbmAmount,0.0); + return cloudVol(layer, pos,samplePos,coverageSP,LoD ,minHeight, maxHeight) ; } else return 0.0; - } -float getPlanetShadow(vec3 playerPos, vec3 WsunVec){ - float planetShadow = min(max(playerPos.y - (-100.0 + 1.0 / abs(WsunVec.y*0.1)),0.0) / 100.0, 1.0); - - planetShadow = mix(pow(1.0-pow(1.0-planetShadow,2.0),2.0), 1.0, pow(abs(WsunVec.y),2.0)); - - return planetShadow; -} - -float GetCloudShadow(vec3 playerPos, vec3 sunVector){ - - float totalShadow = getPlanetShadow(playerPos, sunVector); - - vec3 startPosition = playerPos; - - float cloudShadows = 0.0; - - #ifdef CloudLayer0 - startPosition = playerPos + sunVector / abs(sunVector.y) * max((CloudLayer0_height + 20.0) - playerPos.y, 0.0); - cloudShadows = getCloudShape(SMALLCUMULUS_LAYER, 0, startPosition, CloudLayer0_height, CloudLayer0_height+100.0)*dailyWeatherParams1.x; - #endif - #ifdef CloudLayer1 - startPosition = playerPos + sunVector / abs(sunVector.y) * max((CloudLayer1_height + 20.0) - playerPos.y, 0.0); - cloudShadows += getCloudShape(LARGECUMULUS_LAYER, 0, startPosition, CloudLayer1_height, CloudLayer1_height+100.0)*dailyWeatherParams1.y; - #endif - #ifdef CloudLayer2 - startPosition = playerPos + sunVector / abs(sunVector.y) * max(CloudLayer2_height - playerPos.y, 0.0); - cloudShadows += getCloudShape(ALTOSTRATUS_LAYER, 0, startPosition, CloudLayer2_height, CloudLayer2_height)*dailyWeatherParams1.z * (1.0-abs(WsunVec.y)); - #endif - #if defined CloudLayer0 || defined CloudLayer1 || defined CloudLayer2 - totalShadow *= exp((cloudShadows*cloudShadows) * -200.0); - #endif - - return totalShadow; -} #ifndef CLOUDSHADOWSONLY +uniform sampler2D colortex4; //Skybox -float phaseCloud(float x, float g){ +//Mie phase function +float phaseg(float x, float g){ float gg = g * g; return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14; } -float getCloudScattering( - int LayerIndex, - vec3 rayPosition, - vec3 sunVector, - float dither, - float minHeight, - float maxHeight, - float density +vec3 DoCloudLighting( + float density, + + vec3 skyLightCol, + float skyScatter, + + float sunShadows, + vec3 sunScatter, + vec3 sunMultiScatter, + float distantfog ){ - int samples = 3; - int LOD = 0; + float powder = 1.0 - exp(-10.0 * density); + vec3 directLight = sunScatter * exp(-10.0 * sunShadows) + sunMultiScatter * exp(-3.0 * sunShadows) * powder; - if(LayerIndex == ALTOSTRATUS_LAYER) samples = 2; - - float shadow = 0.0; - vec3 shadowRayPosition = vec3(0.0); - - for (int i = 0; i < samples; i++){ - - if(LayerIndex == ALTOSTRATUS_LAYER){ - shadowRayPosition = rayPosition + sunVector * (1.0 + i * dither) / (pow(abs(sunVector.y*0.5),3.0) * 0.995 + 0.005); - }else{ - shadowRayPosition = rayPosition + sunVector * (1.0 + i + dither)*20.0; - } - // float fadeddensity = density * pow(clamp((shadowRayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0); - - shadow += getCloudShape(LayerIndex, LOD, shadowRayPosition, minHeight, maxHeight) * density; - } - - return shadow; + vec3 indirectLight = skyLightCol * mix(1.0, 2.0 * (1.0 - sqrt((skyScatter*skyScatter*skyScatter)*density)) , pow(distantfog,1.0 - rainStrength*0.5)); + + // return directLight; + // #ifndef TEST + // return indirectLight; + // #endif + return directLight + indirectLight; } -vec3 getCloudLighting( - float shape, - float shapeFaded, - - float sunShadowMask, - vec3 directLightCol, - vec3 directLightCol_multi, - - float indirectShadowMask, - vec3 indirectLightCol, - - float distanceFade -){ - float powderEffect = 1.0 - exp(-3.0*shapeFaded); - - vec3 directScattering = directLightCol * exp(-10.0*sunShadowMask) + directLightCol_multi * exp(-3.0*(sunShadowMask - (1.0-indirectShadowMask*indirectShadowMask)*0.5)) * powderEffect; - vec3 indirectScattering = indirectLightCol * mix(1.0, exp2(-5.0*shape), (indirectShadowMask*indirectShadowMask) * distanceFade); - - // return indirectScattering; - // return directScattering; - return indirectScattering + directScattering; -} - -vec4 raymarchCloud( - int LayerIndex, - float samples, - vec3 rayPosition, - vec3 rayDirection, - float dither, +vec4 renderLayer( + int layer, + in vec3 POSITION, + in vec3 rayProgress, + in vec3 dV_view, + in float mult, + in float dither, + int QUALITY, + float minHeight, float maxHeight, - vec3 sunVector, - vec3 sunScattering, - vec3 sunMultiScattering, - vec3 skyScattering, - float distanceFade, + in vec3 dV_Sun, - float referenceDistance + float cloudDensity, + in vec3 skyLightCol, + in vec3 sunScatter, + in vec3 sunMultiScatter, + in vec3 indirectScatter, + in float distantfog, + bool notVisible, + vec3 FragPosition, + inout vec3 cloudDepth ){ - vec3 color = vec3(0.0); - float totalAbsorbance = 1.0; - - float planetShadow = getPlanetShadow(rayPosition, sunVector); - sunScattering *= planetShadow; - sunMultiScattering *= planetShadow; + vec3 COLOR = vec3(0.0); + float TOTAL_EXTINCTION = 1.0; + bool IntersecTerrain = false; - float distanceFactor = length(rayDirection); - - if(LayerIndex == ALTOSTRATUS_LAYER){ - float density = dailyWeatherParams1.z; - - bool ifAboveOrBelowPlane = max(mix(-1.0, 1.0, clamp(cameraPosition.y - minHeight,0.0,1.0)) * normalize(rayDirection).y,0.0) > 0.0; - - // check if the ray staring position is going farther than the reference distance, if yes, dont begin marching. this is to check for intersections with the world. - // check if the camera is above or below the cloud plane, so it doesnt waste work on the opposite hemisphere - #ifndef VL_CLOUDS_DEFERRED - if(length(rayPosition - cameraPosition) > referenceDistance || ifAboveOrBelowPlane) return vec4(color, totalAbsorbance); + #ifdef CLOUDS_INTERSECT_TERRAIN + // thank you emin for this world intersection thing + #if defined DISTANT_HORIZONS + float maxdist = dhRenderDistance + 16 * 32; #else - if(ifAboveOrBelowPlane) return vec4(color, totalAbsorbance); + float maxdist = far + 16*5; #endif - float shape = getCloudShape(LayerIndex, 1, rayPosition, minHeight, maxHeight); - float shapeWithDensity = shape*density; + float lViewPosM = length(FragPosition) < maxdist ? length(FragPosition) - 1.0 : 100000000.0; + #endif - // check if the pixel has visible clouds before doing work. - if(shapeWithDensity > 1e-5){ - // can add the initial cloud shape sample for a free shadow starting step :D - float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y)); - float indirectShadowMask = 0.5; +if(layer == 2){ + + #ifdef CLOUDS_INTERSECT_TERRAIN + IntersecTerrain = length(rayProgress - cameraPosition) > lViewPosM; + #endif - vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensity, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering, distanceFade); + if(notVisible || IntersecTerrain) return vec4(COLOR, TOTAL_EXTINCTION); + + float signFlip = mix(-1.0, 1.0, clamp(cameraPosition.y - minHeight,0.0,1.0)); + + if(max(signFlip * normalize(dV_view).y,0.0) <= 0.0){ + float altostratus = GetAltostratusDensity(rayProgress); - float densityCoeff = exp(-distanceFactor*shapeWithDensity); - color += (lighting - lighting * densityCoeff) * totalAbsorbance; - totalAbsorbance *= densityCoeff; - } - - return vec4(color, totalAbsorbance); - } - - if(LayerIndex < ALTOSTRATUS_LAYER){ - float density = dailyWeatherParams1.x; - - if(LayerIndex == LARGECUMULUS_LAYER) density = dailyWeatherParams1.y; + float AltoWithDensity = altostratus * cloudDensity; - float skylightOcclusion = 1.0; - #if defined CloudLayer1 && defined CloudLayer0 - if(LayerIndex == SMALLCUMULUS_LAYER) { - float upperLayerOcclusion = getCloudShape(LARGECUMULUS_LAYER, 0, rayPosition + vec3(0.0,1.0,0.0) * max((CloudLayer1_height+20) - rayPosition.y,0.0), CloudLayer1_height, CloudLayer1_height+100.0); - skylightOcclusion = mix(mix(0.0,0.2,dailyWeatherParams1.y), 1.0, pow(1.0 - upperLayerOcclusion*dailyWeatherParams1.y,2)); + if(altostratus > 1e-5){ + float muE = altostratus * cloudDensity; + + float directLight = 0.0; + for (int j = 0; j < 2; j++){ + + // lower the step size as the sun gets higher in the sky + vec3 shadowSamplePos_high = rayProgress + dV_Sun * (1.0 + j * dither) / (pow(abs(dV_Sun.y*0.5),3.0) * 0.995 + 0.005); + + // lower density as the sun gets higher in the sky to simulate.... multiscattering or something idk it looks better this way + directLight += GetAltostratusDensity(shadowSamplePos_high) * cloudDensity * (1.0-abs(dV_Sun.y)); } - skylightOcclusion = mix(1.0, skylightOcclusion, distanceFade); - #endif + vec3 lighting = DoCloudLighting(AltoWithDensity, skyLightCol, 0.5, directLight, sunScatter, sunMultiScatter, distantfog); - for(int i = 0; i < int(samples); i++) { - - // check if the ray staring position is going farther than the reference distance, if yes, dont begin marching. this is to check for intersections with the world. - #ifndef VL_CLOUDS_DEFERRED - if(length(rayPosition - cameraPosition) > referenceDistance) break; - #endif - - // check if the pixel is in the bounding box before doing work. - if(clamp(rayPosition.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayPosition.y - minHeight,0.0,1.0) > 0.0){ - - float shape = getCloudShape(LayerIndex, 1, rayPosition, minHeight, maxHeight); - float shapeWithDensity = shape*density; - float shapeWithDensityFaded = shape*density * pow(clamp((rayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0); - - // check if the pixel has visible clouds before doing work. - if(shapeWithDensityFaded > 1e-5){ - // can add the initial cloud shape sample for a free shadow starting step :D - float indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0); - float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density); - - // do cloud shadows from one layer to another - // large cumulus layer -> small cumulus layer - #if defined CloudLayer0 && defined CloudLayer1 - if(LayerIndex == SMALLCUMULUS_LAYER){ - vec3 shadowStartPos = rayPosition + sunVector / abs(sunVector.y) * max((CloudLayer1_height + 20.0) - rayPosition.y, 0.0); - sunShadowMask += 3.0 * getCloudShape(LARGECUMULUS_LAYER, 0, shadowStartPos, CloudLayer1_height, CloudLayer1_height+100.0)*dailyWeatherParams1.y; - } - #endif - // altostratus layer -> all cumulus layers - #if defined CloudLayer2 - vec3 shadowStartPos = rayPosition + sunVector / abs(sunVector.y) * max(CloudLayer2_height - rayPosition.y, 0.0); - sunShadowMask += getCloudShape(ALTOSTRATUS_LAYER, 0, shadowStartPos, CloudLayer2_height, CloudLayer2_height) * dailyWeatherParams1.z * (1.0-abs(sunVector.y)); - #endif - - vec3 lighting = getCloudLighting(shapeWithDensity, shapeWithDensityFaded, sunShadowMask, sunScattering, sunMultiScattering, indirectShadowMask, skyScattering * skylightOcclusion, distanceFade); - - float densityCoeff = exp(-distanceFactor*shapeWithDensityFaded); - color += (lighting - lighting * densityCoeff) * totalAbsorbance; - totalAbsorbance *= densityCoeff; - - // check if you can see through the cloud on the pixel before doing the next iteration - if (totalAbsorbance < 1e-5) break; - } - } - rayPosition += rayDirection; + COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION; + TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0); } - - return vec4(color, totalAbsorbance); } + + return vec4(COLOR, TOTAL_EXTINCTION); +}else{ + #if defined CloudLayer1 && defined CloudLayer0 + float upperLayerOcclusion = layer == 0 ? GetCumulusDensity(1, rayProgress + vec3(0.0,1.0,0.0) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT) : 0.0; + float skylightOcclusion = mix(1.0, (1.0 - LAYER1_DENSITY)*0.8 + 0.2, (1.0 - exp2(-5.0 * (upperLayerOcclusion*upperLayerOcclusion))) * distantfog); + #else + float skylightOcclusion = 1.0; + #endif + + float expFactor = 11.0; + for(int i = 0; i < QUALITY; i++) { + + #ifdef CLOUDS_INTERSECT_TERRAIN + IntersecTerrain = length(rayProgress - cameraPosition) > lViewPosM; + #endif + + /// avoid overdraw + if(notVisible || IntersecTerrain) break; + + // do not sample anything unless within a clouds bounding box + if(clamp(rayProgress.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayProgress.y - minHeight,0.0,1.0) > 0.0){ + + float cumulus = GetCumulusDensity(layer, rayProgress, 1, minHeight, maxHeight); + float fadedDensity = cloudDensity * pow(clamp((rayProgress.y - minHeight)/25,0.0,1.0),2.0); + float CumulusWithDensity = cloudDensity * cumulus; + + + if(CumulusWithDensity > 1e-5 ){ // make sure no work is done on pixels with no densities + float muE = cumulus * fadedDensity; + + float directLight = 0.0; + for (int j=0; j < 3; j++){ + vec3 shadowSamplePos = rayProgress + dV_Sun * (20.0 + j * (20.0 + dither*20.0)); + directLight += GetCumulusDensity(layer, shadowSamplePos, 0, minHeight, maxHeight) * cloudDensity; + } + + /// shadows cast from one layer to another + /// large cumulus -> small cumulus + #if defined CloudLayer1 && defined CloudLayer0 + if(layer == 0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, rayProgress + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT); + #endif + // altostratus -> cumulus + #ifdef CloudLayer2 + vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0); + float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density * (1.0-abs(WsunVec.y)); + directLight += HighAlt_shadow; + #endif + + float skyScatter = clamp(((maxHeight - rayProgress.y) / 100.0),0.0,1.0); // linear gradient from bottom to top of cloud layer + vec3 lighting = DoCloudLighting(CumulusWithDensity, skyLightCol * skylightOcclusion, skyScatter, directLight, sunScatter, sunMultiScatter, distantfog); + + COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION; + TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0); + + if (TOTAL_EXTINCTION < 1e-5) break; + + } + + } + + rayProgress += dV_view; + } + + return vec4(COLOR, TOTAL_EXTINCTION); +} } -vec3 getRayOrigin( - vec3 rayStartPos, +vec3 layerStartingPosition( + vec3 dV_view, vec3 cameraPos, float dither, @@ -352,132 +407,263 @@ vec3 getRayOrigin( float maxHeight ){ // 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)); + float flip = mix(max(cameraPos.y - maxHeight,0.0), max(minHeight - cameraPos.y,0.0), clamp(dV_view.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 = dV_view*dither + cameraPos + (dV_view/abs(dV_view.y)) * flip; return position; } - -vec4 GetVolumetricClouds( - vec3 viewPos, - vec2 dither, - vec3 sunVector, - vec3 directLightCol, - vec3 indirectLightCol +float invLinZ_cloud (float lindepth){ + return -((2.0*near/lindepth)-far-near)/(far-near); +} +vec4 renderClouds( + vec3 FragPosition, + vec2 Dither, + vec3 LightColor, + vec3 SkyColor, + inout vec3 cloudDepth ){ + vec3 SignedWsunvec = WsunVec; + vec3 WsunVec = WsunVec * (float(sunElevation > 1e-5)*2.0-1.0); + #ifndef VOLUMETRIC_CLOUDS return vec4(0.0,0.0,0.0,1.0); #endif + float total_extinction = 1.0; vec3 color = vec3(0.0); - float totalAbsorbance = 1.0; - vec4 cloudColor = vec4(color, totalAbsorbance); - float cloudheight = 100.0; - float minHeight = CloudLayer0_height; - float maxHeight = cloudheight + minHeight; + float heightRelativeToClouds = clamp(1.0 - max(cameraPosition.y - LAYER0_minHEIGHT,0.0) / 100.0 ,0.0,1.0); - float heightRelativeToClouds = clamp(1.0 - max(cameraPosition.y - minHeight,0.0) / 100.0 ,0.0,1.0); +////////////////////////////////////////// +////// Raymarching stuff +////////////////////////////////////////// + //project pixel position into projected shadowmap space + vec4 viewPos = normalize(gbufferModelViewInverse * vec4(FragPosition,1.0) ); + maxIT_clouds = int(clamp(maxIT_clouds / sqrt(exp2(viewPos.y)),0.0, maxIT)); + // maxIT_clouds = 30; - #if defined DISTANT_HORIZONS - float maxdist = dhRenderDistance + 16 * 32; + vec3 dV_view = normalize(viewPos.xyz); + + // this is the cloud curvature. + dV_view.y += 0.025 * heightRelativeToClouds; + + vec3 dV_view_Alto = dV_view; + + dV_view_Alto *= 5.0/abs(dV_view_Alto.y); + float mult_alto = length(dV_view_Alto); + + // dV_view *= (LAYER0_maxHEIGHT - LAYER0_minHEIGHT)/abs(dV_view.y)/maxIT_clouds; + + vec3 dV_viewTEST = dV_view * (90.0/abs(dV_view.y)/maxIT_clouds); + float mult = length(dV_viewTEST); + + + +////////////////////////////////////////// +////// lighting stuff +////////////////////////////////////////// + + vec3 dV_Sun = WsunVec; + #ifdef EXCLUDE_WRITE_TO_LUT + dV_Sun *= lightCol.a; + #endif + + float SdotV = dot(WsunVec, normalize(mat3(gbufferModelViewInverse)*FragPosition + gbufferModelViewInverse[3].xyz)); + + float mieDay = phaseg(SdotV, 0.85) + phaseg(SdotV, 0.75); + float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ; + + vec3 directScattering = LightColor * mieDay * 3.14 ; + vec3 directMultiScattering = LightColor * mieDayMulti * 3.14 * 2.0; + vec3 sunIndirectScattering = LightColor;// * phaseg(dot(mat3(gbufferModelView)*vec3(0,1,0),normalize(FragPosition)), 0.5) * 3.14; + + // use this to blend into the atmosphere's ground. + vec3 approxdistance = normalize(dV_viewTEST); + #ifdef SKY_GROUND + float distantfog = mix(1.0, max(1.0 - clamp(exp2(pow(abs(approxdistance.y),mix(1.5, 4.0, rainStrength)) * -mix(100.0, 35.0, rainStrength)),0.0,1.0),0.0), heightRelativeToClouds); #else - float maxdist = far + 16*5.0; + float distantfog = 1.0; + float distantfog2 = mix(1.0, max(1.0 - clamp(exp(pow(abs(approxdistance.y),1.5) * -35.0),0.0,1.0),0.0), heightRelativeToClouds); + #endif + + // terrible fake rayleigh scattering + vec3 rC = vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5)*3.0; + float atmosphere = exp(abs(approxdistance.y) * -5.0); + vec3 scatter = distantfog * exp(-10000.0 * rC * atmosphere); + + directScattering *= scatter; + directMultiScattering *= scatter; + + SkyColor *= mix(1.0* Sky_Brightness, 1.0-pow(1.0-clamp(SignedWsunvec.y,0.0,1.0),5.0) * 0.75 + 0.25, distantfog); + +////////////////////////////////////////// +////// render Cloud layers and do blending orders +////////////////////////////////////////// + + // first cloud layer + float MinHeight = LAYER0_minHEIGHT; + float MaxHeight = LAYER0_maxHEIGHT; + + float MinHeight1 = LAYER1_minHEIGHT; + float MaxHeight1 = LAYER1_maxHEIGHT; + + float Height2 = LAYER2_HEIGHT; + + // int above_Layer0 = int(clamp(cameraPosition.y - MaxHeight,0.0,1.0)); + int below_Layer0 = int(clamp(MaxHeight - cameraPosition.y,0.0,1.0)); + int above_Layer1 = int(clamp(MaxHeight1 - cameraPosition.y,0.0,1.0)); + bool below_Layer1 = clamp(cameraPosition.y - MinHeight1,0.0,1.0) < 1.0; + bool below_Layer2 = clamp(cameraPosition.y - Height2,0.0,1.0) < 1.0; + // bool layer1_below_layer0 = MinHeight1 < MinHeight; + + bool altoNotVisible = false; + + + #ifdef CloudLayer0 + vec3 layer0_dV_view = dV_view * (LAYER0_width/abs(dV_view.y)/maxIT_clouds); + vec3 layer0_start = layerStartingPosition(layer0_dV_view, cameraPosition, Dither.y, MinHeight, MaxHeight); + #endif - float lViewPosM = length(viewPos) < maxdist ? length(viewPos) - 1.0 : 100000000.0; - vec4 NormPlayerPos = normalize(gbufferModelViewInverse * vec4(viewPos, 1.0) + vec4(gbufferModelViewInverse[3].xyz,0.0)); + #ifdef CloudLayer1 + vec3 layer1_dV_view = dV_view * (LAYER1_width/abs(dV_view.y)/maxIT_clouds); + vec3 layer1_start = layerStartingPosition(layer1_dV_view, cameraPosition, Dither.y, MinHeight1, MaxHeight1); + #endif + #ifdef CloudLayer2 + vec3 layer2_start = layerStartingPosition(dV_view_Alto, cameraPosition, Dither.y, Height2, Height2); + #endif - vec3 signedSunVec = sunVector; - vec3 unignedSunVec = sunVector * (float(sunElevation > 1e-5)*2.0-1.0); - float SdotV = dot(unignedSunVec, NormPlayerPos.xyz); + #ifdef CloudLayer0 + vec4 layer0 = renderLayer(0,dV_view, layer0_start, layer0_dV_view, mult, Dither.x, maxIT_clouds, MinHeight, MaxHeight, dV_Sun, LAYER0_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, false, FragPosition, cloudDepth); + total_extinction *= layer0.a; - NormPlayerPos.y += 0.025*heightRelativeToClouds; + // stop overdraw. + bool notVisible = layer0.a < 1e-5 && below_Layer1; + altoNotVisible = notVisible; + #else + // stop overdraw. + bool notVisible = false; + #endif - int maxSamples = 15; - int minSamples = 10; - int samples = int(clamp(maxSamples / sqrt(exp2(NormPlayerPos.y)),0.0, minSamples)); - // int samples = 30; - - ///------- setup the ray - vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples); - vec3 rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight); - - ///------- do color stuff outside of the raymarcher loop - vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14; - vec3 sunMultiScattering = directLightCol * 0.8;// * (phaseCloud(SdotV, 0.35) + phaseCloud(-SdotV, 0.35) * 0.5) * 6.28; - vec3 skyScattering = indirectLightCol; - - vec3 distanceEstimation = normalize(NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/samples)); + #ifdef CloudLayer1 + vec4 layer1 = renderLayer(1,dV_view, layer1_start, layer1_dV_view, mult, Dither.x, maxIT_clouds, MinHeight1, MaxHeight1, dV_Sun, LAYER1_DENSITY, SkyColor, directScattering, directMultiScattering, sunIndirectScattering, distantfog, notVisible, FragPosition, cloudDepth); + total_extinction *= layer1.a; - // terrible fake rayleigh scattering - // vec3 rC = vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5)*3.0; - // vec3 rayleighScatter = exp(-10000.0 * rC * exp(abs(distanceEstimation.y) * -5.0)); - // sunMultiScattering *= rayleighScatter; - // sunScattering *= rayleighScatter; - - float distanceFade = 1.0 - clamp(exp2(pow(abs(distanceEstimation.y),1.5) * -100.0),0.0,1.0)*heightRelativeToClouds; -// - pow(1.0-clamp(signedSunVec.y,0.0,1.0),5.0) - skyScattering *= mix(1.0, 2.0, distanceFade); - sunScattering *= distanceFade; - sunMultiScattering *= distanceFade; - - ////------- RENDER SMALL CUMULUS CLOUDS - vec4 smallCumulusClouds = cloudColor; - - #ifdef CloudLayer0 - smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM); - #endif - - ////------- RENDER LARGE CUMULUS CLOUDS - vec4 largeCumulusClouds = cloudColor; - - #ifdef CloudLayer1 - cloudheight = 200.0; - minHeight = CloudLayer1_height; - maxHeight = cloudheight + minHeight; - - rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)/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); - #endif - - ////------- RENDER ALTOSTRATUS CLOUDS - vec4 altoStratusClouds = cloudColor; - - #ifdef CloudLayer2 - cloudheight = 5.0; - minHeight = CloudLayer2_height; - maxHeight = cloudheight + minHeight; - - rayDirection = NormPlayerPos.xyz * (cloudheight/abs(NormPlayerPos.y)); - 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); - #endif - - ////------- BLEND LAYERS + // stop overdraw. + altoNotVisible = (layer1.a < 1e-5 || notVisible) && below_Layer1; + #endif #ifdef CloudLayer2 - cloudColor = altoStratusClouds; + vec4 layer2 = renderLayer(2,dV_view,layer2_start, dV_view_Alto, mult_alto, Dither.x, maxIT_clouds, Height2, Height2, dV_Sun, LAYER2_DENSITY, SkyColor, directScattering * (1.0 + rainStrength*3), directMultiScattering* (1.0 + rainStrength*3), sunIndirectScattering, distantfog, altoNotVisible, FragPosition, cloudDepth); + total_extinction *= layer2.a; + #endif + + /// i know this looks confusing + /// it is changing blending order based on the players position relative to the clouds. + /// to keep it simple for myself, it all revolves around layer0, the lowest cloud layer. + /// for layer1, swap between back to front and front to back blending if you are above or below layer0 + /// for layer2, swap between back to front and front to back blending if you are above or below layer1 + + + /// blend the altostratus clouds first, so it is BEHIND all the cumulus clouds, if the player postion is below the cumulus clouds. + /// handle the case if one of the cloud layers is disabled. + #if !defined CloudLayer1 && defined CloudLayer2 + if(below_Layer2) color = color * layer2.a + layer2.rgb; + #endif + #if defined CloudLayer1 && defined CloudLayer2 + if(below_Layer2) layer1.rgb = layer2.rgb * layer1.a + layer1.rgb; + #endif + + /// blend the cumulus clouds together. swap the blending order from (BACK TO FRONT -> FRONT TO BACK) depending on the player position relative to the lowest cloud layer. + #if defined CloudLayer0 && defined CloudLayer1 + color = mix(layer0.rgb, layer1.rgb, float(below_Layer0)); + color = mix(color * layer1.a + layer1.rgb, color * layer0.a + layer0.rgb, float(below_Layer0)); + #endif + + /// handle the case of one of the cloud layers being disabled. + #if defined CloudLayer0 && !defined CloudLayer1 + color = color * layer0.a + layer0.rgb; + #endif + #if !defined CloudLayer0 && defined CloudLayer1 + color = color * layer1.a + layer1.rgb; + #endif + + /// blend the altostratus clouds last, so it is IN FRONT of all the cumulus clouds when the player position is above them. + #ifdef CloudLayer2 + if(!below_Layer2) color = color * layer2.a + layer2.rgb; + #endif + + #ifndef SKY_GROUND + + // return mix(fogcolor, vec4(color, total_extinction), clamp(distantfog2,0.0,1.0)); + return mix(vec4(vec3(0.0),1.0), vec4(color, total_extinction), clamp(distantfog2,0.0,1.0)); + #else + return vec4(color, total_extinction); + #endif + +} + +#endif + +float GetCloudShadow(vec3 feetPlayerPos){ +#ifdef CLOUDS_SHADOWS + vec3 playerPos = feetPlayerPos + cameraPosition; + + float shadow = 0.0; + + // assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud. + #ifdef CloudLayer0 + vec3 lowShadowStart = playerPos + (WsunVec / max(abs(WsunVec.y),0.0)) * max((CloudLayer0_height + 30) - playerPos.y,0.0) ; + shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height, CloudLayer0_height+100)*LAYER0_DENSITY; #endif #ifdef CloudLayer1 - cloudColor.rgb *= largeCumulusClouds.a; - cloudColor.rgb += largeCumulusClouds.rgb; - cloudColor.a *= largeCumulusClouds.a; + vec3 higherShadowStart = playerPos + (WsunVec / max(abs(WsunVec.y),0.0)) * max((CloudLayer1_height + 50) - playerPos.y,0.0) ; + shadow += GetCumulusDensity(1, higherShadowStart, 0, CloudLayer1_height, CloudLayer1_height+100)*LAYER1_DENSITY; #endif - #ifdef CloudLayer0 - cloudColor.rgb *= smallCumulusClouds.a; - cloudColor.rgb += smallCumulusClouds.rgb; - cloudColor.a *= smallCumulusClouds.a; + #ifdef CloudLayer2 + vec3 highShadowStart = playerPos + (WsunVec / max(abs(WsunVec.y),0.0)) * max(CloudLayer2_height - playerPos.y,0.0); + shadow += GetAltostratusDensity(highShadowStart) * CloudLayer2_density * (1.0-abs(WsunVec.y)); #endif - color = cloudColor.rgb; - totalAbsorbance = cloudColor.a; + shadow = clamp(shadow,0.0,1.0); - return vec4(color, totalAbsorbance); + shadow = exp2((shadow*shadow) * -100.0); + + return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH); + +#else + return 1.0; +#endif } -#endif \ No newline at end of file + + +float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){ +#ifdef CLOUDS_SHADOWS + + float shadow = 0.0; + + #ifdef CloudLayer0 + vec3 lowShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer0_height + 30) - WorldPos.y,0.0) ; + shadow += max(GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height, CloudLayer0_height+100),0.0)*LAYER0_DENSITY; + #endif + #ifdef CloudLayer1 + vec3 higherShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer1_height + 30) - WorldPos.y,0.0) ; + shadow += max(GetCumulusDensity(1,higherShadowStart, 0, CloudLayer1_height,CloudLayer1_height+100) ,0.0)*LAYER1_DENSITY; + #endif + #ifdef CloudLayer2 + vec3 highShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max(CloudLayer2_height - WorldPos.y,0.0); + shadow += GetAltostratusDensity(highShadowStart)*LAYER2_DENSITY * (1.0-abs(WorldSpace_sunVec.y)); + #endif + + shadow = clamp(shadow,0.0,1.0); + + shadow = exp((shadow*shadow) * -100.0); + + return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH); + +#else + return 1.0; +#endif +} \ No newline at end of file diff --git a/shaders/shaders.properties b/shaders/shaders.properties index b6da807..23e1316 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -1,7 +1,6 @@ clouds=off stars=false vignette=false - underwaterOverlay=false dynamicHandLight=true oldLighting=false @@ -85,10 +84,7 @@ program.world1/gbuffers_block_translucent.enabled = TRANSLUCENT_ENTITIES && IS_I program.world-1/deferred2.enabled = false #endif -program.world0/composite11.enabled = false -program.world0/composite5.enabled = TAA_UPSCALING -program.world1/composite5.enabled = TAA_UPSCALING -program.world-1/composite5.enabled = TAA_UPSCALING +program.composite5.enabled = TAA_UPSCALING # SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE ZERO # SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE @@ -107,7 +103,7 @@ blend.gbuffers_beaconbeam = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ON blend.gbuffers_entities_translucent = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE blend.gbuffers_spidereyes = ONE ONE ONE ONE blend.gbuffers_skytextured = ONE ONE ONE ZERO -blend.shadow = ONE ZERO ONE ZERO +blend.shadow = SRC_COLOR ZERO ONE ZERO # Disable blending blend.gbuffers_terrain = off @@ -134,7 +130,7 @@ alphaTest.gbuffers_water = false alphaTest.gbuffers_skybasic = false alphaTest.gbuffers_skytextured = false -sliders =VIGNETTE_STRENGTH CURVATURE_AMOUNT MINIMUM_WATER_ABSORBANCE CHROMATIC_ABERRATION_STRENGTH SELECT_BOX_COL_R SELECT_BOX_COL_G SELECT_BOX_COL_B LPV_VL_FOG_ILLUMINATION_BRIGHTNESS minRayMarchSteps MOTION_BLUR_STRENGTH OVERDRAW_MAX_DISTANCE DAY0_l0_coverage DAY0_l1_coverage DAY0_l2_coverage DAY0_ufog_density DAY0_l0_density DAY0_l1_density DAY0_l2_density DAY0_cfog_density DAY1_l0_coverage DAY1_l1_coverage DAY1_l2_coverage DAY1_ufog_density DAY1_l0_density DAY1_l1_density DAY1_l2_density DAY1_cfog_density DAY2_l0_coverage DAY2_l1_coverage DAY2_l2_coverage DAY2_ufog_density DAY2_l0_density DAY2_l1_density DAY2_l2_density DAY2_cfog_density DAY3_l0_coverage DAY3_l1_coverage DAY3_l2_coverage DAY3_ufog_density DAY3_l0_density DAY3_l1_density DAY3_l2_density DAY3_cfog_density DAY4_l0_coverage DAY4_l1_coverage DAY4_l2_coverage DAY4_ufog_density DAY4_l0_density DAY4_l1_density DAY4_l2_density DAY4_cfog_density DAY5_l0_coverage DAY5_l1_coverage DAY5_l2_coverage DAY5_ufog_density DAY5_l0_density DAY5_l1_density DAY5_l2_density DAY5_cfog_density DAY6_l0_coverage DAY6_l1_coverage DAY6_l2_coverage DAY6_ufog_density DAY6_l0_density DAY6_l1_density DAY6_l2_density DAY6_cfog_density DAY7_l0_coverage DAY7_l1_coverage DAY7_l2_coverage DAY7_ufog_density DAY7_l0_density DAY7_l1_density DAY7_l2_density DAY7_cfog_density DAY8_l0_coverage DAY8_l1_coverage DAY8_l2_coverage DAY8_ufog_density DAY8_l0_density DAY8_l1_density DAY8_l2_density DAY8_cfog_density DAY9_l0_coverage DAY9_l1_coverage DAY9_l2_coverage DAY9_ufog_density DAY9_l0_density DAY9_l1_density DAY9_l2_density DAY9_cfog_density sss_density_multiplier sss_absorbance_multiplier MOTION_AMOUNT TONEMAP WATER_WAVE_SPEED WATER_CAUSTICS_BRIGHTNESS DEBUG_VIEW entityShadowDistanceMul HANDHELD_LIGHT_RANGE CLOUD_SHADOW_STRENGTH CloudLayer0_coverage CloudLayer0_density CloudLayer0_height CloudLayer1_coverage CloudLayer1_density CloudLayer1_height CloudLayer2_coverage CloudLayer2_density CloudLayer2_height PLANET_GROUND_BRIGHTNESS FOG_START_HEIGHT WATER_WAVE_STRENGTH SWAMP_UNIFORM_DENSITY SWAMP_CLOUDY_DENSITY SWAMP_R SWAMP_G SWAMP_B JUNGLE_UNIFORM_DENSITY JUNGLE_CLOUDY_DENSITY JUNGLE_R JUNGLE_G JUNGLE_B DARKFOREST_UNIFORM_DENSITY DARKFOREST_CLOUDY_DENSITY DARKFOREST_R DARKFOREST_G DARKFOREST_B NETHER_PLUME_DENSITY END_STORM_DENSTIY LIT_PARTICLE_BRIGHTNESS UPPER_CURVE LOWER_CURVE EMISSIVE_TYPE SCALE_FACTOR ambientsss_brightness SSS_TYPE Cloud_Speed ORB_ColMult ORB_X ORB_Y ORB_Z ORB_R ORB_G ORB_B TOD_Fog_mult Morning_Uniform_Fog Noon_Uniform_Fog Evening_Uniform_Fog Night_Uniform_Fog Morning_Cloudy_Fog Noon_Cloudy_Fog Evening_Cloudy_Fog Night_Cloudy_Fog Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B Rain_coverage Moon_temp Haze_amount RainFog_amount Sun_temp Puddle_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength BLOOMY_FOG WAVY_SPEED WAVY_STRENGTH BLOOM_STRENGTH shadowDistance Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation BLEND_FACTOR VL_SAMPLES Exposure_Speed POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL moon_illuminance moonColorR moonColorG moonColorB fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ fbmAmount fbmPower1 fbmPower2 Roughness_Threshold Sun_specular_Strength reflection_quality DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS DOF_JITTER_FOCUS JITTER_STRENGTH SHADOWS_GRADE_R MIDS_GRADE_R HIGHLIGHTS_GRADE_R SHADOWS_GRADE_G MIDS_GRADE_G HIGHLIGHTS_GRADE_G SHADOWS_GRADE_B MIDS_GRADE_B HIGHLIGHTS_GRADE_B SHADOWS_GRADE_MUL MIDS_GRADE_MUL HIGHLIGHTS_GRADE_MUL LPV_SATURATION LPV_TINT_SATURATION LPV_NORMAL_STRENGTH +sliders = SELECT_BOX_COL_R SELECT_BOX_COL_G SELECT_BOX_COL_B LPV_VL_FOG_ILLUMINATION_BRIGHTNESS minRayMarchSteps MOTION_BLUR_STRENGTH OVERDRAW_MAX_DISTANCE DAY0_l0_coverage DAY0_l1_coverage DAY0_l2_coverage DAY0_ufog_density DAY0_l0_density DAY0_l1_density DAY0_l2_density DAY0_cfog_density DAY1_l0_coverage DAY1_l1_coverage DAY1_l2_coverage DAY1_ufog_density DAY1_l0_density DAY1_l1_density DAY1_l2_density DAY1_cfog_density DAY2_l0_coverage DAY2_l1_coverage DAY2_l2_coverage DAY2_ufog_density DAY2_l0_density DAY2_l1_density DAY2_l2_density DAY2_cfog_density DAY3_l0_coverage DAY3_l1_coverage DAY3_l2_coverage DAY3_ufog_density DAY3_l0_density DAY3_l1_density DAY3_l2_density DAY3_cfog_density DAY4_l0_coverage DAY4_l1_coverage DAY4_l2_coverage DAY4_ufog_density DAY4_l0_density DAY4_l1_density DAY4_l2_density DAY4_cfog_density DAY5_l0_coverage DAY5_l1_coverage DAY5_l2_coverage DAY5_ufog_density DAY5_l0_density DAY5_l1_density DAY5_l2_density DAY5_cfog_density DAY6_l0_coverage DAY6_l1_coverage DAY6_l2_coverage DAY6_ufog_density DAY6_l0_density DAY6_l1_density DAY6_l2_density DAY6_cfog_density DAY7_l0_coverage DAY7_l1_coverage DAY7_l2_coverage DAY7_ufog_density DAY7_l0_density DAY7_l1_density DAY7_l2_density DAY7_cfog_density DAY8_l0_coverage DAY8_l1_coverage DAY8_l2_coverage DAY8_ufog_density DAY8_l0_density DAY8_l1_density DAY8_l2_density DAY8_cfog_density DAY9_l0_coverage DAY9_l1_coverage DAY9_l2_coverage DAY9_ufog_density DAY9_l0_density DAY9_l1_density DAY9_l2_density DAY9_cfog_density sss_density_multiplier sss_absorbance_multiplier MOTION_AMOUNT TONEMAP WATER_WAVE_SPEED WATER_CAUSTICS_BRIGHTNESS DEBUG_VIEW entityShadowDistanceMul HANDHELD_LIGHT_RANGE CLOUD_SHADOW_STRENGTH CloudLayer0_coverage CloudLayer0_density CloudLayer0_height CloudLayer1_coverage CloudLayer1_density CloudLayer1_height CloudLayer2_coverage CloudLayer2_density CloudLayer2_height PLANET_GROUND_BRIGHTNESS FOG_START_HEIGHT WATER_WAVE_STRENGTH SWAMP_UNIFORM_DENSITY SWAMP_CLOUDY_DENSITY SWAMP_R SWAMP_G SWAMP_B JUNGLE_UNIFORM_DENSITY JUNGLE_CLOUDY_DENSITY JUNGLE_R JUNGLE_G JUNGLE_B DARKFOREST_UNIFORM_DENSITY DARKFOREST_CLOUDY_DENSITY DARKFOREST_R DARKFOREST_G DARKFOREST_B NETHER_PLUME_DENSITY END_STORM_DENSTIY LIT_PARTICLE_BRIGHTNESS UPPER_CURVE LOWER_CURVE EMISSIVE_TYPE SCALE_FACTOR ambientsss_brightness SSS_TYPE Cloud_Speed ORB_ColMult ORB_X ORB_Y ORB_Z ORB_R ORB_G ORB_B TOD_Fog_mult Morning_Uniform_Fog Noon_Uniform_Fog Evening_Uniform_Fog Night_Uniform_Fog Morning_Cloudy_Fog Noon_Cloudy_Fog Evening_Cloudy_Fog Night_Cloudy_Fog Summer_Leaf_R Summer_Leaf_G Summer_Leaf_B Fall_Leaf_R Fall_Leaf_G Fall_Leaf_B Winter_Leaf_R Winter_Leaf_G Winter_Leaf_B Spring_Leaf_R Spring_Leaf_G Spring_Leaf_B Summer_R Summer_G Summer_B Fall_R Fall_G Fall_B Winter_R Winter_G Winter_B Spring_R Spring_G Spring_B Season_Length CaveFogFallOff CaveFogColor_R CaveFogColor_G CaveFogColor_B indirect_effect GI_Strength ambient_brightness AmbientLight_R AmbientLight_G AmbientLight_B Rain_coverage Moon_temp Haze_amount RainFog_amount Sun_temp Puddle_Size LabSSS_Curve Emissive_Curve Emissive_Brightness AO_Strength BLOOMY_FOG WAVY_SPEED WAVY_STRENGTH BLOOM_STRENGTH shadowDistance Sky_Brightness fog_coefficientMieR fog_coefficientMieG fog_coefficientMieB sun_illuminance sunColorG sunColorB sunColorR sky_mieg sky_coefficientMieB sky_coefficientMieG sky_coefficientMieR sky_coefficientRayleighB sky_coefficientRayleighG sky_coefficientRayleighR CLOUDS_QUALITY EXPOSURE_MULTIPLIER MIN_LIGHT_AMOUNT TORCH_R TORCH_G TORCH_B TORCH_AMOUNT shadowMapResolution sunPathRotation BLEND_FACTOR VL_SAMPLES Exposure_Speed POM_DEPTH MAX_ITERATIONS MAX_DIST SSR_STEPS ambientOcclusionLevel SEA_LEVEL moon_illuminance moonColorR moonColorG moonColorB fog_coefficientRayleighR fog_coefficientRayleighG SATURATION Manual_exposure_value focal aperture MANUAL_FOCUS SHADOW_FILTER_SAMPLE_COUNT Max_Filter_Depth VPS_Search_Samples Min_Shadow_Filter_Radius Max_Shadow_Filter_Radius Water_Top_Layer fog_coefficientRayleighB SHARPENING rayMarchSampleCount Dirt_Amount Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B Purkinje_strength Purkinje_strength Purkinje_R Purkinje_G Purkinje_B Texture_MipMap_Bias DoF_Adaptation_Speed Purkinje_Multiplier CROSSTALK VL_RENDER_RESOLUTION BLOOM_QUALITY VL_RENDER_RESOLUTION RAY_COUNT STEPS STEP_LENGTH cloud_LevelOfDetail cloud_ShadowLevelOfDetail cloud_LevelOfDetailLQ cloud_ShadowLevelOfDetailLQ minRayMarchSteps maxRayMarchSteps minRayMarchStepsLQ maxRayMarchStepsLQ fbmAmount fbmPower1 fbmPower2 Roughness_Threshold Sun_specular_Strength reflection_quality DOF_QUALITY DOF_ANAMORPHIC_RATIO AEROCHROME_PINKNESS DOF_JITTER_FOCUS JITTER_STRENGTH SHADOWS_GRADE_R MIDS_GRADE_R HIGHLIGHTS_GRADE_R SHADOWS_GRADE_G MIDS_GRADE_G HIGHLIGHTS_GRADE_G SHADOWS_GRADE_B MIDS_GRADE_B HIGHLIGHTS_GRADE_B SHADOWS_GRADE_MUL MIDS_GRADE_MUL HIGHLIGHTS_GRADE_MUL LPV_SATURATION LPV_TINT_SATURATION LPV_NORMAL_STRENGTH screen.columns=2 screen = \ @@ -176,7 +172,7 @@ SHADER_VERSION_LABEL \ screen.Ambient_light = [LPV] [Torch_Colors] [Ambient_Colors] \ MIN_LIGHT_AMOUNT indirect_effect \ \ - AO_Strength AO_in_sunlight GI_Strength \ + AO_Strength GI_Strength \ ambientOcclusionLevel HQ_SSGI \ Hand_Held_lights SKY_CONTRIBUTION_IN_SSRT \ HANDHELD_LIGHT_RANGE UseQuarterResDepth @@ -213,11 +209,11 @@ SHADER_VERSION_LABEL \ LPV_TINT_SATURATION LPV_REDSTONE_LIGHTS \ LPV_NORMAL_STRENGTH LPV_ENTITY_LIGHTS \ LPV_NOSHADOW_HACK \ - LPV_VL_FOG_ILLUMINATION LPV_VL_FOG_ILLUMINATION_BRIGHTNESS VANILLA_LIGHTMAP_MASK + LPV_VL_FOG_ILLUMINATION LPV_VL_FOG_ILLUMINATION_BRIGHTNESS ######## WORLD screen.World.columns=1 - screen.World = [Water] [Waving_Stuff] PLANET_CURVATURE CURVATURE_AMOUNT [Sky_coefficients] SKY_GROUND AEROCHROME_MODE AEROCHROME_PINKNESS AEROCHROME_WOOL_ENABLED + screen.World = [Water] [Waving_Stuff] [Sky_coefficients] SKY_GROUND AEROCHROME_MODE AEROCHROME_PINKNESS AEROCHROME_WOOL_ENABLED ### WAVING STUFF screen.Waving_Stuff.columns=1 screen.Waving_Stuff = WAVY_PLANTS WAVY_STRENGTH WAVY_SPEED @@ -294,23 +290,22 @@ SHADER_VERSION_LABEL \ ### WATER screen.Water.columns=2 - screen.Water = WATER_REFLECTIONS FAKE_REFRACTION_EFFECT \ + screen.Water = WATER_REFLECTIONS Refraction \ WATER_SUN_SPECULAR Vanilla_like_water \ SCREENSPACE_REFLECTIONS SSR_STEPS \ WATER_BACKGROUND_SPECULAR Dirt_Amount \ - MINIMUM_WATER_ABSORBANCE [Water_fog_color] \ - Water_Top_Layer SNELLS_WINDOW \ - WATER_WAVE_STRENGTH WATER_WAVE_SPEED \ + [Water_fog_color] Water_Top_Layer \ + SNELLS_WINDOW WATER_WAVE_STRENGTH WATER_WAVE_SPEED LARGE_WAVE_DISPLACEMENT screen.Water_fog_color.columns=1 screen.Water_fog_color = Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B ######## POST screen.Post_Processing.columns=2 - screen.Post_Processing = [TAA_OPTIONS] [Tonemapping] [Exposure] [DepthOfField] [Purkinje_effect] [COLOR_GRADING] [GAMEPLAY_EFFECTS] CAMERA_GRIDLINES BLOOM_STRENGTH SHARPENING MOTION_BLUR MOTION_BLUR_STRENGTH CHROMATIC_ABERRATION CHROMATIC_ABERRATION_STRENGTH VIGNETTE VIGNETTE_STRENGTH + screen.Post_Processing = [TAA_OPTIONS] [Tonemapping] [Exposure] [DepthOfField] [Purkinje_effect] [COLOR_GRADING] [GAMEPLAY_EFFECTS] SHARPENING BLOOM_STRENGTH CAMERA_GRIDLINES MOTION_BLUR MOTION_BLUR_STRENGTH ### TAA screen.TAA_OPTIONS.columns = 1 - screen.TAA_OPTIONS= SCREENSHOT_MODE TAA RESPONSIVE_TAA BLEND_FACTOR TAA_UPSCALING SCALE_FACTOR + screen.TAA_OPTIONS= SCREENSHOT_MODE TAA BLEND_FACTOR TAA_UPSCALING SCALE_FACTOR ### DOF screen.DepthOfField.columns = 1 screen.DepthOfField = DOF_QUALITY DOF_ANAMORPHIC_RATIO focal aperture MANUAL_FOCUS DoF_Adaptation_Speed FAR_BLUR_ONLY [JITTER_DOF] @@ -345,13 +340,13 @@ SHADER_VERSION_LABEL \ screen.Mod_support = [DISTANT_HORIZONS_SETTINGS] screen.DISTANT_HORIZONS_SETTINGS.columns = 1 - screen.DISTANT_HORIZONS_SETTINGS = DH_OVERDRAW_PREVENTION OVERDRAW_MAX_DISTANCE DH_AMBIENT_OCCLUSION DH_SUBSURFACE_SCATTERING DH_SCREENSPACE_REFLECTIONS DH_NOISE_TEXTURE DISTANT_HORIZONS_SHADOWMAP shadowDistance shadowMapResolution TOGGLE_VL_FOG VOLUMETRIC_CLOUDS + screen.DISTANT_HORIZONS_SETTINGS = DH_OVERDRAW_PREVENTION OVERDRAW_MAX_DISTANCE DH_AMBIENT_OCCLUSION DH_SUBSURFACE_SCATTERING DH_SCREENSPACE_REFLECTIONS DISTANT_HORIZONS_SHADOWMAP shadowDistance shadowMapResolution TOGGLE_VL_FOG VOLUMETRIC_CLOUDS ######## 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.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 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 @@ -459,10 +454,6 @@ uniform.float.noPuddleAreas = smooth(if(in(biome, 3, 4, 16, 37, 39, 48, 49, 31, ############################ ####### RANDOM STUFF ####### ############################ -# force LUT accumulation to have a high blend factor after a certain amount of time -uniform.float.dayChangeSmooth = smooth(if(abs(smooth(worldDay, 0.05, 0.05) - worldDay) > 0.01, 0.0, 1.0), 300.0, 0.0) - -uniform.bool.worldTimeChangeCheck = abs(smooth(sunAngle, 1.0, 1.0) - sunAngle) > 0.01 #if defined WATER_ON_CAMERA_EFFECT uniform.float.exitWater = smooth(if(isEyeInWater == 1,1,0),0.0,5.0) @@ -475,7 +466,7 @@ uniform.bool.worldTimeChangeCheck = abs(smooth(sunAngle, 1.0, 1.0) - sunAngle) uniform.float.threeHeart = smooth(if(Currenthealth <= 6.0 && currentPlayerHealth > -1.0, 1,0), 0.0,1.0) variable.float.interpolatedHealth = smooth(if(is_hurt, 0.0, Currenthealth), 0.0, 1.0) - + # detect over 5 hearts of damage taken variable.bool.largeHealthDifference = (interpolatedHealth - Currenthealth) >= 7.0 variable.bool.delayedCritDamage = smooth(if(largeHealthDifference, 1.0, 0.0), 0.0, 1.0) > 0.01 @@ -515,8 +506,6 @@ 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) - # photon stuff uniform.vec2.view_res = vec2(viewWidth, viewHeight) uniform.vec2.view_pixel_size = vec2(1.0 / viewWidth, 1.0 / viewHeight) @@ -528,28 +517,20 @@ variable.float.texelSizeX = 1.0/viewWidth variable.float.texelSizeY = 1.0/viewHeight uniform.vec2.texelSize = vec2(texelSizeX,texelSizeY) -#if defined RESPONSIVE_TAA - uniform.int.framemod8 = frameCounter%4 -#else - uniform.int.framemod8 = frameCounter%8 -#endif +uniform.int.framemod8 = frameCounter%8 -variable.float.sunPosXSTEUFF = sunPosition.x -variable.float.sunPosYSTEUFF = sunPosition.y -variable.float.sunPosZSTEUFF = sunPosition.z - -variable.float.normSunVec = sqrt(sunPosXSTEUFF*sunPosXSTEUFF+sunPosYSTEUFF*sunPosYSTEUFF+sunPosZSTEUFF*sunPosZSTEUFF) +variable.float.normSunVec = sqrt(sunPosition.x*sunPosition.x+sunPosition.y*sunPosition.y+sunPosition.z*sunPosition.z) variable.float.normUpVec = sqrt(upPosition.x*upPosition.x+upPosition.y*upPosition.y+upPosition.z*upPosition.z) -variable.float.sunPosX = (sunPosition.x/normSunVec) -variable.float.sunPosY = (sunPosition.y/normSunVec) -variable.float.sunPosZ = (sunPosition.z/normSunVec) +variable.float.sunPosX = sunPosition.x/normSunVec +variable.float.sunPosY = sunPosition.y/normSunVec +variable.float.sunPosZ = sunPosition.z/normSunVec uniform.vec3.sunVec=vec3(sunPosX,sunPosY,sunPosZ) -variable.float.upPosX =(upPosition.x)/normUpVec -variable.float.upPosY =(upPosition.y)/normUpVec -variable.float.upPosZ =(upPosition.z)/normUpVec +variable.float.upPosX = upPosition.x/normUpVec +variable.float.upPosY = upPosition.y/normUpVec +variable.float.upPosZ = upPosition.z/normUpVec uniform.vec3.upVec=vec3(upPosX,upPosY,upPosZ) uniform.float.sunElevation = sunPosX*upPosX+sunPosY*upPosY+sunPosZ*upPosZ diff --git a/shaders/world0/dh_generic.fsh b/shaders/world0/dh_generic.fsh deleted file mode 100644 index 51531cb..0000000 --- a/shaders/world0/dh_generic.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 330 compatibility - -#define OVERWORLD_SHADER - -#include "/dimensions/DH_generic.fsh" \ No newline at end of file diff --git a/shaders/world0/dh_generic.vsh b/shaders/world0/dh_generic.vsh deleted file mode 100644 index 32f39b8..0000000 --- a/shaders/world0/dh_generic.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 330 compatibility - -#define OVERWORLD_SHADER - -#include "/dimensions/DH_generic.vsh" \ No newline at end of file diff --git a/shaders/world0/shadow.fsh b/shaders/world0/shadow.fsh index 5a1d6cc..801129d 100644 --- a/shaders/world0/shadow.fsh +++ b/shaders/world0/shadow.fsh @@ -20,16 +20,7 @@ float blueNoise(){ void main() { - - vec4 shadowColor = vec4(texture2D(tex,texcoord.xy).rgb * color.rgb, texture2DLod(tex, texcoord.xy, 0).a); - - #ifdef TRANSLUCENT_COLORED_SHADOWS - if(shadowColor.a > 0.9999) shadowColor.rgb = vec3(0.0); - #endif - - gl_FragData[0] = shadowColor; - - // gl_FragData[0] = vec4(texture2D(tex,texcoord.xy).rgb * color.rgb, texture2DLod(tex, texcoord.xy, 0).a); + gl_FragData[0] = vec4(texture2D(tex,texcoord.xy).rgb * color.rgb, texture2DLod(tex, texcoord.xy, 0).a); #ifdef Stochastic_Transparent_Shadows if(gl_FragData[0].a < blueNoise()) { discard; return;} diff --git a/shaders/world0/shadow.vsh b/shaders/world0/shadow.vsh index 647346b..7c0970e 100644 --- a/shaders/world0/shadow.vsh +++ b/shaders/world0/shadow.vsh @@ -152,8 +152,6 @@ void main() { color = gl_Color; vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - - // playerpos = vec4(0.0); // playerpos = gbufferModelViewInverse * (gl_ModelViewMatrix * gl_Vertex); @@ -204,9 +202,9 @@ void main() { // } // #endif - // #if defined IS_LPV_ENABLED || defined WAVY_PLANTS || !defined PLANET_CURVATURE + #if defined IS_LPV_ENABLED || defined WAVY_PLANTS vec3 playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; - // #endif + #endif #if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store PopulateShadowVoxel(playerpos); @@ -233,7 +231,6 @@ void main() { int blockId = int(mc_Entity.x + 0.5); - vec3 worldpos = playerpos; #ifdef WAVY_PLANTS // also use normal, so up/down facing geometry does not get detatched from its model parts. bool InterpolateFromBase = gl_MultiTexCoord0.t < max(mc_midTexCoord.t, abs(viewToWorld(normalize(gl_NormalMatrix * gl_Normal)).y)); @@ -251,6 +248,7 @@ void main() { ) && length(position.xy) < 24.0 ){ + vec3 worldpos = playerpos; // apply displacement for waving plant blocks worldpos += calcMovePlants(playerpos + cameraPosition) * max(gl_MultiTexCoord1.y,0.5); @@ -258,16 +256,11 @@ void main() { // apply displacement for waving leaf blocks specifically, overwriting the other waving mode. these wave off of the air. they wave uniformly if(blockId == BLOCK_AIR_WAVING) worldpos = playerpos + calcMoveLeaves(playerpos + cameraPosition, 0.0040, 0.0064, 0.0043, 0.0035, 0.0037, 0.0041, vec3(1.0,0.2,1.0), vec3(0.5,0.1,0.5))*gl_MultiTexCoord1.y; + position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz; } #endif - #ifdef PLANET_CURVATURE - float curvature = length(worldpos) / (16*8); - worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; - #endif - - position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz; - + #ifdef DISTORT_SHADOWMAP if (entityId == ENTITY_SSS_MEDIUM || entityId == ENTITY_SLIME) position.xyz = position.xyz - normalize(gl_NormalMatrix * gl_Normal) * 0.25;