diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp index 76260f506e..1ed900b2b8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp @@ -146,8 +146,12 @@ namespace AZ case AZ::RHI::Format::R8_SNORM: { // Scale the value from AZ::s8 min/max to -1 to 1 + // We need to treat -128 and -127 the same, so that we get a symmetric + // range of -127 to 127 with complementary scaled values of -1 to 1 auto actualMem = reinterpret_cast(mem); - return ScaleValue(actualMem[index], std::numeric_limits::min(), std::numeric_limits::max(), -1, 1); + AZ::s8 signedMax = std::numeric_limits::max(); + AZ::s8 signedMin = aznumeric_cast(-signedMax); + return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1, 1); } case AZ::RHI::Format::D16_UNORM: case AZ::RHI::Format::R16_UNORM: @@ -157,8 +161,12 @@ namespace AZ case AZ::RHI::Format::R16_SNORM: { // Scale the value from AZ::s16 min/max to -1 to 1 + // We need to treat -32768 and -32767 the same, so that we get a symmetric + // range of -32767 to 32767 with complementary scaled values of -1 to 1 auto actualMem = reinterpret_cast(mem); - return ScaleValue(actualMem[index], std::numeric_limits::min(), std::numeric_limits::max(), -1, 1); + AZ::s16 signedMax = std::numeric_limits::max(); + AZ::s16 signedMin = aznumeric_cast(-signedMax); + return ScaleValue(AZStd::max(actualMem[index], signedMin), signedMin, signedMax, -1, 1); } case AZ::RHI::Format::R16_FLOAT: {