Apply materials to faces

Hi everybody,

I want to apply multiple textures to a polygon.

I tried with this example (simplified) :

the problem is that there is only one material for the front AND the back of the wall.

I want to be able to click on the front, choose a material and change it, click on the back and do the same thing.

What can i use ? multimaterials ? submeshes ?

thanks in advance,

Boris

Heya, you can use sub meshes and multi materials to apply a different material to each side. Like this for example. :slight_smile:

2 Likes

Ok, thanks for your answer, i will use submeshes aned multi mterials.

I don’t understand exactly how submeshes work. It is not really clear in the documentation with the example of the sphere.

In my playground, i want to apply a texture to a box from the front to the middle and another from the middle to the back (the box is divided in two equal parts).

I don’t know how to count the indices to do that.

If you could help me…

Okay so there’s a few problems with the box in the PG. One is that the index count of 36 is wrong for the second sub mesh. If you want each sub mesh to have half of the mesh’s indices then each sub mesh should have 18 indices like this PG.

But the next, bigger problem is that what you describe isn’t possible with a normal box mesh. You could re-order the indices to include whichever faces you want for each sub mesh. But each face is made up of two triangles which split the face in half diagonally. You would need twice as many triangles to split each face in half horizontally or vertically, which could be achieved with a custom mesh for example.

PS it might be easier to create the mesh in a DCC tool like Blender… :slight_smile:

And if i merge two boxes with two different materials, do you think it will work ?

See https://playground.babylonjs.com#INZ0Z0#59

from

scroll down to with merged meshes.

1 Like

That’s a good, much simpler idea. I think that would work well although I guess there would be two extra faces. :slight_smile:

2 Likes