materials and or textures per node

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.
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

materials and or textures per node

Post by Papa Lazarou »

Can somebody explain to me how materials and textures work with eachother? In relation to 'per node'.
I understand there is a max 4 of one or the other. But are materials textures plus other settings, or what ?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah materials are textures (if you like) plus other things like whether it should be rendered in wireframe, has depth testing/writing enabled etc.
Image Image Image
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

How do i give a node a new material?
Is the max number of materials per node 4?
And why is it possible to load more than one texture into a material?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can have more than one texture per material because you can have layers of textures, you can have a reflection layer on top of a solid layer, so maybe you have a bus model which has the bus' texture as one layer and then a reflection of the surrounding environment as another layer.

Or there's the terrain node which has a texture layer for the colour of the terrain and also a detail texture layer which gives the terrain more details.

I don't think the max number of materials per node is 4.... you can have one material per mesh buffer (if indeed you are using mesh buffers in the node).

You can look through a number of the tutorials that you downloaded with the SDK to learn about how materials work.
Image Image Image
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Materials are NOT textures! in Irrlicht terminology. Material is set of attributes which are used to draw geometry on to screen or other target. One of the material attributes is texture ...up to 4 can exist per material. How textures are rendered is specified by material type. Material can exist without texture too.

To learn more look at SMaterial class in API.
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

why does the getMaterial() function of a node require an index then?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Because a node can have multiple materials, partly being due to the fact it can be made up of multiple mesh buffers which will all have their own material each.
Image Image Image
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

ok :) Is there an example somewhere of a node that is made up of multiple meshes? Or does one of the tutorials show that?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

when you load a model that has more than one texture for it then you'll end up with a node that is comprised of more than one mesh buffer, at least one mesh buffer per texture.

the dwarf model has 2 textures so whenever that's loaded you've got an example right there.
Image Image Image
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

don't you mean materials, not textures?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The textures end up equating to materials but what i said remains true.
Image Image Image
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

I don't understand.
The mesh in the buffer would be the dwarf mesh right?
Why would that mean more than one?
If the dwarf model has more than one texture, why does that mean it has more than one material?

By the way, blender fails to open the dwarf.x model.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

There is no way material can use more than one texture in one layer (textures in different layers are rendered differently based on material type ...they can blend in to each other for example or get ignored altogether). Thats why each group of geometry which is using its own texture end up having its own material (this is already done in your modeling ap) and its own mesh buffer (which is done in Irrlicht).

Structure of basic mesh scene node in Irrlicht looks like this:

Node contain one mesh among some other attributes like position.
Mesh consist of minimum one mesh buffer (in case of dwarf its two).
Mesh buffer contain one material among other things like vertices and indices.
Material can contain between 0-4 textures in 4 layers among other attributes like color or shininess.

Geometry in Irrlicht is rendered using mesh buffers. Means if node contain more than one mesh buffer, they are rendered one by one ...each using its material.
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

Post by Papa Lazarou »

ok, how do i differentiate between the loaded meshes (buffer) in a mesh node. If there was more than one.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

to see the dwarf model you can run the meshviewer example, it's the model that gets loaded when you open it. If you want the original version (with more animations) you can get it from psionic3d.

to explain a bit further about the dwarf...

It's made up of two meshes basically, there's the dwarf's body and there's the axe. Each of these has its own texture and when you tell your gfx card to draw some vertices you can only specify one base layer texture, so the dwarf and his axe have to be drawn seperately and so are put into seperate mesh buffers so this can be done.

I'm sure this doesn't really explain it fully... i can see where you're getting confused about the materials and textures but i can't really think of how better to explain it!
Image Image Image
Post Reply