Open3D (C++ API)  0.17.0
MaterialModifier.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 
13 
14 namespace open3d {
15 namespace visualization {
16 namespace rendering {
17 
19  enum class MinFilter : uint8_t {
20  Nearest = 0,
21  Linear =
22  1,
24  2,
30  };
31 
32  enum class MagFilter : uint8_t {
33  Nearest = 0,
34  Linear =
35  1,
36  };
37 
38  enum class WrapMode : uint8_t {
39  ClampToEdge,
41  Repeat,
45  };
46 
47  /* filterMag = MagFilter::Nearest
48  * filterMin = MinFilter::Nearest
49  * wrapU = WrapMode::ClampToEdge
50  * wrapV = WrapMode::ClampToEdge
51  * wrapW = WrapMode::ClampToEdge
52  * anisotropy = 0
53  */
55 
56  /* filterMag = MagFilter::Linear
57  * filterMin = MinFilter::LinearMipmapLinear
58  * wrapU = WrapMode::Repeat
59  * wrapV = WrapMode::Repeat
60  * wrapW = WrapMode::Repeat
61  * anisotropy = 8
62  */
64 
65  /* filterMag = MagFilter::Linear
66  * filterMin = MinFilter::Linear
67  * wrapU = WrapMode::ClampToEdge
68  * wrapV = WrapMode::ClampToEdge
69  * wrapW = WrapMode::ClampToEdge
70  * anisotropy = 0
71  */
73 
75 
76  // Creates a TextureSampler with the default parameters but setting the
77  // filtering and wrap modes. 'minMag' is filtering for both minification and
78  // magnification 'uvw' is wrapping mode for all texture coordinate axes
79  explicit TextureSamplerParameters(MagFilter min_mag,
81 
82  // Creates a TextureSampler with the default parameters but setting the
83  // filtering and wrap modes. 'uvw' is wrapping mode for all texture
84  // coordinate axes
86  MagFilter mag,
88 
90  MinFilter min, MagFilter mag, WrapMode u, WrapMode v, WrapMode w);
91 
92  // \param a needs to be a power of 2
93  void SetAnisotropy(std::uint8_t a);
94 
95  std::uint8_t GetAnisotropy() const { return anisotropy; }
96 
102 
103 private:
104  std::uint8_t anisotropy = 0;
105 };
106 
108 public:
109  virtual ~MaterialModifier() = default;
110 
111  virtual MaterialModifier& SetParameter(const char* parameter,
112  int value) = 0;
113  virtual MaterialModifier& SetParameter(const char* parameter,
114  float value) = 0;
115  virtual MaterialModifier& SetParameter(const char* parameter,
116  const Eigen::Vector3f& value) = 0;
117  virtual MaterialModifier& SetColor(const char* parameter,
118  const Eigen::Vector3f& value,
119  bool srgb) = 0;
120  virtual MaterialModifier& SetColor(const char* parameter,
121  const Eigen::Vector4f& value,
122  bool srgb) = 0;
124  const char* parameter,
125  const TextureHandle& texture,
126  const TextureSamplerParameters& sampler) = 0;
127 
128  virtual MaterialModifier& SetDoubleSided(bool doubleSided) = 0;
129 
131 };
132 
133 } // namespace rendering
134 } // namespace visualization
135 } // namespace open3d
Definition: MaterialModifier.h:107
virtual MaterialModifier & SetColor(const char *parameter, const Eigen::Vector3f &value, bool srgb)=0
virtual MaterialModifier & SetDoubleSided(bool doubleSided)=0
virtual MaterialModifier & SetColor(const char *parameter, const Eigen::Vector4f &value, bool srgb)=0
virtual MaterialModifier & SetParameter(const char *parameter, float value)=0
virtual MaterialModifier & SetParameter(const char *parameter, int value)=0
virtual MaterialModifier & SetTexture(const char *parameter, const TextureHandle &texture, const TextureSamplerParameters &sampler)=0
virtual MaterialModifier & SetParameter(const char *parameter, const Eigen::Vector3f &value)=0
virtual MaterialInstanceHandle Finish()=0
Definition: PinholeCameraIntrinsic.cpp:16
@ Linear
Box filtering. Weighted average of 4 neighbors is used.
@ NearestMipmapNearest
Mip-mapping is activated. But no filtering occurs.
WrapMode wrap_w
Definition: MaterialModifier.h:101
MagFilter filter_mag
Definition: MaterialModifier.h:97
static TextureSamplerParameters Simple()
Definition: MaterialModifier.cpp:14
void SetAnisotropy(std::uint8_t a)
Definition: MaterialModifier.cpp:76
std::uint8_t GetAnisotropy() const
Definition: MaterialModifier.h:95
MinFilter filter_min
Definition: MaterialModifier.h:98
WrapMode wrap_v
Definition: MaterialModifier.h:100
WrapMode wrap_u
Definition: MaterialModifier.h:99
static TextureSamplerParameters Pretty()
Definition: MaterialModifier.cpp:18
static TextureSamplerParameters LinearClamp()
Definition: MaterialModifier.cpp:35
@ Linear
Box filtering. Weighted average of 4 neighbors is used.