Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
RoughnessToAlphaMapping.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/primitive_type.h>
6
7#include <algorithm>
8#include <cmath>
9
10namespace ph
11{
12
24{
25public:
28 static real equaled(const real roughness);
29
37 static real squared(const real roughness);
38
41 static real pbrtV3(const real roughness);
42
45 static real map(const real roughness, ERoughnessToAlpha mapType);
46};
47
48// In-header Implementations:
49
50inline real RoughnessToAlphaMapping::equaled(const real roughness)
51{
52 return roughness;
53}
54
55inline real RoughnessToAlphaMapping::squared(const real roughness)
56{
57 return roughness * roughness;
58}
59
60inline real RoughnessToAlphaMapping::pbrtV3(const real roughness)
61{
62 const real clampedRoughness = std::max(roughness, 0.001_r);
63 const real x = std::log(clampedRoughness);
64
65 return 1.621420000_r +
66 0.819955000_r * x +
67 0.173400000_r * x * x +
68 0.017120100_r * x * x * x +
69 0.000640711_r * x * x * x * x;
70}
71
72inline real RoughnessToAlphaMapping::map(const real roughness, const ERoughnessToAlpha mapType)
73{
74 switch(mapType)
75 {
77 return equaled(roughness);
78
80 return squared(roughness);
81
83 return pbrtV3(roughness);
84
85 default:
86 return squared(roughness);
87 }
88}
89
90}// end namespace ph
Maps roughness value in [0, 1] to the alpha parameter in NDF.
Definition RoughnessToAlphaMapping.h:24
static real equaled(const real roughness)
Directly assign roughness value as-is to alpha.
Definition RoughnessToAlphaMapping.h:50
static real squared(const real roughness)
Mapping for a perceptually linear roughness.
Definition RoughnessToAlphaMapping.h:55
static real pbrtV3(const real roughness)
This mapping is used in PBRT-v3.
Definition RoughnessToAlphaMapping.h:60
static real map(const real roughness, ERoughnessToAlpha mapType)
Map roughness value to alpha based on map type.
Definition RoughnessToAlphaMapping.h:72
The root for all renderer implementations.
Definition EEngineProject.h:6
ERoughnessToAlpha
Definition sdl_component_enums.h:26