Tips

Assets

  • Export UAssets
    • Select asset(s) in the Content Browser
    • RMB click > Assets Actions > Export or Bulk Export
      • If we want to export a lot of assets it might be easier to do a bulk export.
    • Mesh
      • Select the destination folder
      • The filename will by default be the name of the asset.
      • Export options
        • LOD : we can choose to include the LODs (or only lod 0 if the Level of Detail is unchecked)
        • Collision
    • Texture
      • We can export textures as .exr (and som other formats if we export one at a time)

UI

  • Named Reroute
    • A named reroute is a good way to get rid of the spaghetti
    • Drag out from the output pin you want to use
    • Start typing “name…” select Add Named Reroute Declaration Node…
    • Give it a good name
    • To use the reroute, press tab and in the top under the Named Reroutes you will find the reroute node we just created
  • Selection
    • Box Select
      • Hold Ctrl + Alt + LMB clcik and drag
  • Tooltip
    • To delay the tooltip we can use:
      • Slate.TooltipSummonDelay to set the time until the tooltip is shown. The default is 0.15 sec.
      • Slate.EnableTooltips whith this you can remove the tooltips.
  • Bulk Edits
    • Select assets in the Content Browser
    • RMB click > Assets Actions > Bulk Edit via Property Matrix…
  • Expand/Collapse folders in World Outliner
    • Hold Shift while expanding / collapsing actors in the world outliner to affect all child items

Material Graph

  • Reroute
    • You can add a reroute node by double clicking the connection line
  • Debug nodes
    • You can use the debug nodes under Debug to visually debug values. Lets say that you want to view the object bounds you can connect the output of an Object Bounds node to an Debug Float 3 node.
    • Debug >
      • Debug Scalar Values
      • Debug Float 2 Values
      • Etc …
  • Material Attributes
    • If you want the result node of a material to be a material attribute:
      • Details > Material >
        • Use Material Attribute : On
  • Asset Editor Open Location
    • This controls where an asset editor will open (including plugins, editor settings, etc)
    • Edit > Editor Preferences > General > Appearance > User Interface >
      • Asset Editor Open Location:
        • Default
        • New Window
        • Main Window
        • etc

Blueprint

You can create your own data type to be used in a blueprint

  • Custom Data Types
    • Create a Structure asset
      • In the content browser, add a Structure asset
        • Blueprint > Structure, call it “F_my_struct”
    • Add varaibles to the struct
      • Double click the struct, and press Add Variable so that we have 2 variables
      • Name the first my_bool and set the datatype to Boolean
      • Name the first my_vector and set the datatype to Vector
      • Press save
    • Add a Blueprint
      • Lets add a blueprint so that we can test the struct
      • In the content browser, RMB click and choose Blueprint Class and choose Actor as parent class
      • Open up the blueprint and select the Construction script tab
      • In the left side Components panel click the + button in the Variables section.
      • Name the variable “test” and click the dropdown to the right to choose the data type
      • Start typing “F_my_s…” select F_my_struct
      • Add the variable to the graph by click and drag on the name and release in the graph, then choose Get…
      • Split the struct pin to expose the individual variables of your struct

Landscape

Quick Setup

  • Create a Level
    • Add lighting actors
  • Create a Landscape
    • Switch to Landscape Editing Mode
      • Shift + 2 (or use the mode dropdown)
    • Create new Landscape
      • In the landscape pane, make sure the Manage mode is selected and click the create button in the bottom left.
    • Do some sculpting
      • Make sure sculpt mode is active (in the landscape pane) and do some quick sculpting to get some shapes to work with
  • Create a Material
    • RMB click in the Content Browser > Add Material
      • Call it “M_Landscape”
      • Open the material in the material editor
    • Use Material Attributes
      • We are going to use material attributes in this material
      • Select the “M_landscape” result node (the only node that exists in the graph if the material was just created)
      • In the Details pane Material >
        • Use Material Attributes : Enable it
    • Add textures
      • We are going to create two material to blend between a “Grass” and a “Dirt” material
      • We are using megascans so find some nice textures
        • Drag in the base color and the normal map of the “Grass” and “Dirt” material respectively
      • We might want to change the Material Expression Texture Sample from “From Texture Asset” to “Shared: Wrap”
    • Add a Make Material Attributes node
      • press tab over an empty space in the graph and start typing “mate…“and select MakeMaterialAttributes from the list
      • With the “m"ake material attributes” node selected press Ctrl + D (since we need one for each material)
      • Connect the base color & normal of the textures to the corresponding input of the “make material attributes” node
    • Add a Landscape Layer Blend node
      • Press the tab and stat typing “land…” select “Landscape Layer Blend”
      • Add Layers
        • With the Layer Blend node selected…
        • in the details pane Material Expression Landscape Layer Blend > Layers…
        • Click the + icon 2 times to add 2 layers
        • Open the added layers rollout and call the first layer name “Grass” and the second “Dirt”
    • Connect Material Attributes to Layer blend
      • Connect the “grass” material attributes to the input of the layer blend we called “grass” and do the same for the “dirt”.
    • Connect Layer blend to result node
      • Connect the ouput of the layer balen to the input of the
    • Save the material
  • Assign the material
    • In the outliner select the landscape (Note we are still in the Landscape mode)
    • In the details > Landscape >
      • Landscape Material : assign the material we just created
    • Create Layer info
      • In the Landscape pane > Layers you will find the 2 layers we created in our material
      • On the first layer (which in our case is “Grass”) click the + on the right hand side of the layer
        • Select Weight-Blended Layer (normal)
        • Save the layer info in the proposed folder (or select where you want it)
        • Repeat this process for the “Dirt” layer

Runtime Virtual Textures

Setup runtime virtual textures

Lets setup virtual textures to blend the materials with the landscape.

  • Enable Virtual Textures
    • Project Settings > Engine > Rendering >
      • Virtual Textures >
        • Enable Virtual Texture Support : On
  • Note!
    • Virtual Textures also works with static meshes, not only on landscapes
    • Meercat Weta example is using that

  • Setup Runtime Virtual Textures
    • Create a folder
      • In the content browser create a folder where we will create our RVT
      • Call it RVT
    • Create Virtual Textures
      • Step in side the create folder, RMB click > Textures > Runtime Virtual Texture
        • Call the first on RVT_Height
        • Duplicate it (Ctrl + D) call it RVT_Material
      • Setup the RVT_Height
        • Open up the RVT_Height (double click it)
        • Size > Size of virtual texture in tiles : 10 (will result in 1024)
        • Layout > Virtual Texture Content : World Height
        • Save it
      • Setup the RVT_Material
        • Open up the RVT_Material (double click it)
        • Size > Size of virtual texture in tiles : 10 (will result in 1024)
        • Layout > Virtual Texture Content : Base Color, Normal, Roughness, Specular (default)
        • Save it
    • Add & setup Virtual Texture Volume
      • Add a Runtime Virtual Texture Volume (actor) to the level
        • call it “RVT_volume_height”
      • Set Virtual Texture
        • With added node selected in the world outliner, go to the details panel
        • In the property Virtual Texture use the drop down to select “RVT_Height”
          • (or drag and drop from the content browser)
      • Set Bounds Align Actor
        • In the property Transform From Bounds > Bounds Align Actor
          • Use the picker (pick actor from scene) and pick the landscape in the 3d view
          • Or use the drop down to select your landscape
        • Click Transform From Bounds > Set Bounds
          • This will setup the transform to encompass the landscape
      • Duplicate the Runtime Virtual Texture Volume
        • Select “RVT_volume_height” in the outliner
        • Duplicat it call it and call it “RVT_volume_material”
        • In the details panel set the Virtual Texture to “RVT_Material”

Setup landscape Material

  • Setup landscape material
    • We need to setup the material so that the RVT knows what to capture
    • Open up the landscape master material
    • Press tab and start typing “run…” and select “RuntimeVirtualTextureOutput”
    • Connect the outputs to the RuntimeVirtualTextureOutput
      • BaseColor
      • Specular
      • Roughness
    • Get the height information
      • Creat a Absolute World Position node
        • Press tab start typing “wo…” select “WorldPosition”
      • Component mask the Z channel
        • Press tab start typing “com…” select “ComponentMask”
        • Connect the output of the “WorldPosition” node to the input of the “Component mask”
        • On the component mask, enable the B (and disable R & B) since we only are interested in the Z (height value)
      • Connect the output of the component mask to the WorldHeight input of the RuntimeVirtualTextureOutput
    • Convert the Normal space
      • Convert space
        • The normal is in tangent space but the VT are expecting it to be in world space, so we need to convert it.
        • Press tab start typing “tra…” select Vector Ops > “Transform”
        • Make sure Source is “Tangent Space” (Default)
        • Make sure Destination is “World Space” (Default)
      • Connect the output of the transform vector node to the normal input of the RuntimeVirtualTextureOutput
  • Draw landscape in VT
    • Setup the landscape to draw in the virtual textures
      • Select the landscape in the outliner
      • In the details panel scroll to Virtual Textures
      • Click the + icon to add 2 items
      • Select the VT_Height & VT_Material respectively.
      • You should now se a small little preview of the VT on the thumbnail nect to the VT we just specified

Blend Material with Landscape

  • Create a simple Material to test the RVT blending
    • Add a material, give it a good name and step in
    • Select the result node of the material and in the details panel set it to Use Material Attributes
    • Set material attributes node
      • Press tab start typing “set…” select Material Attributes > SetMaterialAttributes
      • click the + button to add the channels that you need…
        • Base Color
        • Specular
        • Roughness
        • Normal
      • Add textures or use constants to add data to the material. This will be our test material that we will blend with the landscape using our RVT setup.
    • Blend attributes node
      • Press tab start typing “blendm…” select Material Attributes > BlendMaterialAttributes
      • Connect the output of the set material attributes node to the B input of the blend materials attributes node.

Get material from RVT

  • Get material from the RVT
    • Create a RVT sampler for the material data
      • Press tab start typing “vir…” select Virtual Texture > “RuntimeVirtualTextureSampleParameter”
        • We choose a parameter to be able to specify which VT we want to use
      • Call the parameter it “RVT Material”
      • Make sure that the parameter Virtual Texture > Virtual Texture Content is set to Base Color, Normal, specular, Roughness
    • Set material attributes from the RVT
      • Press tab start typing “set…” select Material Attributes > SetMaterialAttributes
      • click the + button to add the channels that you need…
      • Connect the Base Color, Specular, Roughness and normals from the RVT to the set material attributes node
    • Transform the normal
      • The normal data in the RVT is in world space but needs to be in tangent space.
      • Press tab amd start typing “tra…” select Transform
      • On the tranform node set:
        • Source to World Space
        • Destination to Tangent Space
      • Insert the transform between the RVT sample normal output and the normal input of the set material attributes node.
    • Connect output
      • Connect the output from the set materials attributes node with the A input of the blend materials attributes node

Get height from RVT

  • Create a mask from the height of the RVT
    • Sample the heigth of the RVT
      • We are going to control the blending using our RVT height information
      • Press tab start typing “vir…” select Virtual Texture > “RuntimeVirtualTextureSampleParameter”
        • We choose a parameter to be able to specify which RVT we want to use
      • Call the parameter it “RVT Height”
      • Make sure that the parameter Virtual Texture > Virtual Texture Content is set to World Height
    • Get the world positon of the material
      • Create an “Absolute World Position” node
        • Press tab start typing “wo…” select “WorldPosition”
      • Component mask the Z channel
        • Press tab start typing “com…” select “ComponentMask”
        • Connect the output of the “WorldPosition” node to the input of the “Component mask”
        • On the component mask, enable the B (and disable R & B) since we only are interested in the Z (height value)
    • Calculate where the mesh intersects the landscape
      • Subtract the world Height of the RVT from the world position of the material
        • Create a subtract node
          • press tab, type “-” (minus or dash) select Math > Subtract
        • Connect the output of the component to the “A” input of the subtract node
        • Connect the output of the “RuntimeVirtualTextureSampleParameter” to the “B” input of the subtract node
    • Control the mask blend start (factor in the scale of the mesh)
      • Theory
        • Here we will add a parm to control where the mesh will start to transition from the landscape material to the mesh material.
        • We will make sure that the height of the vt mask (that we will expose as a parameter) will be in relation to the size of the mesh. This means that if you have two instances of the same mesh and you set the scale of one of the mesh to double the size of the first, the “height” of the parameter on the material will “reach” the same “height” of the to meshes.
        • Steps
          • We will start of with the value that we calculated in the earlier step. (Subtract the RVT world height from the absolute world position of the material (of the pixel being shaded)) which will give us a position where the mesh intersects the landscape
          • To this we will add the “height” (z component) of the object bounds of the mesh. This will basically shift the “intesection value upwards” (to cover the entire mesh)
          • Then we will add a parm to let the user control the start of the blending.
          • We will then multiply this parm with the with the z component of the object bounds node…
          • …And subtract this from the height value
          • This means that it we enter a value of 2 to the parm the mask will start in the middle of the mesh no matter the size of the mesh.
      • Get the Z (height) bounds value
        • Create an Object Bounds node
          • Press tab and start typing “objectb…” select Vectors > ObjectBounds
          • This will give us the object bounds of the mesh that material is assigned to
        • Get the Z value
          • Press tab start typing “com…” select “ComponentMask”
          • Connect the output of the “Object Bounds” node to the input of the “Component mask”
          • On the component mask, enable the B (and disable R & B) since we only are interested in the Z (height value)
      • Add the Z value to height
        • Create and Add node
          • Hold “A” and LMB click the node graph
        • Connect the output of the subtract node to the A input
        • Connect the output of the component masked (Z) object bounds node to the B input
      • Create a parameter to control when the blend starts
        • Add a parameter node
          • Hold “S” and LMB click, call it “RVT Blend Height”
          • Set the default value to 1.05
        • Add a multiply node
          • Hold “M” and LMB click the node graph
          • Connect the output of the component masked (Z) object bounds node to the A input of the multiply node
          • Connect the output of the parameter to the B input of the multiply node
      • Subtract the parm value from height
        • Create a subtract node
          • Connect the output of the Add node we created earlier to the A input of the subtract node
          • Connect the output of the multiply node to the B input of the subtract node
    • Control the falloff (blur)
      • Add a parameter node
        • Hold “S” and LMB click, call it “RVT Blend Falloff”
        • Set the default value to 100
      • Create a divide node
        • press tab and type “/” select Math > Divide
        • Connect the output of the subtract node to the A input of the divide node
        • Connect the output of the “RVT Falloff” parameter node to the B input of the divide node
    • Clamp the values
      • Press tab and start typing “sa…” select Math > Saturate
      • connect the output of the divide node to the input of the saturate node

Remove landscape stretching

  • Remove the height texture stretching
    • Theory
      • The runtime virtual texture will be “projected” top down (z axis) so to avoid texture stretching on the blended texture of the mesh we can do the following setup.
      • What we will do is to get the vertex normals of the mesh, component mask the Z value and where the Z is pointing straigh up we will get white and down we eill get black. We can the use tis to mulktiply with to remove the stretching.
    • Get the Normal Z component
      • Add a vertex Normal node
        • Press tab and start typing ‘ver…’ select Coordinates > VertexNormalWS
      • Component mask the Z axis
        • Press tab start typing “com…” select “ComponentMask”
        • Connect the output of the “VertexNormalWS” node to the input of the “Component mask”
        • On the component mask, enable the B (and disable R & B) since we only are interested in the Z
    • Control the effect
      • Add a Parameter to control the effect
        • Hold S and LMB click
        • Call it “RVT Side Amount”
      • Multiply the Z component
        • Add a multiply node
          • Press M and LMB click
        • Connect the output of the component mask to the A input of the multiply node
        • Connect the output of the Parameter node to the B input of the multiply node
        • Add a saturate node to clamp the output
          • press tab start typing ‘sa…’ select Math > Saturate
          • connect the output of the multiply node to the input of the saturate node
    • Mask the RVT height value
      • Theory
        • We will multiply the RVT height mask with the output of what we created in this setup
        • Since the output of the RVT height is white on the top and black on the bottom. we will invert this, multiply it with the value we calculated in this setup, then invert it once agian, so that we can use it to mask the material.
      • Invert the RVT height mask value
        • Create a One Minus node
          • Press tab and start typing “1-…” select Math > OneMinus
        • The last node of the setup we did to calculate the RVT height mask is a saturate node.
          • Note not the saturate node we created in this section
        • Connect this saturate node to the input of the One Minus node
      • Multiply the inverted RVT height value
        • Create a Multiply node
          • Connect the output of the One MInus node to the A input of the Multiply node
          • Connect the output of the saturate node (the one we created in this set up, where we “Mask the height value”)
        • Create on more One Minus node
        • Connect the output of the Multiply node to the input of the One Minus node
      • The output of this One Minus will later be connected to the Alpha input of Blend Materials Attribute node, and will control the blending of the landscape material (comming from the material virtual texture) and the Megascan material applied to the mesh.
M_RVT_blend
Ctrl-C
Example of a material using RVT to blend with landscape

M_landscape
Ctrl-C
Example of a landscape material setup, very WIP
M_landscape_vt
Ctrl-C
Example of a landscape material setup with vt, very WIP
M_virtual_texture
Ctrl-C
Example of a VT setup, very WIP

Optimization

Stats

  • FPS
    • Ctrl + Shift + H