7#include <Common/assertion.h>
8#include <Common/primitive_type.h>
9#include <Common/logging.h>
36 std::vector<float> m_table;
43 float m_minCosWi, m_maxCosWi;
44 float m_minAlpha, m_maxAlpha;
45 float m_minIorN, m_maxIorN;
46 float m_minIorK, m_maxIorK;
48 int calcIndex(
int iCosWi,
int iAlpha,
int iIorN,
int iIorK)
const;
49 void downSampleHalf();
62 m_minCosWi(0.0f), m_maxCosWi(0.0f),
63 m_minAlpha(0.0f), m_maxAlpha(0.0f),
64 m_minIorN (0.0f), m_maxIorN (0.0f),
65 m_minIorK (0.0f), m_maxIorK (0.0f)
75 reader.
read(&m_numCosWi);
76 reader.
read(&m_numAlpha);
77 reader.
read(&m_numIorN);
78 reader.
read(&m_numIorK);
79 reader.
read(&m_minCosWi); reader.
read(&m_maxCosWi);
80 reader.
read(&m_minAlpha); reader.
read(&m_maxAlpha);
81 reader.
read(&m_minIorN); reader.
read(&m_maxIorN);
82 reader.
read(&m_minIorK); reader.
read(&m_maxIorK);
85 "dimension: (cos-w_i = {}, alpha = {}, IOR-n = {}, IOR-k = {})",
86 m_numCosWi, m_numAlpha, m_numIorN, m_numIorK);
89 "range: (cos-w_i = [{}, {}], alpha = [{}, {}], IOR-n = [{}, {}], IOR-k = [{}, {}])",
90 m_minCosWi, m_maxCosWi,
91 m_minAlpha, m_maxAlpha,
93 m_minIorK, m_maxIorK);
95 PH_ASSERT(m_numCosWi > 0 && m_numAlpha > 0 && m_numIorN > 0 && m_numIorK > 0);
97 const std::size_t tableSize =
98 static_cast<std::size_t
>(m_numCosWi) *
99 static_cast<std::size_t
>(m_numAlpha) *
100 static_cast<std::size_t
>(m_numIorN) *
101 static_cast<std::size_t
>(m_numIorK);
102 m_table.resize(tableSize, 0.0f);
103 reader.
read(m_table.data(), m_table.size());
120 result[i] =
sample(cosWi, alpha, iorN[i], iorK[i]);
125inline int TableFGD::calcIndex(
const int iCosWi,
const int iAlpha,
const int iIorN,
const int iIorK)
const
128 PH_ASSERT(0 <= iCosWi && iCosWi < m_numCosWi);
129 PH_ASSERT(0 <= iAlpha && iAlpha < m_numAlpha);
130 PH_ASSERT(0 <= iIorN && iIorN < m_numIorN);
131 PH_ASSERT(0 <= iIorK && iIorK < m_numIorK);
133 return iIorK + m_numIorK * (iIorN + m_numIorN * (iAlpha + m_numAlpha * iCosWi));
Definition BinaryFileReader.h:14
void read(T *out_buffer, std::size_t numElements=1)
Definition BinaryFileReader.h:48
bool open()
Definition BinaryFileReader.cpp:10
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
std::string toString() const
Get a string representation of this path in generic format.
Definition Path.cpp:121
real sample(real cosWi, real alpha, real iorN, real iorK) const
Definition TableFGD.cpp:26
TableFGD(const Path &tableFilePath)
Definition TableFGD.h:54
static constexpr auto NUM_VALUES
Definition TSpectrumBase.h:50
Definition TTristimulusSpectrum.h:11
The root for all renderer implementations.
Definition EEngineProject.h:6
PH_DEFINE_EXTERNAL_LOG_GROUP(ApiDatabase, Core)