UE4 Intro To Materials - Page 12


Index



  1. Lets save the current level and double click to load Maps | BasicMaterials2.
Create new sprite with button

World Aligned Materials

What happens if I want a long stretch of brick wall that follows different shaped and placed geometries. It would take a lot of painstaking tweaking to align all the UV’s. There is a better way in unreal to use world coordinates to place the UVs.


  1. Now move the camera to Room 7 and press Build to set the lighting in the room.
Create new sprite with button

  1. Now add StaticMeshes | Supplied | Wall 400x400 and place them next to each other but offset. We want to have the bricks line up properly.
Create new sprite with button

  1. Assign M_Brick_Clay_Beveled to the new wall pieces. Move them and notice that we would have to zoom in to line up the bricks so the rows spread from one wall piece to another. We can solve this by using World Space then all the objects will align with the texuture automatically. Lets take a look.
Create new sprite with button

  1. Add a new Material called M_RockWS.
Create new sprite with button

  1. Open the material and add a Texture Sample node adding the T_Brick_Hewn_Stone_D texture:
Create new sprite with button

  1. Add a World Aligned Texture node to the graph:
Create new sprite with button

  1. Try to connect the two nodes. Woops we get an error:
Create new sprite with button

  1. Highlight over the input of the World Aligned Textured node and see that it wants a Texture Object. Add a Texture Object Parameter node and delete the Texture Sample node and call it WSRockDiffuse. Assign the T_Brick_Hewn_Stone_D texture
Create new sprite with button

  1. Now connect the output of the Texture Object and plug it into the input of the World Aligned Texture node:
Create new sprite with button

  1. Connect the XYZ Texture output of the World Aligned Texture node to Base Color in the main material node. Press the Apply button.
Create new sprite with button

  1. Select all the cube walls in Room 13. Assign M_RockWS to them. You should see that even though the rock textures are very small that they align based on world position.
Create new sprite with button

  1. Move a wall around and see the UVs adjust. Notice that it is using World Space to map the UV’s so they all line up based on where the material is located. So for something like a brick wall, the bricks will always align.
Create new sprite with button

  1. If we go back to the material and hover over the Texture Size node it states that it defaults it to world size of 64, 64, 64. UE4’s size is 1 unit per milimeter so 6.4 cm or 2.5 inches is not large enough.
Create new sprite with button

  1. Add a Constant Vector 3 node set to 128, 128, 128. This will effectively double the size. Connect the output to Texture Size on World Aligned Texture node. Press the Apply button.
Create new sprite with button

  1. Apply the change and look at it in game:
Create new sprite with button

  1. Add another Texture Object Parameter, name it WSRockNormal and assign the normal texture that goes with this diffuse:
Create new sprite with button

  1. Add a World Aligned Normal node. Connect the Vector 3 to the size to make the normal the same size as the diffuse. Connect the output of the Texture Object Normal to the input. Send the XYZ Texture output to the Normal input on the main material node.
Create new sprite with button

  1. Multiply a color you want to tint the texture in the diffuse:
Create new sprite with button

  1. Add a Scalar and set it to 1. Attach it to the Roughness node and press the Apply button.
Create new sprite with button

  1. Go into the game and move things around and enjoy your seemless textures:
Create new sprite with button

  1. That’s it for Room 7. Press Save All and update Github by committing and pushing all the changes made. Next up we will be animating the UV’s of a texture.
Create new sprite with button



<- Previous   Home    Continue ->