Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
MaterialAsset.h
1#pragma once
2#include "Engine/Core/Asset.h"
3#include "Engine/Core/Settings.h"
4#include "Engine/Files/AssetPath.h"
5#include "Engine/Asset/AssetHandles.h"
6#include "Engine/Mesh/GltfLoader.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:
31 explicit Material(const Asset::MeshPath &assetPath, bool initWithDefaultData = false);
32
40 template<typename T>
41 T& getData();
42
46 void unload() override;
47
52 [[nodiscard]] Rendering::PipelineNames getType() const { return type; }
53
58 [[nodiscard]] const std::filesystem::path& getBaseColorTexturePath() const { return baseColorTexturePath; }
59
64 void setBaseColorTexturePath(const std::filesystem::path& path) { baseColorTexturePath = path; }
65
66 // PBR texture path accessors
70 [[nodiscard]] const std::filesystem::path& getNormalTexturePath() const { return normalTexturePath; }
71
75 [[nodiscard]] const std::filesystem::path& getMetallicRoughnessTexturePath() const { return metallicRoughnessTexturePath; }
76
80 [[nodiscard]] const std::filesystem::path& getEmissiveTexturePath() const { return emissiveTexturePath; }
81
85 [[nodiscard]] const std::filesystem::path& getLightmapTexturePath() const { return lightmapTexturePath; }
86
91 void setNormalTexturePath(const std::filesystem::path& path) { normalTexturePath = path; }
92
97 void setMetallicRoughnessTexturePath(const std::filesystem::path& path) { metallicRoughnessTexturePath = path; }
98
103 void setEmissiveTexturePath(const std::filesystem::path& path) { emissiveTexturePath = path; }
104
109 void setLightmapTexturePath(const std::filesystem::path& path) { lightmapTexturePath = path; }
110
111 // Type-safe handle accessors (compile-time type enforcement)
112
118
124
130
136
142
148
154
160
166
172
173 protected:
177 void updateLoadingState() override;
178
179 Rendering::PipelineNames type = DEFAULT_MATERIAL_PIPELINE;
180 std::filesystem::path baseColorTexturePath;
181 std::filesystem::path normalTexturePath;
182 std::filesystem::path metallicRoughnessTexturePath;
183 std::filesystem::path emissiveTexturePath;
184 std::filesystem::path lightmapTexturePath;
185
186 // Type-safe texture handles for O(1) descriptor index lookup
192 };
193
194 template<typename T>
196 return mainRegistry.get<T>(data);
197 }
198
202 class MaterialAssetManager : public Asset::AssetManager<Asset::MeshPath, Material> {
203 public:
208 };
209}
Base class for asset wrappers. The data is stored in the private member variable 'data' in form of en...
Definition Asset.h:297
entt::entity data
Entity containing the asset's component data.
Definition Asset.h:347
entt::registry & mainRegistry
Registry that owns this asset's ECS data.
Definition Asset.h:346
A manager which is used to look up existing assets and their loading state.
Definition Asset.h:358
MaterialAssetManager()=default
Creates an empty material asset manager.
std::filesystem::path metallicRoughnessTexturePath
Path to metallic-roughness texture from glTF.
std::filesystem::path emissiveTexturePath
Path to emissive texture from glTF.
void setLightmapTextureHandle(Texture2DHandle h)
Set the lightmap texture handle (type-safe)
const std::filesystem::path & getBaseColorTexturePath() const
Gets the base color texture path for this material.
T & getData()
Method to get the material data from the ecs with the corresponding type.
Material(const Asset::MeshPath &assetPath, bool initWithDefaultData=false)
Creates a material asset for a source mesh path.
void setBaseColorTextureHandle(Texture2DHandle h)
Set the base color texture handle (type-safe)
Texture2DHandle getBaseColorTextureHandle() const
Get the type-safe base color texture handle.
Texture2DHandle emissiveTextureHandle_
Descriptor handle for the emissive texture slot.
Texture2DHandle metallicRoughnessTextureHandle_
Descriptor handle for the metallic-roughness texture slot.
Texture2DHandle getMetallicRoughnessTextureHandle() const
Get the type-safe metallic-roughness texture handle.
Texture2DHandle getNormalTextureHandle() const
Get the type-safe normal texture handle.
Texture2DHandle normalTextureHandle_
Descriptor handle for the normal texture slot.
Rendering::PipelineNames type
Pipeline used to render this material.
void setEmissiveTexturePath(const std::filesystem::path &path)
Sets the emissive texture path for this material.
void setNormalTexturePath(const std::filesystem::path &path)
Sets the normal map texture path for this material.
const std::filesystem::path & getLightmapTexturePath() const
Gets the lightmap texture path for this material.
const std::filesystem::path & getEmissiveTexturePath() const
Gets the emissive texture path for this material.
Texture2DHandle getEmissiveTextureHandle() const
Get the type-safe emissive texture handle.
void setMetallicRoughnessTextureHandle(Texture2DHandle h)
Set the metallic-roughness texture handle (type-safe)
void setLightmapTexturePath(const std::filesystem::path &path)
Sets the lightmap texture path for this material.
void setNormalTextureHandle(Texture2DHandle h)
Set the normal texture handle (type-safe)
Texture2DHandle lightmapTextureHandle_
Descriptor handle for the lightmap texture slot.
std::filesystem::path baseColorTexturePath
Path to base color texture from glTF.
Rendering::PipelineNames getType() const
Gets the material type for pipeline lookup.
Texture2DHandle baseColorTextureHandle_
Descriptor handle for the base color texture slot.
const std::filesystem::path & getMetallicRoughnessTexturePath() const
Gets the metallic-roughness texture path for this material.
std::filesystem::path lightmapTexturePath
Path to lightmap texture from VulkanSchnee extension.
void setMetallicRoughnessTexturePath(const std::filesystem::path &path)
Sets the metallic-roughness texture path for this material.
void updateLoadingState() override
Updates the loading state based on presence of material ECS components.
std::filesystem::path normalTexturePath
Path to normal map texture from glTF.
Texture2DHandle getLightmapTextureHandle() const
Get the type-safe lightmap texture handle.
void setBaseColorTexturePath(const std::filesystem::path &path)
Sets the base color texture path for this material.
void unload() override
Unload data.
void setEmissiveTextureHandle(Texture2DHandle h)
Set the emissive texture handle (type-safe)
const std::filesystem::path & getNormalTexturePath() const
Gets the normal map texture path for this material.
The model asset pipeline loads a gltf scene and loads and loads the mesh and material data....
AssetHandle< Texture2DHandleTag > Texture2DHandle
Handle to a file-backed sampled 2D texture.
EnTT component data used by engine systems.
PipelineNames
Named graphics pipelines used by material selection and shader lookup.
Identifies a named mesh-like asset inside an asset file.
Definition AssetPath.h:89