Write Text to Texture : Mipmap problems

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Write Text to Texture : Mipmap problems

Post by Klaim »

Hello,

i'm using Eihort 1.4.0, i'll update to the next version once i resolve this problem :

I'm displaying some texts on a texture that is used in the material of a multiple quads mesh.
I write on the texture using this code snipet (that i just updated on the wiki, please check if my modification did'nt change anything but i doubt about that).


Here is the code initializing the texture content :

Code: Select all

//.....
		m_texture = TextureManager::getSingleton().createManual(textureName,"NetRush",TEX_TYPE_2D, 1024, 1024, MIP_UNLIMITED , PF_X8R8G8B8, TU_DYNAMIC_WRITE_ONLY_DISCARDABLE | TU_AUTOMIPMAP);
		
		//Draw the background to the new texture
		m_texture->getBuffer( )->blit( m_backgroundTexture->getBuffer( ));
		
/// some temporary texts
		std::wstring text( L"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris ac mi auctor turpis nonummy tempus. Praesent arcu. Sed vestibulum sapien ac justo. Etiam viverra elit et tortor. Vivamus et lectus ut eros consectetuer condimentum. Donec ullamcorper posuere." );
		for( int i = 0; i < 48 ; ++i)
			text += L"\n> The NetRush Reloaded!! 01001 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		//write the test texts on the texture
		WriteTextToTexture( text ,m_texture,Image::Box(0,0,1024,1024),m_font.getPointer(),ColourValue(1.0,1.0,1.0,1.0),'l');
		
				
		// Create the material :
		std::string materialName ( "QuadMat_" + getName() );
		m_material = Ogre::MaterialManager::getSingleton().create( materialName , "NetRush");
		m_material->setSceneBlending( Ogre::SBT_TRANSPARENT_COLOUR );
		TextureUnitState* texUnit =  m_material->getTechnique(0)->getPass(0)->createTextureUnitState( textureName );
		

		// create the entity (from scratch) for this display 
		//m_graphicData = new Ogre::Entity( "CQuad_" + m_name, static_cast< ConsoleDisplayFactory* >(m_type)->getConsoleDisplayMesh()  );
		m_graphicData = scene->createEntity( "ConsoleDisplay_" + getName(), static_cast< ConsoleDisplayFactory* >(getType())->getConsoleDisplayMesh()->getName()  );
		m_graphicData->setVisible( true );
		m_graphicData->setMaterialName( materialName );
		
This works perfectly. I had some problems for updating the mipmaps but adding the automipmap flags on the texture creation did the job.

Image

Now i have another function that is called each time i press a key and that display another text on the same texture. Here is the code :

Code: Select all

// build the text to display...
//...

// draw the background
		m_texture->getBuffer( )->blit( m_backgroundTexture->getBuffer( ));

		// write the result text to the texture (in white)
		
		WriteTextToTexture( textToDisplay ,m_texture,Ogre::Image::Box(0,0,1024,1024), m_font.getPointer(), Ogre::ColourValue(1.0,1.0,1.0,1.0),'l');
Image

But it seem that only the mipmap 0 is updated...

I tried to call WriteTextToTexture two times in the initilization function with two different texts and there is the same problem.

I don't understand why it works the first time and not the other ones. I tried to call material->touch() and material->compile() to make it update the texture mipmaps but it don't seem to work.


Any idea?
User avatar
independentCreations
Greenskin
Posts: 121
Joined: Sat Jan 07, 2006 7:30 am
Location: Gold Coast - Australia

Post by independentCreations »

do you really need mip maps for this texture? maybe u could do with out?
Final Creations - Tech Leader For 'The Broken'
v2i - Tech Leader For Architectual Sim.
Ogre Enthusiast
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

I'm not sure if i'll keep mipmaping in the end for this texture, but it's not the problem : it should work with mip mapping. It works the first time, why not the other times?
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

As the prerformances are verry poor i'll change the technique to display the text .

Anyway i don't understand this mipmapping problem. It could reaveal a problem in the texture automipmap generation but i can't find the bug.

No idea?
User avatar
nebukadnezzar
Halfling
Posts: 93
Joined: Sun Jun 11, 2006 4:40 pm
Location: Germany
x 1
Contact:

Post by nebukadnezzar »

yes the performance is poor...
since it copies pixel by pixel...

so could gain more performance by using overlays or may be you want to stick with BetaCairo...
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

Not if it don't let you display changing texts in 3D and don't let you apply shaders on the display mesh ;)
DarkStar
Gnoblar
Posts: 20
Joined: Tue Sep 04, 2007 11:24 am

Post by DarkStar »

Hi all,

I run into the same mipmap problem. Blitting to a texture or doing some pixel by pixel changes in a texture with mipmaps only takes place in mipmap 0. My hardware has no hardware mipmap generation

Code: Select all

13:26:53: RenderSystem capabilities
13:26:53: -------------------------
13:26:53:  * Hardware generation of mipmaps: no
Ogre generates them in software during startup and uses them correctly for rendering the scene.

Code: Select all

13:26:56: Texture: exit.png: Loading 1 faces(PF_A8R8G8B8,128x128x1) with 7 generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x128x1.
Till now I have not found a way to let Ogre recalculate the mipmaps. I did it once at startup, so there should be a function to do it again ...

Any ideas?

regards
Elin
Gnoblar
Posts: 1
Joined: Wed Dec 03, 2008 11:04 am

Post by Elin »

I have tried this piece of code to put text on a sphere, but all I get is that the sphere turn black.

I am new at using ogre, and I am not that familiar with c++, so I can't find the problem, please help?

Code: Select all

Font* font = (Font*) FontManager::getSingleton().getByName("StarWars").getPointer();
TexturePtr texture = TextureManager::getSingleton().createManual("WriteTexture",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,TEX_TYPE_2D, 512, 512, MIP_UNLIMITED , PF_X8R8G8B8, TU_STATIC|TU_AUTOMIPMAP);
writeToTexture("hello world",texture,Image::Box(25,275,370,500),font,ColourValue(1.0,1.0,1.0,1.0),'c', true);
MaterialPtr mat = MaterialManager::getSingleton().create("SphereMat", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  TextureUnitState* t = mat->getTechnique(0)->getPass(0)->createTextureUnitState("WriteTexture");
  
sphereEntity->setMaterialName("SphereMat");
is where I try to put the texture onto the sphere. I don't want to blend the text onto an existing texture, is that why this goes wrong?
Post Reply