I have problem with Multi Material

I created a terrain with noise and wanted to change the material to the height of “y”.
I used BABYLON.MultiMaterial and the loop caught indices with “y” <1.5 as “WaterMaterial” else “StandardMaterial”

I get the error as pic attach. Does anyone have suggestions for me or give me examples to handle this problem?

We will need a repro in the Playground to be able to help

Thank you for the feedback this is my code
https://www.babylonjs-playground.com/#DSUF7F#2

I see no error in the console. What should I look at?

I tried to fix the error in my code on Playground that no longer shows the error but the grid and multi-materials don’t show up, I don’t know where the problem is anymore.

well the ground seems hidden in your pg:

After removing the following two lines of code I get the same error at the beginning
// matWater.addToRenderList(scene.getMeshByName(‘skyBox’));
// matWater.addToRenderList(scene.getMeshByName(‘ground’));

https://www.babylonjs-playground.com/#DSUF7F#4

You must have at least one mesh inside the render list of the water material or the texture will be incomplete.

So can I create many materials including water in a ground triangular grid?
Can you give me an example? Thank you very much

Sorry but I do not understand what you need :frowning:
Why not using separate meshes? like a plane for the water should be enough right?

I am trying to create an automatic, non-duplicated automatic map algorithm with the sea, rivers, lakes, mountains, … distributing plants according to the natural height. But the best way to create mountains is to change the height of the ground net, if connecting multiple ground with many overlapping materials will make it more difficult for me.

Did you check what I did here for worldmonger?
https://www.babylonjs.com/scenes/worldmonger/

Code here:Website/build/Scenes/WorldMonger at master · BabylonJS/Website · GitHub

1 Like

Great, this is what I’m looking for. What method did you use to create it? Can you share important points to consider when implementing it as well as the difficulties you encounter when making it?
I have looked into your code but probably because I have just started learning babylon, there is a lot of reading that I don’t understand
ex: how do you locate and increase the height and change the material?
ex: this._effect = engine.createEffect("./Source_Clone/water",
[“position”, “normal”, “uv”],
[“worldViewProjection”, “world”, “view”, “vLightPosition”, “vEyePosition”, “waterColor”, “vLevels”, “waveData”, “windMatrix”],
[“reflectionSampler”, “refractionSampler”, “bumpSampler”],
“”);

I have read Amit’s article from this page
http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
It inspired me to make a game with a realistic map and never overlap without human intervention. But I had difficulty in doing Amit’s theory conversion because of babylon’s ground made of triangular mesh.
Do you have any ideas to help me create Polygonal Map Generation or another way to create all of them with triangular mesh BABYLON?

I think the first step is probably to get the code and play with it. I create a Ground material which is a custom shader. Maybe you can read the shader code to better understand how it works

Other itneresting thing to consider:

Thank you so much for your suggestions. I will try, if I have any problems hope to continue to be of your help