'Apply material to mesh based on height
I have a randomly generated mesh with height from 0 to 20 and size of 100 by 100 And I want to do following to it.
If mesh height is from 0 to 7 apply material 1
If mesh height is from 5 to 15 apply material 2
If mesh height is from 13 to 20 apply material 3;
This problem has two parts:
- Applying material based on height of mesh.
- Blending material between heights 5 to 7 and 13 to 15.
I managed to achieve this in SRP by using a shader and textures instead of materials and using single material, however I am not a huge fan of it. Not to mention it doesn't work if I try to move to URP which is my goal.
Can someone suggest any resources how to apply material to mesh based on height? I have tired just doing meshRenderer.material = material; and that works, but it only applies one material. When I try to use all 3 materials by doing meshRenderer.materials = materials; it just seems to have some garbage generated, not to mention it is not height specific.
How can I achieve what I described above? Where can I learn more about materials, urp, and how to apply multiple materials to mesh and blend them?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
