Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
conversions.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/math.h"
4
5#include <Common/assertion.h>
6#include <Common/primitive_type.h>
7
8#include <cmath>
9
10namespace ph
11{
12
13namespace lbconv
14{
15
16inline real alpha_to_variance(const real alpha)
17{
18 const real clampedAlpha = math::clamp(alpha, 0.0_r, 0.9999_r);
19 const real alpha1p1 = std::pow(clampedAlpha, 1.1_r);
20 return alpha1p1 / (1.0_r - alpha1p1);
21}
22
23inline real variance_to_alpha(const real variance)
24{
25 return std::pow(variance / (1.0_r + variance), 1.0_r / 1.1_r);
26}
27
28inline real g_to_variance(const real g)
29{
30 PH_ASSERT(0.0_r < g && g <= 1.0_r);
31
32 return std::pow((1.0_r - g) / g, 0.8_r) / (1.0_r + g);
33}
34
35}// end namespace conversions
36
37}// end namespace ph
Miscellaneous math utilities.
real variance_to_alpha(const real variance)
Definition conversions.h:23
real alpha_to_variance(const real alpha)
Definition conversions.h:16
real g_to_variance(const real g)
Definition conversions.h:28
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