|
|
|
|
@ -19,81 +19,6 @@
|
|
|
|
|
#include <GradientSignal/Util.h>
|
|
|
|
|
#include <numeric>
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
template <ImageProcessingAtom::EPixelFormat>
|
|
|
|
|
float RetrieveValue(const AZ::u8* mem, size_t index)
|
|
|
|
|
{
|
|
|
|
|
AZ_Assert(false, "Unimplemented!");
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_Unknown>([[maybe_unused]] const AZ::u8* mem, [[maybe_unused]] size_t index)
|
|
|
|
|
{
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R8>(const AZ::u8* mem, size_t index)
|
|
|
|
|
{
|
|
|
|
|
return mem[index] / static_cast<float>(std::numeric_limits<AZ::u8>::max());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R16>(const AZ::u8* mem, size_t index)
|
|
|
|
|
{
|
|
|
|
|
// 16 bits per channel
|
|
|
|
|
auto actualMem = reinterpret_cast<const AZ::u16*>(mem);
|
|
|
|
|
actualMem += index;
|
|
|
|
|
|
|
|
|
|
return *actualMem / static_cast<float>(std::numeric_limits<AZ::u16>::max());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32>(const AZ::u8* mem, size_t index)
|
|
|
|
|
{
|
|
|
|
|
// 32 bits per channel
|
|
|
|
|
auto actualMem = reinterpret_cast<const AZ::u32*>(mem);
|
|
|
|
|
actualMem += index;
|
|
|
|
|
|
|
|
|
|
return *actualMem / static_cast<float>(std::numeric_limits<AZ::u32>::max());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
float RetrieveValue<ImageProcessingAtom::EPixelFormat::ePixelFormat_R32F>(const AZ::u8* mem, size_t index)
|
|
|
|
|
{
|
|
|
|
|
// 32 bits per channel
|
|
|
|
|
auto actualMem = reinterpret_cast<const float*>(mem);
|
|
|
|
|
actualMem += index;
|
|
|
|
|
|
|
|
|
|
return *actualMem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float RetrieveValue(const AZ::u8* mem, size_t index, ImageProcessingAtom::EPixelFormat format)
|
|
|
|
|
{
|
|
|
|
|
using namespace ImageProcessingAtom;
|
|
|
|
|
|
|
|
|
|
switch (format)
|
|
|
|
|
{
|
|
|
|
|
case ePixelFormat_R8:
|
|
|
|
|
return RetrieveValue<ePixelFormat_R8>(mem, index);
|
|
|
|
|
|
|
|
|
|
case ePixelFormat_R16:
|
|
|
|
|
return RetrieveValue<ePixelFormat_R16>(mem, index);
|
|
|
|
|
|
|
|
|
|
case ePixelFormat_R32:
|
|
|
|
|
return RetrieveValue<ePixelFormat_R32>(mem, index);
|
|
|
|
|
|
|
|
|
|
case ePixelFormat_R32F:
|
|
|
|
|
return RetrieveValue<ePixelFormat_R32F>(mem, index);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return RetrieveValue<ePixelFormat_Unknown>(mem, index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace GradientSignal
|
|
|
|
|
{
|
|
|
|
|
void ImageAsset::Reflect(AZ::ReflectContext* context)
|
|
|
|
|
|