Cloned materials, texture aliases giving blackness

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
pptech
Kobold
Posts: 37
Joined: Mon May 09, 2011 6:14 pm
x 1

Cloned materials, texture aliases giving blackness

Post by pptech »

Hi,

I have some code that works on the desktop version of our application. It involves taking a base material, cloning it and setting a different texture using texture aliases. All that seems to happen is that the texture comes out black on both the simulator and on a device. I have checked the texture file does exist and that applyTextureAliases is going something, so I don't think it is anything simple.

The base material looks like this:

Code: Select all

material Artwork
{
	technique
	{
		pass
		{
			lighting on
			emissive 0.75 0.75 0.75
			diffuse 0.75 0.75 0.75
			depth_bias 0.1 0.1
			
			texture_unit
			{
				texture_alias ArtworkImage
			}
		}
	}
}
It is updated like this:

Code: Select all

	Ogre::MaterialPtr artworkMaterial = Ogre::MaterialManager::getSingleton().getByName("Artwork");
	if (artworkMaterial.isNull())
		return;
		
	Ogre::MaterialPtr artworkMaterialClone = artworkMaterial->clone(std::string("TempArtworkMaterial_") + objectNumber);
		
	Ogre::AliasTextureNamePairList artworkTextures;
	artworkTextures["ArtworkImage"] = artworkFilename;
	artworkMaterialClone->applyTextureAliases(artworkTextures);
			
	artworkMaterialClone->load();
Any thoughts anyone?
Thanks
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Cloned materials, texture aliases giving blackness

Post by masterfalcon »

Is there output in the log for both textures being loaded? What are their formats? Anything else in the log that seems strange?
pptech
Kobold
Posts: 37
Joined: Mon May 09, 2011 6:14 pm
x 1

Re: Cloned materials, texture aliases giving blackness

Post by pptech »

Sorry, I should have confirmed the log entries. Nothing strange in there, all the images appear to have loaded OK.

Code: Select all

Texture: 051L11002_5XJVS.jpg: Loading 1 faces(PF_B8G8R8,201x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 037L11002_5XJV2_looking_closely.jpg: Loading 1 faces(PF_B8G8R8,256x192x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 059L11002_5XJVW_reshot.jpg: Loading 1 faces(PF_B8G8R8,256x182x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 045L11002_5XJVT.jpg: Loading 1 faces(PF_B8G8R8,198x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 047L11002_5XJVY.jpg: Loading 1 faces(PF_B8G8R8,256x189x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 039L11002_5XJVZ_looking_closely.jpg: Loading 1 faces(PF_B8G8R8,183x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 041L11002_5XJXF.jpg: Loading 1 faces(PF_B8G8R8,189x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 015L11020_5XJXG.jpg: Loading 1 faces(PF_B8G8R8,150x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: 007L11020_5XJXB.jpg: Loading 1 faces(PF_B8G8R8,256x195x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
[/quote]
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Cloned materials, texture aliases giving blackness

Post by masterfalcon »

I can't see what could be going wrong here. Is this GL ES 1 or 2? Would you be able to put together a sample project to reproduce the issue?
pptech
Kobold
Posts: 37
Joined: Mon May 09, 2011 6:14 pm
x 1

Re: Cloned materials, texture aliases giving blackness

Post by pptech »

Thanks for taking a look. I'm running on 1.7.2 on an iPad so GL ES1. I'll try and put together a small example, it might help track down the problem if it's something I've done, which is always a possibility :roll:
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Cloned materials, texture aliases giving blackness

Post by masterfalcon »

I'm guessing that it's probably not something that you've done if the same code work on other platforms.
User avatar
ekt
Gremlin
Posts: 150
Joined: Thu Apr 01, 2004 5:55 pm
x 5

Re: Cloned materials, texture aliases giving blackness

Post by ekt »

didn't i read a similar issue where for iP* stuff, non power of 2 texture were a problem?
(above logs talks about 198x256 textures)
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Cloned materials, texture aliases giving blackness

Post by masterfalcon »

That thought popped in my head too. I thought that issue had been fixed but I honestly can't recall. They should be resized automatically, but it's possible that that is not functioning properly.
pptech
Kobold
Posts: 37
Joined: Mon May 09, 2011 6:14 pm
x 1

Re: Cloned materials, texture aliases giving blackness

Post by pptech »

Thanks for the suggestion but I have other textures that are non ^2 that are working OK when loaded via the normal mesh/material route in the same scene.
One thought I had was that these images may well have been produced on a Mac. I remember having some problems with jpegs before where they wouldn't load into Ogre but would in other applications. Does that ring any bells with anyone?
pptech
Kobold
Posts: 37
Joined: Mon May 09, 2011 6:14 pm
x 1

Re: Cloned materials, texture aliases giving blackness

Post by pptech »

I finally got chance to follow up on this issue and ekt you were right, when I resized one of the textures to be a power of two it worked. Oddly, using materials from existing Entities (with non-power of two textures) would also not work even though those materials work elsewhere in the scene. I can't believe that ManualObjects are handling materials differently from Entities but that's just the way it seems.

Does anyone know of an easy way to fix this power of two thing?

Thanks...