texturing a wall or a floor

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mazataza
Posts: 17
Joined: Wed Jan 16, 2013 7:36 am
Location: Karlsruhe, Germany

texturing a wall or a floor

Post by mazataza »

I have a texture of size (254x254)pixel and i want to use it as a texture of a floor.
i added it to my floor node

Code: Select all

 
setMaterialTexture( 0,base_texture);
setMaterialType( video::EMT_SOLID );
 
the effect i got is that the texture is strech to fill the whole floor, which look bad. what i want that the floor will be filled with a repeated of this texture, so that looks like a floor.

should I dived my floor in smaller triangles or there is a trick which can be used?

my current floor for example has the size 1000x1000 units and to draw it i need only for vertex and 6 indeces.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: texturing a wall or a floor

Post by hendu »

To get it repeating without adding more vertices, you can use a shader.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: texturing a wall or a floor

Post by Mel »

Or you can set a scale in the texture matrix of the material.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
mazataza
Posts: 17
Joined: Wed Jan 16, 2013 7:36 am
Location: Karlsruhe, Germany

Re: texturing a wall or a floor

Post by mazataza »

I got the effect by using:

Code: Select all

 
SceneManager->getMeshManipulator()->makePlanarTextureMapping(Mesh, 0.02f);
 
I have not understand what it do, but the do the needed effect.
I don't want to use a shader because my game will be for mobile which may be have no shader.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: texturing a wall or a floor

Post by Mel »

It picks your mesh and applies it a planar texture map with that tile size expressed in world units. i.e, if it was 1, the texture tile would be 1 unit long.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: texturing a wall or a floor

Post by hybrid »

You could also directly set a higher texture coordinate when creating the mesh, in order to know what really happens inside the mesh. Simply set the UV values to 0;1000 when you now set 0;1 (or any other scale that fits). Check the attributes of the vertex elements of your mesh to find the proper places to alter
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: texturing a wall or a floor

Post by randomMesh »

mazataza wrote:I have a texture of size (254x254)pixel
Bad idea, you should use textures which are a power of two in width and height.
"Whoops..."
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: texturing a wall or a floor

Post by Cube_ »

I have to second that, scale it up by two pixels, no one will notice but it will be all that much more efficient.
"this is not the bottleneck you are looking for"
Post Reply