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; } } 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 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) {