Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
TextureImporter.hpp
1#pragma once
2
3#include <string>
4#include <Common/ResourcePipeline/Uuid.hpp>
5#include <Common/Editor/Importer.hpp>
6
7namespace Grindstone::Editor::Importers {
8 enum class SourceChannelDataType {
9 Undefined = 0,
10 Uint8,
11 Float
12 };
13
14 enum class OutputFormat {
15 Undefined = 0,
16 BC1,
17 BC3,
18 BC4,
19 BC6H
20 };
21
22 class TextureImporter : public Importer {
23 public:
24 void Import(Grindstone::Editor::AssetRegistry& assetRegistry, Grindstone::Assets::AssetManager& assetManager, const std::filesystem::path& path) override;
25 Uuid GetUuid();
26 private:
27 Uuid uuid;
28 void GenerateFace(uint32_t minMipLevel, uint32_t faceIterator, uint32_t blockSize, uint8_t* outData);
29 uint8_t CombinePixels(uint8_t* pixelSrc, uint64_t index, uint64_t pitch);
30 uint8_t* CreateMip(uint8_t* pixel, uint32_t width, uint32_t height);
31 void ExtractBlock(
32 const uint8_t* inPtr,
33 const uint32_t levelWidth,
34 uint8_t* colorBlock
35 );
36 void Convert();
37 uint8_t* ExtractFirstFace(uint8_t faceIndex);
38 void GenerateMipList(uint8_t faceIndex, uint32_t minMipLevel, std::vector<uint8_t*>& uncompressedMips);
39 void OutputDds(uint8_t* outPixels, uint64_t contentSize);
40 uint32_t CalculateMipMapLevelCount(uint32_t width, uint32_t height);
41
42 std::filesystem::path path;
43 Grindstone::Assets::AssetManager* assetManager = nullptr;
44 OutputFormat outputFormat = OutputFormat::Undefined;
45 SourceChannelDataType sourceChannelDataType = SourceChannelDataType::Undefined;
46 AssetRegistry* assetRegistry = nullptr;
47 uint8_t* sourcePixels = nullptr;
48 uint32_t sourceWidth = 0;
49 uint32_t sourceHeight = 0;
50 uint32_t texWidth = 0;
51 uint32_t texHeight = 0;
52 uint32_t texChannels = 0;
53 uint32_t targetTexChannels = 0;
54 uint8_t sourceSizePerPixel = 1;
55 bool shouldGenerateMips = true;
56 bool isSixSidedCubemap = false;
57 };
58
59 void ImportTexture(Grindstone::Editor::AssetRegistry& assetRegistry, Grindstone::Assets::AssetManager& assetManger, const std::filesystem::path& inputPath);
60}
Definition AssetManager.hpp:15
Definition AssetRegistry.hpp:14
Definition Importer.hpp:12
Definition TextureImporter.hpp:22
Definition Uuid.hpp:6