3#include "Utilities/Strings.h"
5#include "MaterialDefinition.h"
6#include "MaterialPropertyBuffer.h"
7#include "MaterialProperty.h"
8#include "MaterialOptions.h"
16 COGSCORE_DLL_API ConstantBufferKey addBuffer(
const PropertyName & name,
bool isPerInstance =
true);
18 void finalizeBuffer(
Context* context, ConstantBufferKey bufferKey) {
buffers[bufferKey].finalize(context); }
27 variable.
name = name.to_string();
28 variable.
buffer = bufferKey;
30 variable.flags = flags;
33 enforcePropertyFlags(variable, flags, &defaultValue);
34 variable.setDefault(defaultValue);
37 if (type == MaterialDataType::Float4Array) {
38 assert(dimension !=
static_cast<size_t>(-1) && dimension < std::numeric_limits<uint32_t>::max());
40 std::vector<uint8_t> tmp(
sizeof(glm::vec4) * dimension);
41 for (
size_t i = 0; i < dimension; i++) {
42 std::memcpy(tmp.data() +
sizeof(glm::vec4) * i, &defaultValue,
sizeof(glm::vec4));
45 variable.isArray =
true;
46 variable.arraySize =
static_cast<uint32_t
>(dimension);
49 else if (type == MaterialDataType::Float4x4Array) {
50 assert(dimension !=
static_cast<size_t>(-1) && dimension <= std::numeric_limits<uint32_t>::max());
52 std::vector<uint8_t> tmp(
sizeof(glm::mat4) * dimension);
53 for (
size_t i = 0; i < dimension; i++) {
54 std::memcpy(tmp.data() +
sizeof(glm::mat4) * i, &defaultValue,
sizeof(glm::mat4));
57 variable.isArray =
true;
58 variable.arraySize =
static_cast<uint32_t
>(dimension);
73 enforcePropertyFlags(variable, variable.flags, &value);
76 buffers[variable.buffer].setValue(variable.descriptor.offset, value);
91 std::vector<MaterialPropertyBuffer>
buffers;
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Provides a weakly referenced view over the contents of a string.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
MaterialDataType
Defines available data types for material properties.
std::string PropertyName
Typedef for property names.
uint16_t VariableKey
Used to lookup material properties.
std::vector< MaterialPropertyBuffer > buffers
Constant buffer instances.
std::vector< MaterialProperty > variables
Individual variables from all buffer instances.
uint16_t buffersGeneration
If the constant buffer bindings need updates.
Material property buffers contain properties for a material, such as color, reflectiveness or other v...
COGSCORE_DLL_API MaterialPropertyDescriptor addProperty(size_t propertyAlignment, size_t propertySize, const uint8_t *data)
Add the value pointed to by data, with the given propertySize, to the buffer.
Defines a single material property.
MaterialPropertyDescriptor descriptor
Property descriptor.
bool isPerInstance
If the property is defined per instance or per material.
ConstantBufferKey buffer
Key to the buffer the property value is stored in.
VariableKey key
Key of the property, used to index into the property collection the property will be placed into.
PropertyName name
Name of the property, used to reference named uniforms of constant buffer members in shaders.
MaterialDataType type
Type of data held by property.