Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
BfConstant.h
Go to the documentation of this file.
1#pragma once
2
4#include "Core/SurfaceHit.h"
6
7#include <Common/assertion.h>
8
9#include <cmath>
10#include <string>
11
12namespace ph
13{
14
15class BfConstant final : public BlockFunction
16{
17public:
18 inline BfConstant() :
19 BfConstant(math::Spectrum(0))
20 {}
21
22 inline BfConstant(const math::Spectrum& coeff) :
24 m_absorptionCoeff(coeff)
25 {}
26
27 virtual inline ~BfConstant() override = default;
28
29 virtual inline void evalAbsorptionCoeff(
30 const SurfaceHit& /* X */,
31 math::Spectrum* const out_coeff) const override
32 {
33 PH_ASSERT(out_coeff);
34
35 *out_coeff = m_absorptionCoeff;
36 }
37
38 inline math::Spectrum calcTransmittance(const real dist) const
39 {
40 PH_ASSERT_MSG(dist >= 0.0_r,
41 "dist = " + std::to_string(dist));
42
43 math::Spectrum transmittance;
44 for(std::size_t i = 0; i < math::Spectrum::NUM_VALUES; ++i)
45 {
46 transmittance[i] = std::exp(-m_absorptionCoeff[i] * dist);
47 }
48 return transmittance;
49 }
50
51private:
52 math::Spectrum m_absorptionCoeff;
53};
54
55}// end namespace ph
Definition BfConstant.h:16
virtual ~BfConstant() override=default
BfConstant()
Definition BfConstant.h:18
math::Spectrum calcTransmittance(const real dist) const
Definition BfConstant.h:38
BfConstant(const math::Spectrum &coeff)
Definition BfConstant.h:22
virtual void evalAbsorptionCoeff(const SurfaceHit &, math::Spectrum *const out_coeff) const override
Definition BfConstant.h:29
Definition BlockFunction.h:13
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
Definition TTristimulusSpectrum.h:11
The root for all renderer implementations.
Definition EEngineProject.h:6