33#include <unordered_map>
36#include <glm/mat4x4.hpp>
39#include "graphics/Texture.h"
65 void SetParam(
const std::string &name,
float value);
66 void SetParam(
const std::string &name,
float v0,
float v1);
67 void SetParam(
const std::string &name,
const vec3 &value);
68 void SetParam(
const std::string &name,
const vec4 &value);
69 void SetParam(
const std::string &name,
const std::shared_ptr<Texture> &texture);
70 void SetParam(
const std::string &name,
const std::vector<glm::mat4> &matrices);
89 static std::shared_ptr<Material>
Load(
const str &path);
92 std::shared_ptr<ShaderProgram> m_shaderProgram;
93 std::unordered_map<std::string, float> m_floatParams;
94 std::unordered_map<std::string, std::tuple<float, float>> m_float2Params;
95 std::unordered_map<std::string, vec3> m_float3Params;
96 std::unordered_map<std::string, vec4> m_float4Params;
97 std::unordered_map<std::string, std::shared_ptr<Texture>> m_textures;
98 std::unordered_map<std::string, std::vector<glm::mat4>> m_mat4ArrayParams;
Engine-wide primitive type aliases and GLM math imports.
Shader + uniform storage that defines how a surface is rendered.
void Bind()
Upload all stored parameters to the active ShaderProgram.
void SetShaderProgram(const std::shared_ptr< ShaderProgram > &shaderProgram)
Assign the GLSL program this material will use when drawn.
void SetParam(const std::string &name, float value)
Set a float uniform.
ShaderProgram * GetShaderProgram()
Returns the shader program assigned to this material.
static std::shared_ptr< Material > Load(const str &path)
Load a material from a descriptor file.
Linked GLSL program with cached uniform locations.
glm::vec4 vec4
4-component float vector (e.g. RGBA colour, homogeneous coords).
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
std::string str
Convenience alias for std::string.