How not to embed textures in vsg files #982
-
Hi all, it seems that currently all vsg model files (vsgt/vsgb) embed all required textures. However, I'd like for users of my application to be able to provide alternative textures (without having to recompile the model file(s), and to share textures between models. From the research I did it looks like OSG did actually allow for this (at least in its text format representation), so I'm wondering why this was not done for VSG? Possibly just a lack of time (and it's on the list)? Embedding all required data makes the handling of models certainly much easier.. So I guess my question is, will be this added in the future? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
To handle definition of objects that are supplied by external files I implemented a vsg::External class: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/core/External.h You set up the objects you want to be loaded from file, then assign this vsg::External object to the root node of the subgraph you want to read/write. The VSG's sharing objects within the native loaders can then handle wire up the externally loaded objects with the objects that are used within the scene graph itself. Unfortunately I don't have an example showing how it works in practice. When I originally wrote it 2019 I will have created a test of it, but I can't see anything in vsgExamples now. The idea behind it is that it would work for all objects sub-classed from vsg::Object, not just images like is done with the OSG, and it's done without support for it spreading out over the whole code base, instead it's a locally "trick" that is a bit esoteric but is quite powerful. I hope this makes enough sense for you to start experimenting with it. |
Beta Was this translation helpful? Give feedback.
-
I created a PR adding this functionality, it can be found here. Basically there are two more command line parameters:
The second option enables the user to convert these external textures into vsg's native format, so that the application consuming the model need not include vsgXchange to convert these external textures. If the 'native' option is specified (which is the default) then the original texture will not be changed. Like I wrote in the PR there's one thing I'm unsure about, the vsg::Sampler.. the vsg::Image is now read 'just in time' but the vsg::Sampler has already been precomputed (and embedded in the model file). So if for example the external image was created with mipmaps by the time the model was converted, but is then later changed NOT to include mipmaps, I am not sure what's going to happen (if this is a bad thing or not). |
Beta Was this translation helpful? Give feedback.
To handle definition of objects that are supplied by external files I implemented a vsg::External class:
https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/core/External.h
You set up the objects you want to be loaded from file, then assign this vsg::External object to the root node of the subgraph you want to read/write. The VSG's sharing objects within the native loaders can then handle wire up the externally loaded objects with the objects that are used within the scene graph itself.
Unfortunately I don't have an example showing how it works in practice. When I originally wrote it 2019 I will have created a test of it, but I can't see anything in vsgExamples now.
The id…