Introduction to the Texture2DGenerator asset
The Material generator plugin allows you to create a new type of asset : Texture2DGenerator in Blueprint section.
This asset is our generator. Like blueprints, we will edit it and add blueprint nodes.
Edit this empty asset by double-clicking on it or right-click>Edit Texture2DGenerator
This blueprint-like asset always contains only one event: OnRunTexture2DGenerator
Add functions linked to this event to create our material generation code.
Also check class default variables which contains
- Texture Width: the width size of the output textures (diffuse, normal, etc…)
- Texture Height: the height size of the output textures
- Tileable: if this flag is enabled the texture will be generated to be seamless. Sometimes you can prefer to disable this flag, especially if you don’t want to tile the texture on a mesh.
Creating a material
In order to create our first material, just add a single noise and link it to a GenerateMaterial node such as GenerateFlatMaterial.
On GenerateMaterial nodes, only the DiffuseMapModule is compulsory. If other modules are empty, they are automatically determined using the DiffuseMapModule.
Now, we can run the generation by right-clicking on the asset>Run Texture2DGenerator.
At the end of the execution, the material and its maps are generated. You can set the material to a mesh to preview changes.
If you edit the generated material:
And you can use the material instance to tweak parameters: