diff --git a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp index 16cb5bafd9fccbdb6f8b4b1b75a1b8d61881eab0..2b14ccc0222233b9df499ccfd8b70b9a5b33de0c 100644 --- a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp +++ b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp @@ -84,20 +84,23 @@ struct Sampler { }; /** - * This struct describes a loaded texture. - * Note that textures are currently always loaded with 4 channels as RGBA, even - * if the image has just RGB or is grayscale. + * This struct describes a (partially) loaded texture. + * The data member is not populated after calling probeScene() but only when + * calling loadMesh(), loadScene() or loadTexture(). Note that textures are + * currently always loaded with 4 channels as RGBA, even if the image has just + * RGB or is grayscale. In the case where the glTF-file does not provide a URI + * but references a buffer view for the raw data, the path member will be empty + * even though the rest is initialized properly. */ struct Texture { - std::filesystem::path path; // file path of the encoded texture data - int sampler; // index into the sampler array of the Scene + std::filesystem::path path; // URI to the encoded texture data + int sampler; // index into the sampler array of the Scene union { int width; int w; }; union { int height; int h; }; int channels; - // binary data of the decoded texture - std::vector<char*> data; + std::vector<char*> data; // binary data of the decoded texture }; /** diff --git a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp index 3e7207e46ae0994ff9261c8bb2d28859169685ab..56ae8f5c7c6243c0d89b1b54891204f7e1e84498 100644 --- a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp +++ b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp @@ -453,7 +453,10 @@ namespace vkcv::asset { } /** - * TODO document + * Returns an integer with specific bits set corresponding to the + * textures that appear in the given material. This mask is used in the + * vkcv::asset::Material struct and can be tested via the hasTexture + * method. */ static uint16_t generateTextureMask(fx::gltf::Material &material) { uint16_t textureMask = 0; @@ -621,6 +624,12 @@ namespace vkcv::asset { return ASSET_SUCCESS; } + /** + * Loads and decodes the textures data based on the textures file path. + * The path member is the only one that has to be initialized before + * calling this function, the others (width, height, channels, data) + * are set by this function and the sampler is of no concern here. + */ static int loadTextureData(Texture& texture) { if ((texture.width > 0) && (texture.height > 0) && (texture.channels > 0) && (!texture.data.empty())) {