From 3f4b974a0454a35091f5453e6dad89d8ff606318 Mon Sep 17 00:00:00 2001 From: Tim <15017472+doodlum@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:16:52 +0000 Subject: [PATCH 1/5] chore: random cleanup and fixes --- .../DynamicCubemaps/DynamicCubemaps.hlsli | 29 ++----------------- .../Shaders/WaterEffects/WaterParallax.hlsli | 9 ++---- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli index b8e58daf3..eaea12611 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli @@ -27,8 +27,8 @@ namespace DynamicCubemaps horizon *= horizon * horizon; float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz; - specularIrradiance *= horizon; specularIrradiance = Color::GammaToLinear(specularIrradiance); + specularIrradiance *= horizon; return specularIrradiance; } @@ -47,37 +47,14 @@ namespace DynamicCubemaps float horizon = min(1.0 + dot(R, VN), 1.0); horizon *= 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); - # if defined(DEFERRED) - return horizon * ((F0 + S) * specularBRDF.x + specularBRDF.y); + return horizon * (1 + F0 * (1 / (specularBRDF.x + specularBRDF.y) - 1)); # else float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz; specularIrradiance = Color::GammaToLinear(specularIrradiance); - return specularIrradiance * ((F0 + S) * specularBRDF.x + specularBRDF.y); + return specularIrradiance * (1 + F0 * (1 / (specularBRDF.x + specularBRDF.y) - 1)); # endif } - - float3 GetDynamicCubemapFresnel(float2 uv, float3 N, float3 VN, float3 V, float roughness, float level, float3 diffuseColor, float distance) - { - float NoV = saturate(dot(N, V)); - float2 specularBRDF = EnvBRDFApprox(roughness, NoV); - if (specularBRDF.y > 0.001) { - float3 R = reflect(-V, N); - float3 specularIrradiance = EnvReflectionsTexture.SampleLevel(SampColorSampler, R, level).xyz; - - // Horizon specular occlusion - // https://marmosetco.tumblr.com/post/81245981087 - float horizon = min(1.0 + dot(R, VN), 1.0); - specularIrradiance *= horizon * horizon; - - return specularIrradiance * specularBRDF.y; - } - return 0.0; - } #endif // !WATER } diff --git a/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli b/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli index 9f475a786..ba5a5e3b4 100644 --- a/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli +++ b/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli @@ -1,9 +1,5 @@ namespace WaterEffects { - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // PARALLAX - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // https://github.com/tgjones/slimshader-cpp/blob/master/src/Shaders/Sdk/Direct3D11/DetailTessellation11/POM.hlsl // https://github.com/alandtse/SSEShaderTools/blob/main/shaders_vr/ParallaxEffect.h @@ -46,7 +42,8 @@ namespace WaterEffects heights.x = Normals01Tex.SampleLevel(Normals01Sampler, input.TexCoord1.xy + currentOffset * normalScalesRcp.x, mipLevels.x).w; heights.y = Normals02Tex.SampleLevel(Normals02Sampler, input.TexCoord1.zw + currentOffset * normalScalesRcp.y, mipLevels.y).w; heights.z = Normals03Tex.SampleLevel(Normals03Sampler, input.TexCoord2.xy + currentOffset * normalScalesRcp.z, mipLevels.z).w; - return 1.0 - length(heights); + heights *= NormalsAmplitude.xyz; + return 1.0 - (heights.x + heights.y + heights.z); } float2 GetParallaxOffset(PS_INPUT input, float3 normalScalesRcp) @@ -55,7 +52,7 @@ namespace WaterEffects float2 parallaxOffsetTS = viewDirection.xy / -viewDirection.z; // Parallax scale is also multiplied by normalScalesRcp - parallaxOffsetTS *= 20.0; + parallaxOffsetTS *= 20.0 * 1.5; float3 mipLevels; mipLevels.x = GetMipLevel(input.TexCoord1.xy, Normals01Tex); From 6683e167b144c6c2bf0db83f00c1cb366595392a Mon Sep 17 00:00:00 2001 From: Tim <15017472+doodlum@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:23:51 +0000 Subject: [PATCH 2/5] fix: reduce inference ramp up --- .../Shaders/DynamicCubemaps/InferCubemapCS.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl index 105088e37..46cf0ad18 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl @@ -54,7 +54,7 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray OutputTextu float mipLevel = 0.0; #if !defined(REFLECTIONS) - float k = 2; + float k = 1.5; float brightness = k; #endif From ca03f293a4dfdf48eb608adcd55e4c127fb01d08 Mon Sep 17 00:00:00 2001 From: Tim <15017472+doodlum@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:24:53 +0000 Subject: [PATCH 3/5] chore: reduce default billboard radius --- src/Features/LightLimitFix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Features/LightLimitFix.cpp b/src/Features/LightLimitFix.cpp index 33e31e89a..2cd48a5b4 100644 --- a/src/Features/LightLimitFix.cpp +++ b/src/Features/LightLimitFix.cpp @@ -935,7 +935,7 @@ void LightLimitFix::UpdateLights() light.color = Saturation(light.color, settings.ParticleLightsSaturation); light.color *= particleLight.color.alpha * settings.BillboardBrightness; - light.radius = particleLight.node->worldBound.radius * particleLight.color.alpha * settings.BillboardRadius; + light.radius = particleLight.node->worldBound.radius * particleLight.color.alpha * settings.BillboardRadius * 0.5f; auto position = particleLight.node->world.translate; From e6573c6864a7ba285ec44def0374dd0b255520f1 Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:14:40 +0000 Subject: [PATCH 4/5] chore: remove parallax boost --- features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli b/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli index ba5a5e3b4..dd8d34b2b 100644 --- a/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli +++ b/features/Water Effects/Shaders/WaterEffects/WaterParallax.hlsli @@ -52,7 +52,7 @@ namespace WaterEffects float2 parallaxOffsetTS = viewDirection.xy / -viewDirection.z; // Parallax scale is also multiplied by normalScalesRcp - parallaxOffsetTS *= 20.0 * 1.5; + parallaxOffsetTS *= 20.0; float3 mipLevels; mipLevels.x = GetMipLevel(input.TexCoord1.xy, Normals01Tex); From 10c432731773d5e6fb4969c950185b7d58743609 Mon Sep 17 00:00:00 2001 From: Tim <15017472+doodlum@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:52:24 +0000 Subject: [PATCH 5/5] fix: subsurface scattering namespaces --- .../Shaders/SubsurfaceScattering/SeparableSSS.hlsli | 10 +++++----- .../Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli index 44983cbe7..699032efc 100644 --- a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli +++ b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSS.hlsli @@ -124,7 +124,7 @@ float4 SSSSBlurCS( float scale = distanceToProjectionWindow / depthM; // Calculate the final step to fetch the surrounding pixels: - float2 finalStep = scale * BufferDim.xy * dir; + float2 finalStep = scale * SharedData::BufferDim.xy * dir; finalStep *= sssAmount; finalStep *= profile.x; // Modulate it using the profile finalStep *= 1.0 / 3.0; // Divide by 3 as the kernels range from -3 to 3. @@ -132,15 +132,15 @@ float4 SSSSBlurCS( #if defined(VR) finalStep.x *= 0.5; // Halve horizontal screen resolution uint eyeIndex = texcoord >= 0.5; // 0 = left 1 = right - uint bufferDimHalfX = uint(BufferDim.x * 0.5); + uint bufferDimHalfX = uint(SharedData::BufferDim.x * 0.5); uint2 minCoord = uint2(eyeIndex ? bufferDimHalfX : 0, 0); - uint2 maxCoord = uint2(eyeIndex ? BufferDim.x : bufferDimHalfX, BufferDim.y); + uint2 maxCoord = uint2(eyeIndex ? SharedData::BufferDim.x : bufferDimHalfX, SharedData::BufferDim.y); #else uint2 minCoord = uint2(0, 0); - uint2 maxCoord = uint2(BufferDim.x, BufferDim.y); + uint2 maxCoord = uint2(SharedData::BufferDim.x, SharedData::BufferDim.y); #endif - float jitter = Random::InterleavedGradientNoise(DTid.xy, FrameCount) * Math::TAU; + float jitter = Random::InterleavedGradientNoise(DTid.xy, SharedData::FrameCount) * Math::TAU; float2x2 rotationMatrix = float2x2((jitter), sin(jitter), -sin(jitter), cos(jitter)); float2x2 identityMatrix = float2x2(1.0, 0.0, 0.0, 1.0); diff --git a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl index 6ed4ccafe..b594c2241 100644 --- a/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl +++ b/features/Subsurface Scattering/Shaders/SubsurfaceScattering/SeparableSSSCS.hlsl @@ -22,7 +22,7 @@ cbuffer PerFrameSSS : register(b1) [numthreads(8, 8, 1)] void main(uint3 DTid : SV_DispatchThreadID) { - float2 texCoord = (DTid.xy + 0.5) * BufferDim.zw; + float2 texCoord = (DTid.xy + 0.5) * SharedData::BufferDim.zw; #if defined(HORIZONTAL)