So I notice that SMaterial.setTexture takes an index, and a texture, so a material can have multiple textures. How do the polygons being drawn choose between the different textures they want to be drawn with?
And SomeMaterial has multiple textures set. S3DVertex only has core::vector2d< f32 > for the textures, i.e. the two texture coordinates, there is not any place to put information of which texture to use.
Then, is it possible to draw multiple triangles (/polygons) at the same time with different textures?
you can split a triangle list to two triangle list and use two different scennodes, or you can just do what i'm doing in SLWorldEditor and batch all textures in a unique texture file and select proper UV coordinates. You are awared that you need to add something like "corners" to each texture or sometimes you will see samples from the other texture.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Yeah thanks, I just thought of that once I had posted, that I should combine everything into one texture and use the coordinates. It's not slow to have a big texture like that, is it?
You are confusing what setTexture does in a material. Begin with what is a material. A material is a shader, a builtin shader that irrlicht uses to draw things. There are materials like EMT_SOLID, EMT_TRANSPARENT... that use only a single texture map, that stored in the slot 0. But there are others, the EMT_LIGHTMAP, EMT_NORMAL_MAP, EMT_REFLECTION... which need at least 2 texturemaps, the textures of the slot 0 and the slot 1. So, setTexture in a material tells the engine what textures to use on each slot.
Then, you have the "high end" materials, the shaders, which can make use of more of the available texture slots, for instance, to do shadowmapping, while you are doing normal mapping, while you are using reflections and so on, Those require more textures inside the same material.
On the other hand, we have the scene nodes. A Scene Node is a renderable thing, it has a mesh (most of the times...), and this mesh is composed of one or more meshbuffers, and here comes the good news. Each of these meshbuffers can have their own material, with their own textures, and their own settings. So a single mesh can have multiple textures, because each meshbuffer has its own material, and these materials can have their own textures.
But is slower to have multiple meshes, the least meshes, the faster, even if it has a large texture. Textures are sampled and cached very fast, so a large texture represents little burden during the render, It uses more memory, quite a lot more, but the rendering speed is, with mipmapping enabled, on average the same.
I hope this makes things a little more clear.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
If you need a very complex pattern of single triangles colored by a different texture it might still be faster to just use one larger texture and use only the (first) texture coord to choose from which texture part is used. This way, most of the work is off-loaded to the designer. But it makes rendering much faster, which is after all the higher priority.