// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/BaseTypes.h"
#include "Engine/Core/Collections/Array.h"
///
/// Utility for loading IES files and extract light emission information.
///
class IESLoader
{
private:
float _brightness = 0;
Array _hAngles;
Array _vAngles;
Array _candalaValues;
public:
///
/// Loads the IES file.
///
/// The buffer with data.
/// True if cannot load, otherwise false.
bool Load(const byte* buffer);
///
/// Extracts IES profile data to R16 format (float).
///
/// The result data container.
/// Thr multiplier as the texture is normalized.
float ExtractInR16(Array& output);
public:
uint32 GetWidth() const
{
return 256;
}
uint32 GetHeight() const
{
return 1;
}
float GetBrightness() const
{
return _brightness;
}
private:
float InterpolatePoint(int32 x, int32 y) const;
float InterpolateBilinear(float x, float y) const;
static float ComputeFilterPos(float value, const Array& sortedValues);
};