diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli index f870e1ca50..fcc779d4d3 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli @@ -37,6 +37,8 @@ namespace DynamicCubemaps float3 finalIrradiance = 0; + float directionalAmbientColorSpecular = Color::RGBToLuminance(max(0, mul(SharedData::DirectionalAmbient, float4(R, 1.0))) * Color::ReflectionNormalisationScale); + # if defined(IBL) && defined(LIGHTING) const bool inWorld = (Permutation::ExtraShaderDescriptor & Permutation::ExtraFlags::InWorld); const bool inReflection = (Permutation::ExtraShaderDescriptor & Permutation::ExtraFlags::InReflection); @@ -51,6 +53,10 @@ namespace DynamicCubemaps if (SharedData::InInterior) { float3 specularIrradiance = Color::GammaToLinear(EnvTexture.SampleLevel(SampColorSampler, R, level).xyz); + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvTexture.SampleLevel(SampColorSampler, R, 15).xyz)); + + specularIrradiance = (specularIrradiance / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + finalIrradiance += specularIrradiance; return finalIrradiance; } @@ -60,20 +66,36 @@ namespace DynamicCubemaps float skylightingSpecular = SphericalHarmonics::FuncProductIntegral(skylighting, specularLobe); skylightingSpecular = Skylighting::mixSpecular(SharedData::skylightingSettings, skylightingSpecular); + directionalAmbientColorSpecular *= skylightingSpecular; + float3 specularIrradiance = 1; - if (skylightingSpecular < 1.0) + if (skylightingSpecular < 1.0){ specularIrradiance = Color::GammaToLinear(EnvTexture.SampleLevel(SampColorSampler, R, level).xyz); + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvTexture.SampleLevel(SampColorSampler, R, 15).xyz)); + + specularIrradiance = (specularIrradiance / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + } + float3 specularIrradianceReflections = 1.0; - if (skylightingSpecular > 0.0) + if (skylightingSpecular > 0.0){ specularIrradianceReflections = Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz); + float specularIrradianceReflectionsLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(SampColorSampler, R, 15).xyz)); + + specularIrradianceReflections = (specularIrradianceReflections / max(specularIrradianceReflectionsLuminance, 0.001)) * directionalAmbientColorSpecular; + } + finalIrradiance = lerp(specularIrradiance, specularIrradianceReflections, skylightingSpecular); # else float3 specularIrradiance = Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz); + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvTexture.SampleLevel(SampColorSampler, R, 15).xyz)); + + specularIrradiance = (specularIrradiance / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + finalIrradiance += specularIrradiance; # endif return finalIrradiance; diff --git a/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini b/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini index 13720e22c7..d74feebe30 100644 --- a/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini +++ b/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini @@ -1,2 +1,2 @@ [Info] -Version = 2-2-0 \ No newline at end of file +Version = 2-2-1 \ No newline at end of file diff --git a/features/Skylighting/Shaders/Features/Skylighting.ini b/features/Skylighting/Shaders/Features/Skylighting.ini index 7c4d5a2a34..c9108f73db 100644 --- a/features/Skylighting/Shaders/Features/Skylighting.ini +++ b/features/Skylighting/Shaders/Features/Skylighting.ini @@ -1,2 +1,2 @@ [Info] -Version = 1-2-0 \ No newline at end of file +Version = 1-2-1 \ No newline at end of file diff --git a/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli b/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli index fdffde5e47..0ae3be0eb5 100644 --- a/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli +++ b/features/Skylighting/Shaders/Skylighting/Skylighting.hlsli @@ -36,7 +36,7 @@ namespace Skylighting } #if defined(PSHADER) - void applySkylighting(inout float3 diffuseColor, inout float3 directionalAmbientColor, float skylightingDiffuse) + void applySkylighting(inout float3 diffuseColor, inout float3 directionalAmbientColor, float3 albedo, float skylightingDiffuse) { float maxScale = 1.0; if (directionalAmbientColor.x > 0.0) @@ -49,7 +49,7 @@ namespace Skylighting diffuseColor = max(0.0, diffuseColor - directionalAmbientColor); - directionalAmbientColor = Color::LinearToGamma(Color::GammaToLinear(directionalAmbientColor) * skylightingDiffuse); + directionalAmbientColor = Color::LinearToGamma(Color::GammaToLinear(directionalAmbientColor) * Color::MultiBounceAO(Color::GammaToLinear(albedo / Color::PBRLightingScale), skylightingDiffuse)); diffuseColor += directionalAmbientColor; } @@ -158,4 +158,4 @@ namespace Skylighting } } -#endif \ No newline at end of file +#endif diff --git a/package/Shaders/Common/Color.hlsli b/package/Shaders/Common/Color.hlsli index 8be9da9954..6b74bb92ee 100644 --- a/package/Shaders/Common/Color.hlsli +++ b/package/Shaders/Common/Color.hlsli @@ -7,6 +7,21 @@ namespace Color { static float GammaCorrectionValue = 2.2; + // [Jimenez et al. 2016, "Practical Realtime Strategies for Accurate Indirect Occlusion"] + float3 MultiBounceAO(float3 baseColor, float ao) + { + float3 a = 2.0404 * baseColor - 0.3324; + float3 b = -4.7951 * baseColor + 0.6417; + float3 c = 2.7552 * baseColor + 0.6903; + return max(ao, ((ao * a + b) * ao + c) * ao); + } + + // [Lagarde et al. 2014, "Moving Frostbite to Physically Based Rendering 3.0"] + float SpecularAOLagarde(float NdotV, float ao, float roughness) + { + return saturate(pow(abs(NdotV + ao), exp2(-16.0 * roughness - 1.0)) - 1.0 + ao); + } + float RGBToLuminance(float3 color) { return dot(color, float3(0.2125, 0.7154, 0.0721)); @@ -50,17 +65,20 @@ namespace Color return color; } - // Attempt to match vanilla materials tha are a darker than PBR + // Attempt to match vanilla materials that are darker than PBR const static float PBRLightingScale = 0.666; + // Attempt to normalise reflection brightness against DALC + const static float ReflectionNormalisationScale = 0.666; + float3 GammaToLinear(float3 color) { - return pow(abs(color), 1.8); + return pow(abs(color), 1.6); } float3 LinearToGamma(float3 color) { - return pow(abs(color), 1.0 / 1.8); + return pow(abs(color), 1.0 / 1.6); } float3 GammaToTrueLinear(float3 color) @@ -76,7 +94,7 @@ namespace Color float3 Diffuse(float3 color) { #if defined(TRUE_PBR) - return LinearToGamma(color); + return TrueLinearToGamma(color); #else return color; #endif diff --git a/package/Shaders/Common/PBR.hlsli b/package/Shaders/Common/PBR.hlsli index 2cf32894a7..568e8310fb 100644 --- a/package/Shaders/Common/PBR.hlsli +++ b/package/Shaders/Common/PBR.hlsli @@ -147,21 +147,6 @@ namespace PBR return result; } - // [Jimenez et al. 2016, "Practical Realtime Strategies for Accurate Indirect Occlusion"] - float3 MultiBounceAO(float3 baseColor, float ao) - { - float3 a = 2.0404 * baseColor - 0.3324; - float3 b = -4.7951 * baseColor + 0.6417; - float3 c = 2.7552 * baseColor + 0.6903; - return max(ao, ((ao * a + b) * ao + c) * ao); - } - - // [Lagarde et al. 2014, "Moving Frostbite to Physically Based Rendering 3.0"] - float SpecularAOLagarde(float NdotV, float ao, float roughness) - { - return saturate(pow(abs(NdotV + ao), exp2(-16.0 * roughness - 1.0)) - 1.0 + ao); - } - #if defined(GLINT) float3 GetSpecularDirectLightMultiplierMicrofacetWithGlint(float noise, float roughness, float3 specularColor, float NdotL, float NdotV, float NdotH, float VdotH, float glintH, float logDensity, float microfacetRoughness, float densityRandomization, Glints::GlintCachedVars glintCache, @@ -481,12 +466,12 @@ namespace PBR specularLobeWeight *= horizon; float3 diffuseAO = surfaceProperties.AO; - float3 specularAO = SpecularAOLagarde(NdotV, surfaceProperties.AO, surfaceProperties.Roughness); + float3 specularAO = Color::SpecularAOLagarde(NdotV, surfaceProperties.AO, surfaceProperties.Roughness); - diffuseAO = MultiBounceAO(diffuseColor, diffuseAO.x).y; - specularAO = MultiBounceAO(surfaceProperties.F0, specularAO.x).y; + diffuseAO = Color::MultiBounceAO(diffuseColor, diffuseAO.x).y; + specularAO = Color::MultiBounceAO(surfaceProperties.F0, specularAO.x).y; - diffuseLobeWeight *= diffuseAO * Color::PBRLightingScale; + diffuseLobeWeight *= diffuseAO; specularLobeWeight *= specularAO; } diff --git a/package/Shaders/DeferredCompositeCS.hlsl b/package/Shaders/DeferredCompositeCS.hlsl index 05c6c8ce03..86d6bc91da 100644 --- a/package/Shaders/DeferredCompositeCS.hlsl +++ b/package/Shaders/DeferredCompositeCS.hlsl @@ -50,21 +50,15 @@ void SampleSSGI(uint2 pixCoord, float3 normalWS, out float ao, out float3 il) il = max(0, Color::YCoCgToRGB(float3(ssgiIlY, ssgiIlCoCg))); } -void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, in float3 normal, in float3 view) +void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, in float3 normal, in float3 view, in float roughness) { - // https://www.iryoku.com/stare-into-the-future/ ao = 1 - SsgiAoTexture[pixCoord].x; - const float SpecularPow = 8.0; float NdotV = dot(normal, view); - float s = saturate(-0.3 + NdotV * NdotV); - ao = lerp(pow(ao, SpecularPow), 1.0, s); + ao = Color::SpecularAOLagarde(saturate(NdotV), ao, roughness); float4 ssgiIlYSh = SsgiYTexture[pixCoord]; float ssgiIlY = SphericalHarmonics::FuncProductIntegral(ssgiIlYSh, lobe); float2 ssgiIlCoCg = SsgiCoCgTexture[pixCoord].xy; - // specular is a bit too saturated, because CoCg are average over hemisphere - // we just cheese this bit - ssgiIlCoCg *= 0.8; // pi to compensate for the /pi in specularLobe // i don't think there really should be a 1/PI but without it the specular is too strong @@ -152,18 +146,20 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, i diffuseColor = max(0.0, diffuseColor - directionalAmbientColor); linDiffuseColor = Color::GammaToLinear(diffuseColor); -# if defined(INTERIOR) - linDiffuseColor *= ssgiAo; -# else - linDiffuseColor *= sqrt(ssgiAo); -# endif + + float3 linAlbedo = Color::GammaToLinear(albedo / Color::PBRLightingScale); + + float3 multiBounceAO = Color::MultiBounceAO(linAlbedo, ssgiAo); + + linDiffuseColor *= sqrt(multiBounceAO); + diffuseColor = Color::LinearToGamma(linDiffuseColor); - diffuseColor += Color::LinearToGamma(Color::GammaToLinear(directionalAmbientColor) * ssgiAo); + diffuseColor += Color::LinearToGamma(Color::GammaToLinear(directionalAmbientColor) * multiBounceAO); linDiffuseColor = Color::GammaToLinear(diffuseColor); - linDiffuseColor += ssgiIl * Color::GammaToLinear(albedo); + linDiffuseColor += ssgiIl * linAlbedo; #endif float3 color = linDiffuseColor + specularColor; @@ -183,10 +179,18 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, i float3 finalIrradiance = 0; + float directionalAmbientColorSpecular = Color::RGBToLuminance( + Color::GammaToLinear(max(0, mul(SharedData::DirectionalAmbient, float4(R, 1.0)))) + * Color::ReflectionNormalisationScale + ); # if defined(INTERIOR) float3 specularIrradiance = Color::GammaToLinear(EnvTexture.SampleLevel(LinearSampler, R, level)); - finalIrradiance += specularIrradiance; + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvTexture.SampleLevel(LinearSampler, R, 15))); + + specularIrradiance = (specularIrradiance / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + + finalIrradiance += specularIrradiance; # elif defined(SKYLIGHTING) # if defined(VR) float3 positionMS = positionWS.xyz + FrameBuffer::CameraPosAdjust[eyeIndex].xyz - FrameBuffer::CameraPosAdjust[0].xyz; @@ -199,20 +203,36 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, i float skylightingSpecular = SphericalHarmonics::FuncProductIntegral(skylighting, specularLobe); skylightingSpecular = Skylighting::mixSpecular(SharedData::skylightingSettings, skylightingSpecular); + directionalAmbientColorSpecular *= skylightingSpecular; + float3 specularIrradiance = 1; - if (skylightingSpecular < 1.0) + if (skylightingSpecular < 1.0){ specularIrradiance = Color::GammaToLinear(EnvTexture.SampleLevel(LinearSampler, R, level)); + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvTexture.SampleLevel(LinearSampler, R, 15))); + + specularIrradiance = (specularIrradiance / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + } + float3 specularIrradianceReflections = 1.0; - if (skylightingSpecular > 0.0) + if (skylightingSpecular > 0.0){ specularIrradianceReflections = Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(LinearSampler, R, level)); + float specularIrradianceLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(LinearSampler, R, 15))); + + specularIrradianceReflections = (specularIrradianceReflections / max(specularIrradianceLuminance, 0.001)) * directionalAmbientColorSpecular; + } + finalIrradiance = lerp(specularIrradiance, specularIrradianceReflections, skylightingSpecular); # else float3 specularIrradianceReflections = Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(LinearSampler, R, level)); + float specularIrradianceReflectionsLuminance = Color::RGBToLuminance(Color::GammaToLinear(EnvReflectionsTexture.SampleLevel(LinearSampler, R, 15))); + + specularIrradianceReflections = (specularIrradianceReflections / max(specularIrradianceReflectionsLuminance, 0.001)) * directionalAmbientColorSpecular; + finalIrradiance += specularIrradianceReflections; # endif @@ -227,18 +247,23 @@ void SampleSSGISpecular(uint2 pixCoord, sh2 lobe, out float ao, out float3 il, i float ssgiAo; float3 ssgiIlSpecular; - SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiAo, ssgiIlSpecular, normalWS, V); + SampleSSGISpecular(dispatchID.xy, specularLobe, ssgiAo, ssgiIlSpecular, normalWS, V, roughness); # if defined(VR) float ssgiAo2; float3 ssgiIlSpecular2; - SampleSSGISpecular(pixCoord2, specularLobe, ssgiAo2, ssgiIlSpecular2, normalWS, V); + SampleSSGISpecular(pixCoord2, specularLobe, ssgiAo2, ssgiIlSpecular2, normalWS, V, roughness); float4 ssgiMixed = Stereo::BlendEyeColors(uv1Mono, float4(ssgiIlSpecular, ssgiAo), uv2Mono, float4(ssgiIlSpecular2, ssgiAo2)); ssgiAo = ssgiMixed.a; ssgiIlSpecular = ssgiMixed.rgb; # endif - finalIrradiance = (finalIrradiance * ssgiAo) + ssgiIlSpecular; + finalIrradiance = (finalIrradiance * ssgiAo); + + ssgiIlSpecular = Color::RGBToYCoCg(ssgiIlSpecular); + ssgiIlSpecular = max(0, Color::YCoCgToRGB(float3(ssgiIlSpecular.x, lerp(ssgiIlSpecular.yz, Color::RGBToYCoCg(finalIrradiance).yz, 0.5)))); + + finalIrradiance += ssgiIlSpecular; # endif color += reflectance * finalIrradiance; diff --git a/package/Shaders/Lighting.hlsl b/package/Shaders/Lighting.hlsl index fc58e04df8..f78dd91375 100644 --- a/package/Shaders/Lighting.hlsl +++ b/package/Shaders/Lighting.hlsl @@ -2110,7 +2110,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) pbrSurfaceProperties.Roughness = clamp(rawRMAOS.x, PBR::Constants::MinRoughness, PBR::Constants::MaxRoughness); pbrSurfaceProperties.Metallic = saturate(rawRMAOS.y); pbrSurfaceProperties.AO = rawRMAOS.z; - pbrSurfaceProperties.F0 = lerp(saturate(rawRMAOS.w), Color::GammaToLinear(baseColor.xyz), pbrSurfaceProperties.Metallic); + pbrSurfaceProperties.F0 = lerp(saturate(rawRMAOS.w), Color::GammaToTrueLinear(baseColor.xyz), pbrSurfaceProperties.Metallic); pbrSurfaceProperties.GlintScreenSpaceScale = max(1, glintParameters.x); pbrSurfaceProperties.GlintLogMicrofacetDensity = clamp(PBR::Constants::MaxGlintDensity - glintParameters.y, PBR::Constants::MinGlintDensity, PBR::Constants::MaxGlintDensity); @@ -2885,9 +2885,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) # if defined(DYNAMIC_CUBEMAPS) # if defined(SKYLIGHTING) - float3 wetnessReflectance = DynamicCubemaps::GetDynamicCubemap(wetnessNormal, vertexNormal, viewDirection, waterRoughnessSpecular, 0.02, skylightingSH) * sqrt(wetnessGlossinessSpecular); + float3 wetnessReflectance = DynamicCubemaps::GetDynamicCubemap(wetnessNormal, vertexNormal, viewDirection, waterRoughnessSpecular, 0.02 * wetnessGlossinessSpecular, skylightingSH); # else - float3 wetnessReflectance = DynamicCubemaps::GetDynamicCubemap(wetnessNormal, vertexNormal, viewDirection, waterRoughnessSpecular, 0.02) * sqrt(wetnessGlossinessSpecular); + float3 wetnessReflectance = DynamicCubemaps::GetDynamicCubemap(wetnessNormal, vertexNormal, viewDirection, waterRoughnessSpecular, 0.02 * wetnessGlossinessSpecular); # endif # else float3 wetnessReflectance = 0.0; @@ -2965,7 +2965,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) PBR::GetIndirectLobeWeights(indirectDiffuseLobeWeight, indirectSpecularLobeWeight, worldNormal.xyz, viewDirection, vertexNormal, baseColor.xyz, pbrSurfaceProperties); # if defined(WETNESS_EFFECTS) if (waterRoughnessSpecular < 1.0) - indirectSpecularLobeWeight += PBR::GetWetnessIndirectSpecularLobeWeight(wetnessNormal, viewDirection, vertexNormal, waterRoughnessSpecular) * wetnessGlossinessSpecular; + indirectSpecularLobeWeight = max(indirectSpecularLobeWeight, PBR::GetWetnessIndirectSpecularLobeWeight(wetnessNormal, viewDirection, vertexNormal, waterRoughnessSpecular)); # endif color.xyz += indirectDiffuseLobeWeight * directionalAmbientColor; @@ -3085,24 +3085,26 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) color.xyz = lerp(color.xyz * Color::PBRLightingScale, litLodLandColor, lodLandBlendFactor); specularColor = lerp(specularColorPBR * Color::PBRLightingScale, 0, lodLandBlendFactor); - indirectDiffuseLobeWeight = lerp(indirectDiffuseLobeWeight, vertexColor * lodLandColor.xyz * lodLandFadeFactor, lodLandBlendFactor); + indirectDiffuseLobeWeight = lerp(indirectDiffuseLobeWeight * Color::PBRLightingScale, vertexColor * lodLandColor.xyz * lodLandFadeFactor, lodLandBlendFactor); indirectSpecularLobeWeight = lerp(indirectSpecularLobeWeight, 0, lodLandBlendFactor); pbrGlossiness = lerp(pbrGlossiness, 0, lodLandBlendFactor); } # elif defined(TRUE_PBR) color.xyz *= Color::PBRLightingScale; specularColorPBR *= Color::PBRLightingScale; + indirectDiffuseLobeWeight *= Color::PBRLightingScale; specularColor = specularColorPBR; # endif float3 outputAlbedo = baseColor.xyz * vertexColor; + # if defined(TRUE_PBR) outputAlbedo = indirectDiffuseLobeWeight; # endif # if defined(HAIR) && defined(CS_HAIR) if (SharedData::hairSpecularSettings.Enabled) { - outputAlbedo = indirectDiffuseLobeWeight; + outputAlbedo = indirectDiffuseLobeWeight * Color::PBRLightingScale; } # endif @@ -3113,7 +3115,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) directionalAmbientColor *= outputAlbedo; # if defined(SKYLIGHTING) - Skylighting::applySkylighting(color.xyz, directionalAmbientColor, skylightingDiffuse); + Skylighting::applySkylighting(color.xyz, directionalAmbientColor, outputAlbedo, skylightingDiffuse); # endif # if defined(IBL) && defined(SKYLIGHTING) @@ -3281,7 +3283,6 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) psout.Specular = float4(specularColor, psout.Diffuse.w); psout.Albedo = float4(outputAlbedo, psout.Diffuse.w); - const float wetnessGlossinessGain = 0.65; float outGlossiness = saturate(glossiness * SSRParams.w); # if defined(HAIR) && defined(CS_HAIR) @@ -3297,7 +3298,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) # 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); + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(pbrGlossiness, max(pbrGlossiness, wetnessGlossinessSpecular), wetnessGlossinessSpecular), psout.Diffuse.w); # else psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), pbrGlossiness, psout.Diffuse.w); # endif @@ -3305,7 +3306,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) if (SharedData::hairSpecularSettings.Enabled) { # if defined(WETNESS_EFFECTS) psout.Reflectance = float4(indirectSpecularLobeWeightPrim + indirectSpecularLobeWeightSec + wetnessReflectance, psout.Diffuse.w); - psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, saturate(outGlossiness + wetnessGlossinessGain), wetnessGlossinessSpecular), psout.Diffuse.w); + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, max(outGlossiness, wetnessGlossinessSpecular), wetnessGlossinessSpecular), psout.Diffuse.w); # else psout.Reflectance = float4(indirectSpecularLobeWeightPrim + indirectSpecularLobeWeightSec, psout.Diffuse.w); psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), outGlossiness, psout.Diffuse.w); @@ -3313,7 +3314,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) } else { # if defined(WETNESS_EFFECTS) psout.Reflectance = float4(wetnessReflectance, psout.Diffuse.w); - psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, saturate(outGlossiness + wetnessGlossinessGain), wetnessGlossinessSpecular), psout.Diffuse.w); + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, max(outGlossiness, wetnessGlossinessSpecular), wetnessGlossinessSpecular), psout.Diffuse.w); # else psout.Reflectance = float4(0.0.xxx, psout.Diffuse.w); psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), outGlossiness, psout.Diffuse.w); @@ -3321,7 +3322,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) } # elif defined(WETNESS_EFFECTS) psout.Reflectance = float4(wetnessReflectance, psout.Diffuse.w); - psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, saturate(outGlossiness + wetnessGlossinessGain), wetnessGlossinessSpecular), psout.Diffuse.w); + psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), lerp(outGlossiness, max(outGlossiness, wetnessGlossinessSpecular), wetnessGlossinessSpecular), psout.Diffuse.w); # else psout.Reflectance = float4(0.0.xxx, psout.Diffuse.w); psout.NormalGlossiness = float4(GBuffer::EncodeNormal(screenSpaceNormal), outGlossiness, psout.Diffuse.w); @@ -3342,7 +3343,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) if (dynamicCubemap) { # if defined(WETNESS_EFFECTS) psout.Reflectance.xyz = max(envColor, wetnessReflectance); - psout.NormalGlossiness.z = lerp(1.0 - envRoughness, saturate(1.0 - envRoughness + wetnessGlossinessGain), wetnessGlossinessSpecular); + psout.NormalGlossiness.z = lerp(1.0 - envRoughness, max(1.0 - envRoughness, wetnessGlossinessSpecular), wetnessGlossinessSpecular); # else psout.Reflectance.xyz = envColor; psout.NormalGlossiness.z = 1.0 - envRoughness; @@ -3359,7 +3360,6 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) float stochasticBlend = (screenNoise * screenNoise) < psout.Diffuse.w ? 1.0 : 0.0; psout.NormalGlossiness.w = stochasticBlend; - # endif return psout; diff --git a/package/Shaders/RunGrass.hlsl b/package/Shaders/RunGrass.hlsl index fe84fd440b..d2af9390dc 100644 --- a/package/Shaders/RunGrass.hlsl +++ b/package/Shaders/RunGrass.hlsl @@ -757,7 +757,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) directionalAmbientColor *= albedo; # if defined(SKYLIGHTING) - Skylighting::applySkylighting(diffuseColor, directionalAmbientColor, skylightingDiffuse); + Skylighting::applySkylighting(diffuseColor, directionalAmbientColor, albedo, skylightingDiffuse); # endif # if defined(IBL) && defined(SKYLIGHTING) @@ -965,7 +965,7 @@ PS_OUTPUT main(PS_INPUT input) directionalAmbientColor *= albedo; # if defined(SKYLIGHTING) - Skylighting::applySkylighting(diffuseColor, directionalAmbientColor, skylightingDiffuse); + Skylighting::applySkylighting(diffuseColor, directionalAmbientColor, albedo, skylightingDiffuse); # endif # if defined(IBL) && defined(SKYLIGHTING) diff --git a/src/Deferred.cpp b/src/Deferred.cpp index 63742c9038..6626a6cfb3 100644 --- a/src/Deferred.cpp +++ b/src/Deferred.cpp @@ -98,7 +98,7 @@ void Deferred::SetupResources() // TEMPORAL_AA_WATER_2 // Albedo - SetupRenderTarget(ALBEDO, texDesc, srvDesc, rtvDesc, uavDesc, DXGI_FORMAT_R8G8B8A8_UNORM, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); + SetupRenderTarget(ALBEDO, texDesc, srvDesc, rtvDesc, uavDesc, DXGI_FORMAT_R10G10B10A2_UNORM, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); // Specular SetupRenderTarget(SPECULAR, texDesc, srvDesc, rtvDesc, uavDesc, DXGI_FORMAT_R11G11B10_FLOAT, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); // Reflectance diff --git a/src/Features/ScreenSpaceGI.h b/src/Features/ScreenSpaceGI.h index 305ebe54c5..0d9a92dfc3 100644 --- a/src/Features/ScreenSpaceGI.h +++ b/src/Features/ScreenSpaceGI.h @@ -71,11 +71,11 @@ struct ScreenSpaceGI : Feature float Thickness = 32.f; float2 DepthFadeRange = { 4e4, 5e4 }; // gi - float GISaturation = 0.9f; + float GISaturation = 0.8f; float GIDistanceCompensation = 0.f; // mix float AOPower = 1.0f; - float GIStrength = 1.5f; + float GIStrength = 1.0f; // denoise bool EnableTemporalDenoiser = true; bool EnableBlur = true;