From b964af26bd5dbcd16f3a7b278996cc8b5858d832 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sat, 12 Dec 2020 21:07:22 -0800 Subject: [PATCH] fix bad palette crush FLT_MAX --- Effects/FXB/PaletteCrushEffect.fxb | 4 ++-- Effects/HLSL/PaletteCrushEffect.fx | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Effects/FXB/PaletteCrushEffect.fxb b/Effects/FXB/PaletteCrushEffect.fxb index dfb94e4..ac29c12 100644 --- a/Effects/FXB/PaletteCrushEffect.fxb +++ b/Effects/FXB/PaletteCrushEffect.fxb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:601be54d2ff0278fd16cffd6954d26694c370f7356a715498d94932fe77e3a2f -size 1432 +oid sha256:6cdabdcd65c5293be1d7fe304dcd390f7b5fd3065f1c2135697de09873bc3c9b +size 1448 diff --git a/Effects/HLSL/PaletteCrushEffect.fx b/Effects/HLSL/PaletteCrushEffect.fx index 6126199..23143af 100644 --- a/Effects/HLSL/PaletteCrushEffect.fx +++ b/Effects/HLSL/PaletteCrushEffect.fx @@ -1,7 +1,5 @@ #include "Macros.fxh" -#define FLT_MAX 3.402823466e+38 - DECLARE_TEXTURE(Texture, 0); DECLARE_TEXTURE(Palette, 1); @@ -40,11 +38,12 @@ float4 main_ps(PixelInput input) : SV_TARGET0 float3 sampled_color = sampled.rgb; float3 closest_color = float3(0, 0, 0); - float closest_dist = FLT_MAX; + float closest_dist = 100000; for (int i = 0; i < PaletteWidth; i++) { - float3 palette_color = SAMPLE_TEXTURE(Palette, float2(i / (float)PaletteWidth, 0)); + float texX = (i / (float)PaletteWidth); + float3 palette_color = SAMPLE_TEXTURE(Palette, float2(texX, 0)); float dist = distance(palette_color, sampled_color); if (dist < closest_dist) {