-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial-param.h
99 lines (82 loc) · 3.29 KB
/
material-param.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef PBRLAB_MATERIAL_PARAM_H_
#define PBRLAB_MATERIAL_PARAM_H_
#include <stdint.h>
#include "type.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#endif
#include "mpark/variant.hpp"
#ifdef __clang__
#pragma clang diagnostic pop
#endif
namespace pbrlab {
enum MaterialParameterType {
kCyclesPrincipledBsdfParameter = 0,
kHairBsdfParameter
};
struct CyclesPrincipledBsdfParameter {
float3 base_color = {static_cast<float>(0.8), static_cast<float>(0.8),
static_cast<float>(0.8)};
float subsurface = static_cast<float>(0.0);
float3 subsurface_radius = {static_cast<float>(1.0), static_cast<float>(1.0),
static_cast<float>(1.0)};
float3 subsurface_color = {static_cast<float>(0.7), static_cast<float>(0.1),
static_cast<float>(0.1)};
float metallic = static_cast<float>(0.0);
float specular = static_cast<float>(0.5);
float specular_tint = static_cast<float>(0.0);
float roughness = static_cast<float>(0.5);
float anisotropic = static_cast<float>(0.0);
float anisotropic_rotation = static_cast<float>(0.0);
float sheen = static_cast<float>(0.0);
float sheen_tint = static_cast<float>(0.5);
float clearcoat = static_cast<float>(0.0);
float clearcoat_roughness = static_cast<float>(0.03);
float ior = static_cast<float>(1.45);
float transmission = static_cast<float>(0.0);
float transmission_roughness = static_cast<float>(0.0);
uint32_t base_color_tex_id = static_cast<uint32_t>(-1);
uint32_t subsurface_color_tex_id = static_cast<uint32_t>(-1);
std::string name = "";
};
struct HairBsdfParameter {
enum ColoringHair { kRGB = 0, kMelanin };
ColoringHair coloring_hair = kMelanin;
float3 base_color = {0.18f, 0.06f, 0.02f};
float melanin = 0.5f;
float melanin_redness = 0.8f;
float melanin_randomize = 0.f;
float roughness = 0.2f;
float azimuthal_roughness = 0.3f;
float ior = 1.55f;
float shift = 2.f;
float3 specular_tint = {1.f, 1.f, 1.f};
float3 second_specular_tint = {1.f, 1.f, 1.f};
float3 transmission_tint = {1.f, 1.f, 1.f};
std::string name = "";
};
using MaterialParameter =
mpark::variant<CyclesPrincipledBsdfParameter, HairBsdfParameter>;
inline void SetMaterialName(const std::string& name,
MaterialParameter* material_param) {
if (material_param->index() == kCyclesPrincipledBsdfParameter) {
mpark::get<kCyclesPrincipledBsdfParameter>(*material_param).name = name;
} else if (material_param->index() == kHairBsdfParameter) {
mpark::get<kHairBsdfParameter>(*material_param).name = name;
} else {
assert(false);
}
}
inline std::string GetMaterialName(const MaterialParameter& material_param) {
if (material_param.index() == kCyclesPrincipledBsdfParameter) {
return mpark::get<kCyclesPrincipledBsdfParameter>(material_param).name;
} else if (material_param.index() == kHairBsdfParameter) {
return mpark::get<kHairBsdfParameter>(material_param).name;
} else {
assert(false);
}
return "";
}
} // namespace pbrlab
#endif // PBRLAB_MAfloatERIAL_PARAM_H_