From 06809587e89c04beb2311790c704ac13af882337 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 6 Feb 2020 00:36:57 +0100 Subject: [PATCH] [d3d9] Don't arbitrarily set fog scale to 0 The Witcher 1 sets FOGSTART == FOGEND together with LINEAR fog mode, in which case we previously set fog_scale to 0 and therefore incorrectly override the pixel color with the fog color. Fixes #1401. --- src/d3d9/d3d9_device.cpp | 3 --- src/d3d9/d3d9_fixed_function.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 315ff6b5..fa6a66fa 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4589,9 +4589,6 @@ namespace dxvk { float start = bit::cast(rs[D3DRS_FOGSTART]); float scale = 1.0f / (end - start); - if (!std::isfinite(scale)) - scale = 0.0f; - UpdatePushConstant(&scale); } else if constexpr (Item == D3D9RenderStateItem::PointSize) { diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index e06e187b..04d27b72 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -129,7 +129,7 @@ namespace dxvk { case D3DFOG_LINEAR: { uint32_t fogFactor = spvModule.opFSub(floatType, fogEnd, depth); fogFactor = spvModule.opFMul(floatType, fogFactor, fogScale); - fogFactor = spvModule.opFClamp(floatType, fogFactor, spvModule.constf32(0.0f), spvModule.constf32(1.0f)); + fogFactor = spvModule.opNClamp(floatType, fogFactor, spvModule.constf32(0.0f), spvModule.constf32(1.0f)); return fogFactor; }