Cogs.Core
MaterialDefinition.h
1#pragma once
2
3#include <vector>
4
5#include <glm/glm.hpp>
6
7#include <unordered_map>
8
9#include "MaterialTypes.h"
10#include "EffectDefinition.h"
11#include "MaterialProperty.h"
12
13#include "Resources/VariantDefinition.h"
14
15namespace Cogs
16{
17 namespace Core
18 {
20 {
21 ConstantBufferVariableDefinition() { float4x4Value = glm::mat4(0.0); }
22 ConstantBufferVariableDefinition(const ConstantBufferVariableDefinition & other) : ValueDefinition(other) { float4x4Value = other.float4x4Value; flags = other.flags; }
23 ConstantBufferVariableDefinition operator=(const ConstantBufferVariableDefinition & other) { float4x4Value = other.float4x4Value; ValueDefinition::operator=(other); flags = other.flags; return *this; }
24 union
25 {
26 float floatValue;
27 glm::vec2 float2Value;
28 glm::vec3 float3Value;
29 glm::vec4 float4Value;
30 glm::mat4 float4x4Value;
31 uint32_t uintValue;
32 glm::uvec2 uint2Value;
33 glm::uvec3 uint3Value;
34 glm::uvec4 uint4Value;
35 int intValue;
36 glm::ivec2 int2Value;
37 glm::ivec3 int3Value;
38 glm::ivec4 int4Value;
39 bool boolValue;
40 };
42 };
43
45 {
46 std::string name;
47
48 std::vector<ConstantBufferVariableDefinition> values;
49
50 bool isPerInstance = false;
51 };
52
54 {
55 std::string name;
56
57 MaterialTypePrecision precision = MaterialTypePrecision::Default;
58
59 bool isPerInstance;
60 bool isSrgb;
61 bool isArray;
62
63 uint32_t arraySize;
64
65 TextureDimensions dimensions;
66 MaterialDataType format = MaterialDataType::Unknown;
67 };
68
70 {
71 std::vector<MaterialTextureDefinition> textures;
72
73 std::vector<ConstantBufferDefinition> buffers;
74 };
75
76 enum class MaterialDefinitionFlags : uint32_t
77 {
78 None = 0,
79 IsTemplate = 1 << 0,
80 };
81
82 ENABLE_ENUM_FLAGS(MaterialDefinitionFlags);
83
85 {
86 std::string name;
87
88 MaterialProperties properties;
89
90 EffectDefinition effect;
91
92 MaterialDefinitionFlags flags = MaterialDefinitionFlags::None;
93
94 std::vector<ShaderVariantRequirement> requirements;
95
96 std::unordered_map<std::string, std::string> options;
97
98 std::vector<ShaderVariantDefinition> variants;
99
100 size_t permutationIndex = 0;
101 std::string permutationName;
102
103 size_t enginePermutationMask = 0x1 | 0x2 | 0x4 | 0x8;
104 };
105
107 {
108 std::string inherits;
109
110 std::vector<MaterialDefinition> permutations;
111
112 bool isTemplate() const { return (flags & MaterialDefinitionFlags::IsTemplate) != 0; }
113 };
114 }
115}
TextureDimensions
Texture dimensions.
MaterialDataType
Defines available data types for material properties.
Definition: MaterialTypes.h:20
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Defines a loadable effect.