Game Development Community

Texture reuse.

by James Laker (BurNinG) · in Torque Game Engine Advanced · 01/11/2007 (5:13 am) · 8 replies

I'm not sure if this is a bug or intended to work like this, but it seems wrong to me.
I cant seem to use the same texture more than once. Is there a reason for this?
In the console it says:
Warning,Overwriting material properties for : <Material>

Eg. Using one jpg in more than one materials.cs

#1
01/11/2007 (9:50 am)
I'm not positive but from that warning it looks like you used the same material name more than once. You can use the same texture more than once, but the material name for it must be unique.
#2
01/11/2007 (12:25 pm)
I checked again just to be sure. But that is not the case. All my Material names are unique. When I change the baseTex[0] to any texture name that has been used it will give that error. It even does this when I have have the files (texture) in different places.
#3
01/11/2007 (5:39 pm)
I don't think you can map the same texture name in two directories, because it will assign them both the same material. But you could use the same texture in multiple material definitions by using different MapTo names.

Meaning... The following code will give an error:

new Material(texture1mat)
{
	baseTex[0] = "texture1";
};

(in another directory)

new Material(texture2mat)
{
	baseTex[0] = "texture1";
};

That will map both textures to the texturename texture1map and cause the error as you describe. What I thought you were referring to was....

new Material(texture1mat)
{
      basetex[0] = "texture1";
};

new Material(texture1matbumped)
{
      basetex[0] = "texture1";
      bumptex[0] = "texture1_nm";
      mapto = "texture1bumped";
};

Where in that case we are reusing the same texture twice, but we are mapping the second one to a different material name, but all of our shapese or interiors must refer to it as texture1bumped instead of texture1.
#4
01/11/2007 (7:15 pm)
Using mapTo should allow using the same named texture with different named materials... The default behavior is to use the base texture filename as mapTo name (if mapTo doesn't exist), thus conflict.

We modified our build to not load materials when the materials.cs is executed but only then they are requested via the materialList and there is some mapTo magic which has to take place to make sure it all jives
#5
01/12/2007 (4:26 am)
Maybe that would be useful default functionality? Why did you do that exactly?
#6
01/12/2007 (4:45 am)
Let me see if that changes my problems... thanx for the info. Lets hope, i'm just not understanding it properly.
#7
01/12/2007 (4:53 am)
The reason is that my spaceships and weapons (mountable) use the same normalmap, which works... They all use one bumpmap texture.

The problem is using 1 base texture for all the ships when they are in a team, since its the same colorscheme.
I have to use mapTo to a seperate texture, which i use as the BaseTex anyway. I dont see why this is needed.
#8
01/12/2007 (10:51 am)
Post your materials definition please... :)


If you're using the same material for all of the ships, then you shouldn't even need multiple definitions for any of the materials, so sounds more like a typo or maybe just an oversight.

If you're needing to make differences to each ship based on material settings, then you will need multiple definitions and thus mapTo for each texture