Author Topic: Loading Textures  (Read 1462 times)

wciow

  • Behemoth
  • *******
  • Posts: 968
    • View Profile
Loading Textures
« on: 16 July 2009, 20:34:36 »
A quick noob question for any coders  ;D

Due to the current G3D format I have several models which use the same texture in different folders.

When the engine loads these does it load a seperate copy of each texture or just one?
 
Check out my new Goblin faction - https://forum.megaglest.org/index.php?topic=9658.0

Hectate

  • Guest
Re: Loading Textures
« Reply #1 on: 16 July 2009, 21:14:01 »
I can't speak as a coder, but if there are (for instance) 3 different .tga's (even with the same name and data) then the game will load it into 3 different data blocks (memory space x3), because it has no way to know that it's the same.

On the other hand, you'll notice that the archer and the arrow share the same texture and both reference the same file. As a result, the game loads it into a single data block and references that particular memory space whenever it's needed for either model - thus saving memory. The same thing for technician's sounds being used for multiple (technician-based) units such as the ornithopter.

I utilized a similar technique for the .xml structure of my eaglestone mod. I had a unit directory that I named "shared" and any files that more than one unit used would reference the file from the shared directory structure (ie. shared/sounds/something_die.mp3). I had to create a fake unit .xml that wasn't available or functional in the game otherwise glest would crash looking for the unit (since there was a directory). But the main benefit is that I didn't have to remember that file X was under the archer's directory while file Y was under the technician's directory! It would always be under //shared/whateverIneeded

edit: For your needs, you'd probably need to hand-input an alternative filename for the texture for a couple of the model's so all models point to a single .tga. You should be able to do this when converting the .xml into the .g3d.
« Last Edit: 16 July 2009, 21:22:20 by Hectate »

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: Loading Textures
« Reply #2 on: 17 July 2009, 03:09:54 »
I can't see anywhere that it checks if the file path or contents are the same so I assume a separate copy is loaded for each one.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Loading Textures
« Reply #3 on: 18 July 2009, 03:00:23 »
A quick noob question for any coders  ;D

Due to the current G3D format I have several models which use the same texture in different folders.

When the engine loads these does it load a seperate copy of each texture or just one?

Missed this one! Sorry.
I'd like to actually sort out what is going here, as Hailstone said, as of now it's probably loading them separately if they are in different folders, but I'm fairly certain some of Tucho's models share parts of their textures... if so, then it obviously can be done "properly".  Texture memory is a BIG ISSUE... and we need to do everything in our power to reduce the 'footprint' of our mods.

Are you using Max or Blender? And any chance you could send me an example (say two models, using the same texture... or whatever you have 'lying around' ... don't do any 'work' to make an example for me :) ) So I can investigate.

Edit:
edit: For your needs, you'd probably need to hand-input an alternative filename for the texture for a couple of the model's so all models point to a single .tga. You should be able to do this when converting the .xml into the .g3d.
Sorry, missed this too... This would indeed be the solution for Blender, and should work perfectly.
« Last Edit: 18 July 2009, 03:04:09 by silnarm »
Glest Advanced Engine - Code Monkey

Timeline | Downloads

 

anything