From c2d97ec04568faf5a0c37f598b261d930bd40dfe Mon Sep 17 00:00:00 2001 From: Xonk Date: Sun, 9 Mar 2025 22:36:51 -0400 Subject: [PATCH] improve water waves and underwater fog colors. add support for viveCraft hand with the flashlight/handheld light (more vivecraft support is planned for the future). tweak time of day fog labels. clean a little code. --- shaders/dimensions/DH_solid.fsh | 2 +- shaders/dimensions/DH_translucent.fsh | 2 +- shaders/dimensions/all_particles.fsh | 3 +- shaders/dimensions/all_solid.fsh | 23 +++++- shaders/dimensions/all_translucent.fsh | 42 ++++------ shaders/dimensions/all_translucent.vsh | 2 - shaders/dimensions/composite1.fsh | 12 ++- shaders/dimensions/composite2.fsh | 38 +++++---- shaders/dimensions/composite3.fsh | 2 +- .../dimensions/fogBehindTranslucent_pass.fsh | 2 +- shaders/lang/en_us.lang | 8 +- shaders/lib/TAA_jitter.glsl | 2 +- shaders/lib/diffuse_lighting.glsl | 43 +++++++--- shaders/lib/indirect_lighting_effects.glsl | 2 +- shaders/lib/overworld_fog.glsl | 28 +++++-- shaders/lib/settings.glsl | 6 +- shaders/lib/specular.glsl | 4 +- shaders/lib/waterBump.glsl | 78 ++++++++----------- 18 files changed, 169 insertions(+), 130 deletions(-) diff --git a/shaders/dimensions/DH_solid.fsh b/shaders/dimensions/DH_solid.fsh index a59ea44..53e3dcc 100644 --- a/shaders/dimensions/DH_solid.fsh +++ b/shaders/dimensions/DH_solid.fsh @@ -130,7 +130,7 @@ vec4 applyNoise(in vec4 fragColor, const in vec3 viewPos, const in float viewDis // ideally, close = higher steps and far = lower steps float highestSteps = NOISE_RESOLUTION; float lowestSteps = 2.0; - float transitionLength = 16.0 * 8.0; // distance it takes to reach the lowest steps from the highest. measured in meters/blocks. + float transitionLength = 16.0 * 16.0; // distance it takes to reach the lowest steps from the highest. measured in meters/blocks. float transitionGradient = clamp((length(viewPos - cameraPosition) - (far+32.0)) / transitionLength,0.0,1.0); transitionGradient = sqrt(transitionGradient);// make the gradient appear smoother and less sudden when approaching low steps. diff --git a/shaders/dimensions/DH_translucent.fsh b/shaders/dimensions/DH_translucent.fsh index 22752c3..781df21 100644 --- a/shaders/dimensions/DH_translucent.fsh +++ b/shaders/dimensions/DH_translucent.fsh @@ -300,7 +300,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 bump = normalize(getWaveNormal(waterPos, playerPos, true)); - float bumpmult = 10.0 * WATER_WAVE_STRENGTH; + float bumpmult = WATER_WAVE_STRENGTH; bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index 89475a7..61225a2 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -13,7 +13,6 @@ varying vec4 lmtexcoord; varying vec4 color; -flat varying float exposure; #ifdef LINES flat varying int SELECTION_BOX; @@ -460,7 +459,7 @@ void main() { const vec3 lpvPos = vec3(0.0); #endif - Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos); + Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos); #ifdef LINES gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * toLinear(color.rgb); diff --git a/shaders/dimensions/all_solid.fsh b/shaders/dimensions/all_solid.fsh index a15a697..8e6c103 100644 --- a/shaders/dimensions/all_solid.fsh +++ b/shaders/dimensions/all_solid.fsh @@ -78,6 +78,13 @@ uniform float rainStrength; uniform sampler2D noisetex;//depth uniform sampler2D depthtex0; +#if defined VIVECRAFT + uniform bool vivecraftIsVR; + uniform vec3 vivecraftRelativeMainHandPos; + uniform vec3 vivecraftRelativeOffHandPos; + uniform mat4 vivecraftRelativeMainHandRot; + uniform mat4 vivecraftRelativeOffHandRot; +#endif uniform vec4 entityColor; @@ -350,13 +357,22 @@ void main() { vec3 playerCamPos = cameraPosition; #endif + #ifdef VIVECRAFT + if (vivecraftIsVR) { + playerCamPos = cameraPosition - vivecraftRelativeMainHandPos; + } + #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); + + float pointLight = 1-clamp(1.0-length(worldpos-playerCamPos)/HANDHELD_LIGHT_RANGE,-0.999,1.0); + + torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, pointLight); } + #ifdef HAND - torchlightmap *= 0.9; + // torchlightmap *= 0.9; #endif #endif @@ -428,6 +444,7 @@ void main() { //////////////////////////////// //////////////////////////////// float textureLOD = bias(); vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color; + #if defined HAND if (Albedo.a < 0.1) discard; #endif diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index b55419e..0d19d0c 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -75,10 +75,6 @@ varying vec3 flatnormal; varying vec3 shitnormal; #endif - -flat varying float exposure; - - uniform vec3 sunVec; uniform float near; // uniform float far; @@ -150,6 +146,7 @@ uniform float waterEnteredAltitude; #define FORWARD_BACKGROUND_REFLECTION #define FORWARD_ROUGH_REFLECTION + #ifdef FORWARD_SPECULAR #endif #ifdef FORWARD_ENVIORNMENT_REFLECTION @@ -200,14 +197,16 @@ float blueNoise(){ varying vec3 viewVector; vec3 getParallaxDisplacement(vec3 waterPos, vec3 playerPos) { - float waterHeight = getWaterHeightmap(waterPos.xy) ; - waterHeight = exp(-20*sqrt(waterHeight)); - // waterHeight *= 5.0; + float largeWaves = texture2D(noisetex, waterPos.xy / 600.0 ).b; + float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5); + + float waterHeight = getWaterHeightmap(waterPos.xy, largeWaves, largeWavesCurved); + // waterHeight = exp(-20.0*sqrt(waterHeight)); + waterHeight = exp(-7.0*exp(-7.0*waterHeight)) * 0.25; vec3 parallaxPos = waterPos; parallaxPos.xy += (viewVector.xy / -viewVector.z) * waterHeight; - // parallaxPos.xz -= (viewVector.xy / viewVector.z) * waterHeight; return parallaxPos; } @@ -375,14 +374,13 @@ void convertHandDepth(inout float depth) { ndcDepth /= MC_HAND_DEPTH; depth = ndcDepth * 0.5 + 0.5; } + void Emission( inout vec3 Lighting, vec3 Albedo, - float Emission, - float exposure + float Emission ){ - // 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 + if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); } uniform vec3 eyePosition; @@ -406,7 +404,6 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 viewPos = toScreenSpace(FragCoord*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5, 0.0)); - vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos; //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// MATERIAL MASKS //////////////////////////////// @@ -438,8 +435,6 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) 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; @@ -501,19 +496,16 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 flowDir = normalize(worldSpaceNormal*10.0) * frameTimeCounter * 2.0 * WATER_WAVE_SPEED; - vec2 newPos = playerPos.xy + cameraPosition.xy + abs(flowDir.xz); - newPos = mix(newPos, playerPos.zy + cameraPosition.zy + abs(flowDir.zx), clamp(abs(worldSpaceNormal.x),0,1)); - newPos = mix(newPos, playerPos.xz + cameraPosition.xz, clamp(abs(worldSpaceNormal.y),0,1)); + vec2 newPos = playerPos.xy + cameraPosition.xy + abs(flowDir.xz); + newPos = mix(newPos, playerPos.zy + cameraPosition.zy + abs(flowDir.zx), clamp(abs(worldSpaceNormal.x),0.0,1.0)); + newPos = mix(newPos, playerPos.xz + cameraPosition.xz, clamp(abs(worldSpaceNormal.y),0.0,1.0)); waterPos.xy = newPos; - - // 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; waterPos.xyz = getParallaxDisplacement(waterPos, playerPos); vec3 bump = normalize(getWaveNormal(waterPos, playerPos, false)); - float bumpmult = 10.0 * WATER_WAVE_STRENGTH; + float bumpmult = WATER_WAVE_STRENGTH; bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); NormalTex.xyz = bump; @@ -656,7 +648,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) const vec3 lpvPos = vec3(0.0); #endif - Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, exposure, feetPlayerPos, lpvPos); + Indirect_lighting += doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos); vec4 flashLightSpecularData = vec4(0.0); #ifdef FLASHLIGHT @@ -666,7 +658,7 @@ 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); + Emission(FinalColor, Albedo, SpecularTex.b); #endif //////////////////////////////////////////////////////////////////////////////// @@ -698,7 +690,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) isHand = true; f0 = max(specularValues.g, harcodedF0); #endif - + float roughness = specularValues.r; if(UnchangedAlpha <= 0.0 && !isReflective) f0 = 0.0; diff --git a/shaders/dimensions/all_translucent.vsh b/shaders/dimensions/all_translucent.vsh index c99a077..7743289 100644 --- a/shaders/dimensions/all_translucent.vsh +++ b/shaders/dimensions/all_translucent.vsh @@ -18,7 +18,6 @@ varying vec4 color; uniform sampler2D colortex4; uniform sampler2D noisetex; -flat varying float exposure; #ifdef OVERWORLD_SHADER flat varying vec3 averageSkyCol_Clouds; @@ -200,7 +199,6 @@ void main() { color = vec4(gl_Color.rgb, 1.0); - exposure = texelFetch2D(colortex4,ivec2(10,37),0).r; #ifdef OVERWORLD_SHADER lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index 4d6a3d7..9636d51 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -460,12 +460,9 @@ float SSRT_FlashLight_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, floa void Emission( inout vec3 Lighting, vec3 Albedo, - float Emission, - float exposure + float Emission ){ - // 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 - // if( Emission < 254.5/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve); + if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve)); } #include "/lib/indirect_lighting_effects.glsl" @@ -940,6 +937,7 @@ void main() { #else float minimumAbsorbance = (1.0 - lightLeakFix); #endif + Absorbtion = exp(-totEpsilon * max(Vdiff, minimumAbsorbance)); @@ -1186,7 +1184,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); + vec3 blockLightColor = doBlockLightLighting( vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, feetPlayerPos, lpvPos); Indirect_lighting += blockLightColor; vec4 flashLightSpecularData = vec4(0.0); @@ -1305,7 +1303,7 @@ void main() { vec3 FINAL_COLOR = (Indirect_lighting + Direct_lighting) * albedo; - Emission(FINAL_COLOR, albedo, SpecularTex.a, exposure); + Emission(FINAL_COLOR, albedo, SpecularTex.a); if(lightningBolt) FINAL_COLOR = vec3(77.0, 153.0, 255.0); diff --git a/shaders/dimensions/composite2.fsh b/shaders/dimensions/composite2.fsh index 7efa620..4cc9ca1 100644 --- a/shaders/dimensions/composite2.fsh +++ b/shaders/dimensions/composite2.fsh @@ -33,15 +33,17 @@ 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; +#if defined VIVECRAFT + uniform bool vivecraftIsVR; + uniform vec3 vivecraftRelativeMainHandPos; + uniform vec3 vivecraftRelativeOffHandPos; + uniform mat4 vivecraftRelativeMainHandRot; + uniform mat4 vivecraftRelativeOffHandRot; +#endif + uniform int frameCounter; uniform float frameTimeCounter; @@ -275,16 +277,6 @@ vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, vec3 absorbance = vec3(1.0); vec3 vL = vec3(0.0); - - // float distanceFromWaterSurface = -(normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/(waterEnteredAltitude/2)) * 0.5 + 0.5; - // distanceFromWaterSurface = clamp(distanceFromWaterSurface, 0.0,1.0); - // distanceFromWaterSurface = exp(-7.0*distanceFromWaterSurface*distanceFromWaterSurface); - - // float distanceFromWaterSurface2 = normalize(dVWorld).y + (cameraPosition.y - waterEnteredAltitude)/waterEnteredAltitude; - // distanceFromWaterSurface2 = clamp(-distanceFromWaterSurface2,0.0,1.0); - - // distanceFromWaterSurface2 = exp(-7*pow(distanceFromWaterSurface2,1.5)); - #ifdef OVERWORLD_SHADER float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.1,1.0); @@ -294,6 +286,18 @@ vec4 waterVolumetrics(vec3 rayStart, vec3 rayEnd, float rayLength, vec2 dither, float phase = 0.0; #endif + // float thing = -normalize(dVWorld + (cameraPosition - vec3(cameraPosition.x, waterEnteredAltitude-1.0,cameraPosition.z))).y; + float thing = -normalize(dVWorld).y; + thing = clamp(thing + 0.333,0.0,1.0); + thing = pow(1.0-pow(1.0-thing,2.0),2.0); + + // thing = 1.0; + + // thing = max(exp(-3.0*exp(-3.0*thing)),0.0); + thing *= 15.0; + + thing = 0.0; + float expFactor = 11.0; for (int i=0;i 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){ + if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.y < 1.0){ bouncedLight = texture2D(colortex5, previousPosition.xy).rgb * GI_Strength * CURVE; radiance += bouncedLight; diff --git a/shaders/lib/overworld_fog.glsl b/shaders/lib/overworld_fog.glsl index abde1f1..0e5fee2 100644 --- a/shaders/lib/overworld_fog.glsl +++ b/shaders/lib/overworld_fog.glsl @@ -67,6 +67,7 @@ float phaseCloudFog(float x, float 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 vec3 sunVector, @@ -227,14 +228,31 @@ vec4 GetVolumetricFog( #endif vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz); - vec3 lighting = DirectLight + indirectLight;// * (lightLevelZero*0.99 + 0.01) + Lightning; + vec3 lighting = DirectLight + indirectLight; color += (lighting - lighting * fogVolumeCoeff) * totalAbsorbance; - #if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION - vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0); - vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos; - vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - 0.5, 1e-7); + #if defined FLASHLIGHT && defined FLASHLIGHT_FOG_ILLUMINATION && !defined VL_CLOUDS_DEFERRED + // vec3 shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0); + // vec3 shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos; + vec3 shiftedViewPos; + vec3 shiftedPlayerPos; + float forwardOffset; + + #ifdef VIVECRAFT + if (vivecraftIsVR) { + forwardOffset = 0.0; + shiftedPlayerPos = (progressW - cameraPosition) + ( vivecraftRelativeMainHandPos); + shiftedViewPos = shiftedPlayerPos * mat3(vivecraftRelativeMainHandRot); + } else + #endif + { + forwardOffset = 0.5; + shiftedViewPos = mat3(gbufferModelView)*(progressW-cameraPosition) + vec3(-0.25, 0.2, 0.0); + shiftedPlayerPos = mat3(gbufferModelViewInverse) * shiftedViewPos; + } + + vec2 scaledViewPos = shiftedViewPos.xy / max(-shiftedViewPos.z - forwardOffset, 1e-7); float linearDistance = length(shiftedPlayerPos); float shiftedLinearDistance = length(scaledViewPos); diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 7de7cde..156fae9 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -636,7 +636,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #define FLASHLIGHT_SPECULAR #define FLASHLIGHT_BOUNCED_INDIRECT // #define FLASHLIGHT_FOG_ILLUMINATION -#define FLASHLIGHT_RANGE 32 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 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 60.0 70.0 80.0 90.0 100.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 FLASHLIGHT_RANGE 32 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 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 60.0 70.0 80.0 90.0 100.0 120.0 130.0 140.0 150.0 16.0 170.0 180.0 190.0 200.0 250.0 300.0 350.0 400.0 450.0 500.0 600.0 700.0 800.0 900.0 1000.0 ] #define FLASHLIGHT_SIZE 2.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 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] #define FLASHLIGHT_BRIGHTNESS_MULT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 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 60.0 70.0 80.0 90.0 100.0 ] #define FLASHLIGHT_BRIGHTNESS_FALLOFF_MULT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 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 60.0 70.0 80.0 90.0 100.0 ] @@ -772,7 +772,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #define DH_SCREENSPACE_REFLECTIONS #define DH_TAA_JITTER #define DH_NOISE_TEXTURE -#define NOISE_RESOLUTION 12 // [1 2 3 4 5 6 7 8 12 14 16 24 32 48 64] +#define NOISE_RESOLUTION 16 // [1 2 3 4 5 6 7 8 12 14 16 24 32 48 64] #define NOISE_INTENSITY 12.0 // [1.0 2.0 3.0 4.0 6.0 8.0 10.0 12.0 14.0 16.0 18.0 20.0 22.0 24.0 32.0 48.0 64.0] #define NOISE_DROPOFF 1024 // [128 256 512 768 1024 1536 2048 3072 4096 8192] @@ -827,6 +827,8 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631) #undef TAA #endif // fix settings +#ifdef RESPONSIVE_TAA +#endif #ifdef DH_TAA_JITTER #endif #ifdef DH_SCREENSPACE_REFLECTIONS diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index 0aa8774..0d6a7d0 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -184,7 +184,7 @@ vec4 screenSpaceReflections( // fix UV pos dragging behind due to hand not having a good previous frame position. previousPosition.xy = isHand ? raytracePos.xy : previousPosition.xy; - if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) { + if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.y < 1.0) { reflection.a = 1.0; #ifdef FORWARD_RENDERED_SPECULAR @@ -305,7 +305,7 @@ vec3 specularReflections( // if(isHand){ // f0 = 0.9; - // roughness = 0.0; + // roughness = 0.25; // } bool isMetal = f0 > 229.5/255.0; diff --git a/shaders/lib/waterBump.glsl b/shaders/lib/waterBump.glsl index 4ea9837..46ae365 100644 --- a/shaders/lib/waterBump.glsl +++ b/shaders/lib/waterBump.glsl @@ -3,93 +3,79 @@ float waterCaustics(vec3 worldPos, vec3 sunVec) { vec3 projectedPos = worldPos - (sunVec/sunVec.y*worldPos.y); vec2 pos = projectedPos.xz; - float heightSum = 0.0; - float movement = frameTimeCounter*0.035 * WATER_WAVE_SPEED; - // movement = 0.0; + float movement = frameTimeCounter * 0.035 * WATER_WAVE_SPEED; float radiance = 2.39996; mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); - - vec2 wave_size[3] = vec2[]( + + vec2 wave_size[3] = vec2[]( vec2(48.,12.), vec2(12.,48.), vec2(32.,32.) ); - float WavesLarge = max(texture2D(noisetex, pos / 600.0 ).b,0.1); + float largeWaves = texture2D(noisetex, pos / 600.0 ).b; + float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5); + float heightSum = 0.0; for (int i = 0; i < 3; i++){ pos = rotationMatrix * pos; - heightSum += pow(abs(abs(texture2D(noisetex, pos / wave_size[i] + WavesLarge*0.5 + movement).b * 2.0 - 1.0) * 2.0 - 1.0), 2.0) ; + heightSum += pow(abs(abs(texture2D(noisetex, pos / wave_size[i] + largeWavesCurved * 0.5 + movement).b * 2.0 - 1.0) * 2.0 - 1.0), 1.0+largeWavesCurved) ; } - float FinalCaustics = exp((1.0 + 5.0 * pow(WavesLarge,0.5)) * (heightSum / 3.0 - 0.5)); + return exp((1.0 + 5.0 * sqrt(largeWavesCurved)) * (heightSum / 3.0 - 0.5)); - return FinalCaustics; } -float getWaterHeightmap(vec2 posxz) { - +float getWaterHeightmap(vec2 posxz, in float largeWaves, in float largeWavesCurved) { vec2 pos = posxz; - float heightSum = 0.0; - float movement = frameTimeCounter*0.035 * WATER_WAVE_SPEED; - // movement = 0.0; - + + float movement = frameTimeCounter * 0.035 * WATER_WAVE_SPEED; + float radiance = 2.39996; mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); - vec2 wave_size[3] = vec2[]( + vec2 wave_size[3] = vec2[]( vec2(48.,12.), vec2(12.,48.), vec2(32.,32.) ); - float WavesLarge = max(texture2D(noisetex, pos / 600.0 ).b,0.1); + float heightSum = 0.0; for (int i = 0; i < 3; i++){ + pos = rotationMatrix * pos; - heightSum += texture2D(noisetex, pos / wave_size[i] + WavesLarge*0.5 + movement).b; + heightSum += texture2D(noisetex, pos / wave_size[i] + largeWavesCurved * 0.5 + movement).b; } - return (heightSum / 60.0) * WavesLarge; + return (heightSum/4.5) * max(largeWavesCurved,0.3); } vec3 getWaveNormal(vec3 waterPos, vec3 playerpos, bool isLOD){ - - // vary the normal's "smooth" factor as distance changes, to avoid noise from too much details. - // float range = pow(clamp(1.0 - length(posxz - cameraPosition)/(32*4),0.0,1.0),2.0); - // float deltaPos = mix(0.5, 0.1, range); - float range = min(length(playerpos) / (16*12.0), 3.0) ; - float deltaPos = range + 0.15; - - // float range = 1-max(1.0-length(playerpos) / (16.0*16.0) ,0.0) ; - // range = (1.0-pow(1.0-pow(range,2.0),2.0)) * 3.0; - // float deltaPos = range + 0.15; - - // float normalMult = 1.0 * WATER_WAVE_STRENGTH; - - // if(isLOD){ - // deltaPos = mix(0.9, deltaPos, range); - // } - // added detail for snells window - // if(isEyeInWater == 1) deltaPos = 0.025; - + float largeWaves = texture2D(noisetex, waterPos.xy / 600.0 ).b; + float largeWavesCurved = pow(1.0-pow(1.0-largeWaves,2.5),4.5); + #ifdef HYPER_DETAILED_WAVES - deltaPos = 0.025; + float deltaPos = mix(1.0, 0.05, largeWavesCurved); + #else + float deltaPos = mix(1.0, 0.15, largeWavesCurved); + // reduce high frequency detail as distance increases. reduces noise on waves. why have more details than pixels? + float range = min(length(playerpos) / (16.0*24.0), 3.0); + deltaPos += range; #endif - + vec2 coord = waterPos.xy; - float h0 = getWaterHeightmap(coord); - float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0)); - float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos)); - + float h0 = getWaterHeightmap(coord, largeWaves, largeWavesCurved); + float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0), largeWaves,largeWavesCurved); + float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos), largeWaves,largeWavesCurved); float xDelta = (h1-h0)/deltaPos; float yDelta = (h3-h0)/deltaPos; - vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0))); + vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0))); return wave; -} \ No newline at end of file +}