Gazebo Rendering

API Reference

6.6.3
gz/rendering/ogre2/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 
36 namespace Ogre
37 {
38  class HlmsPbsDatablock;
39  class HlmsUnlitDatablock;
40 } // namespace Ogre
41 
42 namespace ignition
43 {
44  namespace rendering
45  {
46  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
47  //
48  // forward declaration
49  class Ogre2MaterialPrivate;
50 
52  class IGNITION_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) override;
112 
113  // Documentation inherited
114  public: virtual void ClearTexture() override;
115 
116  // Documentation inherited
117  public: virtual bool HasNormalMap() const override;
118 
119  // Documentation inherited
120  public: virtual std::string NormalMap() const override;
121 
122  // Documentation inherited
123  public: virtual void SetNormalMap(const std::string &_normalMap) override;
124 
125  // Documentation inherited
126  public: virtual void ClearNormalMap() override;
127 
128  // Documentation inherited
129  public: virtual bool HasRoughnessMap() const override;
130 
131  // Documentation inherited
132  public: virtual std::string RoughnessMap() const override;
133 
134  // Documentation inherited
135  public: virtual void SetRoughnessMap(
136  const std::string &_roughnessMap) override;
137 
138  // Documentation inherited
139  public: virtual void ClearRoughnessMap() override;
140 
141  // Documentation inherited
142  public: virtual bool HasMetalnessMap() const override;
143 
144  // Documentation inherited
145  public: virtual std::string MetalnessMap() const override;
146 
147  // Documentation inherited
148  public: virtual void SetMetalnessMap(
149  const std::string &_metalnessMap) override;
150 
151  // Documentation inherited
152  public: virtual void ClearMetalnessMap() override;
153 
154  // Documentation inherited
155  public: virtual bool HasEnvironmentMap() const override;
156 
157  // Documentation inherited
158  public: virtual std::string EnvironmentMap() const override;
159 
160  // Documentation inherited
161  public: virtual void SetEnvironmentMap(
162  const std::string &_metalnessMap) override;
163 
164  // Documentation inherited
165  public: virtual void ClearEnvironmentMap() override;
166 
167  // Documentation inherited
168  public: virtual void SetRoughness(const float _roughness) override;
169 
170  // Documentation inherited
171  public: virtual bool HasEmissiveMap() const override;
172 
173  // Documentation inherited
174  public: virtual std::string EmissiveMap() const override;
175 
176  // Documentation inherited
177  public: virtual void SetEmissiveMap(
178  const std::string &_emissiveMap) override;
179 
180  // Documentation inherited
181  public: virtual void ClearEmissiveMap() override;
182 
183  // Documentation inherited
184  public: virtual bool HasLightMap() const override;
185 
186  // Documentation inherited
187  public: virtual std::string LightMap() const override;
188 
189  // Documentation inherited
190  public: virtual unsigned int LightMapTexCoordSet() const override;
191 
192  // Documentation inherited
193  public: virtual void SetLightMap(const std::string &_lightMap,
194  unsigned int _uvSet = 0u) override;
195 
196  // Documentation inherited
197  public: virtual void ClearLightMap() override;
198 
199  // Documentation inherited
200  public: virtual float Roughness() const override;
201 
202  // Documentation inherited
203  public: virtual void SetMetalness(const float _roughness) override;
204 
205  // Documentation inherited
206  public: virtual float Metalness() const override;
207 
210  public: virtual Ogre::MaterialPtr Material();
211 
214  public: virtual Ogre::HlmsPbsDatablock *Datablock() const;
215 
218  public: virtual Ogre::HlmsUnlitDatablock *UnlitDatablock();
219 
223  public: virtual void FillUnlitDatablock(
224  Ogre::HlmsUnlitDatablock *_datablock) const;
225 
226  // Documentation inherited.
227  // \sa BaseMaterial::PreRender()
228  public: virtual void PreRender() override;
229 
230  // Documentation inherited.
231  public: virtual enum MaterialType Type() const override;
232 
233  // Documentation inherited
234  public: virtual bool DepthCheckEnabled() const override;
235 
236  // Documentation inherited
237  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
238 
239  // Documentation inherited
240  public: virtual bool DepthWriteEnabled() const override;
241 
242  // Documentation inherited
243  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
244 
245  // Documentation inherited.
246  // \sa Material::SetVertexShader(const std::string &)
247  public: virtual void SetVertexShader(const std::string &_path) override;
248 
249  // Documentation inherited.
250  // \sa Material::VertexShader() const
251  public: virtual std::string VertexShader() const override;
252 
253  // Documentation inherited.
254  // \sa Material::VertexShaderParams()
255  public: virtual ShaderParamsPtr VertexShaderParams() override;
256 
257  // Documentation inherited.
258  // \sa Material::SetFragmentShader(const std::string &)
259  public: virtual void SetFragmentShader(const std::string &_path)
260  override;
261 
262  // Documentation inherited.
263  // \sa Material::FragmentShader() const
264  public: virtual std::string FragmentShader() const override;
265 
266  // Documentation inherited.
267  // \sa Material::FragmentShaderParams()
268  public: virtual ShaderParamsPtr FragmentShaderParams() override;
269 
274  protected: virtual void SetTextureMapImpl(const std::string &_texture,
275  Ogre::PbsTextureTypes _type);
276 
279  protected: virtual Ogre::TextureGpu *Texture(const std::string &_name);
280 
283  protected: virtual void UpdateTransparency();
284 
285  // Documentation inherited.
286  protected: virtual void Init() override;
287 
289  protected: void UpdateShaderParams();
290 
294  protected: void UpdateShaderParams(ConstShaderParamsPtr _params,
295  Ogre::GpuProgramParametersSharedPtr _ogreParams);
296 
298  protected: Ogre::MaterialPtr ogreMaterial;
299 
301  protected: Ogre::HlmsPbsDatablock *ogreDatablock = nullptr;
302 
304  protected: Ogre::HlmsUnlitDatablock *ogreUnlitDatablock = nullptr;
305 
307  protected: Ogre::HlmsPbs *ogreHlmsPbs = nullptr;
308 
311 
314 
317 
320 
323 
326 
329 
331  protected: unsigned int lightMapUvSet = 0u;
332 
335 
337  private: std::unique_ptr<Ogre2MaterialPrivate> dataPtr;
338 
340  private: friend class Ogre2Scene;
341  };
342  }
343  }
344 }
345 #endif
MaterialType
An enum for the type of material.
Definition: gz/rendering/Material.hh:36
Definition: gz/rendering/ogre/OgreCamera.hh:27
STL class.
STL class.
std::string environmentMapName
Name of the environment map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:322
std::string metalnessMapName
Name of the metalness map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:319
std::string emissiveMapName
Name of the emissive map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:325
std::string lightMapName
Name of the light map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:328
std::string normalMapName
Name of the normal map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:313
Definition: gz/rendering/base/BaseMaterial.hh:38
std::string textureName
Name of the texture.
Definition: gz/rendering/ogre2/Ogre2Material.hh:310
std::string roughnessMapName
Name of the roughness map.
Definition: gz/rendering/ogre2/Ogre2Material.hh:316
Ogre2.x implementation of the scene class.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:57
Ogre 2.x implementation of the material class.
Definition: gz/rendering/ogre2/Ogre2Material.hh:52
std::string ogreDatablockId
Unique id assigned to ogre hlms datablock.
Definition: gz/rendering/ogre2/Ogre2Material.hh:334
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
Ogre::MaterialPtr ogreMaterial
Ogre material. Mainly used for render targets.
Definition: gz/rendering/ogre2/Ogre2Material.hh:298