namespace Msp {
namespace GL {
-PbrMaterial::PbrMaterial():
- receive_shadows(false)
+const Tag PbrMaterial::texture_tags[] =
+{
+ Tag("base_color_map"),
+ Tag("normal_map"),
+ Tag("metalness_map"),
+ Tag("roughness_map"),
+ Tag("occlusion_map"),
+ Tag("emission_map"),
+ Tag()
+};
+
+PbrMaterial::PbrMaterial()
{
set_base_color(0.8f);
set_metalness(0.0f);
bool use_emission = (emission.texture || emission.value.r || emission.value.g || emission.value.b);
spec_values["use_emission"] = use_emission;
spec_values["use_emission_map"] = (emission.texture!=0);
- spec_values["use_shadow_map"] = receive_shadows;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
void PbrMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const
{
attach_texture_to(base_color.texture, texturing, tex_shdata, "base_color_map");
attach_texture_to(occlusion.texture, texturing, tex_shdata, "occlusion_map");
attach_texture_to(emission.texture, texturing, tex_shdata, "emission_map");
}
+#pragma GCC diagnostic pop
+
+const Texture *PbrMaterial::get_texture(Tag tag) const
+{
+ if(tag==texture_tags[0])
+ return base_color.texture;
+ else if(tag==texture_tags[1])
+ return normal.texture;
+ else if(tag==texture_tags[2])
+ return metalness.texture;
+ else if(tag==texture_tags[3])
+ return roughness.texture;
+ else if(tag==texture_tags[4])
+ return occlusion.texture;
+ else if(tag==texture_tags[5])
+ return emission.texture;
+ else
+ return 0;
+}
void PbrMaterial::set_base_color(const Color &color)
{
emission.texture = tex;
}
-void PbrMaterial::set_receive_shadows(bool s)
-{
- receive_shadows = s;
-}
-
DataFile::Loader::ActionMap PbrMaterial::Loader::shared_actions;
add_property("roughness", &PbrMaterial::set_roughness, &PbrMaterial::set_roughness_map);
add_property("occlusion", &PbrMaterial::set_occlusion_map);
add_property("emission", &PbrMaterial::set_emission, &PbrMaterial::set_emission_map, false);
- add("receive_shadows", &PbrMaterial::receive_shadows);
}
} // namespace GL