tyra
tyra copied to clipboard
Improve obj loader
@Foxar please describe the needs if you could.
https://github.com/h4570/tyra/blob/d58163d75be2d6c848f4456f73cebd8a6c1a63bd/src/engine/include/loaders/obj_loader.hpp#L18
So far I've thought of these:
-
[ ] Basic material loading from .mtl file.
-
[ ] Default texture for .obj models, if no texture specified
-
[ ] Error message improvements (if loading failed, why? where exaclty?)
- [ ] Default texture for .obj models, if no texture specified
Good point. I think that will be good idea to perform PRINT_ERR()
(future assert()
) on vt (texture data), vn (normal vector) and 2x on f (faces), if they are triangulated and all values are present.
How is using PRINT_ERR() on those values going to provide a default texture for a model? I was hoping to allow the engine to load a model and use some default texture (solid white color, or green and black squares tileset like in source games) to signify failure to load the texture for the model, without grinding the entire .elf executable to a halt.
Image for reference:
I've changed my original TO-DO to specify that the ".mtl loading" should be for basic materials only, such as solid colors/gradients. This is because .mtl files themselves only designate a filename for textures, which seems redundant to have considering the current way TextureRepositories and png/bmp loaders work.
I'd like opinion on this and if you have any other suggestions for improvements to obj_loader, please add them. @h4570
Hmm.
My thought with PRINT_ERR()
was, to just check if texture data is present (assert()
) and print error if not.
This is pretty good idea, regarding the "no-texture" texture, we can generate this tex in c++ as well. But yesterday I did small investigation there, and I see that we will MUST add non-texture meshes support. For example yesterday I downloaded christmas tree .obj file, which has texture for tree, and only colors for christmas balls. Texture and colors was described in .mtl file.
My point of view is:
- Render "no-texture" texture if texture is described in .obj, but texture loading failed.
- Add new feature, which will enable 2D / 3D rendering without textures (new issue -> enhacement?).
What do you think?
The way I understand this:
Render "no-texture" texture if texture is described in .obj, but texture loading failed.
- Load the obj file, load the texture name from inside of it.
- If it's missing (no
usemtl texture
), load default texture name ( "missingtex" for instance). - If AddByMesh fails to find texture, (no texture.png found), instead default to loading missingtex.
Add new feature, which will enable 2D / 3D rendering without textures (new issue -> enhacement?).
Agreed, we can add a boolean value in loaders if they should expect or not material data. If we take an example of obj_loader: here https://github.com/h4570/tyra/blob/d58163d75be2d6c848f4456f73cebd8a6c1a63bd/src/engine/loaders/obj_loader.cpp#L73
I'd like to note here that recently we've commited some changes to objloader, allowing to load without complete set of Vectors Normals and UVmaps, however it is unlikely to render properly. As such this issue is on hold until we resolve #66
Tomorrow I'd like to look into this issue, testing to see the rendering behavior of models without Normals or UVMaps, as I understand that #66 has been fixed.
Resolved. Tyra 2.0.0 uses tinyobjloader