Ignition Rendering

API Reference

4.1.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 void SetRoughness(const float _roughness) override;
237 
238  // Documentation inherited
239  public: virtual float Roughness() const override;
240 
241  // Documentation inherited
242  public: virtual void SetMetalness(const float _metalness) override;
243 
244  // Documentation inherited
245  public: virtual float Metalness() const override;
246 
247  // Documentation inherited
248  public: virtual MaterialType Type() const override;
249 
250  public: virtual void SetShaderType(enum ShaderType /*_type*/) override
251  {
252  // no op
253  }
254 
255  // Documentation inherited
256  public: virtual enum ShaderType ShaderType() const override
257  {
258  return ST_PIXEL;
259  }
260 
261  // Documentation inherited.
262  // \sa Material::SetDepthMaterial()
263  public: virtual void SetDepthMaterial(const double far,
264  const double near) override;
265 
266  // Documentation inherited.
267  // \sa Material::VertexShader() const
268  public: virtual std::string VertexShader() const override;
269 
270  // Documentation inherited.
271  // \sa Material::VertexShaderParams()
272  public: virtual ShaderParamsPtr VertexShaderParams() override;
273 
274  // Documentation inherited.
275  // \sa Material::SetVertexShader(const std::string &)
276  public: virtual void SetVertexShader(const std::string &_path) override;
277 
278  // Documentation inherited.
279  // \sa Material::FragmentShader() const
280  public: virtual std::string FragmentShader() const override;
281 
282  // Documentation inherited.
283  // \sa Material::FragmentShaderParams()
284  public: virtual ShaderParamsPtr FragmentShaderParams() override;
285 
286  // Documentation inherited.
287  // \sa Material::SetFragmentShader(const std::string &)
288  public: virtual void SetFragmentShader(const std::string &_path) override;
289 
290  // Documentation inherited.
291  public: virtual void CopyFrom(ConstMaterialPtr _material) override;
292 
293  // Documentation inherited.
294  public: virtual void CopyFrom(const common::Material &_material) override;
295 
296  // Documentation inherited.
297  public: virtual void PreRender() override;
298 
299  protected: virtual void Reset();
300 
302  protected: math::Color ambient;
303 
305  protected: math::Color diffuse;
306 
308  protected: math::Color specular;
309 
311  protected: math::Color emissive;
312 
314  protected: double transparency = 0.0;
315 
317  protected: bool textureAlphaEnabled = false;
318 
320  protected: double alphaThreshold = 0.5;
321 
323  protected: bool twoSidedEnabled = false;
324 
326  protected: double shininess = 0.0;
327 
329  protected: double reflectivity = 0.0;
330 
332  protected: bool lightingEnabled = false;
333 
335  protected: bool depthCheckEnabled = true;
336 
338  protected: bool depthWriteEnabled = true;
339 
341  protected: bool reflectionEnabled = false;
342 
344  protected: bool receiveShadows = true;
345 
347  protected: bool castShadows = true;
348  };
349 
351  template <class T>
353  {
354  }
355 
357  template <class T>
359  {
360  }
361 
363  template <class T>
364  void BaseMaterial<T>::SetAmbient(const double _r, const double _g,
365  const double _b, const double _a)
366  {
367  this->SetAmbient(math::Color(_r, _g, _b, _a));
368  }
369 
371  template <class T>
373  {
374  this->ambient = _color;
375  }
376 
378  template <class T>
379  void BaseMaterial<T>::SetDiffuse(const double _r, const double _g,
380  const double _b, const double _a)
381  {
382  this->SetDiffuse(math::Color(_r, _g, _b, _a));
383  }
384 
386  template <class T>
388  {
389  this->diffuse = _color;
390  }
391 
393  template <class T>
394  void BaseMaterial<T>::SetSpecular(const double _r, const double _g,
395  const double _b, const double _a)
396  {
397  this->SetSpecular(math::Color(_r, _g, _b, _a));
398  }
399 
401  template <class T>
403  {
404  this->specular = _color;
405  }
406 
408  template <class T>
409  void BaseMaterial<T>::SetEmissive(const double _r, const double _g,
410  const double _b, const double _a)
411  {
412  this->SetEmissive(math::Color(_r, _g, _b, _a));
413  }
414 
416  template <class T>
418  {
419  this->emissive = _color;
420  }
421 
423  template <class T>
424  void BaseMaterial<T>::SetShininess(const double _shininess)
425  {
426  this->shininess = _shininess;
427  }
428 
430  template <class T>
431  void BaseMaterial<T>::SetTransparency(const double _transparency)
432  {
433  this->transparency = _transparency;
434  }
435 
437  template <class T>
438  void BaseMaterial<T>::SetAlphaFromTexture(bool _enabled, double _alpha,
439  bool _twoSided)
440  {
441  this->textureAlphaEnabled = _enabled;
442  this->alphaThreshold = _alpha;
443  this->twoSidedEnabled = _twoSided;
444  }
445 
447  template <class T>
449  {
450  return this->textureAlphaEnabled;
451  }
452 
454  template <class T>
456  {
457  return this->alphaThreshold;
458  }
459 
461  template <class T>
463  {
464  return this->twoSidedEnabled;
465  }
466 
468  template <class T>
469  void BaseMaterial<T>::SetReflectivity(const double _reflectivity)
470  {
471  this->reflectivity = _reflectivity;
472  }
473 
475  template <class T>
476  void BaseMaterial<T>::SetReflectionEnabled(const bool _enabled)
477  {
478  this->reflectionEnabled = _enabled;
479  }
480 
482  template <class T>
483  void BaseMaterial<T>::SetLightingEnabled(const bool _enabled)
484  {
485  this->lightingEnabled = _enabled;
486  }
487 
489  template <class T>
491  {
492  this->depthCheckEnabled = _enabled;
493  }
494 
496  template <class T>
498  {
499  this->depthWriteEnabled = _enabled;
500  }
501 
503  template <class T>
504  void BaseMaterial<T>::SetCastShadows(const bool _cast)
505  {
506  this->castShadows = _cast;
507  }
508 
510  template <class T>
511  void BaseMaterial<T>::SetReceiveShadows(const bool _receive)
512  {
513  this->receiveShadows = _receive;
514  }
515 
517  template <class T>
519  {
520  return this->ambient;
521  }
522 
524  template <class T>
526  {
527  return this->diffuse;
528  }
529 
531  template <class T>
533  {
534  return this->specular;
535  }
536 
538  template <class T>
540  {
541  return this->emissive;
542  }
543 
545  template <class T>
547  {
548  return this->shininess;
549  }
550 
552  template <class T>
554  {
555  return this->transparency;
556  }
557 
559  template <class T>
561  {
562  return this->reflectivity;
563  }
564 
566  template <class T>
568  {
569  return this->castShadows;
570  }
571 
573  template <class T>
575  {
576  return this->receiveShadows;
577  }
578 
580  template <class T>
582  {
583  return this->lightingEnabled;
584  }
585 
587  template <class T>
589  {
590  return this->depthCheckEnabled;
591  }
592 
594  template <class T>
596  {
597  return this->depthWriteEnabled;
598  }
599 
601  template <class T>
603  {
604  return this->reflectionEnabled;
605  }
606 
608  template <class T>
610  {
611  return MT_CLASSIC;
612  }
613 
615  template <class T>
617  {
618  return std::string();
619  }
620 
622  template <class T>
624  {
625  return nullptr;
626  }
627 
629  template <class T>
631  {
632  // no op
633  }
634 
636  template <class T>
638  {
639  return std::string();
640  }
641 
643  template <class T>
645  {
646  return nullptr;
647  }
648 
650  template <class T>
652  {
653  // no op
654  }
655 
657  template <class T>
659  {
660  return false;
661  }
662 
664  template <class T>
666  {
667  return std::string();
668  }
669 
671  template <class T>
673  {
674  // no op
675  }
676 
678  template <class T>
680  {
681  // no op
682  }
683 
685  template <class T>
687  {
688  return false;
689  }
690 
692  template <class T>
694  {
695  return std::string();
696  }
697 
699  template <class T>
701  {
702  // no op
703  }
704 
706  template <class T>
708  {
709  // no op
710  }
711 
713  template <class T>
715  {
716  return false;
717  }
718 
720  template <class T>
722  {
723  return std::string();
724  }
725 
727  template <class T>
729  {
730  // no op
731  }
732 
734  template <class T>
736  {
737  // no op
738  }
739 
741  template <class T>
743  {
744  return false;
745  }
746 
748  template <class T>
750  {
751  return std::string();
752  }
753 
755  template <class T>
757  {
758  // no op
759  }
760 
762  template <class T>
764  {
765  // no op
766  }
767 
769  template <class T>
771  {
772  return false;
773  }
774 
776  template <class T>
778  {
779  return std::string();
780  }
781 
783  template <class T>
785  {
786  // no op
787  }
788 
790  template <class T>
792  {
793  // no op
794  }
795 
797  template <class T>
799  {
800  return false;
801  }
802 
804  template <class T>
806  {
807  return std::string();
808  }
809 
811  template <class T>
813  {
814  // no op
815  }
816 
818  template <class T>
820  {
821  // no op
822  }
823 
825  template <class T>
827  {
828  // no op
829  }
830 
832  template <class T>
834  {
835  return 0.0f;
836  }
837 
839  template <class T>
841  {
842  // no op
843  }
844 
846  template <class T>
848  {
849  return 0.0f;
850  }
851 
853  template <class T>
855  {
856  auto baseShared = this->shared_from_this();
857 
858  auto thisShared =
859  std::dynamic_pointer_cast<const BaseMaterial<T>>(baseShared);
860 
861  MaterialPtr material = T::Scene()->CreateMaterial(_name);
862  material->CopyFrom(thisShared);
863  return material;
864  }
865 
867  template <class T>
869  {
870  this->SetLightingEnabled(_material->LightingEnabled());
871  this->SetAmbient(_material->Ambient());
872  this->SetDiffuse(_material->Diffuse());
873  this->SetSpecular(_material->Specular());
874  this->SetEmissive(_material->Emissive());
875  this->SetShininess(_material->Shininess());
876  this->SetTransparency(_material->Transparency());
877  this->SetAlphaFromTexture(_material->TextureAlphaEnabled(),
878  _material->AlphaThreshold(), _material->TwoSidedEnabled());
879  // override depth check / depth write after setting transparency
880  this->SetDepthCheckEnabled(_material->DepthCheckEnabled());
881  this->SetDepthWriteEnabled(_material->DepthWriteEnabled());
882  this->SetReflectivity(_material->Reflectivity());
883  this->SetCastShadows(_material->CastShadows());
884  this->SetReceiveShadows(_material->ReceiveShadows());
885  this->SetReflectionEnabled(_material->ReflectionEnabled());
886  this->SetTexture(_material->Texture());
887  this->SetNormalMap(_material->NormalMap());
888  this->SetRoughnessMap(_material->RoughnessMap());
889  this->SetMetalnessMap(_material->MetalnessMap());
890  this->SetRoughness(_material->Roughness());
891  this->SetMetalness(_material->Metalness());
892  this->SetEnvironmentMap(_material->EnvironmentMap());
893  this->SetEmissiveMap(_material->EmissiveMap());
894  this->SetShaderType(_material->ShaderType());
895  this->SetVertexShader(_material->VertexShader());
896  this->SetFragmentShader(_material->FragmentShader());
897  }
898 
900  template <class T>
902  {
903  this->SetLightingEnabled(_material.Lighting());
904  this->SetAmbient(_material.Ambient());
905  this->SetDiffuse(_material.Diffuse());
906  this->SetSpecular(_material.Specular());
907  this->SetEmissive(_material.Emissive());
908  this->SetShininess(_material.Shininess());
909  this->SetTransparency(_material.Transparency());
910  this->SetAlphaFromTexture(_material.TextureAlphaEnabled(),
911  _material.AlphaThreshold(), _material.TwoSidedEnabled());
912  // TODO(anyone): update common::Material
913  this->SetReflectivity(0);
914  this->SetTexture(_material.TextureImage());
915  // TODO(anyone): update common::Material
916  this->SetCastShadows(true);
917  // TODO(anyone): update common::Material
918  this->SetReceiveShadows(true);
919  // TODO(anyone): update common::Material
920  this->SetReflectionEnabled(true);
921  // TODO(anyone): update common::Material
922  this->ClearNormalMap();
923  // TODO(anyone): update common::Material
924  this->SetShaderType(ST_PIXEL);
925 
926  const common::Pbr *pbrMat = _material.PbrMaterial();
927  if (!pbrMat)
928  pbrMat = &kDefaultPbr;
929  this->SetNormalMap(pbrMat->NormalMap());
930  this->SetRoughnessMap(pbrMat->RoughnessMap());
931  this->SetMetalnessMap(pbrMat->MetalnessMap());
932  this->SetRoughness(pbrMat->Roughness());
933  this->SetMetalness(pbrMat->Metalness());
934  this->SetEnvironmentMap(pbrMat->EnvironmentMap());
935  this->SetEmissiveMap(pbrMat->EmissiveMap());
936  }
937 
939  template <class T>
941  {
942  // do nothing
943  }
944 
946  template <class T>
947  void BaseMaterial<T>::SetDepthMaterial(const double /*far*/,
948  const double /*near*/)
949  {
950  // do nothing
951  }
952 
954  template <class T>
956  {
957  this->SetLightingEnabled(true);
958  this->SetDepthCheckEnabled(true);
959  this->SetDepthWriteEnabled(true);
960  this->SetAmbient(0.3, 0.3, 0.3);
961  this->SetDiffuse(1.0, 1.0, 1.0);
962  this->SetSpecular(0.2, 0.2, 0.2);
963  this->SetEmissive(0, 0, 0);
964  this->SetShininess(1.5);
965  this->SetTransparency(0);
966  this->SetReflectivity(0);
967  this->SetCastShadows(true);
968  this->SetReceiveShadows(true);
969  this->SetReflectionEnabled(true);
970  this->ClearTexture();
971  this->ClearNormalMap();
972  this->ClearRoughnessMap();
973  this->ClearMetalnessMap();
974  this->ClearEmissiveMap();
975  this->SetRoughness(kDefaultPbr.Roughness());
976  this->SetMetalness(kDefaultPbr.Metalness());
977  this->SetShaderType(ST_PIXEL);
978  }
979  }
980  }
981 }
982 #endif
virtual void SetTransparency(const double _transparency) override
Set the transparency value.
Definition: BaseMaterial.hh:431
virtual void SetNormalMap(const std::string &_normalMap) override
Set the material normal map.
Definition: BaseMaterial.hh:700
std::string EmissiveMap() const
double AlphaThreshold() const override
Get the alpha threshold.
Definition: BaseMaterial.hh:455
virtual void SetRoughness(const float _roughness) override
Set the roughness value. Only affects material of type MT_PBS.
Definition: BaseMaterial.hh:826
static const common::Pbr kDefaultPbr
Default pbr material properties.
Definition: BaseMaterial.hh:35
virtual void SetCastShadows(const bool _cast) override
Specify if this material casts shadows.
Definition: BaseMaterial.hh:504
virtual void ClearEmissiveMap() override
Removes any emissive map mapped to this material.
Definition: BaseMaterial.hh:819
virtual float Roughness() const override
Get the roughness value of this material.
Definition: BaseMaterial.hh:833
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:364
virtual void Reset()
Definition: BaseMaterial.hh:955
virtual void SetLightingEnabled(const bool _enabled) override
Specify if lighting affects this material.
Definition: BaseMaterial.hh:483
BaseMaterial()
Definition: BaseMaterial.hh:352
virtual void ClearEnvironmentMap() override
Removes any environment map mapped to this material.
Definition: BaseMaterial.hh:791
double Transparency() const
virtual bool DepthCheckEnabled() const override
Determine if depth buffer checking is enabled.
Definition: BaseMaterial.hh:588
virtual void SetReceiveShadows(const bool _receiveShadows) override
Specify if this material receives shadows.
Definition: BaseMaterial.hh:511
virtual void SetDepthMaterial(const double far, const double near) override
Configuration for Depth Material.
Definition: BaseMaterial.hh:947
std::string EnvironmentMap() const
virtual std::string FragmentShader() const override
Get path to the fragment shader.
Definition: BaseMaterial.hh:637
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:840
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:409
virtual bool HasMetalnessMap() const override
Determine if this material has a metalness map.
Definition: BaseMaterial.hh:742
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:940
virtual void SetRoughnessMap(const std::string &_roughnessMap) override
Set the material roughness map.
Definition: BaseMaterial.hh:728
virtual void SetDepthWriteEnabled(bool _enabled) override
Specify if depth buffer writing is enabled.
Definition: BaseMaterial.hh:497
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:379
virtual void ClearNormalMap() override
Removes any normal map mapped to this material.
Definition: BaseMaterial.hh:707
virtual void SetVertexShader(const std::string &_path) override
Set the vertex shader.
Definition: BaseMaterial.hh:630
virtual void ClearRoughnessMap() override
Removes any roughness map mapped to this material.
Definition: BaseMaterial.hh:735
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:438
virtual math::Color Ambient() const override
Get the ambient color.
Definition: BaseMaterial.hh:518
virtual void SetReflectivity(const double _reflectivity) override
Set the reflectivity value.
Definition: BaseMaterial.hh:469
double Roughness() const
virtual std::string Texture() const override
Get the URI of the texture file.
Definition: BaseMaterial.hh:665
virtual math::Color Diffuse() const override
Get the diffuse color.
Definition: BaseMaterial.hh:525
virtual MaterialPtr Clone(const std::string &_name="") const override
Clone this material.
Definition: BaseMaterial.hh:854
virtual ShaderParamsPtr VertexShaderParams() override
Get params for the vertex shader.
Definition: BaseMaterial.hh:623
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:602
virtual double Reflectivity() const override
Get the reflectivity value.
Definition: BaseMaterial.hh:560
virtual std::string EmissiveMap() const override
Get the URI of the emissive map file.
Definition: BaseMaterial.hh:805
math::Color emissive
Emissive color.
Definition: BaseMaterial.hh:311
std::string TextureImage() const
virtual bool HasNormalMap() const override
Determine if this material has a normal map.
Definition: BaseMaterial.hh:686
virtual ~BaseMaterial()
Definition: BaseMaterial.hh:358
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:693
virtual bool CastShadows() const override
Determine if this material casts shadows.
Definition: BaseMaterial.hh:567
virtual std::string RoughnessMap() const override
Get the URI of the roughness map file.
Definition: BaseMaterial.hh:721
virtual math::Color Emissive() const override
Get the emissive color.
Definition: BaseMaterial.hh:539
virtual bool HasEmissiveMap() const override
Determine if this material has an emissive map.
Definition: BaseMaterial.hh:798
virtual void SetShininess(const double _shininess) override
Set the shininess value.
Definition: BaseMaterial.hh:424
bool TwoSidedEnabled() const override
Get the enable two sided rendering value.
Definition: BaseMaterial.hh:462
virtual void SetMetalnessMap(const std::string &_metalnessMap) override
Set the material metalness map.
Definition: BaseMaterial.hh:756
virtual bool ReceiveShadows() const override
Determine if this material receives shadows.
Definition: BaseMaterial.hh:574
virtual void ClearTexture() override
Removes any texture mapped to this material.
Definition: BaseMaterial.hh:679
virtual bool LightingEnabled() const override
Determine if lighting affects this material.
Definition: BaseMaterial.hh:581
virtual float Metalness() const override
Get the metalness value of this material.
Definition: BaseMaterial.hh:847
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:394
virtual void SetEnvironmentMap(const std::string &_metalnessMap) override
Set the material environment map.
Definition: BaseMaterial.hh:784
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:448
virtual void SetDepthCheckEnabled(bool _enabled) override
Specify if depth buffer checking is enabled.
Definition: BaseMaterial.hh:490
virtual double Transparency() const override
Get the transparency value.
Definition: BaseMaterial.hh:553
virtual void SetTexture(const std::string &_texture) override
Set the material texture.
Definition: BaseMaterial.hh:672
Classic shading, i.e. variants of Phong.
Definition: Material.hh:39
bool TextureAlphaEnabled() const
math::Color ambient
Ambient color.
Definition: BaseMaterial.hh:302
virtual math::Color Specular() const override
Get the specular color.
Definition: BaseMaterial.hh:532
virtual void CopyFrom(ConstMaterialPtr _material) override
Copy properties from given Material.
Definition: BaseMaterial.hh:868
virtual bool HasRoughnessMap() const override
Determine if this material has a roughness map.
Definition: BaseMaterial.hh:714
virtual void SetReflectionEnabled(const bool _enabled) override
Specify if this material has a reflection.
Definition: BaseMaterial.hh:476
math::Color specular
Specular color.
Definition: BaseMaterial.hh:308
virtual bool HasEnvironmentMap() const override
Determine if this material has a environment map.
Definition: BaseMaterial.hh:770
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:777
virtual void SetEmissiveMap(const std::string &_emissiveMap) override
Set the material emissive map.
Definition: BaseMaterial.hh:812
virtual bool HasTexture() const override
Determine if this material has a texture.
Definition: BaseMaterial.hh:658
double AlphaThreshold() const
math::Color diffuse
Diffuse color.
Definition: BaseMaterial.hh:305
virtual std::string VertexShader() const override
Get path to the vertex shader.
Definition: BaseMaterial.hh:616
virtual double Shininess() const override
Get the shininess value.
Definition: BaseMaterial.hh:546
math::Color Emissive() const
virtual ShaderParamsPtr FragmentShaderParams() override
Get params for the fragment shader.
Definition: BaseMaterial.hh:644
virtual MaterialType Type() const override
Removes any metalness map mapped to this material.
Definition: BaseMaterial.hh:609
virtual void ClearMetalnessMap() override
Removes any metalness map mapped to this material.
Definition: BaseMaterial.hh:763
virtual std::string MetalnessMap() const override
Get the URI of the metalness map file.
Definition: BaseMaterial.hh:749
virtual void SetFragmentShader(const std::string &_path) override
Set the fragment shader.
Definition: BaseMaterial.hh:651
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:595
virtual void SetShaderType(enum ShaderType) override
Set the ShaderType value.
Definition: BaseMaterial.hh:250