17 #ifndef GZ_RENDERING_BASE_BASEMATERIAL_HH_
18 #define GZ_RENDERING_BASE_BASEMATERIAL_HH_
23 #include "gz/common/Console.hh"
33 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
52 public:
virtual void SetAmbient(
const double _r,
const double _g,
53 const double _b,
const double _a = 1.0)
override;
59 public:
virtual void SetDiffuse(
const double _r,
const double _g,
60 const double _b,
const double _a = 1.0)
override;
66 public:
virtual void SetSpecular(
const double _r,
const double _g,
67 const double _b,
const double _a = 1.0)
override;
73 public:
virtual void SetEmissive(
const double _r,
const double _g,
74 const double _b,
const double _a = 1.0)
override;
84 double _alpha = 0.5,
bool _twoSided =
true)
override;
96 public:
virtual void SetShininess(
const double _shininess)
override;
273 unsigned int _uvSet = 0u)
override;
318 const double near)
override;
368 protected:
double transparency = 0.0;
371 protected:
bool textureAlphaEnabled =
false;
374 protected:
double alphaThreshold = 0.5;
377 protected:
bool twoSidedEnabled =
false;
380 protected:
double renderOrder = 0.0;
383 protected:
double shininess = 0.0;
386 protected:
double reflectivity = 0.0;
389 protected:
bool lightingEnabled =
false;
392 protected:
bool depthCheckEnabled =
true;
395 protected:
bool depthWriteEnabled =
true;
398 protected:
bool reflectionEnabled =
false;
401 protected:
bool receiveShadows =
true;
404 protected:
bool castShadows =
true;
422 const double _b,
const double _a)
431 this->ambient = _color;
437 const double _b,
const double _a)
446 this->diffuse = _color;
452 const double _b,
const double _a)
461 this->specular = _color;
467 const double _b,
const double _a)
476 this->emissive = _color;
483 this->shininess = _shininess;
490 this->transparency = _transparency;
498 this->textureAlphaEnabled = _enabled;
499 this->alphaThreshold = _alpha;
500 this->twoSidedEnabled = _twoSided;
507 return this->textureAlphaEnabled;
514 return this->alphaThreshold;
521 return this->twoSidedEnabled;
528 this->reflectivity = _reflectivity;
535 this->reflectionEnabled = _enabled;
542 this->lightingEnabled = _enabled;
549 this->depthCheckEnabled = _enabled;
556 this->depthWriteEnabled = _enabled;
563 this->castShadows = _castShadows;
570 this->receiveShadows = _receive;
577 this->renderOrder = _renderorder;
584 return this->ambient;
591 return this->diffuse;
598 return this->specular;
605 return this->emissive;
612 return this->shininess;
619 return this->transparency;
626 return this->renderOrder;
633 return this->reflectivity;
640 return this->castShadows;
647 return this->receiveShadows;
654 return this->lightingEnabled;
661 return this->depthCheckEnabled;
668 return this->depthWriteEnabled;
675 return this->reflectionEnabled;
1023 auto baseShared = this->shared_from_this();
1026 std::dynamic_pointer_cast<const BaseMaterial<T>>(baseShared);
1028 MaterialPtr material = T::Scene()->CreateMaterial(_name);
1029 material->CopyFrom(thisShared);
1037 this->SetLightingEnabled(_material->LightingEnabled());
1038 this->SetAmbient(_material->Ambient());
1039 this->SetDiffuse(_material->Diffuse());
1040 this->SetSpecular(_material->Specular());
1041 this->SetEmissive(_material->Emissive());
1042 this->SetRenderOrder(_material->RenderOrder());
1043 this->SetShininess(_material->Shininess());
1044 this->SetAlphaFromTexture(_material->TextureAlphaEnabled(),
1045 _material->AlphaThreshold(), _material->TwoSidedEnabled());
1047 this->SetTransparency(_material->Transparency());
1049 this->SetDepthCheckEnabled(_material->DepthCheckEnabled());
1050 this->SetDepthWriteEnabled(_material->DepthWriteEnabled());
1051 this->SetReflectivity(_material->Reflectivity());
1052 this->SetCastShadows(_material->CastShadows());
1053 this->SetReceiveShadows(_material->ReceiveShadows());
1054 this->SetReflectionEnabled(_material->ReflectionEnabled());
1055 this->SetTexture(_material->Texture(), _material->TextureData());
1056 this->SetNormalMap(_material->NormalMap(), _material->NormalMapData());
1057 this->SetRoughnessMap(_material->RoughnessMap(),
1058 _material->RoughnessMapData());
1059 this->SetMetalnessMap(_material->MetalnessMap(),
1060 _material->MetalnessMapData());
1061 this->SetRoughness(_material->Roughness());
1062 this->SetMetalness(_material->Metalness());
1063 this->SetEnvironmentMap(_material->EnvironmentMap(),
1064 _material->EnvironmentMapData());
1065 this->SetEmissiveMap(_material->EmissiveMap(),
1066 _material->EmissiveMapData());
1067 this->SetLightMap(_material->LightMap(), _material->LightMapData(),
1068 _material->LightMapTexCoordSet());
1069 this->SetShaderType(_material->ShaderType());
1070 this->SetVertexShader(_material->VertexShader());
1071 this->SetFragmentShader(_material->FragmentShader());
1078 this->SetLightingEnabled(_material.
Lighting());
1079 this->SetAmbient(_material.
Ambient());
1080 this->SetDiffuse(_material.
Diffuse());
1081 this->SetSpecular(_material.
Specular());
1082 this->SetEmissive(_material.
Emissive());
1083 this->SetShininess(_material.
Shininess());
1089 this->SetReflectivity(0);
1092 this->SetCastShadows(
true);
1094 this->SetReceiveShadows(
true);
1096 this->SetReflectionEnabled(
true);
1098 this->ClearNormalMap();
1108 this->SetRoughness(pbrMat->
Roughness());
1109 this->SetMetalness(pbrMat->
Metalness());
1136 this->SetLightingEnabled(
true);
1137 this->SetDepthCheckEnabled(
true);
1138 this->SetDepthWriteEnabled(
true);
1139 this->SetAmbient(0.3, 0.3, 0.3);
1140 this->SetDiffuse(1.0, 1.0, 1.0);
1141 this->SetSpecular(0.2, 0.2, 0.2);
1142 this->SetEmissive(0, 0, 0);
1143 this->SetRenderOrder(0);
1144 this->SetShininess(1.5);
1145 this->SetTransparency(0);
1146 this->SetReflectivity(0);
1147 this->SetCastShadows(
true);
1148 this->SetReceiveShadows(
true);
1149 this->SetReflectionEnabled(
true);
1150 this->ClearTexture();
1151 this->ClearNormalMap();
1152 this->ClearRoughnessMap();
1153 this->ClearMetalnessMap();
1154 this->ClearEmissiveMap();
1155 this->ClearLightMap();