skip to Main Content

Generating Procedural Textures

In this post I’m going to show you how to create procedural textures inside the editor. While in the following example we will generate a 1024 x 1024 texture using random RGB values, the same approach can be used with different generation algorithms to achieve your goals. This post was written using 4.22 version of the engine so you may have to modify the following code in case you’re using a newer version.

The whole process takes place in a single c++ method (named GenerateTexture) that:

  1. Generates the asset file inside the editor
  2. Creates the pixel data
  3. Copies the pixel data to the file
  4. Saves the asset when the above steps are completed

In order to test the following code, I created a C++ class that inherits the actor class and then inside the BeginPlay function I called the GenerateTexture method:

Here are a couple of textures that were generated by the previous algorithm:

Avatar photo

This Post Has One Comment

  1. Thank you for taking the time to write these tutorials it is much appreciated.
    Line 31 the NewTexture->PlatformData->NumSlices = 1; statement throws an error on VS2019. Using Unreal engine 4.25, has NumSlices been deprecated? All I could find is PlatformData->SetNumSlices( 1 ); There is no property in Texture.h for NumSlices. Also did you create two different files for the Actor descendent and the ProcTexture classes? Could you clarify for me please.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top