Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
11 changes: 8 additions & 3 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,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;
Expand Down Expand Up @@ -2706,14 +2706,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);
Expand All @@ -2732,7 +2737,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;
Expand Down