Split mesh artifacts into material and texture artifacts
This commit is contained in:
@@ -10,7 +10,8 @@ namespace XCEngine {
|
||||
namespace Resources {
|
||||
|
||||
constexpr Core::uint32 kTextureArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kMeshArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kMaterialArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kMeshArtifactSchemaVersion = 2;
|
||||
|
||||
struct TextureArtifactHeader {
|
||||
char magic[8] = { 'X', 'C', 'T', 'E', 'X', '0', '1', '\0' };
|
||||
@@ -26,7 +27,7 @@ struct TextureArtifactHeader {
|
||||
};
|
||||
|
||||
struct MeshArtifactHeader {
|
||||
char magic[8] = { 'X', 'C', 'M', 'E', 'S', 'H', '1', '\0' };
|
||||
char magic[8] = { 'X', 'C', 'M', 'E', 'S', 'H', '2', '\0' };
|
||||
Core::uint32 schemaVersion = kMeshArtifactSchemaVersion;
|
||||
Core::uint32 vertexCount = 0;
|
||||
Core::uint32 vertexStride = 0;
|
||||
@@ -35,13 +36,17 @@ struct MeshArtifactHeader {
|
||||
Core::uint32 use32BitIndex = 0;
|
||||
Core::uint32 sectionCount = 0;
|
||||
Core::uint32 materialCount = 0;
|
||||
Core::uint32 textureCount = 0;
|
||||
Math::Vector3 boundsMin = Math::Vector3::Zero();
|
||||
Math::Vector3 boundsMax = Math::Vector3::Zero();
|
||||
Core::uint64 vertexDataSize = 0;
|
||||
Core::uint64 indexDataSize = 0;
|
||||
};
|
||||
|
||||
struct MaterialArtifactFileHeader {
|
||||
char magic[8] = { 'X', 'C', 'M', 'A', 'T', '0', '1', '\0' };
|
||||
Core::uint32 schemaVersion = kMaterialArtifactSchemaVersion;
|
||||
};
|
||||
|
||||
struct MaterialArtifactHeader {
|
||||
Core::int32 renderQueue = static_cast<Core::int32>(MaterialRenderQueue::Geometry);
|
||||
MaterialRenderState renderState = {};
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
const Containers::String& GetLibraryRoot() const { return m_libraryRoot; }
|
||||
|
||||
private:
|
||||
static constexpr Core::uint32 kCurrentImporterVersion = 1;
|
||||
static constexpr Core::uint32 kCurrentImporterVersion = 2;
|
||||
|
||||
void EnsureProjectLayout();
|
||||
void LoadSourceAssetDB();
|
||||
@@ -105,6 +105,8 @@ private:
|
||||
ArtifactRecord& outRecord);
|
||||
bool ImportTextureAsset(const SourceAssetRecord& sourceRecord,
|
||||
ArtifactRecord& outRecord);
|
||||
bool ImportMaterialAsset(const SourceAssetRecord& sourceRecord,
|
||||
ArtifactRecord& outRecord);
|
||||
bool ImportModelAsset(const SourceAssetRecord& sourceRecord,
|
||||
ArtifactRecord& outRecord);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -132,10 +133,18 @@ struct MaterialTagEntry {
|
||||
Containers::String value;
|
||||
};
|
||||
|
||||
struct PendingTextureLoadState {
|
||||
IResource* resource = nullptr;
|
||||
Containers::String errorMessage;
|
||||
bool completed = false;
|
||||
};
|
||||
|
||||
struct MaterialTextureBinding {
|
||||
Containers::String name;
|
||||
Core::uint32 slot = 0;
|
||||
ResourceHandle<Texture> texture;
|
||||
Containers::String texturePath;
|
||||
std::shared_ptr<PendingTextureLoadState> pendingLoad;
|
||||
};
|
||||
|
||||
class Material : public IResource {
|
||||
@@ -181,6 +190,7 @@ public:
|
||||
void SetInt(const Containers::String& name, Core::int32 value);
|
||||
void SetBool(const Containers::String& name, bool value);
|
||||
void SetTexture(const Containers::String& name, const ResourceHandle<Texture>& texture);
|
||||
void SetTexturePath(const Containers::String& name, const Containers::String& texturePath);
|
||||
|
||||
float GetFloat(const Containers::String& name) const;
|
||||
Math::Vector2 GetFloat2(const Containers::String& name) const;
|
||||
@@ -191,6 +201,7 @@ public:
|
||||
ResourceHandle<Texture> GetTexture(const Containers::String& name) const;
|
||||
Core::uint32 GetTextureBindingCount() const { return static_cast<Core::uint32>(m_textureBindings.Size()); }
|
||||
Containers::String GetTextureBindingName(Core::uint32 index) const;
|
||||
Containers::String GetTextureBindingPath(Core::uint32 index) const;
|
||||
ResourceHandle<Texture> GetTextureBindingTexture(Core::uint32 index) const;
|
||||
const Containers::Array<MaterialTextureBinding>& GetTextureBindings() const { return m_textureBindings; }
|
||||
std::vector<MaterialProperty> GetProperties() const;
|
||||
@@ -205,6 +216,9 @@ public:
|
||||
void ClearAllProperties();
|
||||
|
||||
private:
|
||||
void BeginAsyncTextureLoad(Core::uint32 index);
|
||||
void ResolvePendingTextureBinding(Core::uint32 index);
|
||||
void ResolvePendingTextureBindings();
|
||||
void MarkChanged(bool updateConstantBuffer);
|
||||
void UpdateMemorySize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user