Texturing question.

Blitz3D Forums/Blitz3D Programming/Texturing question.

John Blackledge(Posted 2004) [#1]
Does Blitz load every copy of the same texture specified by meshes?
For example. if I have 3 meshes in 3 folders, and they all use the same texture for part of their surface, say 'brick1.jpg' a copy of which also resides in each folder, does that mean that Blitz loads the texture 3 times, as each model is loaded
Or as I suspect says 'No, I've already got that texture, I won't load it again.'
Basically hoping that this is the case - I'd like 'brick1.jpg' to be in each folder for modelling convenience (drive space is not a problem) knowing that Blitz will actually only load the first, then use that thereafter.


Ross C(Posted 2004) [#2]
To my knowledge it doesn't. A couple of tests i did, where i loaded the same model into blitz about 10 times, show that VRAM usage is the same with one, as it is with 10. And VRAM only goes up when the last remaining model is free'd.


sswift(Posted 2004) [#3]
I concur.


big10p(Posted 2004) [#4]
That's loading the same model multiple times, though. I think he wants to know what happens when you load different models that happen to use the same texture on one or more of their surfaces. I'm afraid I don't know the answer, however. :P


John Blackledge(Posted 2004) [#5]
Yes, big10p, that _is_ the question.
If 3 models in 3 folders use 3 textures (all with the same name) does Blitz load the first, then say 'I've already got that. No need to load again.' ?


Floyd(Posted 2004) [#6]
They can be loaded multiple times if the 'flags' are incompatible.

For example, if you load a texture with alpha and again without alpha then it really is loaded twice.


GNS(Posted 2004) [#7]
Here's a quick test of the 'same texture from multiple directories' question: http://gnsfiles.250free.com/textureTest.zip

From the above test it -does- seem as if Blitz loads a new copy of the same texture if it's in a different directory. Varying texture flags will also load new copies of a texture.


John Blackledge(Posted 2004) [#8]
Right. Thanks GNS. As your example shows, when models/textures are in separate folders each one uses extra ram - no surprises there.

I've done some tests (a bit difficult to zip up and show) but my conclusion is this:
- If two or more models (wherever they are stored) refer to the same common texture internally (e.g. .\brick1.jpg)
- then that texture will only be loaded once by Blitz and as long as the path (or flags) of the texture do not change then the common texture can be used without extra memory usage, by many models.

The proof of this was:
- Load model with internally referenced texture.
- Alt-tab out, and change the texture.
- Press (e.g. an F key) to re-EntityTexure the model.
- The changed texture does NOT appear.

In other words, either Blitz or the graphics card is saying 'I've already got that texture (by name), so I won't reload'.

You actually have to DeleteEntity and reload, to use the new changed texture.

Why is this so important?
The bottom line here is that if I'm sometimes down to 0.8 of 256 mb of AvailMem.
I have each of my models in separate folders, which all contain brick1.jpg, then brick1.jpg will be loaded multiple times.

So to save vidmem all textures must now be in a common accessible folder.
And all internal model references become .\brick1.jpg.