6#include <Common/assertion.h>
7#include <Common/primitive_type.h>
8#include <Common/logging.h>
22 real
sample(real cosWi, real alpha, real relIor)
const;
25 std::vector<float> m_table;
31 float m_minCosWi, m_maxCosWi;
32 float m_minAlpha, m_maxAlpha;
33 float m_minRelIor, m_maxRelIor;
35 int calcIndex(
int iCosWi,
int iAlpha,
int iRelIor)
const;
47 m_minCosWi (0.0f), m_maxCosWi (0.0f),
48 m_minAlpha (0.0f), m_maxAlpha (0.0f),
49 m_minRelIor(0.0f), m_maxRelIor(0.0f)
59 reader.
read(&m_numCosWi);
60 reader.
read(&m_numAlpha);
61 reader.
read(&m_numRelIor);
62 reader.
read(&m_minCosWi); reader.
read(&m_maxCosWi);
63 reader.
read(&m_minAlpha); reader.
read(&m_maxAlpha);
64 reader.
read(&m_minRelIor); reader.
read(&m_maxRelIor);
66 PH_DEBUG_LOG(
TableTIR,
"dimension: (cos-w_i = {}, alpha = {}, relative-IOR = {})",
67 m_numCosWi, m_numAlpha, m_numRelIor);
69 PH_DEBUG_LOG(
TableTIR,
"range: (cos-w_i = [{}, {}], alpha = [{}, {}], relative-IOR = [{}, {}])",
70 m_minCosWi, m_maxCosWi,
71 m_minAlpha, m_maxAlpha,
72 m_minRelIor, m_maxRelIor);
74 PH_ASSERT(m_numCosWi > 0 && m_numAlpha > 0 && m_numRelIor > 0);
76 const std::size_t tableSize =
77 static_cast<std::size_t
>(m_numCosWi) *
78 static_cast<std::size_t
>(m_numAlpha) *
79 static_cast<std::size_t
>(m_numRelIor);
80 m_table.resize(tableSize, 0.0f);
81 reader.
read(m_table.data(), m_table.size());
84inline int TableTIR::calcIndex(
const int iCosWi,
const int iAlpha,
const int iRelIor)
const
87 PH_ASSERT(0 <= iCosWi && iCosWi < m_numCosWi);
88 PH_ASSERT(0 <= iAlpha && iAlpha < m_numAlpha);
89 PH_ASSERT(0 <= iRelIor && iRelIor < m_numRelIor);
91 return iRelIor + m_numRelIor * (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 relIor) const
Definition TableTIR.cpp:23
TableTIR(const Path &tableFilePath)
Definition TableTIR.h:40
The root for all renderer implementations.
Definition EEngineProject.h:6
PH_DEFINE_EXTERNAL_LOG_GROUP(ApiDatabase, Core)