Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
Microfacet.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/TVector3.h"
4#include "Core/SurfaceHit.h"
5#include "Core/LTA/PDF.h"
6
7#include <Common/primitive_type.h>
8
9#include <array>
10
11namespace ph
12{
13
22{
23public:
24 virtual ~Microfacet() = default;
25
32 virtual real distribution(
33 const SurfaceHit& X,
34 const math::Vector3R& N,
35 const math::Vector3R& H) const = 0;
36
40 virtual real geometry(
41 const SurfaceHit& X,
42 const math::Vector3R& N,
43 const math::Vector3R& H,
44 const math::Vector3R& L,
45 const math::Vector3R& V) const = 0;
46
53 virtual void sampleH(
54 const SurfaceHit& X,
55 const math::Vector3R& N,
56 const std::array<real, 2>& sample,
57 math::Vector3R* out_H) const = 0;
58
63 const SurfaceHit& X,
64 const math::Vector3R& N,
65 const math::Vector3R& H) const = 0;
66
72 virtual void sampleVisibleH(
73 const SurfaceHit& X,
74 const math::Vector3R& N,
75 const math::Vector3R& V,
76 const std::array<real, 2>& sample,
77 math::Vector3R* out_H) const;
78
83 const SurfaceHit& X,
84 const math::Vector3R& N,
85 const math::Vector3R& H,
86 const math::Vector3R& V) const;
87
88protected:
98 static bool isSidednessAgreed(
99 real NoD,
100 real HoD);
101
105 static bool isSidednessAgreed(
106 real NoL,
107 real NoV,
108 real HoL,
109 real HoV);
110};
111
113 const SurfaceHit& X,
114 const math::Vector3R& N,
115 const math::Vector3R& /* V */,
116 const std::array<real, 2>& sample,
117 math::Vector3R* const out_H) const
118{
119 return sampleH(X, N, sample, out_H);
120}
121
123 const SurfaceHit& X,
124 const math::Vector3R& N,
125 const math::Vector3R& H,
126 const math::Vector3R& /* V */) const
127{
128 return pdfSampleH(X, N, H);
129}
130
132 const real NoD,
133 const real HoD)
134{
135 return HoD * NoD > 0.0_r;
136}
137
139 const real NoL,
140 const real NoV,
141 const real HoL,
142 const real HoV)
143{
144 return isSidednessAgreed(NoL, HoL) && isSidednessAgreed(NoV, HoV);
145}
146
147}// end namespace ph
Definition Microfacet.h:22
virtual real geometry(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &L, const math::Vector3R &V) const =0
Masking and shadowing due to nearby microfacets. The term.
virtual lta::PDF pdfSampleH(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const =0
static bool isSidednessAgreed(real NoD, real HoD)
Definition Microfacet.h:131
virtual void sampleH(const SurfaceHit &X, const math::Vector3R &N, const std::array< real, 2 > &sample, math::Vector3R *out_H) const =0
Generate a microfacet normal H for the distribution. This samples all possible H vectors for the dist...
virtual ~Microfacet()=default
virtual lta::PDF pdfSampleVisibleH(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &V) const
Definition Microfacet.h:122
virtual real distribution(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const =0
Distribution of the microfacet normal. The term. Also commonly knwon as the NDF (normal distribution...
virtual void sampleVisibleH(const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &V, const std::array< real, 2 > &sample, math::Vector3R *out_H) const
Same as sampleH(), but tries to take geometry term into consideration. This samples only potentially ...
Definition Microfacet.h:112
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
A sample from a Probability Density Function (PDF).
Definition PDF.h:14
The root for all renderer implementations.
Definition EEngineProject.h:6