Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
MaterialData.h
Go to the documentation of this file.
1#pragma once
2#include <glm/vec3.hpp>
3#include <glm/vec4.hpp>
4
5#include "MaterialShader.h"
6
7namespace EngineCore
8{
10
11 };
12
13 template<typename T>
15
16#define TYPE_TRAIT_CLASS(name) \
17 class name : public MaterialData \
18
19#define TYPE_TRAIT(name, materialName) \
20 template<> \
21 struct MaterialNameTrait<name> { \
22 static constexpr PipelineNames value = materialName; \
23 }; \
24
25
32 {
33 public:
35 explicit NormalMaterialData(bool debug) : debug(debug) {}
36
41 bool getDebug() const { return debug; }
42 private:
43 bool debug;
44 };
46
47
54 {
55 public:
56 DiffuseFlatColorMaterialData() : color(glm::vec3(1, 0, 1)) {}
57 explicit DiffuseFlatColorMaterialData(const glm::vec3 &color) : color(color) {}
58
59 glm::vec3 getColor() const { return color; }
60
61 private:
63 glm::vec3 color;
64 };
66
67
74 {
75 public:
79
80 private:
82 glm::vec4 baseColorFactor;
83 public:
84 [[nodiscard]] uint32_t base_color_texture_index() const {
86 }
87
88 [[nodiscard]] glm::vec4 base_color_factor() const {
89 return baseColorFactor;
90 }
91 };
93
94
104 {
105 public:
106 // Default constructor with sensible defaults
108 : baseColorTextureIndex(0xFFFFFFFF),
109 baseColorFactor(1.0f),
110 sh_scale(0.15f),
111 ambient_term(0.1f),
112 debug_mode(0),
113 tone_mapping(1),
114 normalTextureIndex(0xFFFFFFFF),
116 emissiveTextureIndex(0xFFFFFFFF),
117 lightmapTextureIndex(0xFFFFFFFF),
118 roughnessFactor(1.0f),
119 metallicFactor(0.0f),
120 normalScale(1.0f),
121 emissiveFactor(0.0f) {
122 }
123
124 // Legacy constructor for backwards compatibility
142
143 // Existing accessors
144 [[nodiscard]] uint32_t base_color_texture_index() const { return baseColorTextureIndex; }
145 [[nodiscard]] glm::vec4 base_color_factor() const { return baseColorFactor; }
146 [[nodiscard]] float sh_scale1() const { return sh_scale; }
147 [[nodiscard]] float ambient_term1() const { return ambient_term; }
148 [[nodiscard]] uint32_t debug_mode1() const { return debug_mode; }
149 [[nodiscard]] uint32_t tone_mapping1() const { return tone_mapping; }
150
151 // PBR accessors
152 [[nodiscard]] uint32_t normal_texture_index() const { return normalTextureIndex; }
153 [[nodiscard]] uint32_t roughness_metallic_texture_index() const { return roughnessMetallicTextureIndex; }
154 [[nodiscard]] uint32_t emissive_texture_index() const { return emissiveTextureIndex; }
155 [[nodiscard]] uint32_t lightmap_texture_index() const { return lightmapTextureIndex; }
156 [[nodiscard]] float roughness_factor() const { return roughnessFactor; }
157 [[nodiscard]] float metallic_factor() const { return metallicFactor; }
158 [[nodiscard]] float normal_scale() const { return normalScale; }
159 [[nodiscard]] glm::vec3 emissive_factor() const { return emissiveFactor; }
160
161 // PBR setters
162 void setNormalTextureIndex(uint32_t index) { normalTextureIndex = index; }
164 void setEmissiveTextureIndex(uint32_t index) { emissiveTextureIndex = index; }
165 void setLightmapTextureIndex(uint32_t index) { lightmapTextureIndex = index; }
166 void setRoughnessFactor(float factor) { roughnessFactor = factor; }
167 void setMetallicFactor(float factor) { metallicFactor = factor; }
168 void setNormalScale(float scale) { normalScale = scale; }
169 void setEmissiveFactor(const glm::vec3& factor) { emissiveFactor = factor; }
170
171 private:
172 // Original fields
175 float sh_scale;
177 uint32_t debug_mode;
178 uint32_t tone_mapping;
179
180 // PBR extension fields (0xFFFFFFFF = not present)
188 glm::vec3 emissiveFactor;
189 };
191
192
194 {
195 public:
203
204 [[nodiscard]] uint32_t base_color_texture_index() const {
206 }
207
208 [[nodiscard]] glm::vec4 base_color_factor() const {
209 return baseColorFactor;
210 }
211
212 [[nodiscard]] float sh_scale1() const {
213 return sh_scale;
214 }
215
216 [[nodiscard]] float ambient_term1() const {
217 return ambient_term;
218 }
219
220 private:
223 float sh_scale;
225 };
227
228
232 {
233 public:
241
242 [[nodiscard]] uint32_t base_color_texture_index() const {
244 }
245
246 [[nodiscard]] glm::vec4 base_color_factor() const {
247 return baseColorFactor;
248 }
249
250 [[nodiscard]] float sh_scale1() const {
251 return sh_scale;
252 }
253
254 [[nodiscard]] float ambient_term1() const {
255 return ambient_term;
256 }
257
258 private:
261 float sh_scale;
263 };
265
266
268 {
269 public:
277
278 [[nodiscard]] uint32_t base_color_texture_index() const {
280 }
281
282 [[nodiscard]] glm::vec4 base_color_factor() const {
283 return baseColorFactor;
284 }
285
286 [[nodiscard]] float sh_scale1() const {
287 return sh_scale;
288 }
289
290 [[nodiscard]] float ambient_term1() const {
291 return ambient_term;
292 }
293
294 private:
297 float sh_scale;
299 };
301
312 {
313 public:
314 // Default constructor with sensible defaults
316 : baseColorTextureIndex(0xFFFFFFFF),
317 baseColorFactor(1.0f),
318 sh_scale(0.15f),
319 ambient_term(0.1f),
320 debug_mode(0),
321 tone_mapping(1),
322 normalTextureIndex(0xFFFFFFFF),
324 emissiveTextureIndex(0xFFFFFFFF),
325 lightmapTextureIndex(0xFFFFFFFF),
326 roughnessFactor(1.0f),
327 metallicFactor(0.0f),
328 normalScale(1.0f),
329 emissiveFactor(0.0f) {
330 }
331
332 // Legacy constructor for backwards compatibility
350
351 // Existing accessors
352 [[nodiscard]] uint32_t base_color_texture_index() const { return baseColorTextureIndex; }
353 [[nodiscard]] glm::vec4 base_color_factor() const { return baseColorFactor; }
354 [[nodiscard]] float sh_scale1() const { return sh_scale; }
355 [[nodiscard]] float ambient_term1() const { return ambient_term; }
356 [[nodiscard]] uint32_t debug_mode1() const { return debug_mode; }
357 [[nodiscard]] uint32_t tone_mapping1() const { return tone_mapping; }
358
359 // PBR accessors
360 [[nodiscard]] uint32_t normal_texture_index() const { return normalTextureIndex; }
361 [[nodiscard]] uint32_t roughness_metallic_texture_index() const { return roughnessMetallicTextureIndex; }
362 [[nodiscard]] uint32_t emissive_texture_index() const { return emissiveTextureIndex; }
363 [[nodiscard]] uint32_t lightmap_texture_index() const { return lightmapTextureIndex; }
364 [[nodiscard]] float roughness_factor() const { return roughnessFactor; }
365 [[nodiscard]] float metallic_factor() const { return metallicFactor; }
366 [[nodiscard]] float normal_scale() const { return normalScale; }
367 [[nodiscard]] glm::vec3 emissive_factor() const { return emissiveFactor; }
368
369 // PBR setters
370 void setNormalTextureIndex(uint32_t index) { normalTextureIndex = index; }
372 void setEmissiveTextureIndex(uint32_t index) { emissiveTextureIndex = index; }
373 void setLightmapTextureIndex(uint32_t index) { lightmapTextureIndex = index; }
374 void setRoughnessFactor(float factor) { roughnessFactor = factor; }
375 void setMetallicFactor(float factor) { metallicFactor = factor; }
376 void setNormalScale(float scale) { normalScale = scale; }
377 void setEmissiveFactor(const glm::vec3& factor) { emissiveFactor = factor; }
378
379 private:
380 // Original fields
383 float sh_scale;
385 uint32_t debug_mode;
386 uint32_t tone_mapping;
387
388 // PBR extension fields (0xFFFFFFFF = not present)
396 glm::vec3 emissiveFactor;
397 };
399
400
410 {
411 public:
412 // Default constructor with sensible defaults
414 : baseColorTextureIndex(0xFFFFFFFF),
415 baseColorFactor(1.0f),
416 normalTextureIndex(0xFFFFFFFF),
417 lightmapTextureIndex(0xFFFFFFFF),
418 roughnessFactor(1.0f),
419 metallicFactor(0.0f),
420 normalScale(1.0f),
421 emissiveFactor(0.0f),
422 sh_scale(0.15f),
423 ambient_term(1.0f), // Default to full brightness when no lightmap present
424 debug_mode(0),
425 tone_mapping(0) {
426 }
427
428 // Full constructor
429 StaticLightmapMaterialData(uint32_t baseColorTexIdx, const glm::vec4& baseColorFac,
430 uint32_t normalTexIdx, uint32_t lightmapTexIdx,
431 float roughness, float metallic, float normScale,
432 const glm::vec3& emissive, float shScale, float ambientTerm,
433 uint32_t debugMode, uint32_t toneMap)
434 : baseColorTextureIndex(baseColorTexIdx),
435 baseColorFactor(baseColorFac),
436 normalTextureIndex(normalTexIdx),
437 lightmapTextureIndex(lightmapTexIdx),
438 roughnessFactor(roughness),
439 metallicFactor(metallic),
440 normalScale(normScale),
441 emissiveFactor(emissive),
442 sh_scale(shScale),
443 ambient_term(ambientTerm),
444 debug_mode(debugMode),
445 tone_mapping(toneMap) {
446 }
447
448 // Accessors
449 [[nodiscard]] uint32_t base_color_texture_index() const { return baseColorTextureIndex; }
450 [[nodiscard]] glm::vec4 base_color_factor() const { return baseColorFactor; }
451 [[nodiscard]] uint32_t normal_texture_index() const { return normalTextureIndex; }
452 [[nodiscard]] uint32_t lightmap_texture_index() const { return lightmapTextureIndex; }
453 [[nodiscard]] float roughness_factor() const { return roughnessFactor; }
454 [[nodiscard]] float metallic_factor() const { return metallicFactor; }
455 [[nodiscard]] float normal_scale() const { return normalScale; }
456 [[nodiscard]] glm::vec3 emissive_factor() const { return emissiveFactor; }
457 [[nodiscard]] float sh_scale1() const { return sh_scale; }
458 [[nodiscard]] float ambient_term1() const { return ambient_term; }
459 [[nodiscard]] uint32_t debug_mode1() const { return debug_mode; }
460 [[nodiscard]] uint32_t tone_mapping1() const { return tone_mapping; }
461
462 // Setters
463 void setBaseColorTextureIndex(uint32_t index) { baseColorTextureIndex = index; }
464 void setNormalTextureIndex(uint32_t index) { normalTextureIndex = index; }
465 void setLightmapTextureIndex(uint32_t index) { lightmapTextureIndex = index; }
466 void setRoughnessFactor(float factor) { roughnessFactor = factor; }
467 void setMetallicFactor(float factor) { metallicFactor = factor; }
468 void setNormalScale(float scale) { normalScale = scale; }
469 void setEmissiveFactor(const glm::vec3& factor) { emissiveFactor = factor; }
470
471 private:
479 glm::vec3 emissiveFactor;
480 float sh_scale;
482 uint32_t debug_mode;
483 uint32_t tone_mapping;
484 };
486
487}
#define TYPE_TRAIT_CLASS(name)
#define TYPE_TRAIT(name, materialName)
Material data for an Object which displays a flat color.
DiffuseFlatColorMaterialData(const glm::vec3 &color)
DiffuseShaderMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor)
Dynamic textures material with PBR and lightmap support.
void setRoughnessMetallicTextureIndex(uint32_t index)
void setLightmapTextureIndex(uint32_t index)
void setEmissiveTextureIndex(uint32_t index)
void setEmissiveFactor(const glm::vec3 &factor)
DynamicTexturesMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor, float sh_scale, float ambient_term, uint32_t debug_mode, uint32_t tone_mapping)
L0ShaderMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor, float sh_scale, float ambient_term)
glm::vec4 base_color_factor() const
uint32_t base_color_texture_index() const
L1 Spherical Harmoics shader.
uint32_t base_color_texture_index() const
L1ShaderMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor, float sh_scale, float ambient_term)
glm::vec4 base_color_factor() const
L2ShaderMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor, float sh_scale, float ambient_term)
glm::vec4 base_color_factor() const
uint32_t base_color_texture_index() const
Moveable diffuse shader with PBR and lightmap support.
void setRoughnessMetallicTextureIndex(uint32_t index)
MovableDiffuseShaderMaterialData(uint32_t base_color_texture_index, const glm::vec4 &base_color_factor, float sh_scale, float ambient_term, uint32_t debug_mode, uint32_t tone_mapping)
void setEmissiveFactor(const glm::vec3 &factor)
Material data for an object which displays its normals.
bool getDebug() const
Gets whether the normals shader is launched in debug mode.
Static lightmap material with PBR support.
void setLightmapTextureIndex(uint32_t index)
StaticLightmapMaterialData(uint32_t baseColorTexIdx, const glm::vec4 &baseColorFac, uint32_t normalTexIdx, uint32_t lightmapTexIdx, float roughness, float metallic, float normScale, const glm::vec3 &emissive, float shScale, float ambientTerm, uint32_t debugMode, uint32_t toneMap)
void setBaseColorTextureIndex(uint32_t index)
void setEmissiveFactor(const glm::vec3 &factor)
void setNormalTextureIndex(uint32_t index)
Log category system implementation.
@ MOVABLE_DIFFUSE_SHADER
Converters from other number / vector systems into glm.
Definition Converter.cpp:24