From 66a0a97ca776e2a4b93e8e430eadce6199010c81 Mon Sep 17 00:00:00 2001 From: TheRiverwoodModder <125157333+TheRiverwoodModder@users.noreply.github.com> Date: Sun, 29 Sep 2024 18:50:28 -0700 Subject: [PATCH] feat: add raindrop ripples on water --- .../WetnessEffects/WetnessEffects.hlsli | 6 +-- .../textures/water/waterrainripples.dds | Bin 0 -> 1540 bytes package/Shaders/Water.hlsl | 37 +++++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 features/Wetness Effects/textures/water/waterrainripples.dds diff --git a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli index 7e8e17703..e68bf1a17 100644 --- a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli +++ b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli @@ -52,7 +52,7 @@ namespace WetnessEffects } // xyz - ripple normal, w - splotches - float4 GetRainDrops(float3 worldPos, float t, float3 normal) + float4 GetRainDrops(float3 worldPos, float t, float3 normal, float rippleStrengthModifier = 1) { const static float uintToFloat = rcp(4294967295.0); const float rippleBreadthRcp = rcp(wetnessEffectsSettings.RippleBreadth); @@ -110,7 +110,7 @@ namespace WetnessEffects float band_lerp = (sqrt(distSqr) - ripple_inner_radius) * rippleBreadthRcp; if (band_lerp > 0. && band_lerp < 1.) { float deriv = (band_lerp < .5 ? SmoothstepDeriv(band_lerp * 2.) : -SmoothstepDeriv(2. - band_lerp * 2.)) * - lerp(wetnessEffectsSettings.RippleStrength, 0, rippleT * rippleT); + lerp(wetnessEffectsSettings.RippleStrength * rippleStrengthModifier, 0, rippleT * rippleT); float3 grad = float3(normalize(vec2Centre), -deriv); float3 bitangent = float3(-grad.y, grad.x, 0); @@ -140,7 +140,7 @@ namespace WetnessEffects float3 R = reflect(-V, N); float NoV = saturate(dot(N, V)); -#if defined(DYNAMIC_CUBEMAPS) +#if defined(DYNAMIC_CUBEMAPS) && !defined(WATER) # if defined(DEFERRED) float level = roughness * 7.0; float3 specularIrradiance = 1.0; diff --git a/features/Wetness Effects/textures/water/waterrainripples.dds b/features/Wetness Effects/textures/water/waterrainripples.dds new file mode 100644 index 0000000000000000000000000000000000000000..e4aadcc3c524dbdca1c805a6ebc479bfb9b88f92 GIT binary patch literal 1540 zcmZ>930A0KU|?Vu;9^h!(jd&h!oa`?q}V`g5`Y3wEl?|iON5~THf 0 && wetnessEffectsSettings.Raining > 0.0f && wetnessEffectsSettings.EnableRaindropFx && + (rainDropDistance < maxRainDropDistance) && wetnessOcclusion > 0.05) { + float rippleStrengthModifier = (wetnessOcclusion * wetnessOcclusion) * distanceFadeout; + raindropInfo = WetnessEffects::GetRainDrops(input.WPosition + CameraPosAdjust[a_eyeIndex], wetnessEffectsSettings.Time, finalNormal, rippleStrengthModifier); + } + + float3 rippleNormal = normalize(raindropInfo.xyz); + finalNormal = WetnessEffects::ReorientNormal(rippleNormal, finalNormal); +# endif + return finalNormal; }