4#include "hellfire/graphics/managers/MaterialManager.h"
7#include <glm/gtc/type_ptr.hpp>
9#include "hellfire/graphics/material/Material.h"
10#include "hellfire/graphics/shader/Shader.h"
15 std::cerr <<
"Warning: Material " << material
.get_name() <<
" has no compiled shader!" << std::endl;
32 switch (property
.type) {
34 const float value = std::get<
float>(property.value);
35 binder.set_float(uniform_name, value);
40 const glm::vec2 value = std::get<glm::vec2>(property.value);
41 binder.set_vec2(uniform_name, value);
46 const glm::vec3 value = std::get<glm::vec3>(property.value);
47 binder.set_vec3(uniform_name, value);
53 const glm::vec4 value = std::get<glm::vec4>(property.value);
54 binder.set_vec4(uniform_name, value);
61 binder.set_int(uniform_name, texture_unit);
64 if (
const char* flag_name = get_texture_flag_for_uniform(uniform_name)) {
65 binder.set_bool(flag_name,
true);
71 if (
const char* flag_name = get_texture_flag_for_uniform(uniform_name)) {
72 binder.set_bool(flag_name,
false);
76 std::cout <<
"Warning: Invalid texture for " << uniform_name << std::endl;
83 const bool value = std::get<
bool>(property.value);
84 binder.set_bool(uniform_name, value);
89 const int value = std::get<
int>(property.value);
90 binder.set_int(uniform_name, value);
95 const glm::mat3 value = std::get<glm::mat3>(property.value);
96 binder.set_mat3(uniform_name, value);
101 const glm::mat4 value = std::get<glm::mat4>(property.value);
102 binder.set_mat4(uniform_name, value);
109 const char*
MaterialManager::get_texture_flag_for_uniform(
const std::string& uniform_name) {
static void bind_property(const Material::Property &property, uint32_t shader_program, int &texture_unit)
static void bind_property_to_shader(const Material::Property &property, uint32_t shader_program, int &texture_unit)
static void bind_material(const Material &material)
void bind() const
Used to bind a Material for rendering.
uint32_t get_compiled_shader_id() const
const std::string & get_name() const
void bind(unsigned int slot=0) const
static constexpr const char * ROUGHNESS_TEXTURE
static constexpr const char * DIFFUSE_TEXTURE
static constexpr const char * NORMAL_TEXTURE
static constexpr const char * USE_SPECULAR_TEXTURE
static constexpr const char * SPECULAR_TEXTURE
static constexpr const char * USE_ROUGHNESS_TEXTURE
static constexpr const char * AO_TEXTURE
static constexpr const char * USE_AO_TEXTURE
static constexpr const char * USE_EMISSIVE_TEXTURE
static constexpr const char * METALLIC_TEXTURE
static constexpr const char * EMISSIVE_TEXTURE
static constexpr const char * USE_NORMAL_TEXTURE
static constexpr const char * USE_DIFFUSE_TEXTURE
static constexpr const char * USE_METALLIC_TEXTURE