Page Info
Skill Level:
Engine Version:

3. Blueprint Setup

With the render targets and needed Materials setup and ready to use, it is now time to bring everything together using a Blueprint. In the following section, we will go over how to setup all of the various parts of the Height Field Painter Blueprint.

Blueprint Creation & Variable Setup

  1. Right-click in the Content Browser and from the menu in the Create Basic Asset section, click on the Blueprint Class option.


  2. From the Pick Parent Class window, select Actor and name it HeightFieldPainter.


  3. Double-click on the HeightFieldPainter Blueprint to open it up and then click on the Event Graph tab. When the Event Graph is open, add the following variables.


    Variable Name Variable Type Default Value
    HeightfieldRT Texture Render Target 2D N/A
    PainterMaterialInstance Material Instance Dynamic N/A
    MouseDown Bool N/A
    ForceSplatMID Material Instance Dynamic N/A
    InteractionDistance Float 1000.0
    BrushSize Float 0.04
    BrushStrength Float 1.0

Components Setup

Inside of the Components tab, press the Add Component button and add a Static Mesh Component to the Blueprint. Once the Static Mesh Component has been added, select the Static Mesh Component and setup the following options.


Section Property Required Asset Value
Transform Mobility N/A Movable
Static Mesh Static Mesh SM_Plane1000_512 N/A
Materials Material HeightfieldPainterMaterial N/A
Collision Generate Overlap Events N/A Checked
Collision Collision Presets N/A OverlapOnlyPawn

Construction Script Setup

The Construction script is used to create and assign a 2D render target in addition to creating and assigning the required Dynamic Material Instances. If you arean't already there, click on the Construction Script tab and then copy the following code into your Blueprints Construction Script.

Copy Node Graph


Trace from Camera Function Setup

The Trace from Camera function will be used to determine the location on the Static Mesh that should have its height increased. It determines this location by casting a ray from the center of the player's camera into the world. When that ray intersects with a Static Mesh, the location that it intersects will be the location that is raised. To set up the Trace from Camera function, you will need to do the following.

  1. Click the small (white) plus sign on the Functions tab to create a new function and name it TraceFromCamera.


  2. Open the TraceFromCamera function and copy the following Blueprint code into your Blueprint by hovering your mouse over the image below and then clicking on the Copy Expression Graph option, selecting the code, copying it, and then pasting it into the TraceFromCamera function.

    Copy Node Graph


    Do not forget to Compile and Save your Blueprint so that it can be used.

Event Graph Setup

Now that all of the need parts have been created and setup, it is now time to connect all of the various parts together in the Event Graph. You can copy the completed Blueprint code into your Blueprint by hovering your mouse over the image below and then clicking on the Copy Node Graph option, copying-and-pasting the provided Blueprint code into your Height Field Painter Blueprint.

Copy Node Graph


When you copy-paste the Blueprint code, the Event Begin Play node will not be added to the graph. Make sure that you add the Event Begin Play node and connect it to the Enable Input input.


Now that the required Blueprints have been setup, in the next section we will go over how to use the height map painter inside UE4.