From 3acecbf307dfdbbf3b2e743b3ebdd30badfd584c Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:18:54 +0000 Subject: [PATCH 1/3] fix: effect shader lights (#746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: effect shader lights * style: 🎨 apply clang-format changes --------- Co-authored-by: doodlum --- package/Shaders/Effect.hlsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/Shaders/Effect.hlsl b/package/Shaders/Effect.hlsl index b22cfaffc6..8af5db29db 100644 --- a/package/Shaders/Effect.hlsl +++ b/package/Shaders/Effect.hlsl @@ -532,9 +532,11 @@ float3 GetLightingColor(float3 msPosition, float3 worldPosition, float4 screenPo color += dirLightColor * GetEffectShadow(worldPosition, normalize(worldPosition), screenPosition, eyeIndex); } +# if !defined(LIGHT_LIMIT_FIX) color.x += dot(PLightColorR * lightFadeMul, 1.0.xxxx); color.y += dot(PLightColorG * lightFadeMul, 1.0.xxxx); color.z += dot(PLightColorB * lightFadeMul, 1.0.xxxx); +# endif return color; } @@ -621,7 +623,7 @@ PS_OUTPUT main(PS_INPUT input) float lightDist = length(lightDirection); float intensityFactor = saturate(lightDist / light.radius); float intensityMultiplier = 1 - intensityFactor * intensityFactor; - float3 lightColor = light.color.xyz * intensityMultiplier; + float3 lightColor = light.color.xyz * intensityMultiplier * 0.5; propertyColor += lightColor; } } From 0269ac0051ee370ea7ba0e6e0e834ca2b6952ddf Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:19:41 +0000 Subject: [PATCH 2/3] feat: fixed vanilla ssr (#745) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: fixed vanilla ssr * style: 🎨 apply clang-format changes * fix: vr * style: 🎨 apply clang-format changes * chore: remove deltaUvDepthDR --------- Co-authored-by: doodlum --- package/Shaders/ISReflectionsRayTracing.hlsl | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/package/Shaders/ISReflectionsRayTracing.hlsl b/package/Shaders/ISReflectionsRayTracing.hlsl index 2b7ced3d39..91872e57bc 100644 --- a/package/Shaders/ISReflectionsRayTracing.hlsl +++ b/package/Shaders/ISReflectionsRayTracing.hlsl @@ -57,6 +57,16 @@ float hash(float2 p) return frac(p.x * p.y * float2(0.5, 0.5).x); } +float3 ViewToUVDepthHelper(float3 x, uint eyeIndex) +{ + float4 newPosition = float4(x, 1.0); + float4 uv = mul(CameraProj[eyeIndex], newPosition); + uv.xyz /= uv.w; + float3 uvDepth = float3(uv.xy * float2(0.5, -0.5) + 0.5, uv.z); + uvDepth.xy = FrameBuffer::GetDynamicResolutionAdjustedScreenPosition(uvDepth.xy); + return uvDepth; +} + PS_OUTPUT main(PS_INPUT input) { PS_OUTPUT psout; @@ -85,6 +95,12 @@ PS_OUTPUT main(PS_INPUT input) float ssrPower = max(srcNormal.z >= 1e-5, srcNormal.w); bool isSsrDisabled = ssrPower < 1e-5; + [branch] if (isSsrDisabled) + { + psout.Color = 0; + return psout; + } + # if defined(SPECMASK) float3 color = ColorTex.Sample(ColorSampler, uvStartDR).xyz; @@ -116,7 +132,7 @@ PS_OUTPUT main(PS_INPUT input) float3 uvDepthFinish = ViewToUVDepth(vsFinish.xyz); float3 deltaUvDepth = uvDepthFinish - uvDepthStart; - float3 uvDepthFinishDR = uvDepthStart + deltaUvDepth * (SSRParams.x * rcp(length(deltaUvDepth.xy))); + float3 uvDepthFinishDR = uvDepthStart + deltaUvDepth * SSRParams.x * rcp(length(deltaUvDepth.xy)); uvDepthFinishDR.xy = FrameBuffer::GetDynamicResolutionAdjustedScreenPosition(uvDepthFinishDR.xy); # ifdef VR @@ -124,7 +140,6 @@ PS_OUTPUT main(PS_INPUT input) # endif float3 uvDepthStartDR = float3(uvStartDR, vsStart.z); - float3 deltaUvDepthDR = uvDepthFinishDR - uvDepthStartDR; float3 uvDepthPreResultDR = uvDepthStartDR; float3 uvDepthResultDR = float3(uvDepthStartDR.xy, depthStart); @@ -142,7 +157,7 @@ PS_OUTPUT main(PS_INPUT input) ; // Adjust based on performance/quality tradeoff for (; iterationIndex < maxIterations; iterationIndex++) { - float3 iterationUvDepthDR = uvDepthStartDR + (iterationIndex / (float)maxIterations) * deltaUvDepthDR; + float3 iterationUvDepthDR = ViewToUVDepthHelper(lerp(csStart.xyz, csFinish.xyz, (iterationIndex / (float)maxIterations) * SSRParams.x * rcp(length(deltaUvDepth.xy))), eyeIndex); float3 iterationUvDepthSampleDR = # ifdef VR // Apply dynamic resolution adjustments and stereo UV conversions From 09b6477103b76d33f42addb167477b3df8630802 Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:50:58 +0000 Subject: [PATCH 3/3] feat: po3 light placer support (#747) --- src/Features/LightLimitFix.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Features/LightLimitFix.cpp b/src/Features/LightLimitFix.cpp index 26d7db2043..07d768cf34 100644 --- a/src/Features/LightLimitFix.cpp +++ b/src/Features/LightLimitFix.cpp @@ -341,6 +341,8 @@ void LightLimitFix::BSLightingShader_SetupGeometry_GeometrySetupConstantPointLig SetLightPosition(light, niLight->world.translate, inWorld); + light.lightFlags = static_cast(runtimeData.ambient.red); + if (bsLight->IsShadowLight()) { auto* shadowLight = static_cast(bsLight); GET_INSTANCE_MEMBER(shadowLightIndex, shadowLight); @@ -791,6 +793,8 @@ void LightLimitFix::UpdateLights() light.radius = runtimeData.radius.x; + light.lightFlags = static_cast(runtimeData.ambient.red); + if (!IsGlobalLight(bsLight)) { // List of BSMultiBoundRooms affected by a light for (const auto& roomPtr : bsLight->rooms) {