Ignition Rendering

API Reference

5.0.0
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 IGNITION_RENDERING_BASE_BASEMATERIAL_HH_
18 #define IGNITION_RENDERING_BASE_BASEMATERIAL_HH_
19 
20 #include <string>
21 
23 
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 _cast) 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  // no op
275  }
276 
277  // Documentation inherited
278  public: virtual enum ShaderType ShaderType() const override
279  {
280  return ST_PIXEL;
281  }
282 
283  // Documentation inherited.
284  // \sa Material::SetDepthMaterial()
285  public: virtual void SetDepthMaterial(const double far,
286  const double near) override;
287 
288  // Documentation inherited.
289  // \sa Material::VertexShader() const
290  public: virtual std::string VertexShader() const override;
291 
292  // Documentation inherited.
293  // \sa Material::VertexShaderParams()
294  public: virtual ShaderParamsPtr VertexShaderParams() override;
295 
296  // Documentation inherited.
297  // \sa Material::SetVertexShader(const std::string &)
298  public: virtual void SetVertexShader(const std::string &_path) override;
299 
300  // Documentation inherited.
301  // \sa Material::FragmentShader() const
302  public: virtual std::string FragmentShader() const override;
303 
304  // Documentation inherited.
305  // \sa Material::FragmentShaderParams()
306  public: virtual ShaderParamsPtr FragmentShaderParams() override;
307 
308  // Documentation inherited.
309  // \sa Material::SetFragmentShader(const std::string &)
310  public: virtual void SetFragmentShader(const std::string &_path) override;
311 
312  // Documentation inherited.
313  public: virtual void CopyFrom(ConstMaterialPtr _material) override;
314 
315  // Documentation inherited.
316  public: virtual void CopyFrom(const common::Material &_material) override;
317 
318  // Documentation inherited.
319  public: virtual void PreRender() override;
320 
321  protected: virtual void Reset();
322 
324  protected: math::Color ambient;
325 
327  protected: math::Color diffuse;
328 
330  protected: math::Color specular;
331 
333  protected: math::Color emissive;
334 
336  protected: double transparency = 0.0;
337 
339  protected: bool textureAlphaEnabled = false;
340 
342  protected: double alphaThreshold = 0.5;
343 
345  protected: bool twoSidedEnabled = false;
346 
348  protected: double renderOrder = 0.0;
349 
351  protected: double shininess = 0.0;
352 
354  protected: double reflectivity = 0.0;
355 
357  protected: bool lightingEnabled = false;
358 
360  protected: bool depthCheckEnabled = true;
361 
363  protected: bool depthWriteEnabled = true;
364 
366  protected: bool reflectionEnabled = false;
367 
369  protected: bool receiveShadows = true;
370 
372  protected: bool castShadows = true;
373  };
374 
376  template <class T>
378  {
379  }
380 
382  template <class T>
384  {
385  }
386 
388  template <class T>
389  void BaseMaterial<T>::SetAmbient(const double _r, const double _g,
390  const double _b, const double _a)
391  {
392  this->SetAmbient(math::Color(_r, _g, _b, _a));
393  }
394 
396  template <class T>
398  {
399  this->ambient = _color;
400  }
401 
403  template <class T>
404  void BaseMaterial<T>::SetDiffuse(const double _r, const double _g,
405  const double _b, const double _a)
406  {
407  this->SetDiffuse(math::Color(_r, _g, _b, _a));
408  }
409 
411  template <class T>
413  {
414  this->diffuse = _color;
415  }
416 
418  template <class T>
419  void BaseMaterial<T>::SetSpecular(const double _r, const double _g,
420  const double _b, const double _a)
421  {
422  this->SetSpecular(math::Color(_r, _g, _b, _a));
423  }
424 
426  template <class T>
428  {
429  this->specular = _color;
430  }
431 
433  template <class T>
434  void BaseMaterial<T>::SetEmissive(const double _r, const double _g,
435  const double _b, const double _a)
436  {
437  this->SetEmissive(math::Color(_r, _g, _b, _a));
438  }
439 
441  template <class T>
443  {
444  this->emissive = _color;
445  }
446 
448  template <class T>
449  void BaseMaterial<T>::SetShininess(const double _shininess)
450  {
451  this->shininess = _shininess;
452  }
453 
455  template <class T>
456  void BaseMaterial<T>::SetTransparency(const double _transparency)
457  {
458  this->transparency = _transparency;
459  }
460 
462  template <class T>
463  void BaseMaterial<T>::SetAlphaFromTexture(bool _enabled, double _alpha,
464  bool _twoSided)
465  {
466  this->textureAlphaEnabled = _enabled;
467  this->alphaThreshold = _alpha;
468  this->twoSidedEnabled = _twoSided;
469  }
470 
472  template <class T>
474  {
475  return this->textureAlphaEnabled;
476  }
477 
479  template <class T>
481  {
482  return this->alphaThreshold;
483  }
484 
486  template <class T>
488  {
489  return this->twoSidedEnabled;
490  }
491 
493  template <class T>
494  void BaseMaterial<T>::SetReflectivity(const double _reflectivity)
495  {
496  this->reflectivity = _reflectivity;
497  }
498 
500  template <class T>
501  void BaseMaterial<T>::SetReflectionEnabled(const bool _enabled)
502  {
503  this->reflectionEnabled = _enabled;
504  }
505 
507  template <class T>
508  void BaseMaterial<T>::SetLightingEnabled(const bool _enabled)
509  {
510  this->lightingEnabled = _enabled;
511  }
512 
514  template <class T>
516  {
517  this->depthCheckEnabled = _enabled;
518  }
519 
521  template <class T>
523  {
524  this->depthWriteEnabled = _enabled;
525  }
526 
528  template <class T>
529  void BaseMaterial<T>::SetCastShadows(const bool _cast)
530  {
531  this->castShadows = _cast;
532  }
533 
535  template <class T>
536  void BaseMaterial<T>::SetReceiveShadows(const bool _receive)
537  {
538  this->receiveShadows = _receive;
539  }
540 
542  template <class T>
543  void BaseMaterial<T>::SetRenderOrder(const float _renderorder)
544  {
545  this->renderOrder = _renderorder;
546  }
547 
549  template <class T>
551  {
552  return this->ambient;
553  }
554 
556  template <class T>
558  {
559  return this->diffuse;
560  }
561 
563  template <class T>
565  {
566  return this->specular;
567  }
568 
570  template <class T>
572  {
573  return this->emissive;
574  }
575 
577  template <class T>
579  {
580  return this->shininess;
581  }
582 
584  template <class T>
586  {
587  return this->transparency;
588  }
589 
591  template <class T>
593  {
594  return this->renderOrder;
595  }
596 
598  template <class T>
600  {
601  return this->reflectivity;
602  }
603 
605  template <class T>
607  {
608  return this->castShadows;
609  }
610 
612  template <class T>
614  {
615  return this->receiveShadows;
616  }
617 
619  template <class T>
621  {
622  return this->lightingEnabled;
623  }
624 
626  template <class T>
628  {
629  return this->depthCheckEnabled;
630  }
631 
633  template <class T>
635  {
636  return this->depthWriteEnabled;
637  }
638 
640  template <class T>
642  {
643  return this->reflectionEnabled;
644  }
645 
647  template <class T>
649  {
650  return MT_CLASSIC;
651  }
652 
654  template <class T>
656  {
657  return std::string();
658  }
659 
661  template <class T>
663  {
664  return nullptr;
665  }
666 
668  template <class T>
670  {
671  // no op
672  }
673 
675  template <class T>
677  {
678  return std::string();
679  }
680 
682  template <class T>
684  {
685  return nullptr;
686  }
687 
689  template <class T>
691  {
692  // no op
693  }
694 
696  template <class T>
698  {
699  return false;
700  }
701 
703  template <class T>
705  {
706  return std::string();
707  }
708 
710  template <class T>
712  {
713  // no op
714  }
715 
717  template <class T>
719  {
720  // no op
721  }
722 
724  template <class T>
726  {
727  return false;
728  }
729 
731  template <class T>
733  {
734  return std::string();
735  }
736 
738  template <class T>
740  {
741  // no op
742  }
743 
745  template <class T>
747  {
748  // no op
749  }
750 
752  template <class T>
754  {
755  return false;
756  }
757 
759  template <class T>
761  {
762  return std::string();
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 false;
784  }
785 
787  template <class T>
789  {
790  return std::string();
791  }
792 
794  template <class T>
796  {
797  // no op
798  }
799 
801  template <class T>
803  {
804  // no op
805  }
806 
808  template <class T>
810  {
811  return false;
812  }
813 
815  template <class T>
817  {
818  return std::string();
819  }
820 
822  template <class T>
824  {
825  // no op
826  }
827 
829  template <class T>
831  {
832  // no op
833  }
834 
836  template <class T>
838  {
839  return false;
840  }
841 
843  template <class T>
845  {
846  return std::string();
847  }
848 
850  template <class T>
852  {
853  // no op
854  }
855 
857  template <class T>
859  {
860  // no op
861  }
862 
864  template <class T>
866  {
867  return false;
868  }
869 
871  template <class T>
873  {
874  return std::string();
875  }
876 
878  template <class T>
880  {
881  return 0u;
882  }
883 
885  template <class T>
886  void BaseMaterial<T>::SetLightMap(const std::string &, unsigned int)
887  {
888  // no op
889  }
890 
892  template <class T>
894  {
895  // no op
896  }
897 
899  template <class T>
901  {
902  // no op
903  }
904 
906  template <class T>
908  {
909  return 0.0f;
910  }
911 
913  template <class T>
915  {
916  // no op
917  }
918 
920  template <class T>
922  {
923  return 0.0f;
924  }
925 
927  template <class T>
929  {
930  auto baseShared = this->shared_from_this();
931 
932  auto thisShared =
933  std::dynamic_pointer_cast<const BaseMaterial<T>>(baseShared);
934 
935  MaterialPtr material = T::Scene()->CreateMaterial(_name);
936  material->CopyFrom(thisShared);
937  return material;
938  }
939 
941  template <class T>
943  {
944  this->SetLightingEnabled(_material->LightingEnabled());
945  this->SetAmbient(_material->Ambient());
946  this->SetDiffuse(_material->Diffuse());
947  this->SetSpecular(_material->Specular());
948  this->SetEmissive(_material->Emissive());
949  this->SetRenderOrder(_material->RenderOrder());
950  this->SetShininess(_material->Shininess());
951  this->SetAlphaFromTexture(_material->TextureAlphaEnabled(),
952  _material->AlphaThreshold(), _material->TwoSidedEnabled());
953  // override transparency / blend setting after setting alpha from texture
954  this->SetTransparency(_material->Transparency());
955  // override depth check / depth write after setting transparency
956  this->SetDepthCheckEnabled(_material->DepthCheckEnabled());
957  this->SetDepthWriteEnabled(_material->DepthWriteEnabled());
958  this->SetReflectivity(_material->Reflectivity());
959  this->SetCastShadows(_material->CastShadows());
960  this->SetReceiveShadows(_material->ReceiveShadows());
961  this->SetReflectionEnabled(_material->ReflectionEnabled());
962  this->SetTexture(_material->Texture());
963  this->SetNormalMap(_material->NormalMap());
964  this->SetRoughnessMap(_material->RoughnessMap());
965  this->SetMetalnessMap(_material->MetalnessMap());
966  this->SetRoughness(_material->Roughness());
967  this->SetMetalness(_material->Metalness());
968  this->SetEnvironmentMap(_material->EnvironmentMap());
969  this->SetEmissiveMap(_material->EmissiveMap());
970  this->SetLightMap(_material->LightMap(),
971  _material->LightMapTexCoordSet());
972  this->SetShaderType(_material->ShaderType());
973  this->SetVertexShader(_material->VertexShader());
974  this->SetFragmentShader(_material->FragmentShader());
975  }
976 
978  template <class T>
980  {
981  this->SetLightingEnabled(_material.Lighting());
982  this->SetAmbient(_material.Ambient());
983  this->SetDiffuse(_material.Diffuse());
984  this->SetSpecular(_material.Specular());
985  this->SetEmissive(_material.Emissive());
986  this->SetShininess(_material.Shininess());
987  this->SetTransparency(_material.Transparency());
988  this->SetAlphaFromTexture(_material.TextureAlphaEnabled(),
989  _material.AlphaThreshold(), _material.TwoSidedEnabled());
990  this->SetRenderOrder(_material.RenderOrder());
991  // TODO(anyone): update common::Material
992  this->SetReflectivity(0);
993  this->SetTexture(_material.TextureImage());
994  // TODO(anyone): update common::Material
995  this->SetCastShadows(true);
996  // TODO(anyone): update common::Material
997  this->SetReceiveShadows(true);
998  // TODO(anyone): update common::Material
999  this->SetReflectionEnabled(true);
1000  // TODO(anyone): update common::Material
1001  this->ClearNormalMap();
1002  // TODO(anyone): update common::Material
1003  this->SetShaderType(ST_PIXEL);
1004 
1005  const common::Pbr *pbrMat = _material.PbrMaterial();
1006  if (!pbrMat)
1007  pbrMat = &kDefaultPbr;
1008  this->SetNormalMap(pbrMat->NormalMap());
1009  this->SetRoughnessMap(pbrMat->RoughnessMap());
1010  this->SetMetalnessMap(pbrMat->MetalnessMap());
1011  this->SetRoughness(pbrMat->Roughness());
1012  this->SetMetalness(pbrMat->Metalness());
1013  this->SetEnvironmentMap(pbrMat->EnvironmentMap());
1014  this->SetEmissiveMap(pbrMat->EmissiveMap());
1015  this->SetLightMap(pbrMat->LightMap(), pbrMat->LightMapTexCoordSet());
1016  }
1017 
1019  template <class T>
1021  {
1022  // do nothing
1023  }
1024 
1026  template <class T>
1027  void BaseMaterial<T>::SetDepthMaterial(const double /*far*/,
1028  const double /*near*/)
1029  {
1030  // do nothing
1031  }
1032 
1034  template <class T>
1036  {
1037  this->SetLightingEnabled(true);
1038  this->SetDepthCheckEnabled(true);
1039  this->SetDepthWriteEnabled(true);
1040  this->SetAmbient(0.3, 0.3, 0.3);
1041  this->SetDiffuse(1.0, 1.0, 1.0);
1042  this->SetSpecular(0.2, 0.2, 0.2);
1043  this->SetEmissive(0, 0, 0);
1044  this->SetRenderOrder(0);
1045  this->SetShininess(1.5);
1046  this->SetTransparency(0);
1047  this->SetReflectivity(0);
1048  this->SetCastShadows(true);
1049  this->SetReceiveShadows(true);
1050  this->SetReflectionEnabled(true);
1051  this->ClearTexture();
1052  this->ClearNormalMap();
1053  this->ClearRoughnessMap();
1054  this->ClearMetalnessMap();
1055  this->ClearEmissiveMap();
1056  this->ClearLightMap();
1057  this->SetRoughness(kDefaultPbr.Roughness());
1058  this->SetMetalness(kDefaultPbr.Metalness());
1059  this->SetShaderType(ST_PIXEL);
1060  }
1061  }
1062  }
1063 }
1064 #endif
virtual void SetTransparency(const double _transparency) override
Set the transparency value.
Definition: BaseMaterial.hh:456
virtual void SetNormalMap(const std::string &_normalMap) override
Set the material normal map.
Definition: BaseMaterial.hh:739
std::string EmissiveMap() const
double AlphaThreshold() const override
Get the alpha threshold.
Definition: BaseMaterial.hh:480
virtual void SetRoughness(const float _roughness) override
Set the roughness value. Only affects material of type MT_PBS.
Definition: BaseMaterial.hh:900
static const common::Pbr kDefaultPbr
Default pbr material properties.
Definition: BaseMaterial.hh:35
virtual bool HasLightMap() const override
Determine if this material has a light map.
Definition: BaseMaterial.hh:865
virtual void ClearLightMap() override
Removes any light map mapped to this material.
Definition: BaseMaterial.hh:893
unsigned int LightMapTexCoordSet() const
virtual void SetCastShadows(const bool _cast) override
Specify if this material casts shadows.
Definition: BaseMaterial.hh:529
virtual void ClearEmissiveMap() override
Removes any emissive map mapped to this material.
Definition: BaseMaterial.hh:858
virtual float Roughness() const override
Get the roughness value of this material.
Definition: BaseMaterial.hh:907
virtual void SetAmbient(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the ambient color.
Definition: BaseMaterial.hh:389
virtual void Reset()
Definition: BaseMaterial.hh:1035
virtual void SetLightingEnabled(const bool _enabled) override
Specify if lighting affects this material.
Definition: BaseMaterial.hh:508
BaseMaterial()
Definition: BaseMaterial.hh:377
virtual void ClearEnvironmentMap() override
Removes any environment map mapped to this material.
Definition: BaseMaterial.hh:830
virtual void SetLightMap(const std::string &_lightMap, unsigned int uvSet=0u) override
Set the material light map.
Definition: BaseMaterial.hh:886
double Transparency() const
virtual bool DepthCheckEnabled() const override
Determine if depth buffer checking is enabled.
Definition: BaseMaterial.hh:627
virtual unsigned int LightMapTexCoordSet() const override
Get the texture coordinate set used by lightmap.
Definition: BaseMaterial.hh:879
virtual void SetReceiveShadows(const bool _receiveShadows) override
Specify if this material receives shadows.
Definition: BaseMaterial.hh:536
virtual void SetDepthMaterial(const double far, const double near) override
Configuration for Depth Material.
Definition: BaseMaterial.hh:1027
std::string EnvironmentMap() const
virtual std::string FragmentShader() const override
Get path to the fragment shader.
Definition: BaseMaterial.hh:676
std::string RoughnessMap() const
STL class.
virtual void SetMetalness(const float _metalness) override
Set the metalness value. Only affects material of type MT_PBS.
Definition: BaseMaterial.hh:914
virtual void SetEmissive(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the emissive color.
Definition: BaseMaterial.hh:434
virtual bool HasMetalnessMap() const override
Determine if this material has a metalness map.
Definition: BaseMaterial.hh:781
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: BaseMaterial.hh:1020
virtual void SetRoughnessMap(const std::string &_roughnessMap) override
Set the material roughness map.
Definition: BaseMaterial.hh:767
std::string LightMap() const
virtual void SetDepthWriteEnabled(bool _enabled) override
Specify if depth buffer writing is enabled.
Definition: BaseMaterial.hh:522
virtual void SetDiffuse(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the diffuse color.
Definition: BaseMaterial.hh:404
virtual void ClearNormalMap() override
Removes any normal map mapped to this material.
Definition: BaseMaterial.hh:746
virtual void SetVertexShader(const std::string &_path) override
Set the vertex shader.
Definition: BaseMaterial.hh:669
virtual void ClearRoughnessMap() override
Removes any roughness map mapped to this material.
Definition: BaseMaterial.hh:774
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: BaseMaterial.hh:463
virtual math::Color Ambient() const override
Get the ambient color.
Definition: BaseMaterial.hh:550
virtual void SetReflectivity(const double _reflectivity) override
Set the reflectivity value.
Definition: BaseMaterial.hh:494
double Roughness() const
virtual std::string Texture() const override
Get the URI of the texture file.
Definition: BaseMaterial.hh:704
virtual math::Color Diffuse() const override
Get the diffuse color.
Definition: BaseMaterial.hh:557
virtual MaterialPtr Clone(const std::string &_name="") const override
Clone this material.
Definition: BaseMaterial.hh:928
virtual ShaderParamsPtr VertexShaderParams() override
Get params for the vertex shader.
Definition: BaseMaterial.hh:662
std::string NormalMap() const
T dynamic_pointer_cast(T... args)
virtual bool ReflectionEnabled() const override
Determine if this material has a reflection.
Definition: BaseMaterial.hh:641
virtual double Reflectivity() const override
Get the reflectivity value.
Definition: BaseMaterial.hh:599
virtual std::string EmissiveMap() const override
Get the URI of the emissive map file.
Definition: BaseMaterial.hh:844
math::Color emissive
Emissive color.
Definition: BaseMaterial.hh:333
std::string TextureImage() const
virtual bool HasNormalMap() const override
Determine if this material has a normal map.
Definition: BaseMaterial.hh:725
virtual ~BaseMaterial()
Definition: BaseMaterial.hh:383
virtual std::string LightMap() const override
Get the URI of the light map file.
Definition: BaseMaterial.hh:872
math::Color Ambient() const
std::string MetalnessMap() const
virtual std::string NormalMap() const override
Get the URI of the normal map file.
Definition: BaseMaterial.hh:732
virtual bool CastShadows() const override
Determine if this material casts shadows.
Definition: BaseMaterial.hh:606
virtual std::string RoughnessMap() const override
Get the URI of the roughness map file.
Definition: BaseMaterial.hh:760
virtual math::Color Emissive() const override
Get the emissive color.
Definition: BaseMaterial.hh:571
virtual bool HasEmissiveMap() const override
Determine if this material has an emissive map.
Definition: BaseMaterial.hh:837
virtual void SetRenderOrder(const float _renderOrder) override
Set the render order. When polygons are coplanar, you can get problems with &#39;depth fighting&#39; where th...
Definition: BaseMaterial.hh:543
virtual void SetShininess(const double _shininess) override
Set the shininess value.
Definition: BaseMaterial.hh:449
bool TwoSidedEnabled() const override
Get the enable two sided rendering value.
Definition: BaseMaterial.hh:487
virtual void SetMetalnessMap(const std::string &_metalnessMap) override
Set the material metalness map.
Definition: BaseMaterial.hh:795
virtual bool ReceiveShadows() const override
Determine if this material receives shadows.
Definition: BaseMaterial.hh:613
virtual void ClearTexture() override
Removes any texture mapped to this material.
Definition: BaseMaterial.hh:718
virtual bool LightingEnabled() const override
Determine if lighting affects this material.
Definition: BaseMaterial.hh:620
virtual float Metalness() const override
Get the metalness value of this material.
Definition: BaseMaterial.hh:921
virtual void SetSpecular(const double _r, const double _g, const double _b, const double _a=1.0) override
Set the specular color.
Definition: BaseMaterial.hh:419
virtual void SetEnvironmentMap(const std::string &_metalnessMap) override
Set the material environment map.
Definition: BaseMaterial.hh:823
ShaderType
Available types of shaders. Note that not all rendering-engines will be able to use each type...
Definition: ShaderType.hh:34
Definition: BaseMaterial.hh:38
Per pixel lighting shader.
Definition: ShaderType.hh:40
bool TextureAlphaEnabled() const override
Get the enable alpha from textures.
Definition: BaseMaterial.hh:473
virtual void SetDepthCheckEnabled(bool _enabled) override
Specify if depth buffer checking is enabled.
Definition: BaseMaterial.hh:515
virtual double Transparency() const override
Get the transparency value.
Definition: BaseMaterial.hh:585
virtual void SetTexture(const std::string &_texture) override
Set the material texture.
Definition: BaseMaterial.hh:711
Classic shading, i.e. variants of Phong.
Definition: Material.hh:39
bool TextureAlphaEnabled() const
math::Color ambient
Ambient color.
Definition: BaseMaterial.hh:324
virtual math::Color Specular() const override
Get the specular color.
Definition: BaseMaterial.hh:564
virtual void CopyFrom(ConstMaterialPtr _material) override
Copy properties from given Material.
Definition: BaseMaterial.hh:942
virtual bool HasRoughnessMap() const override
Determine if this material has a roughness map.
Definition: BaseMaterial.hh:753
virtual void SetReflectionEnabled(const bool _enabled) override
Specify if this material has a reflection.
Definition: BaseMaterial.hh:501
math::Color specular
Specular color.
Definition: BaseMaterial.hh:330
virtual bool HasEnvironmentMap() const override
Determine if this material has a environment map.
Definition: BaseMaterial.hh:809
math::Color Specular() const
double Metalness() const
math::Color Diffuse() const
Represents a surface material of a Geometry.
Definition: Material.hh:47
virtual std::string EnvironmentMap() const override
Get the URI of the environment map file.
Definition: BaseMaterial.hh:816
virtual void SetEmissiveMap(const std::string &_emissiveMap) override
Set the material emissive map.
Definition: BaseMaterial.hh:851
virtual bool HasTexture() const override
Determine if this material has a texture.
Definition: BaseMaterial.hh:697
double AlphaThreshold() const
math::Color diffuse
Diffuse color.
Definition: BaseMaterial.hh:327
virtual std::string VertexShader() const override
Get path to the vertex shader.
Definition: BaseMaterial.hh:655
virtual double Shininess() const override
Get the shininess value.
Definition: BaseMaterial.hh:578
math::Color Emissive() const
virtual ShaderParamsPtr FragmentShaderParams() override
Get params for the fragment shader.
Definition: BaseMaterial.hh:683
virtual MaterialType Type() const override
Removes any metalness map mapped to this material.
Definition: BaseMaterial.hh:648
virtual void ClearMetalnessMap() override
Removes any metalness map mapped to this material.
Definition: BaseMaterial.hh:802
virtual float RenderOrder() const override
Get the render order value of this material.
Definition: BaseMaterial.hh:592
virtual std::string MetalnessMap() const override
Get the URI of the metalness map file.
Definition: BaseMaterial.hh:788
virtual void SetFragmentShader(const std::string &_path) override
Set the fragment shader.
Definition: BaseMaterial.hh:690
MaterialType
An enum for the type of material.
Definition: Material.hh:36
virtual bool DepthWriteEnabled() const override
Determine if depth buffer writing is enabled.
Definition: BaseMaterial.hh:634
virtual void SetShaderType(enum ShaderType) override
Set the ShaderType value.
Definition: BaseMaterial.hh:272