4#include "hellfire/graphics/managers/ShaderManager.h"
5#include "hellfire/graphics/material/Material.h"
7#include "hellfire/core/Application.h"
8#include "hellfire/utilities/ServiceLocator.h"
13 if (shader_program == 0) {
14 std::cerr <<
"Warning: Material " <<
get_name() <<
" has no compiled shader!" << std::endl;
18 bound_texture_units_.clear();
26 if (shader_program == 0)
return;
33 for (
int texture_unit : bound_texture_units_) {
34 glActiveTexture(GL_TEXTURE0 + texture_unit);
35 glBindTexture(GL_TEXTURE_2D, 0);
37 bound_texture_units_.clear();
40 void Material::bind_all_properties(
const uint32_t shader_program,
int &texture_unit)
const {
41 for (
const auto &property: properties_ | std::views::values) {
43 int start_texture_unit = texture_unit;
45 MaterialManager::bind_property_to_shader(property, shader_program, texture_unit);
48 if (property.type == PropertyType::TEXTURE && texture_unit > start_texture_unit) {
49 bound_texture_units_.push_back(start_texture_unit);
55 auto material = std::make_shared<
Material>(name);
58 material->set_diffuse_color(glm::vec3(0.8f));
59 material->set_specular_color(glm::vec3(0.5f));
62 material->set_shininess(8.0f);
63 material->set_opacity(1.0f);
64 material->set_metallic(0.0f);
65 material->set_roughness(0.5f);
68 material->set_uv_tiling(1.0f, 1.0f);
69 material->set_uv_offset(glm::vec2(0.0f));
70 material->set_uv_rotation(0.0f);
87 const std::string &fragment_path) {
88 auto material = std::make_shared<
Material>(name);
89 material->set_custom_shader(vertex_path, fragment_path);
static void compile_shader_from_material(Material &material)
void bind_all_properties(uint32_t shader_program, int &texture_unit) const
void bind() const
Used to bind a Material for rendering.
uint32_t get_compiled_shader_id() const
void unbind_all_textures() const
const std::string & get_name() const
void set_compiled_shader_id(uint32_t shader_id)
static constexpr const char * USE_SPECULAR_TEXTURE
static constexpr const char * USE_ROUGHNESS_TEXTURE
static constexpr const char * USE_AO_TEXTURE
static constexpr const char * USE_EMISSIVE_TEXTURE
static constexpr const char * USE_NORMAL_TEXTURE
static constexpr const char * USE_DIFFUSE_TEXTURE
static constexpr const char * USE_METALLIC_TEXTURE