Creating Textures Using Blueprints and Render Targets

When creating Textures for your Unreal Engine 4 (UE4) project, you will generally need to use an external 2D painting program like Adobe Photoshop or GIMP. While authoring content in this manner can give you amazing results, there are some instances where having the ability to create content like this inside of UE4 would be helpful. In the following How - To, we will take a look at how you can use Blueprints and render targets to create Textures for your UE4 projects by first creating a new empty level in a UE4 project and then creating and setting up the render targets for use.

1 - Project Setup

Before we get started, there are a couple assets that we'll need to create as part of our project setup.

Create a New Empty Level

Creating a new Empty Level to place your Texture creation Blueprint in will make things easier to manage, ensuring that nothing else is affecting your Texture creation process. To create a new Empty Level inside of UE4, you will need to do the following:

  1. From the Main Toolbar, go to File > New Level.

  2. From the New Level window that is displayed, click on the Empty Level option.

  3. After clicking on the Empty Level option, UE4 will load a new level that has nothing inside of it. Once that has happened, save the level by clicking on the Save button on the Main Toolbar, naming it BlueprintTextureCreation.

With the level now created and saved in the next section we will go over creating and setting up the required assets.

2 - Required Asset Creation & Setup

Before we can create the Height Field Painter Blueprint, we will need to create and setup the following asset types inside of the UE4 Content Browser. In the following sections, we will go over how each of the assets needs to be setup as well as any special properties that you will need to be aware of.

Please note that the following is not specific to any UE4 project type. The following can be accomplished in any project that uses UE4 version 4.13 or later.

  • Render Target

  • Material

  • Blueprint (Based off Actor)

Render Target Creation & Setup

  1. Right-click inside of the Content Browser and from the displayed menu, go to Create Advanced Asset > Materials & Textures and then select the Render Target option.

  2. Name the newly created Render Target, RT_Height_Filed_Painter, and then press the Save All button to save your work.

Material Creation & Setup

  1. Right-click inside of the Content Browser and from the Create Basic Asset list, select the Material option to create a new Material, naming it MAT_HeighfieldPainter.
  2. Select the MAT_HeightfieldPainter Material in the Content Browser and then right-click on it. From the displayed menu, under the Common section, select the Duplicate option to create a copy of the Material, naming it MAT_ForceSplat.
  3. Double-click on the MAT_HeighfieldPainter Material to open it up and then select the Main Material Node. In the Details panel under the Material section, setup the following parameters.
    • Shading Model: Unlit
  4. The MAT_HeighfieldPainter Material is going to use the World Position Offset input to increase the Z-height of the Static Mesh vertices it is applied to. You can copy it into your Material by hovering your mouse over the image below and then clicking on the Copy Expression Graph option, copying-and-pasting the provided Material code into MAT_HeighfieldPainter.
    Copy Expression Graph
    Do not forget to Apply and Save your Material so that it can be used.
  5. Open up the MAT_ForceSplat Material and then select the Main Material Node. In the Details panel under the Material section set up the following parameters.
    • Blend Mode: Additive
    • Shading Model: Unlit
    • Allow Negative Emissive Color: Checked
  6. Since the MAT_ForceSplat Material is going to act as our paint brush for raising the surface of our height field, it will need to have a few options that will allow you to control its size and intensity. You can copy the completed Material into your Material by hovering your mouse over the image below and then clicking on the Copy Expression Graph option, copying-and-pasting the provided Material code into MAT_ForceSplat.
    Copy Expression Graph
    Do not forget to Apply and Save your Material when done so that it can be used.

With the required assets now setup, in the next section, we will take a look at creating a Blueprint that will link all of the assets together to create the height map painter.

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 & Setup

To create a Blueprint that will work with both render targets and Materials, you will need to do the following.

  1. Right-click in the Content Browser and from the menu that is displayed in the Create Basic Asset section, select the Blueprint option to create a new Blueprint.

  2. From the Pick Parent Class window, select the Actor class and then name the Blueprint BP_Texture_Creator.

  3. Double-click on the BP_Texture_Creator Blueprint to open it up and once opened, click on the Event Graph tab to open up the Event Graph.

  4. Add the following Blueprint nodes to the Event Graph:

    • Custom Event

    • Draw Material to Render Target

  5. Select the Custom Event node and press F2 so that you can rename the Custom Event node to Bake. Then, connect it's output to the input of the Draw Material to Render Target node.

  6. Next, on the Draw Material to Render Target node, load the render target that was created previously into the Texture Render Target slot by clicking on the small white triangle next to Select Asset, and then from the list, find the render target RT_00 and select it by clicking on it. Once that is completed, do the same for the Material section, selecting RT_Material_00.

  7. Now, click on the Construction Script tab and drag off the Construction Script node to display the Executable actions menu.

    Please note that DrawMaterialToRenderTarget will not work in Construction scripts outside of the UE4 editor which means if you are trying to do this at runtime it will not work.

  8. From this menu locate the Bake event that was created by inputting Bake into the search box and once found, click on it to add it to the graph and then connect the output of the Construction Script to the input on the Bake node.

  9. Finally, press the Compile and Save buttons to compile and save your Blueprint.

Now that the Blueprint has been setup, in the next section, we will take a look at how you capture and save a Texture that displays what was created in the Material.

4 - Texture Creation & End Result

In this section, we will take a look at how to bring all parts of this how to together so that we can create and save Texture assets based on the Material that was created.

Texture Creation

Now that all of the required parts have been created and set up, we will take a look at how to create and save the Textures that are created.

  1. Locate the BP_Texture_Creator Blueprint in the Content Browser, dragging it into the level.

  2. Locate the RT_Material_00 Material in the Content Browser and double-click on it to open it up. When opened, select the Noise Material Expression node.

  3. With the Noise Material Expression selected, go to the Details panel and input the following values into their respective parameters. When completed, press the Apply button to compile the Material.

    • Scale: 2.0

    • Levels: 8.0

    • Output Min: -0.01

    • Level Scale: 3.0

  4. Select the BP_Texture_Creator Blueprint that was placed in the level and move it slightly in any direction to update the RT_00 render target that is in the Content Browser. When you do this, you should see the RT_00 render target update and display exactly what was in the RT_Material_00.

    Anytime you want to see or update the changes that were made in the Material, you will need to [slightly] move the Blueprint.

  5. Inside of the Content Browser, right-click on the RT_00 render target and in the Render Targets Actions section of the menu, select the Create Static Texture option to create a new Texture asset that will display the output of RT_Material_00.

End Result

When completed, you should have a new 2D Texture that will display the contents of RT_Material_00 that is now ready to be used in any other Material of your liking.

Remember that in order to see your changes you will need to make sure that you compile your Material and [slightly] move your Blueprint so that your changes will be propagated to your render target.