16#ifndef AEONGAMES_MATERIAL_H
17#define AEONGAMES_MATERIAL_H
22#include <initializer_list>
24#include "aeongames/ResourceId.hpp"
25#include "aeongames/Vector2.hpp"
29#include "aeongames/Resource.hpp"
41 using UniformValue = std::variant<uint32_t, int32_t, float, Vector2, Vector3, Vector4, Matrix4x4>;
68 DLL
void LoadFromMemory ( const
void* aBuffer,
size_t aBufferSize ) final;
107 class UniformVariable
110 UniformVariable (
const std::string & aName,
size_t aOffset ) :
113 const std::string & GetName()
const
125 DLL
size_t LoadVariables (
const MaterialMsg& aMaterialMsg );
126 DLL
void LoadSamplers (
const MaterialMsg& aMaterialMsg );
127 DLL
size_t LoadVariables ( std::initializer_list<UniformKeyValue> aUniforms );
128 DLL
void LoadSamplers ( std::initializer_list<SamplerKeyValue> aSamplers );
129 std::vector<UniformVariable> mVariables{};
130 std::vector<SamplerKeyValue> mSamplers{};
131 std::vector<uint8_t> mUniformBuffer{};
Header for 4x4 matrix class.
Header for the 3D vector class.
Header for the 4D vector class.
Material(Material &&)=delete
No move allowed.
DLL void SetSampler(const std::string &aName, const ResourceId &aValue)
Set a sampler binding by name.
DLL void Unload() final
Unload material data and release resources.
std::variant< uint32_t, int32_t, float, Vector2, Vector3, Vector4, Matrix4x4 > UniformValue
Variant type holding any supported uniform value.
DLL void Set(size_t aIndex, const UniformValue &aValue)
Set a uniform value by index.
DLL const std::vector< uint8_t > & GetUniformBuffer() const
Get the raw uniform buffer.
std::tuple< std::string, UniformValue > UniformKeyValue
Key-value pair mapping a uniform name to its value.
DLL void LoadFromMemory(const void *aBuffer, size_t aBufferSize) final
Load material data from a raw memory buffer.
DLL Material()
Default constructor.
DLL ResourceId GetSampler(const std::string &aName)
Get the resource id of a sampler by name.
DLL void LoadFromPBMsg(const MaterialMsg &aMaterialMsg)
Load material data from a protobuf message.
DLL ~Material() final
Destructor.
DLL const std::vector< std::tuple< uint32_t, ResourceId > > & GetSamplers() const
Get all sampler bindings.
std::tuple< uint32_t, ResourceId > SamplerKeyValue
Key-value pair mapping a sampler binding index to an image resource id.
DLL Material & operator=(const Material &aMaterial)
Assignment operator due to rule of zero/three/five.
Base class for loadable engine resources.
Identifies a resource by its type and path CRC32 hashes.
<- This is here just for the literals
DLL const void * GetUniformValuePointer(const Material::UniformValue &aValue)
Get a pointer to the raw data of a uniform value.
DLL size_t GetUniformValueSize(const Material::UniformValue &aValue)
Get the byte size of a uniform value.