From 1de1676467687a68d8025b2fff2d31e09b8a84fd Mon Sep 17 00:00:00 2001 From: Exist Date: Thu, 13 Feb 2025 20:16:11 +0100 Subject: [PATCH 1/2] pbr wetness consistent, overall less wet --- .../Shaders/WetnessEffects/WetnessEffects.hlsli | 3 +-- package/Shaders/Lighting.hlsl | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli index b0a77c6331..4c2c2cd17c 100644 --- a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli +++ b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli @@ -166,7 +166,6 @@ namespace WetnessEffects float3 GetWetnessSpecular(float3 N, float3 L, float3 V, float3 lightColor, float roughness) { - lightColor *= 0.01; - return LightingFuncGGX_OPT3(N, V, L, roughness, 1.0 - roughness) * lightColor; + return LightingFuncGGX_OPT3(N, V, L, roughness, 0.02) * lightColor; } } diff --git a/package/Shaders/Lighting.hlsl b/package/Shaders/Lighting.hlsl index bca918c195..ef03f80a55 100644 --- a/package/Shaders/Lighting.hlsl +++ b/package/Shaders/Lighting.hlsl @@ -1866,6 +1866,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace } puddle *= nearFactor; + puddle *= saturate(dot(worldSpaceNormal, float3(0, 0, 1))); float3 wetnessSpecular = 0.0; @@ -2415,7 +2416,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace baseColor.xyz = lerp(baseColor.xyz, pow(baseColor.xyz, 1.0 + wetnessDarkeningAmount), 0.8); # endif - float3 wetnessReflectance = WetnessEffects::GetWetnessAmbientSpecular(screenUV, wetnessNormal, worldSpaceVertexNormal, worldSpaceViewDirection, 1.0 - wetnessGlossinessSpecular) * wetnessGlossinessSpecular; + float3 wetnessReflectance = WetnessEffects::GetWetnessAmbientSpecular(screenUV, wetnessNormal, worldSpaceVertexNormal, worldSpaceViewDirection, waterRoughnessSpecular) * wetnessGlossinessSpecular; # if !defined(DEFERRED) wetnessSpecular += wetnessReflectance; @@ -2706,14 +2707,19 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace # endif psout.Albedo = float4(outputAlbedo, psout.Diffuse.w); + const float wetnessGlossinessGain = 0.65; float outGlossiness = saturate(glossiness * SSRParams.w); # if defined(TRUE_PBR) psout.Reflectance = float4(indirectSpecularLobeWeight, psout.Diffuse.w); +# if defined(WETNESS_EFFECTS) + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(pbrGlossiness, saturate(pbrGlossiness + wetnessGlossinessGain), wetnessGlossinessSpecular), psout.Diffuse.w); +# else psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), pbrGlossiness, psout.Diffuse.w); +# endif # elif defined(WETNESS_EFFECTS) psout.Reflectance = float4(wetnessReflectance, psout.Diffuse.w); - psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, 1.0, wetnessGlossinessSpecular), psout.Diffuse.w); + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, saturate(outGlossiness + wetnessGlossinessGain), wetnessGlossinessSpecular), psout.Diffuse.w); # else psout.Reflectance = float4(0.0.xxx, psout.Diffuse.w); psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), outGlossiness, psout.Diffuse.w); @@ -2732,7 +2738,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace if (dynamicCubemap) { # if defined(WETNESS_EFFECTS) psout.Reflectance.xyz = max(envColor, wetnessReflectance); - psout.NormalGlossiness.z = lerp(1.0 - envRoughness, 1.0, wetnessGlossinessSpecular); + psout.NormalGlossiness.z = lerp(1.0 - envRoughness, saturate(1.0 - envRoughness + wetnessGlossinessGain), wetnessGlossinessSpecular); # else psout.Reflectance.xyz = envColor; psout.NormalGlossiness.z = 1.0 - envRoughness; From af63c239e36720de6b74ff0970005c004b3f36a0 Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Sun, 16 Feb 2025 15:02:57 +0000 Subject: [PATCH 2/2] chore: remove bad line --- package/Shaders/Lighting.hlsl | 1 - 1 file changed, 1 deletion(-) diff --git a/package/Shaders/Lighting.hlsl b/package/Shaders/Lighting.hlsl index ef03f80a55..34f728bb88 100644 --- a/package/Shaders/Lighting.hlsl +++ b/package/Shaders/Lighting.hlsl @@ -1866,7 +1866,6 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace } puddle *= nearFactor; - puddle *= saturate(dot(worldSpaceNormal, float3(0, 0, 1))); float3 wetnessSpecular = 0.0;