Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
LerpedSurfaceOptics.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <Common/primitive_type.h>
9
10#include <memory>
11#include <vector>
12
13namespace ph
14{
15
19{
20public:
22 const std::shared_ptr<SurfaceOptics>& optics0,
23 const std::shared_ptr<SurfaceOptics>& optics1);
24
28 const std::shared_ptr<SurfaceOptics>& optics0,
29 const std::shared_ptr<SurfaceOptics>& optics1,
30 real ratio);
31
35 const std::shared_ptr<SurfaceOptics>& optics0,
36 const std::shared_ptr<SurfaceOptics>& optics1,
37 const std::shared_ptr<TTexture<math::Spectrum>>& ratio);
38
39 ESurfacePhenomenon getPhenomenonOf(SurfaceElemental elemental) const override;
40
41 std::string toString() const override;
42
43private:
44 void calcBsdf(
45 const BsdfQueryContext& ctx,
46 const BsdfEvalInput& in,
47 BsdfEvalOutput& out) const override;
48
49 void genBsdfSample(
50 const BsdfQueryContext& ctx,
51 const BsdfSampleInput& in,
52 SampleFlow& sampleFlow,
53 BsdfSampleOutput& out) const override;
54
55 void calcBsdfPdf(
56 const BsdfQueryContext& ctx,
57 const BsdfPdfInput& in,
58 BsdfPdfOutput& out) const override;
59
60 static real probabilityOfPickingOptics0(const math::Spectrum& ratio);
61
62 std::shared_ptr<SurfaceOptics> m_optics0;
63 std::shared_ptr<SurfaceOptics> m_optics1;
64 std::shared_ptr<TTexture<math::Spectrum>> m_ratio;
66 bool m_containsDelta;
67};
68
69// In-header Implementations:
70
71inline std::string LerpedSurfaceOptics::toString() const
72{
73 return
74 "Lerped Surface Optics, "
75 "optics_0: " + m_optics0->toString() +
76 "optics_1: " + m_optics1->toString() +
78}
79
80inline real LerpedSurfaceOptics::probabilityOfPickingOptics0(const math::Spectrum& ratio)
81{
82 // Depending on the purpose of rendering, favoring human visual system may be preferable,
83 // e.g., using luminance. Currently we use the absolute sum just to be fair.
84 const real weight0 = ratio.abs().sum();
85 const real weight1 = ratio.complement().abs().sum();
86 return math::clamp(weight0 / (weight0 + weight1), 0.0_r, 1.0_r);
87}
88
89}// end namespace ph
Input for BsdfEvalQuery.
Definition BsdfEvalQuery.h:20
Output for BsdfEvalQuery.
Definition BsdfEvalQuery.h:47
Input for BsdfPdfQuery.
Definition BsdfPdfQuery.h:19
Output for BsdfPdfQuery.
Definition BsdfPdfQuery.h:46
The environment a BSDF query is performed under.
Definition BsdfQueryContext.h:13
Input for BsdfSampleQuery.
Definition BsdfSampleQuery.h:21
Output for BsdfSampleQuery.
Definition BsdfSampleQuery.h:45
Linearly interpolate between two surface optics.
Definition LerpedSurfaceOptics.h:19
std::string toString() const override
Definition LerpedSurfaceOptics.h:71
ESurfacePhenomenon getPhenomenonOf(SurfaceElemental elemental) const override
Get the phenomenon of a surface component. One can also setup query for a specific elemental....
Definition LerpedSurfaceOptics.cpp:68
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
Describes how light interacts with a surface.
Definition SurfaceOptics.h:17
friend class LerpedSurfaceOptics
Definition SurfaceOptics.h:19
virtual std::string toString() const
Definition SurfaceOptics.h:104
Common settings and operations for sampling a texture.
Definition TSampler.h:18
Definition TTexture.h:12
Derived complement() const
Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
Definition TArithmeticArrayBase.ipp:502
Derived abs() const
Definition TArithmeticArrayBase.ipp:466
Definition TTristimulusSpectrum.h:11
T clamp(const T value, const T lowerBound, const T upperBound)
Clamps a value to [lowerBound, upperBound]. None of value, lowerBound and upperBound can be NaN,...
Definition math.h:77
The root for all renderer implementations.
Definition EEngineProject.h:6
ESurfacePhenomenon
Available surface phenomena.
Definition surface_optics_fwd.h:16
int SurfaceElemental
Definition surface_optics_fwd.h:30