Open3D (C++ API)  0.16.1
MaterialModifier.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 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
32
33namespace open3d {
34namespace visualization {
35namespace rendering {
36
38 enum class MinFilter : uint8_t {
39 Nearest = 0,
40 Linear =
41 1,
42 NearestMipmapNearest =
43 2,
44 LinearMipmapNearest = 3,
45 NearestMipmapLinear = 4,
47 LinearMipmapLinear = 5
49 };
50
51 enum class MagFilter : uint8_t {
52 Nearest = 0,
53 Linear =
54 1,
55 };
56
57 enum class WrapMode : uint8_t {
58 ClampToEdge,
60 Repeat,
62 MirroredRepeat,
64 };
65
66 /* filterMag = MagFilter::Nearest
67 * filterMin = MinFilter::Nearest
68 * wrapU = WrapMode::ClampToEdge
69 * wrapV = WrapMode::ClampToEdge
70 * wrapW = WrapMode::ClampToEdge
71 * anisotropy = 0
72 */
74
75 /* filterMag = MagFilter::Linear
76 * filterMin = MinFilter::LinearMipmapLinear
77 * wrapU = WrapMode::Repeat
78 * wrapV = WrapMode::Repeat
79 * wrapW = WrapMode::Repeat
80 * anisotropy = 8
81 */
83
84 /* filterMag = MagFilter::Linear
85 * filterMin = MinFilter::Linear
86 * wrapU = WrapMode::ClampToEdge
87 * wrapV = WrapMode::ClampToEdge
88 * wrapW = WrapMode::ClampToEdge
89 * anisotropy = 0
90 */
92
94
95 // Creates a TextureSampler with the default parameters but setting the
96 // filtering and wrap modes. 'minMag' is filtering for both minification and
97 // magnification 'uvw' is wrapping mode for all texture coordinate axes
98 explicit TextureSamplerParameters(MagFilter min_mag,
100
101 // Creates a TextureSampler with the default parameters but setting the
102 // filtering and wrap modes. 'uvw' is wrapping mode for all texture
103 // coordinate axes
105 MagFilter mag,
107
109 MinFilter min, MagFilter mag, WrapMode u, WrapMode v, WrapMode w);
110
111 // \param a needs to be a power of 2
112 void SetAnisotropy(std::uint8_t a);
113
114 std::uint8_t GetAnisotropy() const { return anisotropy; }
115
121
122private:
123 std::uint8_t anisotropy = 0;
124};
125
127public:
128 virtual ~MaterialModifier() = default;
129
130 virtual MaterialModifier& SetParameter(const char* parameter,
131 int value) = 0;
132 virtual MaterialModifier& SetParameter(const char* parameter,
133 float value) = 0;
134 virtual MaterialModifier& SetParameter(const char* parameter,
135 const Eigen::Vector3f& value) = 0;
136 virtual MaterialModifier& SetColor(const char* parameter,
137 const Eigen::Vector3f& value,
138 bool srgb) = 0;
139 virtual MaterialModifier& SetColor(const char* parameter,
140 const Eigen::Vector4f& value,
141 bool srgb) = 0;
143 const char* parameter,
144 const TextureHandle& texture,
145 const TextureSamplerParameters& sampler) = 0;
146
147 virtual MaterialModifier& SetDoubleSided(bool doubleSided) = 0;
148
150};
151
152} // namespace rendering
153} // namespace visualization
154} // namespace open3d
Definition: MaterialModifier.h:126
virtual MaterialModifier & SetTexture(const char *parameter, const TextureHandle &texture, const TextureSamplerParameters &sampler)=0
virtual MaterialModifier & SetDoubleSided(bool doubleSided)=0
virtual MaterialModifier & SetParameter(const char *parameter, float value)=0
virtual MaterialModifier & SetColor(const char *parameter, const Eigen::Vector3f &value, bool srgb)=0
virtual MaterialModifier & SetParameter(const char *parameter, int value)=0
virtual MaterialInstanceHandle Finish()=0
virtual MaterialModifier & SetColor(const char *parameter, const Eigen::Vector4f &value, bool srgb)=0
virtual MaterialModifier & SetParameter(const char *parameter, const Eigen::Vector3f &value)=0
Definition: PinholeCameraIntrinsic.cpp:35
WrapMode wrap_w
Definition: MaterialModifier.h:120
MagFilter filter_mag
Definition: MaterialModifier.h:116
static TextureSamplerParameters Simple()
Definition: MaterialModifier.cpp:33
void SetAnisotropy(std::uint8_t a)
Definition: MaterialModifier.cpp:95
std::uint8_t GetAnisotropy() const
Definition: MaterialModifier.h:114
MinFilter filter_min
Definition: MaterialModifier.h:117
WrapMode wrap_v
Definition: MaterialModifier.h:119
WrapMode wrap_u
Definition: MaterialModifier.h:118
static TextureSamplerParameters Pretty()
Definition: MaterialModifier.cpp:37
static TextureSamplerParameters LinearClamp()
Definition: MaterialModifier.cpp:54