Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ShapeInvariantMicrofacet.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <Common/assertion.h>
7
8namespace ph
9{
10
16{
17public:
19 EMaskingShadowing maskingShadowingType);
20
25 virtual std::array<real, 2> getAlphas(const SurfaceHit& X) const = 0;
26
35 virtual real lambda(
36 const SurfaceHit& X,
37 const math::Vector3R& N,
38 const math::Vector3R& H,
39 const math::Vector3R& unitDir,
40 const std::array<real, 2>& alphas) const = 0;
41
43 const SurfaceHit& X,
44 const math::Vector3R& N,
45 const math::Vector3R& H) const override = 0;
46
47 void sampleH(
48 const SurfaceHit& X,
49 const math::Vector3R& N,
50 const std::array<real, 2>& sample,
51 math::Vector3R* out_H) const override = 0;
52
53 real geometry(
54 const SurfaceHit& X,
55 const math::Vector3R& N,
56 const math::Vector3R& H,
57 const math::Vector3R& L,
58 const math::Vector3R& V) const override;
59
61 const SurfaceHit& X,
62 const math::Vector3R& N,
63 const math::Vector3R& H) const override;
64
65protected:
69 real smithG1(real lambdaValue) const;
70
76 const SurfaceHit& X,
77 const math::Vector3R& L,
78 const math::Vector3R& V) const;
79
86 const SurfaceHit& X,
87 const math::Vector3R& N,
88 const math::Vector3R& H) const;
89
91 const SurfaceHit& X,
92 const math::Vector3R& N,
93 const math::Vector3R& H,
94 const math::Vector3R& V) const;
95
97};
98
100 const SurfaceHit& X,
101 const math::Vector3R& N,
102 const math::Vector3R& H) const
103{
104 return {
105 .value = projectedDistribution(X, N, H),
107}
108
109inline real ShapeInvariantMicrofacet::smithG1(const real lambdaValue) const
110{
111 return 1.0_r / (1.0_r + lambdaValue);
112}
113
115 const SurfaceHit& X,
116 const math::Vector3R& N,
117 const math::Vector3R& H) const
118{
119 PH_ASSERT_GE(N.dot(H), -1e-3_r);
120
121 return distribution(X, N, H) * N.absDot(H);
122}
123
125 const SurfaceHit& X,
126 const math::Vector3R& N,
127 const math::Vector3R& H,
128 const math::Vector3R& V) const
129{
130 PH_ASSERT_GE(N.dot(H), -1e-3_r);
131
132 const real lambdaV = lambda(X, N, H, V, getAlphas(X));
133 const real g1V = smithG1(lambdaV);
134 const real ndf = distribution(X, N, H);
135 const real vndf = g1V * ndf * std::abs(H.dot(V) / N.dot(V));
136
137 return vndf;
138}
139
140}// end namespace ph
Definition Microfacet.h:22
Definition ShapeInvariantMicrofacet.h:16
virtual real lambda(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &unitDir, const std::array< real, 2 > &alphas) const =0
The function that appears in the masking-shadowing term. For isotropic distributions,...
real visibleDistribution(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &V) const
Definition ShapeInvariantMicrofacet.h:124
real geometry(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &L, const math::Vector3R &V) const override
Masking and shadowing due to nearby microfacets. The term.
Definition ShapeInvariantMicrofacet.cpp:20
real distribution(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const override=0
Distribution of the microfacet normal. The term. Also commonly knwon as the NDF (normal distribution...
real empiricalPhiCorrelation(const SurfaceHit &X, const math::Vector3R &L, const math::Vector3R &V) const
Definition ShapeInvariantMicrofacet.cpp:86
void sampleH(const SurfaceHit &X, const math::Vector3R &N, const std::array< real, 2 > &sample, math::Vector3R *out_H) const override=0
Generate a microfacet normal H for the distribution. This samples all possible H vectors for the dist...
EMaskingShadowing m_maskingShadowingType
Definition ShapeInvariantMicrofacet.h:96
real projectedDistribution(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const
Definition ShapeInvariantMicrofacet.h:114
lta::PDF pdfSampleH(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const override
Definition ShapeInvariantMicrofacet.h:99
real smithG1(real lambdaValue) const
Definition ShapeInvariantMicrofacet.h:109
virtual std::array< real, 2 > getAlphas(const SurfaceHit &X) const =0
ShapeInvariantMicrofacet(EMaskingShadowing maskingShadowingType)
Definition ShapeInvariantMicrofacet.cpp:12
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
A sample from a Probability Density Function (PDF).
Definition PDF.h:14
real value
Definition PDF.h:18
T dot(const Derived &rhs) const
Definition TVectorNBase.ipp:14
T absDot(const Derived &rhs) const
Definition TVectorNBase.ipp:26
The root for all renderer implementations.
Definition EEngineProject.h:6
EMaskingShadowing
Different types of masking and shadowing terms for microfacet distributions. Eric Heitz has published...
Definition enums.h:11