Gazebo Rendering

API Reference

3.7.2
gz/rendering/base/BaseMaterial.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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_BASE_BASEMATERIAL_HH_
18 #define GZ_RENDERING_BASE_BASEMATERIAL_HH_
19 
20 #include <string>
21 
22 #include "gz/common/Console.hh"
23 
24 #include "gz/rendering/Material.hh"
25 #include "gz/rendering/Scene.hh"
27 
28 namespace ignition
29 {
30  namespace rendering
31  {
32  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
33  //
35  static const common::Pbr kDefaultPbr;
36 
37  template <class T>
38  class BaseMaterial :
39  public virtual Material,
40  public virtual T
41  {
42  protected: BaseMaterial();
43 
44  public: virtual ~BaseMaterial();
45 
46  // Documentation inherited
47  public: virtual MaterialPtr Clone(const std::string &_name = "") const
48  override;
49 
50  // Documentation inherited
51  public: virtual void SetAmbient(const double _r, const double _g,
52  const double _b, const double _a = 1.0) override;
53 
54  // Documentation inherited
55  public: virtual void SetAmbient(const math::Color &_color) override;
56 
57  // Documentation inherited
58  public: virtual void SetDiffuse(const double _r, const double _g,
59  const double _b, const double _a = 1.0) override;
60 
61  // Documentation inherited
62  public: virtual void SetDiffuse(const math::Color &_color) override;
63 
64  // Documentation inherited
65  public: virtual void SetSpecular(const double _r, const double _g,
66  const double _b, const double _a = 1.0) override;
67 
68  // Documentation inherited
69  public: virtual void SetSpecular(const math::Color &_color) override;
70 
71  // Documentation inherited
72  public: virtual void SetEmissive(const double _r, const double _g,
73  const double _b, const double _a = 1.0) override;
74 
75  // Documentation inherited
76  public: virtual void SetEmissive(const math::Color &_color) override;
77 
78  // Documentation inherited
79  public: virtual void SetTransparency(const double _transparency) override;
80 
81  // Documentation inherited
82  public: virtual void SetShininess(const double _shininess) override;
83 
84  // Documentation inherited
85  public: virtual void SetReflectivity(const double _reflectivity) override;
86 
87  // Documentation inherited
88  public: virtual void SetCastShadows(const bool _castShadows) override;
89 
90  // Documentation inherited
91  public: virtual void SetReceiveShadows(const bool _receiveShadows)
92  override;
93 
94  // Documentation inherited
95  public: virtual void SetReflectionEnabled(const bool _enabled) override;
96 
97  // Documentation inherited
98  public: virtual void SetLightingEnabled(const bool _enabled) override;
99 
100  // Documentation inherited.
101  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
102 
103  // Documentation inherited.
104  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
105 
106  // Documentation inherited
107  public: virtual math::Color Ambient() const override;
108 
109  // Documentation inherited
110  public: virtual math::Color Diffuse() const override;
111 
112  // Documentation inherited
113  public: virtual math::Color Specular() const override;
114 
115  // Documentation inherited
116  public: virtual math::Color Emissive() const override;
117 
118  // Documentation inherited
119  public: virtual double Transparency() const override;
120 
121  // Documentation inherited
122  public: virtual double Reflectivity() const override;
123 
124  // Documentation inherited
125  public: virtual double Shininess() const override;
126 
127  // Documentation inherited
128  public: virtual bool CastShadows() const override;
129 
130  // Documentation inherited
131  public: virtual bool ReceiveShadows() const override;
132 
133  // Documentation inherited
134  public: virtual bool LightingEnabled() const override;
135 
136  // Documentation inherited
137  public: virtual bool DepthCheckEnabled() const override;
138 
139  // Documentation inherited
140  public: virtual bool DepthWriteEnabled() const override;
141 
142  // Documentation inherited
143  public: virtual bool ReflectionEnabled() const override;
144 
145  // Documentation inherited
146  public: virtual bool HasTexture() const override;
147 
148  // Documentation inherited
149  public: virtual std::string Texture() const override;
150 
151  // Documentation inherited
152  public: virtual void SetTexture(const std::string &_texture) override;
153 
154  // Documentation inherited
155  public: virtual void ClearTexture() override;
156 
157  // Documentation inherited
158  public: virtual bool HasNormalMap() const override;
159 
160  // Documentation inherited
161  public: virtual std::string NormalMap() const override;
162 
163  // Documentation inherited
164  public: virtual void SetNormalMap(const std::string &_normalMap)
165  override;
166 
167  // Documentation inherited
168  public: virtual void ClearNormalMap() override;
169 
170  // Documentation inherited
171  public: virtual bool HasRoughnessMap() const override;
172 
173  // Documentation inherited
174  public: virtual std::string RoughnessMap() const override;
175 
176  // Documentation inherited
177  public: virtual void SetRoughnessMap(const std::string &_roughnessMap)
178  override;
179 
180  // Documentation inherited
181  public: virtual void ClearRoughnessMap() override;
182 
183  // Documentation inherited
184  public: virtual bool HasMetalnessMap() const override;
185 
186  // Documentation inherited
187  public: virtual std::string MetalnessMap() const override;
188 
189  // Documentation inherited
190  public: virtual void SetMetalnessMap(const std::string &_metalnessMap)
191  override;
192 
193  // Documentation inherited
194  public: virtual void ClearMetalnessMap() override;
195 
196  // Documentation inherited
197  public: virtual bool HasEnvironmentMap() const override;
198 
199  // Documentation inherited
200  public: virtual std::string EnvironmentMap() const override;
201 
202  // Documentation inherited
203  public: virtual void SetEnvironmentMap(const std::string &_metalnessMap)
204  override;
205 
206  // Documentation inherited
207  public: virtual void ClearEnvironmentMap() override;
208 
209  // Documentation inherited
210  public: virtual bool HasEmissiveMap() const override;
211 
212  // Documentation inherited
213  public: virtual std::string EmissiveMap() const override;
214 
215  // Documentation inherited
216  public: virtual void SetEmissiveMap(const std::string &_emissiveMap)
217  override;
218 
219  // Documentation inherited
220  public: virtual void ClearEmissiveMap() override;
221 
222  // Documentation inherited
223  public: virtual void SetRoughness(const float _roughness) override;
224 
225  // Documentation inherited
226  public: virtual float Roughness() const override;
227 
228  // Documentation inherited
229  public: virtual void SetMetalness(const float _metalness) override;
230 
231  // Documentation inherited
232  public: virtual float Metalness() const override;
233 
234  // Documentation inherited
235  public: virtual MaterialType Type() const override;
236 
237  public: virtual void SetShaderType(enum ShaderType _type) override
238  {
239  (void)_type;
240  // no op
241  }
242 
243  // Documentation inherited
244  public: virtual enum ShaderType ShaderType() const override
245  {
246  return ST_PIXEL;
247  }
248 
249  // Documentation inherited.
250  // \sa Material::SetDepthMaterial()
251  public: virtual void SetDepthMaterial(const double far,
252  const double near) override;
253 
254  // Documentation inherited.
255  // \sa Material::VertexShader() const
256  public: virtual std::string VertexShader() const override;
257 
258  // Documentation inherited.
259  // \sa Material::VertexShaderParams()
260  public: virtual ShaderParamsPtr VertexShaderParams() override;
261 
262  // Documentation inherited.
263  // \sa Material::SetVertexShader(const std::string &)
264  public: virtual void SetVertexShader(const std::string &_path) override;
265 
266  // Documentation inherited.
267  // \sa Material::FragmentShader() const
268  public: virtual std::string FragmentShader() const override;
269 
270  // Documentation inherited.
271  // \sa Material::FragmentShaderParams()
272  public: virtual ShaderParamsPtr FragmentShaderParams() override;
273 
274  // Documentation inherited.
275  // \sa Material::SetFragmentShader(const std::string &)
276  public: virtual void SetFragmentShader(const std::string &_path) override;
277 
278  // Documentation inherited.
279  public: virtual void CopyFrom(ConstMaterialPtr _material) override;
280 
281  // Documentation inherited.
282  public: virtual void CopyFrom(const common::Material &_material) override;
283 
284  // Documentation inherited.
285  public: virtual void PreRender() override;
286 
287  protected: virtual void Reset();
288 
290  protected: math::Color ambient;
291 
293  protected: math::Color diffuse;
294 
296  protected: math::Color specular;
297 
299  protected: math::Color emissive;
300 
302  protected: double transparency = 0.0;
303 
305  protected: double shininess = 0.0;
306 
308  protected: double reflectivity = 0.0;
309 
311  protected: bool lightingEnabled = false;
312 
314  protected: bool depthCheckEnabled = true;
315 
317  protected: bool depthWriteEnabled = true;
318 
320  protected: bool reflectionEnabled = false;
321 
323  protected: bool receiveShadows = true;
324 
326  protected: bool castShadows = true;
327  };
328 
330  template <class T>
332  {
333  }
334 
336  template <class T>
338  {
339  }
340 
342  template <class T>
343  void BaseMaterial<T>::SetAmbient(const double _r, const double _g,
344  const double _b, const double _a)
345  {
346  this->SetAmbient(math::Color(_r, _g, _b, _a));
347  }
348 
350  template <class T>
352  {
353  this->ambient = _color;
354  }
355 
357  template <class T>
358  void BaseMaterial<T>::SetDiffuse(const double _r, const double _g,
359  const double _b, const double _a)
360  {
361  this->SetDiffuse(math::Color(_r, _g, _b, _a));
362  }
363 
365  template <class T>
367  {
368  this->diffuse = _color;
369  }
370 
372  template <class T>
373  void BaseMaterial<T>::SetSpecular(const double _r, const double _g,
374  const double _b, const double _a)
375  {
376  this->SetSpecular(math::Color(_r, _g, _b, _a));
377  }
378 
380  template <class T>
382  {
383  this->specular = _color;
384  }
385 
387  template <class T>
388  void BaseMaterial<T>::SetEmissive(const double _r, const double _g,
389  const double _b, const double _a)
390  {
391  this->SetEmissive(math::Color(_r, _g, _b, _a));
392  }
393 
395  template <class T>
397  {
398  this->emissive = _color;
399  }
400 
402  template <class T>
403  void BaseMaterial<T>::SetShininess(const double _shininess)
404  {
405  this->shininess = _shininess;
406  }
407 
409  template <class T>
410  void BaseMaterial<T>::SetTransparency(const double _transparency)
411  {
412  this->transparency = _transparency;
413  }
414 
416  template <class T>
417  void BaseMaterial<T>::SetReflectivity(const double _reflectivity)
418  {
419  this->reflectivity = _reflectivity;
420  }
421 
423  template <class T>
424  void BaseMaterial<T>::SetReflectionEnabled(const bool _enabled)
425  {
426  this->reflectionEnabled = _enabled;
427  }
428 
430  template <class T>
431  void BaseMaterial<T>::SetLightingEnabled(const bool _enabled)
432  {
433  this->lightingEnabled = _enabled;
434  }
435 
437  template <class T>
439  {
440  this->depthCheckEnabled = _enabled;
441  }
442 
444  template <class T>
446  {
447  this->depthWriteEnabled = _enabled;
448  }
449 
451  template <class T>
452  void BaseMaterial<T>::SetCastShadows(const bool _castShadows)
453  {
454  this->castShadows = _castShadows;
455  }
456 
458  template <class T>
459  void BaseMaterial<T>::SetReceiveShadows(const bool _receive)
460  {
461  this->receiveShadows = _receive;
462  }
463 
465  template <class T>
467  {
468  return this->ambient;
469  }
470 
472  template <class T>
474  {
475  return this->diffuse;
476  }
477 
479  template <class T>
481  {
482  return this->specular;
483  }
484 
486  template <class T>
488  {
489  return this->emissive;
490  }
491 
493  template <class T>
495  {
496  return this->shininess;
497  }
498 
500  template <class T>
502  {
503  return this->transparency;
504  }
505 
507  template <class T>
509  {
510  return this->reflectivity;
511  }
512 
514  template <class T>
516  {
517  return this->castShadows;
518  }
519 
521  template <class T>
523  {
524  return this->receiveShadows;
525  }
526 
528  template <class T>
530  {
531  return this->lightingEnabled;
532  }
533 
535  template <class T>
537  {
538  return this->depthCheckEnabled;
539  }
540 
542  template <class T>
544  {
545  return this->depthWriteEnabled;
546  }
547 
549  template <class T>
551  {
552  return this->reflectionEnabled;
553  }
554 
556  template <class T>
558  {
559  return MT_CLASSIC;
560  }
561 
563  template <class T>
565  {
566  return std::string();
567  }
568 
570  template <class T>
572  {
573  return nullptr;
574  }
575 
577  template <class T>
579  {
580  // no op
581  }
582 
584  template <class T>
586  {
587  return std::string();
588  }
589 
591  template <class T>
593  {
594  return nullptr;
595  }
596 
598  template <class T>
600  {
601  // no op
602  }
603 
605  template <class T>
607  {
608  return false;
609  }
610 
612  template <class T>
614  {
615  return std::string();
616  }
617 
619  template <class T>
621  {
622  // no op
623  }
624 
626  template <class T>
628  {
629  // no op
630  }
631 
633  template <class T>
635  {
636  return false;
637  }
638 
640  template <class T>
642  {
643  return std::string();
644  }
645 
647  template <class T>
649  {
650  // no op
651  }
652 
654  template <class T>
656  {
657  // no op
658  }
659 
661  template <class T>
663  {
664  return false;
665  }
666 
668  template <class T>
670  {
671  return std::string();
672  }
673 
675  template <class T>
677  {
678  // no op
679  }
680 
682  template <class T>
684  {
685  // no op
686  }
687 
689  template <class T>
691  {
692  return false;
693  }
694 
696  template <class T>
698  {
699  return std::string();
700  }
701 
703  template <class T>
705  {
706  // no op
707  }
708 
710  template <class T>
712  {
713  // no op
714  }
715 
717  template <class T>
719  {
720  return false;
721  }
722 
724  template <class T>
726  {
727  return std::string();
728  }
729 
731  template <class T>
733  {
734  // no op
735  }
736 
738  template <class T>
740  {
741  // no op
742  }
743 
745  template <class T>
747  {
748  return false;
749  }
750 
752  template <class T>
754  {
755  return std::string();
756  }
757 
759  template <class T>
761  {
762  // no op
763  }
764 
766  template <class T>
768  {
769  // no op
770  }
771 
773  template <class T>
775  {
776  // no op
777  }
778 
780  template <class T>
782  {
783  return 0.0f;
784  }
785 
787  template <class T>
789  {
790  // no op
791  }
792 
794  template <class T>
796  {
797  return 0.0f;
798  }
799 
801  template <class T>
803  {
804  auto baseShared = this->shared_from_this();
805 
806  auto thisShared =
807  std::dynamic_pointer_cast<const BaseMaterial<T>>(baseShared);
808 
809  MaterialPtr material = T::Scene()->CreateMaterial(_name);
810  material->CopyFrom(thisShared);
811  return material;
812  }
813 
815  template <class T>
817  {
818  this->SetLightingEnabled(_material->LightingEnabled());
819  this->SetAmbient(_material->Ambient());
820  this->SetDiffuse(_material->Diffuse());
821  this->SetSpecular(_material->Specular());
822  this->SetEmissive(_material->Emissive());
823  this->SetShininess(_material->Shininess());
824  this->SetTransparency(_material->Transparency());
825  // override depth check / depth write after setting transparency
826  this->SetDepthCheckEnabled(_material->DepthCheckEnabled());
827  this->SetDepthWriteEnabled(_material->DepthWriteEnabled());
828  this->SetReflectivity(_material->Reflectivity());
829  this->SetCastShadows(_material->CastShadows());
830  this->SetReceiveShadows(_material->ReceiveShadows());
831  this->SetReflectionEnabled(_material->ReflectionEnabled());
832  this->SetTexture(_material->Texture());
833  this->SetNormalMap(_material->NormalMap());
834  this->SetRoughnessMap(_material->RoughnessMap());
835  this->SetMetalnessMap(_material->MetalnessMap());
836  this->SetRoughness(_material->Roughness());
837  this->SetMetalness(_material->Metalness());
838  this->SetEnvironmentMap(_material->EnvironmentMap());
839  this->SetEmissiveMap(_material->EmissiveMap());
840  this->SetShaderType(_material->ShaderType());
841  this->SetVertexShader(_material->VertexShader());
842  this->SetFragmentShader(_material->FragmentShader());
843  }
844 
846  template <class T>
848  {
849  this->SetLightingEnabled(_material.Lighting());
850  this->SetAmbient(_material.Ambient());
851  this->SetDiffuse(_material.Diffuse());
852  this->SetSpecular(_material.Specular());
853  this->SetEmissive(_material.Emissive());
854  this->SetShininess(_material.Shininess());
855  this->SetTransparency(_material.Transparency());
856  // TODO(anyone): update common::Material
857  this->SetReflectivity(0);
858  this->SetTexture(_material.TextureImage());
859  // TODO(anyone): update common::Material
860  this->SetCastShadows(true);
861  // TODO(anyone): update common::Material
862  this->SetReceiveShadows(true);
863  // TODO(anyone): update common::Material
864  this->SetReflectionEnabled(true);
865  // TODO(anyone): update common::Material
866  this->ClearNormalMap();
867  // TODO(anyone): update common::Material
868  this->SetShaderType(ST_PIXEL);
869 
870  const common::Pbr *pbrMat = _material.PbrMaterial();
871  if (!pbrMat)
872  pbrMat = &kDefaultPbr;
873  this->SetNormalMap(pbrMat->NormalMap());
874  this->SetRoughnessMap(pbrMat->RoughnessMap());
875  this->SetMetalnessMap(pbrMat->MetalnessMap());
876  this->SetRoughness(pbrMat->Roughness());
877  this->SetMetalness(pbrMat->Metalness());
878  this->SetEnvironmentMap(pbrMat->EnvironmentMap());
879  this->SetEmissiveMap(pbrMat->EmissiveMap());
880  }
881 
883  template <class T>
885  {
886  // do nothing
887  }
888 
890  template <class T>
891  void BaseMaterial<T>::SetDepthMaterial(const double /*far*/,
892  const double /*near*/)
893  {
894  // do nothing
895  }
896 
898  template <class T>
900  {
901  this->SetLightingEnabled(true);
902  this->SetDepthCheckEnabled(true);
903  this->SetDepthWriteEnabled(true);
904  this->SetAmbient(0.3, 0.3, 0.3);
905  this->SetDiffuse(1.0, 1.0, 1.0);
906  this->SetSpecular(0.2, 0.2, 0.2);
907  this->SetEmissive(0, 0, 0);
908  this->SetShininess(1.5);
909  this->SetTransparency(0);
910  this->SetReflectivity(0);
911  this->SetCastShadows(true);
912  this->SetReceiveShadows(true);
913  this->SetReflectionEnabled(true);
914  this->ClearTexture();
915  this->ClearNormalMap();
916  this->ClearRoughnessMap();
917  this->ClearMetalnessMap();
918  this->ClearEmissiveMap();
919  this->SetRoughness(kDefaultPbr.Roughness());
920  this->SetMetalness(kDefaultPbr.Metalness());
921  this->SetShaderType(ST_PIXEL);
922  }
923  }
924  }
925 }
926 #endif
virtual math::Color Diffuse() const override
Get the diffuse color.
Definition: gz/rendering/base/BaseMaterial.hh:473
virtual void SetDepthMaterial(const double far, const double near) override
Configuration for Depth Material.
Definition: gz/rendering/base/BaseMaterial.hh:891
virtual void SetEmissive(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the emissive color.
Definition: gz/rendering/base/BaseMaterial.hh:388
MaterialType
An enum for the type of material.
Definition: gz/rendering/Material.hh:36
double transparency
Transparent. 1: fully transparent, 0: opaque.
Definition: gz/rendering/base/BaseMaterial.hh:302
virtual bool HasEnvironmentMap() const override
Determine if this material has a environment map.
Definition: gz/rendering/base/BaseMaterial.hh:718
virtual void ClearMetalnessMap() override
Removes any metalness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:711
virtual void Reset()
Definition: gz/rendering/base/BaseMaterial.hh:899
virtual float Roughness() const override
Get the roughness value of this material.
Definition: gz/rendering/base/BaseMaterial.hh:781
virtual double Reflectivity() const override
Get the reflectivity value.
Definition: gz/rendering/base/BaseMaterial.hh:508
STL class.
STL class.
math::Color ambient
Ambient color.
Definition: gz/rendering/base/BaseMaterial.hh:290
virtual void SetShininess(const double _shininess) override
Set the shininess value.
Definition: gz/rendering/base/BaseMaterial.hh:403
virtual void SetReceiveShadows(const bool _receiveShadows) override
Specify if this material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:459
BaseMaterial()
Definition: gz/rendering/base/BaseMaterial.hh:331
std::string RoughnessMap() const
virtual void SetDiffuse(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the diffuse color.
Definition: gz/rendering/base/BaseMaterial.hh:358
bool lightingEnabled
Flag to indicate if dynamic lighting is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:311
virtual float Metalness() const override
Get the metalness value of this material.
Definition: gz/rendering/base/BaseMaterial.hh:795
std::string NormalMap() const
virtual std::string FragmentShader() const override
Get path to the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:585
bool castShadows
Set to true to enable object with this material to cast shadows.
Definition: gz/rendering/base/BaseMaterial.hh:326
bool depthCheckEnabled
Flag to indicate if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:314
virtual void SetFragmentShader(const std::string &_path) override
Set the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:599
virtual std::string Texture() const override
Get the URI of the texture file.
Definition: gz/rendering/base/BaseMaterial.hh:613
virtual void SetAmbient(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the ambient color.
Definition: gz/rendering/base/BaseMaterial.hh:343
virtual enum ShaderType ShaderType() const override
Get the ShaderType value.
Definition: gz/rendering/base/BaseMaterial.hh:244
virtual void SetDepthWriteEnabled(bool _enabled) override
Specify if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:445
virtual void SetDepthCheckEnabled(bool _enabled) override
Specify if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:438
virtual std::string EmissiveMap() const override
Get the URI of the emissive map file.
Definition: gz/rendering/base/BaseMaterial.hh:753
virtual void SetVertexShader(const std::string &_path) override
Set the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:578
virtual void SetRoughness(const float _roughness) override
Set the roughness value. Only affects material of type MT_PBS.
Definition: gz/rendering/base/BaseMaterial.hh:774
virtual MaterialType Type() const override
Removes any metalness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:557
bool depthWriteEnabled
Flag to indicate if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:317
virtual void SetReflectionEnabled(const bool _enabled) override
Specify if this material has a reflection.
Definition: gz/rendering/base/BaseMaterial.hh:424
virtual std::string VertexShader() const override
Get path to the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:564
virtual bool HasMetalnessMap() const override
Determine if this material has a metalness map.
Definition: gz/rendering/base/BaseMaterial.hh:690
Definition: gz/rendering/base/BaseMaterial.hh:38
virtual double Transparency() const override
Get the transparency value.
Definition: gz/rendering/base/BaseMaterial.hh:501
std::string TextureImage() const
virtual bool HasEmissiveMap() const override
Determine if this material has an emissive map.
Definition: gz/rendering/base/BaseMaterial.hh:746
virtual MaterialPtr Clone(const std::string &_name="") const override
Clone this material.
Definition: gz/rendering/base/BaseMaterial.hh:802
math::Color specular
Specular color.
Definition: gz/rendering/base/BaseMaterial.hh:296
virtual void SetEnvironmentMap(const std::string &_metalnessMap) override
Set the material environment map.
Definition: gz/rendering/base/BaseMaterial.hh:732
virtual bool CastShadows() const override
Determine if this material casts shadows.
Definition: gz/rendering/base/BaseMaterial.hh:515
virtual bool HasRoughnessMap() const override
Determine if this material has a roughness map.
Definition: gz/rendering/base/BaseMaterial.hh:662
virtual void SetShaderType(enum ShaderType _type) override
Set the ShaderType value.
Definition: gz/rendering/base/BaseMaterial.hh:237
static const common::Pbr kDefaultPbr
Default pbr material properties.
Definition: gz/rendering/base/BaseMaterial.hh:35
math::Color Emissive() const
std::string MetalnessMap() const
virtual void SetCastShadows(const bool _castShadows) override
Specify if this material casts shadows.
Definition: gz/rendering/base/BaseMaterial.hh:452
virtual void SetLightingEnabled(const bool _enabled) override
Specify if lighting affects this material.
Definition: gz/rendering/base/BaseMaterial.hh:431
virtual bool HasTexture() const override
Determine if this material has a texture.
Definition: gz/rendering/base/BaseMaterial.hh:606
virtual std::string EnvironmentMap() const override
Get the URI of the environment map file.
Definition: gz/rendering/base/BaseMaterial.hh:725
virtual math::Color Ambient() const override
Get the ambient color.
Definition: gz/rendering/base/BaseMaterial.hh:466
virtual void SetMetalnessMap(const std::string &_metalnessMap) override
Set the material metalness map.
Definition: gz/rendering/base/BaseMaterial.hh:704
virtual math::Color Emissive() const override
Get the emissive color.
Definition: gz/rendering/base/BaseMaterial.hh:487
virtual void ClearNormalMap() override
Removes any normal map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:655
double shininess
Shininess factor.
Definition: gz/rendering/base/BaseMaterial.hh:305
virtual ShaderParamsPtr FragmentShaderParams() override
Get params for the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:592
virtual bool DepthCheckEnabled() const override
Determine if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:536
bool reflectionEnabled
Flag to indicate if reflection is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:320
std::string EnvironmentMap() const
bool receiveShadows
True if material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:323
virtual bool LightingEnabled() const override
Determine if lighting affects this material.
Definition: gz/rendering/base/BaseMaterial.hh:529
virtual std::string MetalnessMap() const override
Get the URI of the metalness map file.
Definition: gz/rendering/base/BaseMaterial.hh:697
virtual void ClearEmissiveMap() override
Removes any emissive map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:767
@ MT_CLASSIC
Classic shading, i.e. variants of Phong.
Definition: gz/rendering/Material.hh:39
virtual void SetReflectivity(const double _reflectivity) override
Set the reflectivity value.
Definition: gz/rendering/base/BaseMaterial.hh:417
math::Color diffuse
Diffuse color.
Definition: gz/rendering/base/BaseMaterial.hh:293
virtual double Shininess() const override
Get the shininess value.
Definition: gz/rendering/base/BaseMaterial.hh:494
virtual std::string RoughnessMap() const override
Get the URI of the roughness map file.
Definition: gz/rendering/base/BaseMaterial.hh:669
virtual bool ReceiveShadows() const override
Determine if this material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:522
double reflectivity
Reflectivity.
Definition: gz/rendering/base/BaseMaterial.hh:308
std::string EmissiveMap() const
double Metalness() const
@ ST_PIXEL
Per pixel lighting shader.
Definition: gz/rendering/ShaderType.hh:40
virtual void ClearEnvironmentMap() override
Removes any environment map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:739
virtual void CopyFrom(ConstMaterialPtr _material) override
Copy properties from given Material.
Definition: gz/rendering/base/BaseMaterial.hh:816
math::Color Diffuse() const
virtual std::string NormalMap() const override
Get the URI of the normal map file.
Definition: gz/rendering/base/BaseMaterial.hh:641
virtual void SetNormalMap(const std::string &_normalMap) override
Set the material normal map.
Definition: gz/rendering/base/BaseMaterial.hh:648
virtual ShaderParamsPtr VertexShaderParams() override
Get params for the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:571
virtual bool ReflectionEnabled() const override
Determine if this material has a reflection.
Definition: gz/rendering/base/BaseMaterial.hh:550
double Roughness() const
virtual void SetSpecular(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the specular color.
Definition: gz/rendering/base/BaseMaterial.hh:373
virtual math::Color Specular() const override
Get the specular color.
Definition: gz/rendering/base/BaseMaterial.hh:480
virtual bool DepthWriteEnabled() const override
Determine if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:543
virtual void SetMetalness(const float _metalness) override
Set the metalness value. Only affects material of type MT_PBS.
Definition: gz/rendering/base/BaseMaterial.hh:788
ShaderType
Available types of shaders. Note that not all rendering-engines will be able to use each type....
Definition: gz/rendering/ShaderType.hh:34
virtual void SetTexture(const std::string &_texture) override
Set the material texture.
Definition: gz/rendering/base/BaseMaterial.hh:620
virtual void SetTransparency(const double _transparency) override
Set the transparency value.
Definition: gz/rendering/base/BaseMaterial.hh:410
virtual bool HasNormalMap() const override
Determine if this material has a normal map.
Definition: gz/rendering/base/BaseMaterial.hh:634
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
virtual ~BaseMaterial()
Definition: gz/rendering/base/BaseMaterial.hh:337
math::Color emissive
Emissive color.
Definition: gz/rendering/base/BaseMaterial.hh:299
double Transparency() const
virtual void SetEmissiveMap(const std::string &_emissiveMap) override
Set the material emissive map.
Definition: gz/rendering/base/BaseMaterial.hh:760
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: gz/rendering/base/BaseMaterial.hh:884
virtual void SetRoughnessMap(const std::string &_roughnessMap) override
Set the material roughness map.
Definition: gz/rendering/base/BaseMaterial.hh:676
math::Color Ambient() const
virtual void ClearRoughnessMap() override
Removes any roughness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:683
math::Color Specular() const
virtual void ClearTexture() override
Removes any texture mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:627