Skip to content

Commit

Permalink
feat: add raindrop effects, splashes and ripples to rain wetness (doo…
Browse files Browse the repository at this point in the history
…dlum#176)

* feat: wetness + rain splotches

* feat: ripples

* feat: rain minor turbulence

* chores: added raindrop settings

* fix: use paused game time; def parameter tweak

* Update CommonLibSSE-NG

* chore: add chaotic ripple strength, correct normal reorient

* feat: add rain occlusion

* feat: add toggle for all raindrop fx

* feat: add splashes strength option

* fix: nullptr dereference of proj matrix, duplicate copyresource

* chore: shift raindrop UV by normal

* fix: regression in wetness fadeout

* chore: increased wetness light intensity

* chore: cull dynamic cubemaps by distance

* feat: wetness + rain splotches

* feat: ripples

* feat: rain minor turbulence

* chores: added raindrop settings

* fix: use paused game time; def parameter tweak

* chore: add chaotic ripple strength, correct normal reorient

* feat: add rain occlusion

* feat: add toggle for all raindrop fx

* feat: add splashes strength option

* fix: nullptr dereference of proj matrix, duplicate copyresource

* chore: shift raindrop UV by normal

* fix: regression in wetness fadeout

* chore: increased wetness light intensity

* fix: splash cutoff, camelCase, grammar error, default settings

* fix: added fade in / fade out logic for raindrop fx

* chore: move density calculation out of shader

* chore: reduce SSS range

* feat: only use envbrdrf appoximation

* chore: SSS depth attenuation curve

* chore: cleanup and fix timers

* style: 🎨 apply clang-format changes

---------

Co-authored-by: doodlum <[email protected]>
Co-authored-by: TheRiverwoodModder <[email protected]>
Co-authored-by: Pentalimbed <[email protected]>
  • Loading branch information
4 people authored Mar 12, 2024
1 parent c68a3bf commit 16ed418
Show file tree
Hide file tree
Showing 12 changed files with 440 additions and 254 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
TextureCube<float4> specularTexture : register(t64);
Texture2D<float4> specularBRDF_LUT : register(t65);

#if !defined(VR)
Texture2D<float4> ssrTexture : register(t66);
Texture2D<float4> ssrRawTexture : register(t67);
#endif
// https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile
float2 EnvBRDFApprox(float3 F0, float Roughness, float NoV)
{
const float4 c0 = { -1, -0.0275, -0.572, 0.022 };
const float4 c1 = { 1, 0.0425, 1.04, -0.04 };
float4 r = Roughness * c0 + c1;
float a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;
float2 AB = float2(-1.04, 1.04) * a004 + r.zw;
return AB;
}

#if !defined(WATER)
float3 GetDynamicCubemap(float2 uv, float3 N, float3 V, float roughness, float3 F0, float complexMaterial)
float3 GetDynamicCubemap(float2 uv, float3 N, float3 VN, float3 V, float roughness, float3 F0, float complexMaterial)
{
float3 R = reflect(-V, N);
float NoV = saturate(dot(N, V));

float level = roughness * 9.0;

float3 specularIrradiance = specularTexture.SampleLevel(SampColorSampler, R, level);

# if defined(DYNAMIC_CUBEMAPS) && !defined(VR)
// if (!FrameParams.z && FrameParams.y){
// float4 ssrBlurred = ssrTexture.SampleLevel(SampColorSampler, uv, 0);
// float4 ssrRaw = ssrRawTexture.SampleLevel(SampColorSampler, uv, 0);
// float4 ssrTexture = lerp(ssrRaw, ssrBlurred, sqrt(roughness));
// specularIrradiance = sRGB2Lin(lerp(specularIrradiance, ssrTexture.rgb, ssrTexture.a));
// } else {
specularIrradiance = sRGB2Lin(specularIrradiance);
//}
# else
specularIrradiance = sRGB2Lin(specularIrradiance);
# endif

F0 = sRGB2Lin(F0);

// Split-sum approximation factors for Cook-Torrance specular BRDF.
float2 specularBRDF = specularBRDF_LUT.SampleLevel(SampColorSampler, float2(NoV, roughness), 0);
float2 specularBRDF = EnvBRDFApprox(F0, roughness, NoV);

// Horizon specular occlusion
float horizon = min(1.0 + dot(R, N), 1.0);
// https://marmosetco.tumblr.com/post/81245981087
float horizon = min(1.0 + dot(R, VN), 1.0);
specularIrradiance *= horizon * horizon;

// Roughness dependent fresnel
// https://www.jcgt.org/published/0008/01/03/paper.pdf
float3 Fr = max(1.0.xxx - roughness.xxx, F0) - F0;
float3 S = Fr * pow(1.0 - NoV, 5.0);

return lerp(specularIrradiance * F0, specularIrradiance * ((F0 + S) * specularBRDF.x + specularBRDF.y), false);
return lerp(specularIrradiance * F0, specularIrradiance * ((F0 * S) * specularBRDF.x + specularBRDF.y), complexMaterial);
}
#endif
110 changes: 0 additions & 110 deletions features/Dynamic Cubemaps/Shaders/DynamicCubemaps/SpbrdfCS.hlsl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ float smoothbumpstep(float edge0, float edge1, float x)

position.w = smoothstep(1.0, 4096.0 * 0.001, distance); // Objects which are far away from the perspective of the camera do not fade out

if (depth > 0.999)
if (linearDepth > (4096.0 * 5.0))
position.w = 0;

DynamicCubemapPosition[ThreadID] = lerp(DynamicCubemapPosition[ThreadID], position, lerpFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ float4 SSSSBlurCS(
depth = GetScreenDepth(depth);

// If the difference in depth is huge, we lerp color back to "colorM":
float s = saturate(profile.y * (1.0 / 3.0) * distanceToProjectionWindow * abs(depthM - depth));
color = lerp(color, colorM.rgb, s);
float s = saturate(profile.y * distanceToProjectionWindow * abs(depthM - depth));
color = lerp(color, colorM.rgb, s * s);

// Accumulate:
colorBlurred.rgb += Kernels[i].rgb * color.rgb;
Expand Down
Loading

0 comments on commit 16ed418

Please sign in to comment.