How to paint landscapes with multiple textures/materials. Credits go to CodeLikeMe for teaching me this.
- Firstly, create a new Landscape. For this tutorial, it doesn’t matter how large it is.
- Now in your content browser. Create a new folder and call it landscape. We will store our landscape materials.
- I have mine like this: Content > Geometry > _Materials > Landscape.
- Open it and create new material and call it M_Landscape.
- The prefix ‘M’ for material
- Click the output node (see the image, below how it looks)
- Under the Material section, tick the box “Use Material Attributes” (see the image, below how it looks)
- Near the output node, right-click and type in “Landscape Layer Blend”
- Click the node and under the section “Material Expression Landscape Layer Blend,”
- Press the ‘+’ three times to create three array elements
- Open each array element (click the ‘>’) and change the Layer Name to L1, then L2, and so on…
- The 0th index of the array will have a Preview Weight of 1
- This will be the default brush
- Get out of the material window, in the same folder as the M_Landscape, right-click, and create a Material Function
- It’s under the Materials & Textures tab
- Call it MF_Layer
- The prefix ‘MF’ for Material Function
- Open MF_Layer
- Right-click, type in “Input”
- Click the Input Node and rename it to Base color
- From the output end, type “MakeMaterialAttributes”
- It should be connected to Base color
- The OUT on the MakeMaterialAttributes node should be connected the Output Result
- Open and Minimize/Drag to another monitor the M_Landscape material
- Drag the MF_Layer into the M_landscape material editor
- You should have something that looks like this:
- Connect each MF_Layer to a Vector Parameter
- To create a vector parameter right-click the editor and type “Vector parameter”
- Rename each Param to L1 Color, L2 Color, and so on
- Double click the black box in each Param and choose a color
- Here’s what I have:
- Apply and save the material and close it
- Now right click M_Landscape and create a material instance
- Call it MI_Landscape
- The prefix ‘MI’ stands for Material Instance
- Why are we doing this?
- Material Instances of other materials allow us to edit materials non-destructively and without recompiling the material
- Click your landscape and in the Details tab, click “Landscape”
- Assign the Landscape Material to MI_Landscape
- Go to Landscape Mode and click “Paint”
- Scroll down to target Layers and click the plus Icon
- Select Weight-Blended Layer
- Allow it to have the default folder directory
- Repeat till all the Layers have it
- You should now be able to color your landscape. This should work similarly for materials.