Multiple NeoTextures?


I’ve been messing around with JME3 for a number of days now, and having only messed about with OpenGL myself previously am really pretty impressed with how powerful it is.

One problem I’ve come up against however is how to load multiple .tgr textures. When I try to do so, only the first texture file I load seems to be used- would you be able to help me work out what is wrong with my code below? I’m sure it’s only something fairly simple that I’m not understanding.


assetManager.registerLoader(“com.jme3.material.plugins.NeoTextureMaterialLoader”, “tgr”);

NeoTextureMaterialKey key2 = new NeoTextureMaterialKey(“Materials/grass1.tgr”);

grass1 = assetManager.loadAsset(key2);

NeoTextureMaterialKey key1 = new NeoTextureMaterialKey(“Materials/grass2.tgr”);

grass2 = assetManager.loadAsset(key1);


Thanks for any help!

Uh, the loader is from the contribution repository, its entirely possible that the loader does that and its simply a bug… However it shouldn’t… Do the material settings at least change when you specify them? Try for example setting a different shininess or something with the second material.

Now that I know it’s not some intentional behaviour, I’ve experimented a little more…

By rendering object with grass1 as texture-

  • grass1.tgr texture shown
  • grass1 'shininess' update shows visible change
  • grass2 'shininess' update shows no visible change

By rendering object with grass2 as texture-
  • grass1.tgr texture still shown
  • grass1 'shininess' update shows no visible change
  • grass2 'shininess' update show visible change

This would seem to suggest to me that the loader isn't correctly loading in the new texture on the second load call, but that the usual JME3 functions for the material seem to be fine- as I believe you may also be suspecting.

I think unfortunately this means I'll need to instead revert to using image-based textures for the time being, although I was already considering doing so given that the loading time using the NeoTexture way seems to be almost 5 secs a time for me :(... That's definitely not to say I'm not intrigued as to what's going on here though!

Yeah, the creation algorithms have lots of room for improvements as Holger said, so they are a tad slow right now. I will have a look at the loader though, it should be able to load multiple textures :slight_smile: You can export images from NeoTexture, you know that right?

Yeah, that’s what I’m going to resort to doing… I just quite liked the idea of very minimal distribution overheads by using dynamic recreation of the textures on the client- definitely got a decent idea there :slight_smile:

Although it might take a bit of finding (don’t they always?), I dare say the bug should be a relatively simple one!

Thanks for your help

Yes, definitely, the loaders I wrote for loading the textures are pretty simple, maybe you want to have a look at it yourself, you can check the source here, I don’t know when I will find the time to debug this. One drawback of the current NeoTexture generator is that it uses static methods, so you always access one instance… Might have something to do with it…

Looking at the source myself, maybe you try enabling or disabling the cache… I think its disabled by default.

I’ll try giving it a look when I have some time on my hands- unfortunately that’s really not the case right now :(. Hopefully should be able to lend a hand, given that I’m sure you have your hands more than full already. Thanks for the indication of where to look.

You can enable/disable the cache without compiling it or anything, its an option in the key. It should change whats happening in the only way I can think to fix this right now…

Ok sure, I’ll give it a try… How do I actually go about changing it?

key.enableCache() or something like that.