Skip to content
Snippets Groups Projects
Commit cfe370e8 authored by Trevor Hollmann's avatar Trevor Hollmann
Browse files

[#79] Update documentation of asset loader.

parent f85a24e3
No related branches found
No related tags found
1 merge request!69Resolve "Rework Asset Loader API"
Pipeline #26613 passed
...@@ -84,20 +84,23 @@ struct Sampler { ...@@ -84,20 +84,23 @@ struct Sampler {
}; };
/** /**
* This struct describes a loaded texture. * This struct describes a (partially) loaded texture.
* Note that textures are currently always loaded with 4 channels as RGBA, even * The data member is not populated after calling probeScene() but only when
* if the image has just RGB or is grayscale. * 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 { struct Texture {
std::filesystem::path path; // file path of the encoded texture data std::filesystem::path path; // URI to the encoded texture data
int sampler; // index into the sampler array of the Scene int sampler; // index into the sampler array of the Scene
union { int width; int w; }; union { int width; int w; };
union { int height; int h; }; union { int height; int h; };
int channels; int channels;
// binary data of the decoded texture std::vector<char*> data; // binary data of the decoded texture
std::vector<char*> data;
}; };
/** /**
......
...@@ -453,7 +453,10 @@ namespace vkcv::asset { ...@@ -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) { static uint16_t generateTextureMask(fx::gltf::Material &material) {
uint16_t textureMask = 0; uint16_t textureMask = 0;
...@@ -621,6 +624,12 @@ namespace vkcv::asset { ...@@ -621,6 +624,12 @@ namespace vkcv::asset {
return ASSET_SUCCESS; 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) { static int loadTextureData(Texture& texture) {
if ((texture.width > 0) && (texture.height > 0) && (texture.channels > 0) && if ((texture.width > 0) && (texture.height > 0) && (texture.channels > 0) &&
(!texture.data.empty())) { (!texture.data.empty())) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment