Gazebo Rendering

API Reference

6.6.3
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 SetAlphaFromTexture(bool _enabled,
83  double _alpha = 0.5, bool _twoSided = true) override;
84 
85  // Documentation inherited
86  public: bool TextureAlphaEnabled() const override;
87 
88  // Documentation inherited
89  public: double AlphaThreshold() const override;
90 
91  // Documentation inherited
92  public: bool TwoSidedEnabled() const override;
93 
94  // Documentation inherited
95  public: virtual void SetShininess(const double _shininess) override;
96 
97  // Documentation inherited
98  public: virtual void SetReflectivity(const double _reflectivity) override;
99 
100  // Documentation inherited
101  public: virtual void SetCastShadows(const bool _castShadows) override;
102 
103  // Documentation inherited
104  public: virtual void SetReceiveShadows(const bool _receiveShadows)
105  override;
106 
107  // Documentation inherited
108  public: virtual void SetReflectionEnabled(const bool _enabled) override;
109 
110  // Documentation inherited
111  public: virtual void SetLightingEnabled(const bool _enabled) override;
112 
113  // Documentation inherited.
114  public: virtual void SetDepthCheckEnabled(bool _enabled) override;
115 
116  // Documentation inherited.
117  public: virtual void SetDepthWriteEnabled(bool _enabled) override;
118 
119  // Documentation inherited
120  public: virtual math::Color Ambient() const override;
121 
122  // Documentation inherited
123  public: virtual math::Color Diffuse() const override;
124 
125  // Documentation inherited
126  public: virtual math::Color Specular() const override;
127 
128  // Documentation inherited
129  public: virtual math::Color Emissive() const override;
130 
131  // Documentation inherited
132  public: virtual double Transparency() const override;
133 
134  // Documentation inherited
135  public: virtual double Reflectivity() const override;
136 
137  // Documentation inherited
138  public: virtual double Shininess() const override;
139 
140  // Documentation inherited
141  public: virtual bool CastShadows() const override;
142 
143  // Documentation inherited
144  public: virtual bool ReceiveShadows() const override;
145 
146  // Documentation inherited
147  public: virtual bool LightingEnabled() const override;
148 
149  // Documentation inherited
150  public: virtual bool DepthCheckEnabled() const override;
151 
152  // Documentation inherited
153  public: virtual bool DepthWriteEnabled() const override;
154 
155  // Documentation inherited
156  public: virtual bool ReflectionEnabled() const override;
157 
158  // Documentation inherited
159  public: virtual bool HasTexture() const override;
160 
161  // Documentation inherited
162  public: virtual std::string Texture() const override;
163 
164  // Documentation inherited
165  public: virtual void SetTexture(const std::string &_texture) override;
166 
167  // Documentation inherited
168  public: virtual void ClearTexture() override;
169 
170  // Documentation inherited
171  public: virtual bool HasNormalMap() const override;
172 
173  // Documentation inherited
174  public: virtual std::string NormalMap() const override;
175 
176  // Documentation inherited
177  public: virtual void SetNormalMap(const std::string &_normalMap)
178  override;
179 
180  // Documentation inherited
181  public: virtual void ClearNormalMap() override;
182 
183  // Documentation inherited
184  public: virtual bool HasRoughnessMap() const override;
185 
186  // Documentation inherited
187  public: virtual std::string RoughnessMap() const override;
188 
189  // Documentation inherited
190  public: virtual void SetRoughnessMap(const std::string &_roughnessMap)
191  override;
192 
193  // Documentation inherited
194  public: virtual void ClearRoughnessMap() override;
195 
196  // Documentation inherited
197  public: virtual bool HasMetalnessMap() const override;
198 
199  // Documentation inherited
200  public: virtual std::string MetalnessMap() const override;
201 
202  // Documentation inherited
203  public: virtual void SetMetalnessMap(const std::string &_metalnessMap)
204  override;
205 
206  // Documentation inherited
207  public: virtual void ClearMetalnessMap() override;
208 
209  // Documentation inherited
210  public: virtual bool HasEnvironmentMap() const override;
211 
212  // Documentation inherited
213  public: virtual std::string EnvironmentMap() const override;
214 
215  // Documentation inherited
216  public: virtual void SetEnvironmentMap(const std::string &_metalnessMap)
217  override;
218 
219  // Documentation inherited
220  public: virtual void ClearEnvironmentMap() override;
221 
222  // Documentation inherited
223  public: virtual bool HasEmissiveMap() const override;
224 
225  // Documentation inherited
226  public: virtual std::string EmissiveMap() const override;
227 
228  // Documentation inherited
229  public: virtual void SetEmissiveMap(const std::string &_emissiveMap)
230  override;
231 
232  // Documentation inherited
233  public: virtual void ClearEmissiveMap() override;
234 
235  // Documentation inherited
236  public: virtual bool HasLightMap() const override;
237 
238  // Documentation inherited
239  public: virtual std::string LightMap() const override;
240 
241  // Documentation inherited
242  public: virtual unsigned int LightMapTexCoordSet() const override;
243 
244  // Documentation inherited
245  public: virtual void SetLightMap(const std::string &_lightMap,
246  unsigned int _uvSet = 0u) override;
247 
248  // Documentation inherited
249  public: virtual void ClearLightMap() override;
250 
251  // Documentation inherited
252  public: virtual void SetRenderOrder(const float _renderOrder) override;
253 
254  // Documentation inherited
255  public: virtual float RenderOrder() const override;
256 
257  // Documentation inherited
258  public: virtual void SetRoughness(const float _roughness) override;
259 
260  // Documentation inherited
261  public: virtual float Roughness() const override;
262 
263  // Documentation inherited
264  public: virtual void SetMetalness(const float _metalness) override;
265 
266  // Documentation inherited
267  public: virtual float Metalness() const override;
268 
269  // Documentation inherited
270  public: virtual MaterialType Type() const override;
271 
272  public: virtual void SetShaderType(enum ShaderType _type) override
273  {
274  (void)_type;
275  // no op
276  }
277 
278  // Documentation inherited
279  public: virtual enum ShaderType ShaderType() const override
280  {
281  return ST_PIXEL;
282  }
283 
284  // Documentation inherited.
285  // \sa Material::SetDepthMaterial()
286  public: virtual void SetDepthMaterial(const double far,
287  const double near) override;
288 
289  // Documentation inherited.
290  // \sa Material::VertexShader() const
291  public: virtual std::string VertexShader() const override;
292 
293  // Documentation inherited.
294  // \sa Material::VertexShaderParams()
295  public: virtual ShaderParamsPtr VertexShaderParams() override;
296 
297  // Documentation inherited.
298  // \sa Material::SetVertexShader(const std::string &)
299  public: virtual void SetVertexShader(const std::string &_path) override;
300 
301  // Documentation inherited.
302  // \sa Material::FragmentShader() const
303  public: virtual std::string FragmentShader() const override;
304 
305  // Documentation inherited.
306  // \sa Material::FragmentShaderParams()
307  public: virtual ShaderParamsPtr FragmentShaderParams() override;
308 
309  // Documentation inherited.
310  // \sa Material::SetFragmentShader(const std::string &)
311  public: virtual void SetFragmentShader(const std::string &_path) override;
312 
313  // Documentation inherited.
314  public: virtual void CopyFrom(ConstMaterialPtr _material) override;
315 
316  // Documentation inherited.
317  public: virtual void CopyFrom(const common::Material &_material) override;
318 
319  // Documentation inherited.
320  public: virtual void PreRender() override;
321 
322  protected: virtual void Reset();
323 
325  protected: math::Color ambient;
326 
328  protected: math::Color diffuse;
329 
331  protected: math::Color specular;
332 
334  protected: math::Color emissive;
335 
337  protected: double transparency = 0.0;
338 
340  protected: bool textureAlphaEnabled = false;
341 
343  protected: double alphaThreshold = 0.5;
344 
346  protected: bool twoSidedEnabled = false;
347 
349  protected: double renderOrder = 0.0;
350 
352  protected: double shininess = 0.0;
353 
355  protected: double reflectivity = 0.0;
356 
358  protected: bool lightingEnabled = false;
359 
361  protected: bool depthCheckEnabled = true;
362 
364  protected: bool depthWriteEnabled = true;
365 
367  protected: bool reflectionEnabled = false;
368 
370  protected: bool receiveShadows = true;
371 
373  protected: bool castShadows = true;
374  };
375 
377  template <class T>
379  {
380  }
381 
383  template <class T>
385  {
386  }
387 
389  template <class T>
390  void BaseMaterial<T>::SetAmbient(const double _r, const double _g,
391  const double _b, const double _a)
392  {
393  this->SetAmbient(math::Color(_r, _g, _b, _a));
394  }
395 
397  template <class T>
399  {
400  this->ambient = _color;
401  }
402 
404  template <class T>
405  void BaseMaterial<T>::SetDiffuse(const double _r, const double _g,
406  const double _b, const double _a)
407  {
408  this->SetDiffuse(math::Color(_r, _g, _b, _a));
409  }
410 
412  template <class T>
414  {
415  this->diffuse = _color;
416  }
417 
419  template <class T>
420  void BaseMaterial<T>::SetSpecular(const double _r, const double _g,
421  const double _b, const double _a)
422  {
423  this->SetSpecular(math::Color(_r, _g, _b, _a));
424  }
425 
427  template <class T>
429  {
430  this->specular = _color;
431  }
432 
434  template <class T>
435  void BaseMaterial<T>::SetEmissive(const double _r, const double _g,
436  const double _b, const double _a)
437  {
438  this->SetEmissive(math::Color(_r, _g, _b, _a));
439  }
440 
442  template <class T>
444  {
445  this->emissive = _color;
446  }
447 
449  template <class T>
450  void BaseMaterial<T>::SetShininess(const double _shininess)
451  {
452  this->shininess = _shininess;
453  }
454 
456  template <class T>
457  void BaseMaterial<T>::SetTransparency(const double _transparency)
458  {
459  this->transparency = _transparency;
460  }
461 
463  template <class T>
464  void BaseMaterial<T>::SetAlphaFromTexture(bool _enabled, double _alpha,
465  bool _twoSided)
466  {
467  this->textureAlphaEnabled = _enabled;
468  this->alphaThreshold = _alpha;
469  this->twoSidedEnabled = _twoSided;
470  }
471 
473  template <class T>
475  {
476  return this->textureAlphaEnabled;
477  }
478 
480  template <class T>
482  {
483  return this->alphaThreshold;
484  }
485 
487  template <class T>
489  {
490  return this->twoSidedEnabled;
491  }
492 
494  template <class T>
495  void BaseMaterial<T>::SetReflectivity(const double _reflectivity)
496  {
497  this->reflectivity = _reflectivity;
498  }
499 
501  template <class T>
502  void BaseMaterial<T>::SetReflectionEnabled(const bool _enabled)
503  {
504  this->reflectionEnabled = _enabled;
505  }
506 
508  template <class T>
509  void BaseMaterial<T>::SetLightingEnabled(const bool _enabled)
510  {
511  this->lightingEnabled = _enabled;
512  }
513 
515  template <class T>
517  {
518  this->depthCheckEnabled = _enabled;
519  }
520 
522  template <class T>
524  {
525  this->depthWriteEnabled = _enabled;
526  }
527 
529  template <class T>
530  void BaseMaterial<T>::SetCastShadows(const bool _castShadows)
531  {
532  this->castShadows = _castShadows;
533  }
534 
536  template <class T>
537  void BaseMaterial<T>::SetReceiveShadows(const bool _receive)
538  {
539  this->receiveShadows = _receive;
540  }
541 
543  template <class T>
544  void BaseMaterial<T>::SetRenderOrder(const float _renderorder)
545  {
546  this->renderOrder = _renderorder;
547  }
548 
550  template <class T>
552  {
553  return this->ambient;
554  }
555 
557  template <class T>
559  {
560  return this->diffuse;
561  }
562 
564  template <class T>
566  {
567  return this->specular;
568  }
569 
571  template <class T>
573  {
574  return this->emissive;
575  }
576 
578  template <class T>
580  {
581  return this->shininess;
582  }
583 
585  template <class T>
587  {
588  return this->transparency;
589  }
590 
592  template <class T>
594  {
595  return this->renderOrder;
596  }
597 
599  template <class T>
601  {
602  return this->reflectivity;
603  }
604 
606  template <class T>
608  {
609  return this->castShadows;
610  }
611 
613  template <class T>
615  {
616  return this->receiveShadows;
617  }
618 
620  template <class T>
622  {
623  return this->lightingEnabled;
624  }
625 
627  template <class T>
629  {
630  return this->depthCheckEnabled;
631  }
632 
634  template <class T>
636  {
637  return this->depthWriteEnabled;
638  }
639 
641  template <class T>
643  {
644  return this->reflectionEnabled;
645  }
646 
648  template <class T>
650  {
651  return MT_CLASSIC;
652  }
653 
655  template <class T>
657  {
658  return std::string();
659  }
660 
662  template <class T>
664  {
665  return nullptr;
666  }
667 
669  template <class T>
671  {
672  // no op
673  }
674 
676  template <class T>
678  {
679  return std::string();
680  }
681 
683  template <class T>
685  {
686  return nullptr;
687  }
688 
690  template <class T>
692  {
693  // no op
694  }
695 
697  template <class T>
699  {
700  return false;
701  }
702 
704  template <class T>
706  {
707  return std::string();
708  }
709 
711  template <class T>
713  {
714  // no op
715  }
716 
718  template <class T>
720  {
721  // no op
722  }
723 
725  template <class T>
727  {
728  return false;
729  }
730 
732  template <class T>
734  {
735  return std::string();
736  }
737 
739  template <class T>
741  {
742  // no op
743  }
744 
746  template <class T>
748  {
749  // no op
750  }
751 
753  template <class T>
755  {
756  return false;
757  }
758 
760  template <class T>
762  {
763  return std::string();
764  }
765 
767  template <class T>
769  {
770  // no op
771  }
772 
774  template <class T>
776  {
777  // no op
778  }
779 
781  template <class T>
783  {
784  return false;
785  }
786 
788  template <class T>
790  {
791  return std::string();
792  }
793 
795  template <class T>
797  {
798  // no op
799  }
800 
802  template <class T>
804  {
805  // no op
806  }
807 
809  template <class T>
811  {
812  return false;
813  }
814 
816  template <class T>
818  {
819  return std::string();
820  }
821 
823  template <class T>
825  {
826  // no op
827  }
828 
830  template <class T>
832  {
833  // no op
834  }
835 
837  template <class T>
839  {
840  return false;
841  }
842 
844  template <class T>
846  {
847  return std::string();
848  }
849 
851  template <class T>
853  {
854  // no op
855  }
856 
858  template <class T>
860  {
861  // no op
862  }
863 
865  template <class T>
867  {
868  return false;
869  }
870 
872  template <class T>
874  {
875  return std::string();
876  }
877 
879  template <class T>
881  {
882  return 0u;
883  }
884 
886  template <class T>
887  void BaseMaterial<T>::SetLightMap(const std::string &, unsigned int)
888  {
889  // no op
890  }
891 
893  template <class T>
895  {
896  // no op
897  }
898 
900  template <class T>
902  {
903  // no op
904  }
905 
907  template <class T>
909  {
910  return 0.0f;
911  }
912 
914  template <class T>
916  {
917  // no op
918  }
919 
921  template <class T>
923  {
924  return 0.0f;
925  }
926 
928  template <class T>
930  {
931  auto baseShared = this->shared_from_this();
932 
933  auto thisShared =
934  std::dynamic_pointer_cast<const BaseMaterial<T>>(baseShared);
935 
936  MaterialPtr material = T::Scene()->CreateMaterial(_name);
937  material->CopyFrom(thisShared);
938  return material;
939  }
940 
942  template <class T>
944  {
945  this->SetLightingEnabled(_material->LightingEnabled());
946  this->SetAmbient(_material->Ambient());
947  this->SetDiffuse(_material->Diffuse());
948  this->SetSpecular(_material->Specular());
949  this->SetEmissive(_material->Emissive());
950  this->SetRenderOrder(_material->RenderOrder());
951  this->SetShininess(_material->Shininess());
952  this->SetAlphaFromTexture(_material->TextureAlphaEnabled(),
953  _material->AlphaThreshold(), _material->TwoSidedEnabled());
954  // override transparency / blend setting after setting alpha from texture
955  this->SetTransparency(_material->Transparency());
956  // override depth check / depth write after setting transparency
957  this->SetDepthCheckEnabled(_material->DepthCheckEnabled());
958  this->SetDepthWriteEnabled(_material->DepthWriteEnabled());
959  this->SetReflectivity(_material->Reflectivity());
960  this->SetCastShadows(_material->CastShadows());
961  this->SetReceiveShadows(_material->ReceiveShadows());
962  this->SetReflectionEnabled(_material->ReflectionEnabled());
963  this->SetTexture(_material->Texture());
964  this->SetNormalMap(_material->NormalMap());
965  this->SetRoughnessMap(_material->RoughnessMap());
966  this->SetMetalnessMap(_material->MetalnessMap());
967  this->SetRoughness(_material->Roughness());
968  this->SetMetalness(_material->Metalness());
969  this->SetEnvironmentMap(_material->EnvironmentMap());
970  this->SetEmissiveMap(_material->EmissiveMap());
971  this->SetLightMap(_material->LightMap(),
972  _material->LightMapTexCoordSet());
973  this->SetShaderType(_material->ShaderType());
974  this->SetVertexShader(_material->VertexShader());
975  this->SetFragmentShader(_material->FragmentShader());
976  }
977 
979  template <class T>
981  {
982  this->SetLightingEnabled(_material.Lighting());
983  this->SetAmbient(_material.Ambient());
984  this->SetDiffuse(_material.Diffuse());
985  this->SetSpecular(_material.Specular());
986  this->SetEmissive(_material.Emissive());
987  this->SetShininess(_material.Shininess());
988  this->SetTransparency(_material.Transparency());
989  this->SetAlphaFromTexture(_material.TextureAlphaEnabled(),
990  _material.AlphaThreshold(), _material.TwoSidedEnabled());
991  this->SetRenderOrder(_material.RenderOrder());
992  // TODO(anyone): update common::Material
993  this->SetReflectivity(0);
994  this->SetTexture(_material.TextureImage());
995  // TODO(anyone): update common::Material
996  this->SetCastShadows(true);
997  // TODO(anyone): update common::Material
998  this->SetReceiveShadows(true);
999  // TODO(anyone): update common::Material
1000  this->SetReflectionEnabled(true);
1001  // TODO(anyone): update common::Material
1002  this->ClearNormalMap();
1003  // TODO(anyone): update common::Material
1004  this->SetShaderType(ST_PIXEL);
1005 
1006  const common::Pbr *pbrMat = _material.PbrMaterial();
1007  if (!pbrMat)
1008  pbrMat = &kDefaultPbr;
1009  this->SetNormalMap(pbrMat->NormalMap());
1010  this->SetRoughnessMap(pbrMat->RoughnessMap());
1011  this->SetMetalnessMap(pbrMat->MetalnessMap());
1012  this->SetRoughness(pbrMat->Roughness());
1013  this->SetMetalness(pbrMat->Metalness());
1014  this->SetEnvironmentMap(pbrMat->EnvironmentMap());
1015  this->SetEmissiveMap(pbrMat->EmissiveMap());
1016  this->SetLightMap(pbrMat->LightMap(), pbrMat->LightMapTexCoordSet());
1017  }
1018 
1020  template <class T>
1022  {
1023  // do nothing
1024  }
1025 
1027  template <class T>
1028  void BaseMaterial<T>::SetDepthMaterial(const double /*far*/,
1029  const double /*near*/)
1030  {
1031  // do nothing
1032  }
1033 
1035  template <class T>
1037  {
1038  this->SetLightingEnabled(true);
1039  this->SetDepthCheckEnabled(true);
1040  this->SetDepthWriteEnabled(true);
1041  this->SetAmbient(0.3, 0.3, 0.3);
1042  this->SetDiffuse(1.0, 1.0, 1.0);
1043  this->SetSpecular(0.2, 0.2, 0.2);
1044  this->SetEmissive(0, 0, 0);
1045  this->SetRenderOrder(0);
1046  this->SetShininess(1.5);
1047  this->SetTransparency(0);
1048  this->SetReflectivity(0);
1049  this->SetCastShadows(true);
1050  this->SetReceiveShadows(true);
1051  this->SetReflectionEnabled(true);
1052  this->ClearTexture();
1053  this->ClearNormalMap();
1054  this->ClearRoughnessMap();
1055  this->ClearMetalnessMap();
1056  this->ClearEmissiveMap();
1057  this->ClearLightMap();
1058  this->SetRoughness(kDefaultPbr.Roughness());
1059  this->SetMetalness(kDefaultPbr.Metalness());
1060  this->SetShaderType(ST_PIXEL);
1061  }
1062  }
1063  }
1064 }
1065 #endif
virtual math::Color Diffuse() const override
Get the diffuse color.
Definition: gz/rendering/base/BaseMaterial.hh:558
virtual void SetDepthMaterial(const double far, const double near) override
Configuration for Depth Material.
Definition: gz/rendering/base/BaseMaterial.hh:1028
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:435
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:337
virtual std::string LightMap() const override
Get the URI of the light map file.
Definition: gz/rendering/base/BaseMaterial.hh:873
virtual bool HasEnvironmentMap() const override
Determine if this material has a environment map.
Definition: gz/rendering/base/BaseMaterial.hh:810
virtual void ClearMetalnessMap() override
Removes any metalness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:803
virtual void Reset()
Definition: gz/rendering/base/BaseMaterial.hh:1036
virtual float Roughness() const override
Get the roughness value of this material.
Definition: gz/rendering/base/BaseMaterial.hh:908
virtual double Reflectivity() const override
Get the reflectivity value.
Definition: gz/rendering/base/BaseMaterial.hh:600
STL class.
STL class.
math::Color ambient
Ambient color.
Definition: gz/rendering/base/BaseMaterial.hh:325
virtual void ClearLightMap() override
Removes any light map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:894
virtual void SetShininess(const double _shininess) override
Set the shininess value.
Definition: gz/rendering/base/BaseMaterial.hh:450
virtual void SetReceiveShadows(const bool _receiveShadows) override
Specify if this material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:537
BaseMaterial()
Definition: gz/rendering/base/BaseMaterial.hh:378
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:405
bool lightingEnabled
Flag to indicate if dynamic lighting is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:358
virtual float Metalness() const override
Get the metalness value of this material.
Definition: gz/rendering/base/BaseMaterial.hh:922
std::string NormalMap() const
virtual void SetRenderOrder(const float _renderOrder) override
Set the render order. When polygons are coplanar, you can get problems with 'depth fighting' where th...
Definition: gz/rendering/base/BaseMaterial.hh:544
virtual std::string FragmentShader() const override
Get path to the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:677
bool castShadows
Set to true to enable object with this material to cast shadows.
Definition: gz/rendering/base/BaseMaterial.hh:373
bool depthCheckEnabled
Flag to indicate if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:361
virtual void SetFragmentShader(const std::string &_path) override
Set the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:691
virtual std::string Texture() const override
Get the URI of the texture file.
Definition: gz/rendering/base/BaseMaterial.hh:705
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:390
virtual enum ShaderType ShaderType() const override
Get the ShaderType value.
Definition: gz/rendering/base/BaseMaterial.hh:279
virtual void SetDepthWriteEnabled(bool _enabled) override
Specify if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:523
virtual void SetDepthCheckEnabled(bool _enabled) override
Specify if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:516
std::string LightMap() const
virtual std::string EmissiveMap() const override
Get the URI of the emissive map file.
Definition: gz/rendering/base/BaseMaterial.hh:845
virtual void SetVertexShader(const std::string &_path) override
Set the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:670
virtual void SetRoughness(const float _roughness) override
Set the roughness value. Only affects material of type MT_PBS.
Definition: gz/rendering/base/BaseMaterial.hh:901
virtual MaterialType Type() const override
Removes any metalness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:649
bool depthWriteEnabled
Flag to indicate if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:364
virtual void SetReflectionEnabled(const bool _enabled) override
Specify if this material has a reflection.
Definition: gz/rendering/base/BaseMaterial.hh:502
virtual std::string VertexShader() const override
Get path to the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:656
virtual bool HasMetalnessMap() const override
Determine if this material has a metalness map.
Definition: gz/rendering/base/BaseMaterial.hh:782
Definition: gz/rendering/base/BaseMaterial.hh:38
bool twoSidedEnabled
Enable two sided rendering.
Definition: gz/rendering/base/BaseMaterial.hh:346
virtual double Transparency() const override
Get the transparency value.
Definition: gz/rendering/base/BaseMaterial.hh:586
bool TextureAlphaEnabled() const
std::string TextureImage() const
virtual bool HasEmissiveMap() const override
Determine if this material has an emissive map.
Definition: gz/rendering/base/BaseMaterial.hh:838
virtual MaterialPtr Clone(const std::string &_name="") const override
Clone this material.
Definition: gz/rendering/base/BaseMaterial.hh:929
math::Color specular
Specular color.
Definition: gz/rendering/base/BaseMaterial.hh:331
unsigned int LightMapTexCoordSet() const
virtual void SetEnvironmentMap(const std::string &_metalnessMap) override
Set the material environment map.
Definition: gz/rendering/base/BaseMaterial.hh:824
virtual bool CastShadows() const override
Determine if this material casts shadows.
Definition: gz/rendering/base/BaseMaterial.hh:607
virtual bool HasRoughnessMap() const override
Determine if this material has a roughness map.
Definition: gz/rendering/base/BaseMaterial.hh:754
virtual void SetShaderType(enum ShaderType _type) override
Set the ShaderType value.
Definition: gz/rendering/base/BaseMaterial.hh:272
bool TwoSidedEnabled() const override
Get the enable two sided rendering value.
Definition: gz/rendering/base/BaseMaterial.hh:488
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:530
virtual void SetLightingEnabled(const bool _enabled) override
Specify if lighting affects this material.
Definition: gz/rendering/base/BaseMaterial.hh:509
virtual bool HasTexture() const override
Determine if this material has a texture.
Definition: gz/rendering/base/BaseMaterial.hh:698
bool textureAlphaEnabled
Enable alpha channel based texture transparency.
Definition: gz/rendering/base/BaseMaterial.hh:340
virtual std::string EnvironmentMap() const override
Get the URI of the environment map file.
Definition: gz/rendering/base/BaseMaterial.hh:817
virtual math::Color Ambient() const override
Get the ambient color.
Definition: gz/rendering/base/BaseMaterial.hh:551
virtual void SetMetalnessMap(const std::string &_metalnessMap) override
Set the material metalness map.
Definition: gz/rendering/base/BaseMaterial.hh:796
virtual math::Color Emissive() const override
Get the emissive color.
Definition: gz/rendering/base/BaseMaterial.hh:572
virtual void ClearNormalMap() override
Removes any normal map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:747
double shininess
Shininess factor.
Definition: gz/rendering/base/BaseMaterial.hh:352
virtual ShaderParamsPtr FragmentShaderParams() override
Get params for the fragment shader.
Definition: gz/rendering/base/BaseMaterial.hh:684
virtual void SetAlphaFromTexture(bool _enabled, double _alpha=0.5, bool _twoSided=true) override
Set the material to use the alpha channel from the textures.
Definition: gz/rendering/base/BaseMaterial.hh:464
virtual bool DepthCheckEnabled() const override
Determine if depth buffer checking is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:628
bool reflectionEnabled
Flag to indicate if reflection is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:367
std::string EnvironmentMap() const
bool receiveShadows
True if material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:370
virtual bool LightingEnabled() const override
Determine if lighting affects this material.
Definition: gz/rendering/base/BaseMaterial.hh:621
virtual std::string MetalnessMap() const override
Get the URI of the metalness map file.
Definition: gz/rendering/base/BaseMaterial.hh:789
virtual void ClearEmissiveMap() override
Removes any emissive map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:859
@ 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:495
math::Color diffuse
Diffuse color.
Definition: gz/rendering/base/BaseMaterial.hh:328
virtual double Shininess() const override
Get the shininess value.
Definition: gz/rendering/base/BaseMaterial.hh:579
virtual std::string RoughnessMap() const override
Get the URI of the roughness map file.
Definition: gz/rendering/base/BaseMaterial.hh:761
virtual bool ReceiveShadows() const override
Determine if this material receives shadows.
Definition: gz/rendering/base/BaseMaterial.hh:614
double reflectivity
Reflectivity.
Definition: gz/rendering/base/BaseMaterial.hh:355
virtual bool HasLightMap() const override
Determine if this material has a light map.
Definition: gz/rendering/base/BaseMaterial.hh:866
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:831
double AlphaThreshold() const
virtual void CopyFrom(ConstMaterialPtr _material) override
Copy properties from given Material.
Definition: gz/rendering/base/BaseMaterial.hh:943
double AlphaThreshold() const override
Get the alpha threshold.
Definition: gz/rendering/base/BaseMaterial.hh:481
math::Color Diffuse() const
virtual std::string NormalMap() const override
Get the URI of the normal map file.
Definition: gz/rendering/base/BaseMaterial.hh:733
virtual void SetNormalMap(const std::string &_normalMap) override
Set the material normal map.
Definition: gz/rendering/base/BaseMaterial.hh:740
virtual ShaderParamsPtr VertexShaderParams() override
Get params for the vertex shader.
Definition: gz/rendering/base/BaseMaterial.hh:663
virtual bool ReflectionEnabled() const override
Determine if this material has a reflection.
Definition: gz/rendering/base/BaseMaterial.hh:642
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:420
bool TextureAlphaEnabled() const override
Get the enable alpha from textures.
Definition: gz/rendering/base/BaseMaterial.hh:474
virtual math::Color Specular() const override
Get the specular color.
Definition: gz/rendering/base/BaseMaterial.hh:565
virtual bool DepthWriteEnabled() const override
Determine if depth buffer writing is enabled.
Definition: gz/rendering/base/BaseMaterial.hh:635
virtual void SetMetalness(const float _metalness) override
Set the metalness value. Only affects material of type MT_PBS.
Definition: gz/rendering/base/BaseMaterial.hh:915
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:712
virtual float RenderOrder() const override
Get the render order value of this material.
Definition: gz/rendering/base/BaseMaterial.hh:593
virtual void SetTransparency(const double _transparency) override
Set the transparency value.
Definition: gz/rendering/base/BaseMaterial.hh:457
virtual bool HasNormalMap() const override
Determine if this material has a normal map.
Definition: gz/rendering/base/BaseMaterial.hh:726
Represents a surface material of a Geometry.
Definition: gz/rendering/Material.hh:47
double alphaThreshold
Threshold for alpha channel rejection.
Definition: gz/rendering/base/BaseMaterial.hh:343
double renderOrder
Material render order.
Definition: gz/rendering/base/BaseMaterial.hh:349
virtual ~BaseMaterial()
Definition: gz/rendering/base/BaseMaterial.hh:384
math::Color emissive
Emissive color.
Definition: gz/rendering/base/BaseMaterial.hh:334
double Transparency() const
virtual void SetEmissiveMap(const std::string &_emissiveMap) override
Set the material emissive map.
Definition: gz/rendering/base/BaseMaterial.hh:852
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:1021
virtual unsigned int LightMapTexCoordSet() const override
Get the texture coordinate set used by lightmap.
Definition: gz/rendering/base/BaseMaterial.hh:880
virtual void SetLightMap(const std::string &_lightMap, unsigned int _uvSet=0u) override
Set the material light map.
Definition: gz/rendering/base/BaseMaterial.hh:887
virtual void SetRoughnessMap(const std::string &_roughnessMap) override
Set the material roughness map.
Definition: gz/rendering/base/BaseMaterial.hh:768
math::Color Ambient() const
virtual void ClearRoughnessMap() override
Removes any roughness map mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:775
math::Color Specular() const
virtual void ClearTexture() override
Removes any texture mapped to this material.
Definition: gz/rendering/base/BaseMaterial.hh:719