Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
BsdfHelper.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/TVector3.h"
4#include "Math/math.h"
5
6#include <Common/assertion.h>
7
8namespace ph
9{
10
11class BsdfHelper final
12{
13public:
14 static inline bool makeHalfVector(
15 const math::Vector3R& L, const math::Vector3R& V,
16 math::Vector3R* const out_H)
17 {
18 PH_ASSERT(out_H);
19
20 *out_H = L.add(V);
21 if(out_H->isZero())
22 {
23 return false;
24 }
25 else
26 {
27 out_H->normalizeLocal();
28 return true;
29 }
30 }
31
32 static inline bool makeHalfVectorSameHemisphere(
33 const math::Vector3R& L, const math::Vector3R& V, const math::Vector3R& N,
34 math::Vector3R* const out_H)
35 {
36 PH_ASSERT(out_H);
37
38 if(!makeHalfVector(L, V, out_H))
39 {
40 return false;
41 }
42
43 out_H->mulLocal(static_cast<real>(math::sign(N.dot(*out_H))));
44 return !out_H->isZero();
45 }
46};
47
48}// end namespace ph
Definition BsdfHelper.h:12
static bool makeHalfVectorSameHemisphere(const math::Vector3R &L, const math::Vector3R &V, const math::Vector3R &N, math::Vector3R *const out_H)
Definition BsdfHelper.h:32
static bool makeHalfVector(const math::Vector3R &L, const math::Vector3R &V, math::Vector3R *const out_H)
Definition BsdfHelper.h:14
bool isZero() const
Definition TArithmeticArrayBase.ipp:549
Derived & normalizeLocal()
Definition TVectorNBase.ipp:57
T dot(const Derived &rhs) const
Definition TVectorNBase.ipp:14
Derived & mulLocal(const Derived &rhs)
Definition TArithmeticArrayBase.ipp:112
Derived add(const Derived &rhs) const
Definition TArithmeticArrayBase.ipp:26
Miscellaneous math utilities.
int sign(const T value)
Extract the sign of value.
Definition math.h:154
The root for all renderer implementations.
Definition EEngineProject.h:6