Labels

Wednesday, April 9, 2014

UDK Landscapes Part 3: Using Weightmaps to Apply Your Landscape Materials


This is the third and final installment of the UDK Landscape trilogy. In the first two parts of this series, we created our height and weight maps using Terresculptor and then imported those maps into UDK. In this post we will show you how to apply materials to your landscape to make it look nice and pretty.

This one is relatively complicated if you aren't familiar with UDK's Material Editor, so I've made the instructions as detailed as possible.

(This tutorial begins immediately following the last step in Part 2)

1. Open your Content Browser, right click in the gray area between the various file thumbnails and select "New Material" from the options that populate.



2. Name your material and click OK.



3. In the Content Browser, double-click the brand new material you just made to open the Material Editor.



4. In the node editor viewport, right-click and select "New TerrainLayerWeight." Left-click on this node and press "CTRL + W" twice to create two duplicates.You can clean this up and move the individual nodes around by holding "CTRL" and dragging them with left-click.



5. Now, hold down "T" and left-click on an unoccupied space in the node viewport to create a new texture sample. Create three of these and position them next to your Terrain Layer Weights.



6. For each Texture Sample node, connect its black output into the "Layer" input of its neighboring Terrain Layer Weight. Next Connect each TerrainLayerWeight output into the "Base" input of the Terrain Layer Weight immediately below it. Connect the output of the bottom Terrain Layer Weight into the "Diffuse" input of your material. (Ignore the "missing input texture" error)



7. Change the "Parameter Name" of each of your layer weights by clicking them and editing their properties in the Properties menu below. [Again, as before when we imported the weightmaps, order them from the most steep slope to the least steep.] Make sure to name each the exact same name as used in the weightmaps you imported earlier. Set the "Preview Weight" value of each to "0.25."



8. Now you need to import the diffuse texture samples you plan to use for your terrain layers. a) Open the Content Browser and left-click to select the diffuse texture you plan to use for your top terrain layer. b) Back in your Material Editor, left-click to select the top Texture Sample Node. c) Click the green arrow under the properties of your texture sample to use the texture you selected in the Content Browser for this layer. The texture should now appear in the node inside your Material Editor. Do this for each of your layers.



9. Still in the Node Editor viewport, right click and under "Terrain," select the option to add "New TerrainLayerCoords." Create three of these nodes and plug each output into the "UV" input of the Texture Samples, as shown in the picture below. Under the properties of each, change the "Mapping Scale" value to "8" and the "Mapping Rotation" to "25." Click the green check mark button at the top left hand corner of your Material Editor to save your changes, then close the Material Editor window.



10. In the Content Browser, select the landscape material that we just finished editing and in your Editor viewport, double-click on your landscape to bring up the Landscape Properties menu. Under the "Landscape" tab in the properties menu, click the green arrow next to "Landscape Material" to apply your material. Depending on your landscape size, UDK will take a few (or several) seconds to load up your material onto your landscape.





11. In the Content Browser, double-click on your landscape material to again open the Material Editor (if you closed it). Hold Ctrl+Alt and left-click to drag a box around all of the nodes you have created so far. Once your nodes are selected, hold Ctrl and left-click to drag them upward to make room for new nodes. With all of the nodes still selected, press Ctrl+W to duplicate them. Position the duplicated nodes below the original ones. If you would like, you can label each group "Far" and "Close," respectively, by selecting all of the nodes in a group by holding Ctrl+Alt and left-clicking to drag and select each group of nodes, right click and choose "New Comment" in the menu and typing in the appropriate name for each.



12. Hold down the "L" key on your keyboard and left-click to create a "Lerp" node. Hold "Alt" and click to disconnect the "Far" group from your material's diffuse input. Now reconnect the nodes as shown in the picture below with the bottom layer weight of "Far" input in the Lerp's "A" input and the bottom layer weight of the "Close" input connected to the Lerp's "B" input. Connect the Lerp output to your material's diffuse input. Ignore the "Alpha" error, for now.



13. In all three of the TerrainCoords nodes in the "Close" group, change the value of the "Mapping Scale" from "12" to "5."



14. Now we need to add a texture for the "alpha" input of the Lerp. You can Google search alpha masks or even make your own in Photoshop or paint, but for simplicity search "mask" in your Content Browser and choose one of the black and white images that has a variety of both black and white dispersed across the whole texture. Drag and drop your selected alpha texture into your Material Editor. Right-click in the Material Editor and add a new TextureCoordinate (TexCoord)  node.



15. Change the Properties of your newly created TexCoord node's U and VTiling values from "1" to "8." Connect the TexCoord node's output to the alpha mask Texture Sample node's input and connect the black Texture Sample output into the Lerp's "Alpha" input node. Click the green check mark at the top left of the Material Editor to apply the changes.




And that's mostly it. Any other adjustments you need to make to your landscape from this point should be covered in PendantixUDK's tutorial series, especially this final touch-ups video here.

The new Unreal Engine 4 was released in the middle of me creating this tutorial (as I was making the landscape for my own project), so I stopped working on my UDK project and started porting everything over to UE4. I will post an updated version of this tutorial for Unreal Engine 4 soon.

No comments:

Post a Comment