Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
FullPhoton.h
Go to the documentation of this file.
1#pragma once
2
5#include "Math/TVector3.h"
6
7#include <Common/utility.h>
8#include <Common/assertion.h>
9#include <Common/primitive_type.h>
10
11namespace ph
12{
13
17class FullPhoton : public TPhoton<FullPhoton>
18{
19public:
20 template<EPhotonData TYPE>
21 static constexpr bool impl_has();
22
23 template<EPhotonData TYPE>
24 decltype(auto) impl_get() const;
25
26 template<EPhotonData TYPE, typename T>
27 void impl_set(const T& value);
28
29private:
30 math::Spectrum m_throughputRadiance;
31 math::Vector3R m_pos;
32 math::Vector3R m_fromDir;
33 math::Vector3R m_geometryNormal;
34 uint32 m_pathLength;
35};
36
37// In-header Implementations:
38
39template<EPhotonData TYPE>
40inline constexpr bool FullPhoton::impl_has()
41{
42 if constexpr(
44 TYPE == EPhotonData::Pos ||
45 TYPE == EPhotonData::FromDir ||
48 {
49 return true;
50 }
51 else
52 {
53 return false;
54 }
55}
56
57template<EPhotonData TYPE>
58inline decltype(auto) FullPhoton::impl_get() const
59{
60 if constexpr(TYPE == EPhotonData::ThroughputRadiance)
61 {
62 return m_throughputRadiance;
63 }
64 else if constexpr(TYPE == EPhotonData::Pos)
65 {
66 return m_pos;
67 }
68 else if constexpr(TYPE == EPhotonData::FromDir)
69 {
70 return m_fromDir;
71 }
72 else if constexpr(TYPE == EPhotonData::GeometryNormal)
73 {
74 return m_geometryNormal;
75 }
76 else if constexpr(TYPE == EPhotonData::PathLength)
77 {
78 return m_pathLength;
79 }
80 else
81 {
82 PH_ASSERT_UNREACHABLE_SECTION();
83 return false;
84 }
85}
86
87template<EPhotonData TYPE, typename T>
88inline void FullPhoton::impl_set(const T& value)
89{
90 if constexpr(TYPE == EPhotonData::ThroughputRadiance)
91 {
92 m_throughputRadiance = value;
93 }
94 else if constexpr(TYPE == EPhotonData::Pos)
95 {
96 m_pos = value;
97 }
98 else if constexpr(TYPE == EPhotonData::FromDir)
99 {
100 m_fromDir = value;
101 }
102 else if constexpr(TYPE == EPhotonData::GeometryNormal)
103 {
104 m_geometryNormal = value;
105 }
106 else if constexpr(TYPE == EPhotonData::PathLength)
107 {
108 m_pathLength = lossless_cast<uint32>(value);
109 }
110 else
111 {
112 PH_ASSERT_UNREACHABLE_SECTION();
113 }
114}
115
116}// end namespace ph
This photon type stores all possible photon data without any loss of information. It is unrecommended...
Definition FullPhoton.h:18
static constexpr bool impl_has()
Definition FullPhoton.h:40
decltype(auto) impl_get() const
Definition FullPhoton.h:58
void impl_set(const T &value)
Definition FullPhoton.h:88
Definition TPhoton.h:31
Definition TTristimulusSpectrum.h:11
The root for all renderer implementations.
Definition EEngineProject.h:6