Open quirinpa opened 1 year ago
If the texture
field is null, then it's likely that the asset simply doesn't have a normal map for that primitive. They're optional.
( However if the data
field is null, then you might have forgotten to call cgltf_load_buffers
first. )
Oh.. I see.. The normal map. I was looking for the main texture, where is it located in the data structure?
Keep in mind that some primitives might have no textures whatsoever, but you could look in base_color_texture
if you already know that it has a baseColorTexture
.
Thank you so much @prideout, it appears I was looking in the wrong place. Now I can see the textures.
I'm trying to combine cgltf and stb_image to be able to import textures and render them on my 3D model using OpenGL. The code is available here. I was hoping that the binary texture data would be under primitive->material->normal_texture.texture->buffer_view, but unfortunately "texture" is NULL.
Here is the call I was hoping to use to load the binary information about the images:
m->texture.data = stbi_load_from_memory(tview->buffer->data + tview->offset, tview->size, &m->texture.w, &m->texture.h, &m->texture.channels, 3);
But this does not work. Can you please help me out?
I know cgltf is not concerned with loading images, but couldn't it at least load the binary image data in the glb file? The binary information only, it doesn't need to understand or process it.