Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
MaterialAsset.h
Go to the documentation of this file.
1#pragma once
2#include "Engine/Core/Asset.h"
7
8namespace Engine::Ecs
9{
11} // namespace Engine::Ecs
12
13namespace Ecs {
14 class ModelAssetPipeline;
15}
16
17namespace Engine::Assets {
23 class Material : public Asset::AssetBase {
25 public:
26 explicit Material(const Asset::Path &assetPath, bool initWithDefaultData = false);
27
35 template<typename T>
36 T& getData();
37
41 void unload() override;
42
47 [[nodiscard]] Rendering::PipelineNames getType() const { return type; }
48
53 [[nodiscard]] const std::filesystem::path& getBaseColorTexturePath() const { return baseColorTexturePath; }
54
59 void setBaseColorTexturePath(const std::filesystem::path& path) { baseColorTexturePath = path; }
60
61 // PBR texture path accessors
62 [[nodiscard]] const std::filesystem::path& getNormalTexturePath() const { return normalTexturePath; }
63 [[nodiscard]] const std::filesystem::path& getMetallicRoughnessTexturePath() const { return metallicRoughnessTexturePath; }
64 [[nodiscard]] const std::filesystem::path& getEmissiveTexturePath() const { return emissiveTexturePath; }
65 [[nodiscard]] const std::filesystem::path& getLightmapTexturePath() const { return lightmapTexturePath; }
66
67 void setNormalTexturePath(const std::filesystem::path& path) { normalTexturePath = path; }
68 void setMetallicRoughnessTexturePath(const std::filesystem::path& path) { metallicRoughnessTexturePath = path; }
69 void setEmissiveTexturePath(const std::filesystem::path& path) { emissiveTexturePath = path; }
70 void setLightmapTexturePath(const std::filesystem::path& path) { lightmapTexturePath = path; }
71
72 // Type-safe handle accessors (compile-time type enforcement)
73
79
85
91
97
103
109
115
121
127
133
134 protected:
138 void updateLoadingState() override;
139
141 std::filesystem::path baseColorTexturePath;
142 std::filesystem::path normalTexturePath;
143 std::filesystem::path metallicRoughnessTexturePath;
144 std::filesystem::path emissiveTexturePath;
145 std::filesystem::path lightmapTexturePath;
146
147 // Type-safe texture handles for O(1) descriptor index lookup
153 };
154
155 template<typename T>
157 return mainRegistry.get<T>(data);
158 }
159
160 class MaterialAssetManager : public Asset::AssetManager<Asset::Path, Material> {
161 public:
163 };
164}
constexpr Engine::Rendering::PipelineNames DEFAULT_MATERIAL_PIPELINE
Definition Settings.h:59
Base class for asset wrappers. The data is stored in the private member variable 'data' in form of en...
Definition Asset.h:168
entt::entity data
Definition Asset.h:207
entt::registry & mainRegistry
Definition Asset.h:206
A manager which is used to look up existing assets and their loading state.
Definition Asset.h:250
std::filesystem::path metallicRoughnessTexturePath
Path to metallic-roughness texture from glTF.
std::filesystem::path emissiveTexturePath
Path to emissive texture from glTF.
const std::filesystem::path & getBaseColorTexturePath() const
Gets the base color texture path for this material.
AlbedoTextureHandle baseColorTextureHandle_
T & getData()
Method to get the material data from the ecs with the corresponding type.
NormalTextureHandle getNormalTextureHandle() const
Get the type-safe normal texture handle.
EmissiveTextureHandle emissiveTextureHandle_
void setLightmapTextureHandle(LightmapTextureHandle h)
Set the lightmap texture handle (type-safe)
AlbedoTextureHandle getBaseColorTextureHandle() const
Get the type-safe base color texture handle.
MetallicRoughnessTextureHandle metallicRoughnessTextureHandle_
EmissiveTextureHandle getEmissiveTextureHandle() const
Get the type-safe emissive texture handle.
void setEmissiveTextureHandle(EmissiveTextureHandle h)
Set the emissive texture handle (type-safe)
Rendering::PipelineNames type
Material(const Asset::Path &assetPath, bool initWithDefaultData=false)
void setEmissiveTexturePath(const std::filesystem::path &path)
void setNormalTextureHandle(NormalTextureHandle h)
Set the normal texture handle (type-safe)
void setNormalTexturePath(const std::filesystem::path &path)
const std::filesystem::path & getLightmapTexturePath() const
void setMetallicRoughnessTextureHandle(MetallicRoughnessTextureHandle h)
Set the metallic-roughness texture handle (type-safe)
LightmapTextureHandle getLightmapTextureHandle() const
Get the type-safe lightmap texture handle.
const std::filesystem::path & getEmissiveTexturePath() const
void setLightmapTexturePath(const std::filesystem::path &path)
std::filesystem::path baseColorTexturePath
Path to base color texture from glTF.
Rendering::PipelineNames getType() const
Gets the material type for pipeline lookup.
const std::filesystem::path & getMetallicRoughnessTexturePath() const
std::filesystem::path lightmapTexturePath
Path to lightmap texture from VulkanSchnee extension.
MetallicRoughnessTextureHandle getMetallicRoughnessTextureHandle() const
Get the type-safe metallic-roughness texture handle.
void setMetallicRoughnessTexturePath(const std::filesystem::path &path)
void updateLoadingState() override
Updates the loading state based on presence of material ECS components.
LightmapTextureHandle lightmapTextureHandle_
std::filesystem::path normalTexturePath
Path to normal map texture from glTF.
void setBaseColorTextureHandle(AlbedoTextureHandle h)
Set the base color texture handle (type-safe)
void setBaseColorTexturePath(const std::filesystem::path &path)
Sets the base color texture path for this material.
NormalTextureHandle normalTextureHandle_
void unload() override
Unload data.
const std::filesystem::path & getNormalTexturePath() const
The model asset pipeline loads a gltf scene and loads and loads the mesh and material data....
Data structs for the Entity Component System.
TypedTextureHandle< TextureType::Emissive > EmissiveTextureHandle
TypedTextureHandle< TextureType::Lightmap > LightmapTextureHandle
TypedTextureHandle< TextureType::Normal > NormalTextureHandle
TypedTextureHandle< TextureType::BaseColor > AlbedoTextureHandle
TypedTextureHandle< TextureType::MetallicRoughness > MetallicRoughnessTextureHandle