Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TViewPathHandler.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core/SurfaceHit.h"
4#include "Math/TVector2.h"
7#include "Utility/utility.h"
8#include "Utility/traits.h"
9
10#include <cstddef>
11
12namespace ph
13{
14
15template<typename T>
16concept CViewPathHandler = requires
17{
18 typename T::ViewPathHandlerTag;
19};
20
24template<typename Derived>
26{
27public:
28 using ViewPathHandlerTag = void;
29
34 const math::Vector2D& rasterCoord,
35 const math::Vector2S& sampleIndex,
36 const math::Spectrum& pathThroughput);
37
42 std::size_t pathLength,
43 const SurfaceHit& surfaceHit,
44 const math::Spectrum& pathThroughput) -> ViewPathTracingPolicy;
45
49
54
55// Hide special members as this class is not intended to be used polymorphically.
56// It is derived class's choice to expose them (by defining them in public) or not.
57protected:
59};
60
61// In-header Implementations:
62
63template<typename Derived>
65 const math::Vector2D& rasterCoord,
66 const math::Vector2S& sampleIndex,
67 const math::Spectrum& pathThroughput)
68{
69 static_assert(requires (
70 Derived derived,
71 math::Vector2D rasterCoord,
72 math::Vector2S sampleIndex,
73 math::Spectrum pathThroughput)
74 {
75 {
76 derived.impl_onReceiverSampleStart(
77 rasterCoord,
78 sampleIndex,
79 pathThroughput)
80 }
81 -> CSame<bool>;
82 },
83 "A view path handler type must implement a method callable as "
84 "`impl_onReceiverSampleStart(math::Vector2D{}, math::Vector2S{}, math::Spectrum{}) -> bool`.");
85
86 return static_cast<Derived&>(*this).impl_onReceiverSampleStart(
87 rasterCoord,
88 sampleIndex,
89 pathThroughput);
90}
91
92template<typename Derived>
94 const std::size_t pathLength,
95 const SurfaceHit& surfaceHit,
96 const math::Spectrum& pathThroughput) -> ViewPathTracingPolicy
97{
98 static_assert(requires (
99 Derived derived,
100 std::size_t pathLength,
101 SurfaceHit surfaceHit,
102 math::Spectrum pathThroughput)
103 {
104 {
105 derived.impl_onPathHitSurface(
106 pathLength,
107 surfaceHit,
108 pathThroughput)
109 }
111 },
112 "A view path handler type must implement a method callable as "
113 "`impl_onPathHitSurface(std::size_t{}, SurfaceHit{}, math::Spectrum{}) -> ViewPathTracingPolicy`.");
114
115 return static_cast<Derived&>(*this).impl_onPathHitSurface(
116 pathLength,
117 surfaceHit,
118 pathThroughput);
119}
120
121template<typename Derived>
123{
124 static_assert(requires (Derived derived)
125 {
126 { derived.impl_onReceiverSampleEnd() } -> CSame<void>;
127 },
128 "A view path handler type must implement a method callable as "
129 "`impl_onReceiverSampleEnd() -> void`.");
130
131 static_cast<Derived&>(*this).impl_onReceiverSampleEnd();
132}
133
134template<typename Derived>
136{
137 static_assert(requires (Derived derived)
138 {
139 { derived.impl_onSampleBatchFinished() } -> CSame<void>;
140 },
141 "A view path handler type must implement a method callable as "
142 "`impl_onSampleBatchFinished() -> void`.");
143
144 static_cast<Derived&>(*this).impl_onSampleBatchFinished();
145}
146
147}// end namespace ph
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
Process and control a view path tracing process. Derived classes need to implement all methods with "...
Definition TViewPathHandler.h:26
void onSampleBatchFinished()
Called after a batch of receiver samples has been consumed. Sample batch is as defined by the sample ...
Definition TViewPathHandler.h:135
void onReceiverSampleEnd()
Called after a receiver sample has ended.
Definition TViewPathHandler.h:122
auto onPathHitSurface(std::size_t pathLength, const SurfaceHit &surfaceHit, const math::Spectrum &pathThroughput) -> ViewPathTracingPolicy
Called after the view path hits a surface, with corresponding hit information given.
Definition TViewPathHandler.h:93
void ViewPathHandlerTag
Definition TViewPathHandler.h:28
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(TViewPathHandler)
bool onReceiverSampleStart(const math::Vector2D &rasterCoord, const math::Vector2S &sampleIndex, const math::Spectrum &pathThroughput)
Called after a receiver sample is generated.
Definition TViewPathHandler.h:64
Specifying and querying policies for tracing view path.
Definition ViewPathTracingPolicy.h:24
Definition TTristimulusSpectrum.h:11
Definition traits.h:113
Definition TViewPathHandler.h:16
The root for all renderer implementations.
Definition EEngineProject.h:6