Gazebo Rendering

API Reference

9.0.0~pre2
Ogre2Material.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef GZ_RENDERING_OGRE2_OGRE2MATERIAL_HH_
18#define GZ_RENDERING_OGRE2_OGRE2MATERIAL_HH_
19
20#include <memory>
21#include <string>
22
25
26#ifdef _MSC_VER
27 #pragma warning(push, 0)
28#endif
29#include <Hlms/Pbs/OgreHlmsPbsPrerequisites.h>
30#include <OgreGpuProgramParams.h>
31#include <OgreMaterial.h>
32#ifdef _MSC_VER
33 #pragma warning(pop)
34#endif
35
36namespace Ogre
37{
38 class HlmsPbsDatablock;
39 class HlmsUnlitDatablock;
40} // namespace Ogre
41
42namespace gz
43{
44 namespace rendering
45 {
46 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
47 //
48 // forward declaration
49 class Ogre2MaterialPrivate;
50
52 class GZ_RENDERING_OGRE2_VISIBLE Ogre2Material :
53 public BaseMaterial<Ogre2Object>
54 {
56 protected: Ogre2Material();
57
59 public: virtual ~Ogre2Material();
60
61 // Documentation inherited
62 public: virtual void Destroy() override;
63
64 // Documentation inherited
65 public: virtual math::Color Diffuse() const override;
66
67 // Documentation inherited
68 public: virtual void SetDiffuse(const math::Color &_color) override;
69
70 // Documentation inherited
71 public: virtual math::Color Specular() const override;
72
73 // Documentation inherited
74 public: virtual void SetSpecular(const math::Color &_color) override;
75
76 // Documentation inherited
77 public: virtual math::Color Emissive() const override;
78
79 // Documentation inherited
80 public: virtual void SetEmissive(const math::Color &_color) override;
81
82 // Documentation inherited
83 public: virtual void SetTransparency(const double _transparency) override;
84
85 // Documentation inherited
86 public: virtual void SetAlphaFromTexture(bool _enabled,
87 double _alpha = 0.5, bool _twoSided = true) override;
88
89 // Documentation inherited
90 public: virtual float RenderOrder() const override;
91
92 // Documentation inherited
93 // Review the official documentation to get more details about this
94 // parameter, in particular mDepthBiasConstant
95 public: virtual void SetRenderOrder(const float _renderOrder) override;
96
97 // Documentation inherited
98 public: virtual bool ReceiveShadows() const override;
99
100 // Documentation inherited
101 public: virtual void SetReceiveShadows(const bool _receiveShadows)
102 override;
103
104 // Documentation inherited
105 public: virtual bool HasTexture() const override;
106
107 // Documentation inherited
108 public: virtual std::string Texture() const override;
109
110 // Documentation inherited
111 public: virtual void SetTexture(const std::string &_texture,
112 const std::shared_ptr<const common::Image> &_img) override;
113
114 // Documentation inherited
116 const override;
117
118 // Documentation inherited
119 public: virtual void ClearTexture() override;
120
121 // Documentation inherited
122 public: virtual bool HasNormalMap() const override;
123
124 // Documentation inherited
125 public: virtual std::string NormalMap() const override;
126
127 // Documentation inherited
129 const override;
130
131 // Documentation inherited
132 public: virtual void SetNormalMap(const std::string &_normalMap,
133 const std::shared_ptr<const common::Image> &_img) override;
134
135 // Documentation inherited
136 public: virtual void ClearNormalMap() override;
137
138 // Documentation inherited
139 public: virtual bool HasRoughnessMap() const override;
140
141 // Documentation inherited
142 public: virtual std::string RoughnessMap() const override;
143
144 // Documentation inherited
146 const override;
147
148 // Documentation inherited
149 public: virtual void SetRoughnessMap(const std::string &_roughnessMap,
150 const std::shared_ptr<const common::Image> &_img) override;
151
152 // Documentation inherited
153 public: virtual void ClearRoughnessMap() override;
154
155 // Documentation inherited
156 public: virtual bool HasMetalnessMap() const override;
157
158 // Documentation inherited
159 public: virtual std::string MetalnessMap() const override;
160
161 // Documentation inherited
163 const override;
164
165 // Documentation inherited
166 public: virtual void SetMetalnessMap(const std::string &_metalnessMap,
167 const std::shared_ptr<const common::Image> &_img) override;
168
169 // Documentation inherited
170 public: virtual void ClearMetalnessMap() override;
171
172 // Documentation inherited
173 public: virtual bool HasEnvironmentMap() const override;
174
175 // Documentation inherited
176 public: virtual std::string EnvironmentMap() const override;
177
178 // Documentation inherited
180 const override;
181
182 // Documentation inherited
183 public: virtual void SetEnvironmentMap(
184 const std::string &_environmentMap,
185 const std::shared_ptr<const common::Image> &_img) override;
186
187 // Documentation inherited
188 public: virtual void ClearEnvironmentMap() override;
189
190 // Documentation inherited
191 public: virtual void SetRoughness(const float _roughness) override;
192
193 // Documentation inherited
194 public: virtual bool HasEmissiveMap() const override;
195
196 // Documentation inherited
197 public: virtual std::string EmissiveMap() const override;
198
199 // Documentation inherited
201 const override;
202
203 // Documentation inherited
204 public: virtual void SetEmissiveMap(
205 const std::string &_emissiveMap,
206 const std::shared_ptr<const common::Image> &_img) override;
207
208 // Documentation inherited
209 public: virtual void ClearEmissiveMap() override;
210
211 // Documentation inherited
212 public: virtual bool HasLightMap() const override;
213
214 // Documentation inherited
215 public: virtual std::string LightMap() const override;
216
217 // Documentation inherited
218 public: virtual unsigned int LightMapTexCoordSet() const override;
219
220 // Documentation inherited
221 public: virtual void SetLightMap(const std::string &_lightMap,
223 unsigned int _uvSet = 0u) override;
224
225 // Documentation inherited
227 const override;
228
229 // Documentation inherited
230 public: virtual void ClearLightMap() override;
231
232 // Documentation inherited
233 public: virtual float Roughness() const override;
234
235 // Documentation inherited
236 public: virtual void SetMetalness(const float _roughness) override;
237
238 // Documentation inherited
239 public: virtual float Metalness() const override;
240
243 public: virtual Ogre::MaterialPtr Material();
244
247 public: virtual Ogre::HlmsPbsDatablock *Datablock() const;
248
251 public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock();
252
256 public: virtual void FillUnlitDatablock(
257 Ogre::HlmsUnlitDatablock *_datablock) const;
258
259 // Documentation inherited.
260 // \sa BaseMaterial::PreRender()
261 public: virtual void PreRender() override;
262
263 // Documentation inherited.
264 public: virtual enum MaterialType Type() const override;
265
266 // Documentation inherited
267 public: virtual bool DepthCheckEnabled() const override;
268
269 // Documentation inherited
270 public: virtual void SetDepthCheckEnabled(bool _enabled) override;
271
272 // Documentation inherited
273 public: virtual bool DepthWriteEnabled() const override;
274
275 // Documentation inherited
276 public: virtual void SetDepthWriteEnabled(bool _enabled) override;
277
278 // Documentation inherited.
279 // \sa Material::SetVertexShader(const std::string &)
280 public: virtual void SetVertexShader(const std::string &_path) override;
281
282 // Documentation inherited.
283 // \sa Material::VertexShader() const
284 public: virtual std::string VertexShader() const override;
285
286 // Documentation inherited.
287 // \sa Material::VertexShaderParams()
288 public: virtual ShaderParamsPtr VertexShaderParams() override;
289
290 // Documentation inherited.
291 // \sa Material::SetFragmentShader(const std::string &)
292 public: virtual void SetFragmentShader(const std::string &_path)
293 override;
294
295 // Documentation inherited.
296 // \sa Material::FragmentShader() const
297 public: virtual std::string FragmentShader() const override;
298
299 // Documentation inherited.
300 // \sa Material::FragmentShaderParams()
301 public: virtual ShaderParamsPtr FragmentShaderParams() override;
302
307 protected: virtual void SetTextureMapImpl(const std::string &_texture,
308 Ogre::PbsTextureTypes _type);
309
316 protected: void SetTextureMapDataImpl(const std::string& _texture,
318 Ogre::PbsTextureTypes _type);
319
322 protected: virtual Ogre::TextureGpu *Texture(const std::string &_name);
323
326 protected: virtual void UpdateTransparency();
327
328 // Documentation inherited.
329 protected: virtual void Init() override;
330
332 protected: void UpdateShaderParams();
333
338 Ogre::GpuProgramParametersSharedPtr _ogreParams);
339
341 protected: Ogre::MaterialPtr ogreMaterial;
342
344 protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr;
345
347 protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr;
348
350 protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr;
351
354
357
360
363
366
369
372
374 protected: unsigned int lightMapUvSet = 0u;
375
378
381
383 private: friend class Ogre2Scene;
384 };
385 }
386 }
387}
388#endif