Open3D (C++ API)  0.12.0
Material.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2020 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Core>
30 #include <string>
31 #include <unordered_map>
32 
33 #include "open3d/geometry/Image.h"
36 
37 namespace open3d {
38 namespace visualization {
39 namespace rendering {
40 
41 struct Material {
42  std::string name;
43 
44  // Rendering attributes
45  bool has_alpha = false;
46 
47  // PBR Material properties and maps
48  Eigen::Vector4f base_color = Eigen::Vector4f(1.f, 1.f, 1.f, 1.f);
49  float base_metallic = 0.f;
50  float base_roughness = 1.f;
51  float base_reflectance = 0.5f;
52  float base_clearcoat = 0.f;
54  float base_anisotropy = 0.f;
55 
56  // PBR material properties for refractive materials
57  float thickness = 1.f;
58  float transmission = 1.f;
59  Eigen::Vector3f absorption_color =
60  Eigen::Vector3f(1.f, 1.f, 1.f); // linear color
61  float absorption_distance = 1.f;
62 
63  float point_size = 3.f;
64  float line_width = 1.f;
65 
66  std::shared_ptr<geometry::Image> albedo_img;
67  std::shared_ptr<geometry::Image> normal_img;
68  std::shared_ptr<geometry::Image> ao_img;
69  std::shared_ptr<geometry::Image> metallic_img;
70  std::shared_ptr<geometry::Image> roughness_img;
71  std::shared_ptr<geometry::Image> reflectance_img;
72  std::shared_ptr<geometry::Image> clearcoat_img;
73  std::shared_ptr<geometry::Image> clearcoat_roughness_img;
74  std::shared_ptr<geometry::Image> anisotropy_img;
75 
76  // Combined images
77  std::shared_ptr<geometry::Image> ao_rough_metal_img;
78 
79  // Colormap (incompatible with other settings except point_size)
80  // Values for 'value' must be in [0, 1] and the vector must be sorted
81  // by increasing value. 'shader' must be "unlitGradient".
82  std::shared_ptr<Gradient> gradient;
83  float scalar_min = 0.0f;
84  float scalar_max = 1.0f;
85 
86  // Colors are assumed to be sRGB and tone-mapped accordingly.
87  // If tone-mapping is disabled, then colors would be in linear RGB space,
88  // in which case this should be set to false.
89  bool sRGB_color = true;
90 
91  // Background image (shader = "unlitBackground")
92  float aspect_ratio = 0.0f; // 0: uses base_color; >0: uses albedo_img
93 
94  // Generic material properties
95  std::unordered_map<std::string, Eigen::Vector4f> generic_params;
96  std::unordered_map<std::string, geometry::Image> generic_imgs;
97 
98  std::string shader;
99 };
100 
101 } // namespace rendering
102 } // namespace visualization
103 } // namespace open3d
std::shared_ptr< geometry::Image > anisotropy_img
Definition: Material.h:74
std::shared_ptr< geometry::Image > clearcoat_roughness_img
Definition: Material.h:73
float absorption_distance
Definition: Material.h:61
std::shared_ptr< geometry::Image > normal_img
Definition: Material.h:67
bool has_alpha
Definition: Material.h:45
std::unordered_map< std::string, Eigen::Vector4f > generic_params
Definition: Material.h:95
std::shared_ptr< Gradient > gradient
Definition: Material.h:82
std::shared_ptr< geometry::Image > ao_img
Definition: Material.h:68
float point_size
Definition: Material.h:63
float line_width
Definition: Material.h:64
float aspect_ratio
Definition: Material.h:92
Eigen::Vector3f absorption_color
Definition: Material.h:59
float base_clearcoat
Definition: Material.h:52
float scalar_min
Definition: Material.h:83
std::unordered_map< std::string, geometry::Image > generic_imgs
Definition: Material.h:96
float thickness
Definition: Material.h:57
float transmission
Definition: Material.h:58
std::shared_ptr< geometry::Image > roughness_img
Definition: Material.h:70
float base_roughness
Definition: Material.h:50
float base_reflectance
Definition: Material.h:51
std::shared_ptr< geometry::Image > albedo_img
Definition: Material.h:66
std::string shader
Definition: Material.h:98
float scalar_max
Definition: Material.h:84
Definition: PinholeCameraIntrinsic.cpp:35
float base_anisotropy
Definition: Material.h:54
std::shared_ptr< geometry::Image > reflectance_img
Definition: Material.h:71
std::shared_ptr< geometry::Image > metallic_img
Definition: Material.h:69
std::shared_ptr< geometry::Image > clearcoat_img
Definition: Material.h:72
float base_clearcoat_roughness
Definition: Material.h:53
std::shared_ptr< geometry::Image > ao_rough_metal_img
Definition: Material.h:77
bool sRGB_color
Definition: Material.h:89
Eigen::Vector4f base_color
Definition: Material.h:48
float base_metallic
Definition: Material.h:49
std::string name
Definition: Material.h:42