Changing texture seems broken

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
robert82h
Gnoblar
Posts: 23
Joined: Thu Jun 13, 2013 5:41 pm
x 7

Changing texture seems broken

Post by robert82h »

Hi, it seems that changing a texture using setTexture() doesn't work on Android (and maybe in GLES2 in general). I opened a bug ticket for that (https://ogre3d.atlassian.net/browse/OGRE-222), but I'd like to hear from others if they had similar problems or if anybody managed to change the texture of a material on Android.

I'm changing the texture like this

Code: Select all

material->getTechnique(0)>getPass(0)>getTextureUnitState(0)->setTextureName("new_tex")
but the new texture is not applied, the material still renders using the old material.
robert82h
Gnoblar
Posts: 23
Joined: Thu Jun 13, 2013 5:41 pm
x 7

Re: Changing texture seems broken

Post by robert82h »

This doesn't seem to be specific to textures, other material properties are affected as well. For example, when changing the color using Technique::setDiffuse() or Pass::setDiffuse(), the material is rendered using the old values with the GLES2 backend. With the OpenGL render system, the changes take effect immediately.

I managed to find a different way to change the textures that works on both render systems: texture aliases. Calling TextureUnitState::setTextureAlias() changes the texture, however I cannot adjust any other material property like color this way.
User avatar
trilobite
Silver Sponsor
Silver Sponsor
Posts: 135
Joined: Thu Jul 13, 2006 9:16 pm
Location: San Juan Capistrano, CA, USA
x 1

Re: Changing texture seems broken

Post by trilobite »

This past week, I have been attempting to upgrade one of my Ogre 1.7 applications to Ogre 1.9.0. But I am starting to think that this is not a very good idea. This post is just about ONE of the several deal-killing problems I have been experiencing.

I am going to bump this thread since I am experiencing the same problem with Ogre ver. 1.9.0.
the code:

Code: Select all

mMaterial->getBestTechnique()->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
produced the expected effect in previous versions. But not in the current version.
Following the above code, I confirmed that the material reports that the name of the texture has changed to the new name.

Code: Select all

strTexture =mMaterial->getBestTechnique()->getPass(0)->getTextureUnitState(0)->getTextureName();
But the output in the scene has not.
I am using this code to change the texture of a simple billboard.

Code: Select all

mMoonBillboardSet->setMaterial(mMaterial);
No change on the scene. The texture displayed is at all times the texture listed in the *.material file.

If I have no filename listed in the texture_unit of my *.material file, and then set the texture name using the standard code above, then the billboard display is either black or some kind of weird visual artifact.
So, despite that the LIST is updated with the new texture names, this information is never passed on to the renderer.

The effect shows up with either the DirectX9 driver and the OpenGL driver.
the ->setTextureNameAlias() workaround produced no improvement.

And finally, there is no evidence that my shader code is executing. Here is some of my material code...

Code: Select all

fragment_program CaelumPhaseMoonFP cg
{
	source CaelumPhaseMoon.cg
	entry_point PhaseMoonFP
	profiles ps_2_0 arbfp1 fp30

	default_params
	{
		param_named phase float 0.3
	}
}

material CaelumPhaseMoon
{
    	receive_shadows off
    	technique 
    	{
        		pass Main
        		{
            			lighting off
            			depth_check off
            			depth_write off
            			fog_override true none
            			ambient 0 0 0
            			diffuse 0 0 0
			        scene_blend alpha_blend 
            
            			fragment_program_ref CaelumPhaseMoonFP
            			{
            			}

			texture_unit 
            			{
                			texture moon_disc.dds 2d
            			}
       		}
    	}

	technique
	{
		pass
		{
			lighting off
			depth_check off
			depth_write off
			scene_blend alpha_blend
			fog_override true none
			
			texture_unit MoonDisc
      	    		{
            				texture moon_disc.dds 2d
            			}
		}
	}
}
This, is an application that has been very solid for several Ogre generations. In short -- Ogre 1.9.0 seems to be borked real bad.
Anybody have ideas on how to fix this? Or has the API significantly changed such that old methods for changing textures on-the-fly have been replaced by new methods? Am I missing something really obvious?
I have spent several days searching for the magic combination. But no luck. Help.
Thanks.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: Changing texture seems broken

Post by Wolfmanfx »

Check my answer in the other thread - just disable RTSS to have the old OGRE behavior.
supadenz
Halfling
Posts: 41
Joined: Sat Feb 16, 2013 2:18 am
x 1

Re: Changing texture seems broken

Post by supadenz »

Don't you need to use RTSS on GLES2?