Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PhotonMappingVisualizer.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector2.h"
6#include "SDL/sdl_interface.h"
10
11#include <Common/primitive_type.h>
12
13#include <memory>
14
15namespace ph { class IRayEnergyEstimator; }
16namespace ph { class SampleFilter; }
17
18namespace ph
19{
20
22{
23public:
24 void cook(const CoreCookingContext& ctx, CoreCookedUnit& cooked) override;
25
28
29protected:
32
33private:
34 EPhotonMappingMode m_mode;
35 ESampleFilter m_sampleFilter;
36 uint64 m_numPhotons;
37 uint64 m_numPasses;
38 uint64 m_numSamplesPerPixel;
39 real m_photonRadius;
40 uint32 m_glossyMergeBeginLength;
41 uint32 m_stochasticViewSampleBeginLength;
42
43public:
45 {
46 ClassType clazz("photon-mapping");
47 clazz.docName("Photon Mapping Visualizer");
48 clazz.description("Render frames with common photon mapping methods.");
49 clazz.baseOn<FrameVisualizer>();
50
51 TSdlEnumField<OwnerType, EPhotonMappingMode> mode("mode", &OwnerType::m_mode);
52 mode.description(
53 "The photon mapping technique used by the visualizer.");
54 mode.defaultTo(EPhotonMappingMode::Vanilla);
55 mode.optional();
56 clazz.addField(mode);
57
58 TSdlEnumField<OwnerType, ESampleFilter> sampleFilter("sample-filter", &OwnerType::m_sampleFilter);
59 sampleFilter.description(
60 "Sample filter for the film sampling process.");
62 sampleFilter.optional();
63 clazz.addField(sampleFilter);
64
65 // Borrow the default values there
66 const PMCommonParams commonParams{};
67
68 TSdlUInt64<OwnerType> numPhotons("num-photons", &OwnerType::m_numPhotons);
69 numPhotons.description(
70 "Number of photons used. For progressive techniques, this value is for a single pass.");
71 numPhotons.defaultTo(commonParams.numPhotons);
72 numPhotons.optional();
73 clazz.addField(numPhotons);
74
75 TSdlUInt64<OwnerType> numPasses("num-passes", &OwnerType::m_numPasses);
76 numPasses.description(
77 "Number of passes performed by progressive techniques.");
78 numPasses.defaultTo(commonParams.numPasses);
79 numPasses.optional();
80 clazz.addField(numPasses);
81
82 TSdlUInt64<OwnerType> numSamplesPerPixel("num-samples-per-pixel", &OwnerType::m_numSamplesPerPixel);
83 numSamplesPerPixel.description(
84 "Number of samples per pixel. Higher values can resolve image aliasing, but can consume "
85 "large amounts of memory for some algorithms. This value can also mean the number of "
86 "statistics gathered in a single pixel for some techniques. If the value is not a "
87 "power-of-2 number, it may be adjusted.");
88 numSamplesPerPixel.defaultTo(commonParams.numSamplesPerPixel);
89 numSamplesPerPixel.optional();
90 clazz.addField(numSamplesPerPixel);
91
92 TSdlReal<OwnerType> photonRadius("photon-radius", &OwnerType::m_photonRadius);
93 photonRadius.description(
94 "Energy contribution radius for each photon. For progressive techniques, this value is for "
95 "setting up the initial radius.");
96 photonRadius.defaultTo(commonParams.kernelRadius);
97 photonRadius.optional();
98 clazz.addField(photonRadius);
99
100 TSdlUInt32<OwnerType> glossyMergeBeginLength("glossy-merge-begin-length", &OwnerType::m_glossyMergeBeginLength);
101 glossyMergeBeginLength.description(
102 "Hint for the minimum path length to start estimating energy using photons on glossy surface."
103 "If the scene contains diffuse surface and is easily reachable by photons, it is recommended "
104 "to set this to a lower value.");
105 glossyMergeBeginLength.defaultTo(commonParams.glossyMergeBeginLength);
106 glossyMergeBeginLength.optional();
107 clazz.addField(glossyMergeBeginLength);
108
109 TSdlUInt32<OwnerType> stochasticViewSampleBeginLength("stochastic-view-sample-begin-length", &OwnerType::m_stochasticViewSampleBeginLength);
110 stochasticViewSampleBeginLength.description(
111 "Hint for the view path length to start random path sampling. If this value differ too much "
112 "from the mean specular path length from the scene, the energy estimation result may contain "
113 "higher variance or bias. Beware when using higher values as non-stochastic path may be "
114 "branched, which can result in exponential growth of number of rays.");
115 stochasticViewSampleBeginLength.defaultTo(commonParams.stochasticViewSampleBeginLength);
116 stochasticViewSampleBeginLength.optional();
117 clazz.addField(stochasticViewSampleBeginLength);
118
119 return clazz;
120 }
121};
122
123// In-header Implementations:
124
126{
127 return m_mode;
128}
129
131{
132 return m_sampleFilter;
133}
134
135}// end namespace ph
Definition CoreCookedUnit.h:19
Definition CoreCookingContext.h:15
Definition FrameVisualizer.h:16
Common parameters of photon mapping.
Definition PMCommonParams.h:13
Definition PhotonMappingVisualizer.h:22
ESampleFilter getSampleFilter() const
Definition PhotonMappingVisualizer.h:130
void cook(const CoreCookingContext &ctx, CoreCookedUnit &cooked) override
Definition PhotonMappingVisualizer.cpp:18
EPhotonMappingMode getMode() const
Definition PhotonMappingVisualizer.h:125
PMCommonParams makeCommonParams() const
Definition PhotonMappingVisualizer.cpp:123
SampleFilter makeSampleFilter() const
Definition PhotonMappingVisualizer.cpp:102
PH_DEFINE_SDL_CLASS(TSdlOwnerClass< PhotonMappingVisualizer >)
Definition PhotonMappingVisualizer.h:44
An image reconstruction kernel.
Definition SampleFilter.h:17
Definition TSdlEnumField.h:23
A field class that binds a integral member variable.
Definition TSdlInteger.h:21
SDL binding type for a canonical SDL resource class.
Definition TSdlOwnerClass.h:23
A field class that binds a floating point member variable.
Definition TSdlReal.h:21
TSdlValue & description(std::string descriptionStr)
Definition TSdlValue.ipp:95
TSdlValue & optional()
Definition TSdlValue.ipp:103
TSdlValue & defaultTo(T defaultValue)
Definition TSdlValue.ipp:71
The root for all renderer implementations.
Definition EEngineProject.h:6
ESampleFilter
Definition sdl_sample_filter_type.h:9
EPhotonMappingMode
Definition sdl_photon_mapping_mode.h:9