Please post links to articles or examples or explain it in 'lamense terms' for me if you don't mind
Multiple textures on one model.
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Multiple textures on one model.
I know this has been asked many many times before but I never really understood the answers. So how can I have multiple textures on a terrain, scene node, etc.
Please post links to articles or examples or explain it in 'lamense terms' for me if you don't mind
Please post links to articles or examples or explain it in 'lamense terms' for me if you don't mind
Well, a mesh can have only 1 texture (build out of up to 4 texture layers) !!!
If you look at a multi textured mesh you'll see that it is build out of many mesh buffers !!!
Each buffer is representing a single, one texture mesh !!!
You can iterate through the mesh buffers and get their textures by using meshbuffer->getMaterial()->Texture1 to Texture4 (the 4 texture layers)...
But I don't know how to do this with a terrain scene node !?!?!
If you look at a multi textured mesh you'll see that it is build out of many mesh buffers !!!
Each buffer is representing a single, one texture mesh !!!
You can iterate through the mesh buffers and get their textures by using meshbuffer->getMaterial()->Texture1 to Texture4 (the 4 texture layers)...
But I don't know how to do this with a terrain scene node !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
the vertex data needs to have texture coordinates for each stage, or number of textures on a single mesh buffer. For example, the reason detail mapping works with terrain, is because terrain uses S3DVertex2TCoords vertices.
You can get around this, at least in DirectX, by setting up the other ( 1-3)TextureStageStates to use the texture coords from texture stage 0. Not sure if it's possible in OpenGL to do that.
Terrain already supports 2 textures. Most meshes are loaded into the standard S3DVertex vertex format and only have 1 texture coordinate. I'm not sure if Irrlicht added it, but I posted somewhere on this forum, a function to convert a mesh from S3DVertex to S3DVertex2TCoords, and posted some screenshots with the sydney.md2 model with detail mapping.
If you need that function again, I can provide it for you( or IrrSpintz has it if you want to download that source and merge it into your custom Irrlicht ). Or, you could just write a custom function to do that, without modifying the Irrlicht source.
You can get around this, at least in DirectX, by setting up the other ( 1-3)TextureStageStates to use the texture coords from texture stage 0. Not sure if it's possible in OpenGL to do that.
Terrain already supports 2 textures. Most meshes are loaded into the standard S3DVertex vertex format and only have 1 texture coordinate. I'm not sure if Irrlicht added it, but I posted somewhere on this forum, a function to convert a mesh from S3DVertex to S3DVertex2TCoords, and posted some screenshots with the sydney.md2 model with detail mapping.
If you need that function again, I can provide it for you( or IrrSpintz has it if you want to download that source and merge it into your custom Irrlicht ). Or, you could just write a custom function to do that, without modifying the Irrlicht source.

-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
I could never get IrrSprintz to compile, but here are some screenies of what happens when you use two different textures on the same cube node. in different layers.
layer 0, before adding in layer 1

and after adding in layer 1.

If I use the same texture for layer one as in layer 0 it gives the same bland look.
But still, neither of the textures are visible, and texture in layer one is just a darker version of the texture in layer 0. (in case thats important).
layer 0, before adding in layer 1

and after adding in layer 1.

If I use the same texture for layer one as in layer 0 it gives the same bland look.
But still, neither of the textures are visible, and texture in layer one is just a darker version of the texture in layer 0. (in case thats important).
maybe I misunderstood something, but didn't you read my post ???
the texture layers have nothing to do with multi texturing !!!
They all affect just one texture by mixing the graphics several ways !!!
Have a look at the water scene node, the 1st layer (0) represents the ground and the 2nd layer (1) represents the water surface !!!
Or is this what you mean by multi texturing !?!?!
the texture layers have nothing to do with multi texturing !!!
They all affect just one texture by mixing the graphics several ways !!!
Have a look at the water scene node, the 1st layer (0) represents the ground and the 2nd layer (1) represents the water surface !!!
Or is this what you mean by multi texturing !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
hmm, but not by using the texture layers !!!
Once again: the 4 t.layers are building one texture by mixing the layers !!!
If you need more than one texture the mesh the node is build from must contain different mesh buffers (for each texture one mesh buffer).
I don't really know, but AFAIK the terrain scene node uses just one mesh buffer so it can only have one texture !!!
The 4 texture layers have nothing to do with multi texturing !!!
For example have a look inside a multi textured .x file !!!
for each texture there is a single mesh buffer (called frames in .x files)...
Or let's say you have a mesh with 5 textures, how would you change the 5th texture, since there are just 4 layers ???
Once again: the 4 t.layers are building one texture by mixing the layers !!!
If you need more than one texture the mesh the node is build from must contain different mesh buffers (for each texture one mesh buffer).
I don't really know, but AFAIK the terrain scene node uses just one mesh buffer so it can only have one texture !!!
The 4 texture layers have nothing to do with multi texturing !!!
For example have a look inside a multi textured .x file !!!
for each texture there is a single mesh buffer (called frames in .x files)...
Or let's say you have a mesh with 5 textures, how would you change the 5th texture, since there are just 4 layers ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
I'm not trying to add confusion here, but texture layers have everything to do with multitexture. Multitexture is applying/blending multiple textures to a single primitive simultaneously. If you are using multiple texture stages/layers in Irrlicht, you are most definitely using multitexture. The textures for each stage are blended together.
If you are applying one texture to one set of vertices [a single mesh buffer] and a different texture to another set of vertices [another mesh buffer], then this is not multitexturing.
If you are applying one texture to one set of vertices [a single mesh buffer] and a different texture to another set of vertices [another mesh buffer], then this is not multitexturing.
Well, I see, it's a question of definition the word multitexturing...
that's what I meant by "maybe I misunderstood" earlier...
You're right, even if I have only one mesh buffer and using more than one texture layer of it, there are multiple textures, so you can call it multi texturing...
But also if I have a mesh with a texture on a part of it (for example the head) and another texture on another part of it (for example the body), it's multi texturing, isn't it ???
So, in fact there is now the question, what exactly was asked for ???
that's what I meant by "maybe I misunderstood" earlier...
You're right, even if I have only one mesh buffer and using more than one texture layer of it, there are multiple textures, so you can call it multi texturing...
But also if I have a mesh with a texture on a part of it (for example the head) and another texture on another part of it (for example the body), it's multi texturing, isn't it ???
So, in fact there is now the question, what exactly was asked for ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
ahh, alpha blending would be interesting, too !!!
But I never did this and have no clue how to (yet)...
@monke: every mesh has functions t access the buffers:
and every mesh buffer has a function to access the material:
If you finally got the material of a buffer you have access to its texture layers colors...
You should have a look at the doku for this...
But I never did this and have no clue how to (yet)...
@monke: every mesh has functions t access the buffers:
Code: Select all
mesh->getMeshBufferCount();
mesh->getMeshBuffer();Code: Select all
buffer->getMaterial();You should have a look at the doku for this...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:

