cgv
surface_material.h
1 #pragma once
2 
3 #include <complex>
4 #include <cgv/media/color.h>
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace media {
10  namespace illum {
11 
13 enum BrdfType {
14  BT_LAMBERTIAN = 0, // use lambertian for diffuse part
15  BT_OREN_NAYAR = 1, // use oren nayar for diffuse part
16  BT_STRAUSS_DIFFUSE = 2, // use diffuse part of strauss model for diffuse part
17  // reserve one more diffuse models for future use
18  BT_PHONG = 4, // shininess in range [1,128] is computed roughness
19  BT_BLINN = 8, // shininess in range [1,128] is computed roughness
20  BT_COOK_TORRANCE = 12,
21  BT_STRAUSS = 16
22 };
23 
25 class CGV_API surface_material
26 {
27 public:
30 protected:
32  BrdfType brdf_type;
36  float roughness;
38  float metalness;
44  float transparency;
46  std::complex<float> propagation_slow_down;
53 public: //@<
56  BrdfType _brdf_type = BrdfType(BT_STRAUSS_DIFFUSE + BT_STRAUSS),
57  color_type _diffuse_reflectance = color_type(0.5f, 0.5f, 0.5f),
58  float _roughness = 0.5f,
59  float _metalness = 0.0f,
60  float _ambient_occlusion = 1.0f,
61  color_type _emission = color_type(0,0,0),
62  float _transparency = 0.0f,
63  const std::complex<float>& _propagation_slow_down = std::complex<float>(1.5f,0.0f),
64  float _roughness_anisotropy = 0.0f,
65  float _roughness_orientation = 0.0f,
66  color_type _specular_reflectance = color_type(1,1,1)
67  );
68 
69  void set_brdf_type(BrdfType brdf_type) { this->brdf_type = brdf_type; }
70  BrdfType get_brdf_type() const { return brdf_type; }
71  BrdfType& ref_brdf_type() { return brdf_type; }
72 
73  void set_ambient_occlusion(float ambient_occlusion) { this->ambient_occlusion = ambient_occlusion; }
74  float get_ambient_occlusion() const { return ambient_occlusion; }
75  float& ref_ambient_occlusion() { return ambient_occlusion; }
76 
77  void set_diffuse_reflectance(color_type diffuse_reflectance) { this->diffuse_reflectance = diffuse_reflectance; }
78  color_type get_diffuse_reflectance() const { return diffuse_reflectance; }
79  color_type& ref_diffuse_reflectance() { return diffuse_reflectance; }
80 
81  void set_specular_reflectance(color_type specular_reflectance) { this->specular_reflectance = specular_reflectance; }
82  color_type get_specular_reflectance() const { return specular_reflectance; }
83  color_type& ref_specular_reflectance() { return specular_reflectance; }
84 
85  void set_emission(color_type emission) { this->emission = emission; }
86  color_type get_emission() const { return emission; }
87  color_type& ref_emission() { return emission; }
88 
89  void set_transparency(float transparency) { this->transparency = transparency; }
90  float get_transparency() const { return transparency; }
91  float& ref_transparency() { return transparency; }
92 
93  void set_roughness(float roughness) { this->roughness = roughness; }
94  float get_roughness() const { return roughness; }
95  float& ref_roughness() { return roughness; }
96 
97  void set_metalness(float metalness) { this->metalness = metalness; }
98  float get_metalness() const { return metalness; }
99  float& ref_metalness() { return metalness; }
100 
101  void set_roughness_anisotropy(float roughness_anisotropy) { this->roughness_anisotropy = roughness_anisotropy; }
102  float get_roughness_anisotropy() const { return roughness_anisotropy; }
103  float& ref_roughness_anisotropy() { return roughness_anisotropy; }
104 
105  void set_roughness_orientation(float roughness_orientation) { this->roughness_orientation = roughness_orientation; }
106  float get_roughness_orientation() const { return roughness_orientation; }
107  float& ref_roughness_orientation() { return roughness_orientation; }
108 
109  void set_propagation_slow_down(std::complex<float> propagation_slow_down) { this->propagation_slow_down = propagation_slow_down; }
110  std::complex<float> get_propagation_slow_down() const { return propagation_slow_down; }
111  std::complex<float>& ref_propagation_slow_down() { return propagation_slow_down; }
112 };
113 
114 enum StandardMaterial
115 {
116  // transparent
117  SM_WATER,
118  SM_GLASS,
119 
120  // metals
121  SM_ALUMINUM,
122  SM_SILVER,
123  SM_COPPER,
124  SM_GOLD
125 };
126 
128 extern CGV_API const surface_material& get_surface_material(StandardMaterial material_id);
129 
130  }
131  }
132 }
133 
134 #include <cgv/config/lib_end.h>
cgv::media::illum::surface_material::roughness
float roughness
surface roughness in the range 0,1, defaults to 0.5
Definition: surface_material.h:36
cgv::media::illum::surface_material::roughness_orientation
float roughness_orientation
orientation of roughness in range [0,1], where 0 corresponds to u-direction and 0....
Definition: surface_material.h:50
cgv::media::illum::surface_material::color_type
color< float, RGB > color_type
used color type
Definition: surface_material.h:29
cgv::media::illum::surface_material::diffuse_reflectance
color_type diffuse_reflectance
diffuse reflectance of surface, defaults to 0.5,0.5,0.5
Definition: surface_material.h:34
cgv::media::color< float, RGB >
cgv::media::illum::surface_material
simple class to hold the material properties of a phong material
Definition: surface_material.h:26
cgv::media::illum::surface_material::brdf_type
BrdfType brdf_type
store brdf type, defaults to BT_COOK_TORRANCE
Definition: surface_material.h:32
cgv::media::illum::surface_material::ambient_occlusion
float ambient_occlusion
scalar factor to down scale ambient light, defaults to 1
Definition: surface_material.h:40
cgv::media::illum::surface_material::transparency
float transparency
modulation for transparency, defaults to 0
Definition: surface_material.h:44
cgv::media::illum::surface_material::propagation_slow_down
std::complex< float > propagation_slow_down
complex fraction of complex interior over real exterior index of refraction, defaults to 1....
Definition: surface_material.h:46
cgv::media::illum::surface_material::specular_reflectance
color_type specular_reflectance
specular color used to modulate specular reflection component, should be 1,1,1
Definition: surface_material.h:52
cgv::media::illum::surface_material::emission
color_type emission
emissive color component, defaults to 0,0,0
Definition: surface_material.h:42
cgv::media::illum::surface_material::roughness_anisotropy
float roughness_anisotropy
difference of roughness matrix eigenvalues in range [0,1] relative to roughness, i....
Definition: surface_material.h:48
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::media::illum::surface_material::metalness
float metalness
metalness of surface
Definition: surface_material.h:38