Unreal Engine
Not validated
The Unreal materials under engine/unreal/ are built by a Python editor script written from the Unreal Engine 5 documentation. It has never been run in Unreal (roadmap unreal-materials, in validation). Several Python calls are from memory of the API; the script prints a warning and goes on when one fails. The checklist of what to look at first is the "Not validated" section of engine/unreal/README.md.
Which format
Use FBX. It carries every LOD (<name>_LOD0, _LOD1…), the bark and leaf materials, the texture files beside it, the wind data in the vertex colours and UV sets, and the impostor card as the last LOD. The glTF route through Unreal's Interchange importer has not been looked at.
What ships
Unreal materials are binary assets tied to an engine version, so engine/unreal/ ships text:
| File | Does |
|---|---|
AskrVegetation.ush | wind as World Position Offset (flutter, branch bend, main sway, distance fade) and leaf helpers |
AskrImpostor.ush | the impostor: card placement (vertex) and the 3-view blend with parallax (pixel) |
askr_build_materials.py | builds MPC_AskrWind, M_AskrBark, M_AskrLeaves, M_AskrImpostor, and the instances of one tree |
askr_wind_controller.py | sets the wind collection from the editor's Python console |
Install
Export the tree as FBX with its impostor:
shaskrgarden-cli export oak.treegen.json -f fbx -o out/oak --impostorKeep
oak_export.json, the textures and theoak_Impostor_*.pngfiles together.Enable Python Editor Script Plugin (Edit > Plugins). Optionally copy the files into the project (the folder with the
.uproject) with File > Install engine support… in the editor oraskrgarden-cli engine-package unreal D:/Projects/MyGame: they go toPlugins/AskrGarden.In the Output Log (Cmd), run
py "<repo>/engine/unreal/askr_build_materials.py". It copies the two.ushfiles to<Project>/Shaders/and creates the base materials under/Game/AskrGarden/. Restart the editor once: Unreal maps the project'sShadersfolder only at startup, and the materials show compile errors until then.Import
oak.fbxinto/Game/AskrGarden/Trees/oak/with Import Mesh LODs on, Vertex Color Import Option: Replace, Normal Import Method: Import Normals, Build Nanite off, and Convert Scene and Convert Scene Unit on. Then, in the Static Mesh editor's Build Settings, turn Use Full Precision UVs on: the wind pivots are metres stored in UV channels and half-precision UVs lose them.Run the script again for this tree:
shpy "<repo>/engine/unreal/askr_build_materials.py" --sidecar "D:/out/oak/oak_export.json" --source fbxIt imports the textures, makes
MI_oak_bark,MI_oak_leavesandMI_oak_Impostorwith the values of the sidecar, and sets the mesh's material slots and LOD screen sizes.
Wind
The materials read the Material Parameter Collection MPC_AskrWind, with the same names and defaults as the other engines (wind values). Set FadeEnd to the distance where the impostor takes over. To change the wind:
- in the editor:
import askr_wind_controller as w; w.set_wind(direction_deg=20, strength=0.6)in the Python console; - in a game: a Blueprint actor that calls Set Scalar Parameter Value and Set Vector Parameter Value on
MPC_AskrWindevery tick (the recipe is inengine/unreal/README.md).
Things to know
- Axes and units. The tree is baked Y up in metres; Unreal is Z up in centimetres. The FBX importer converts positions and normals, but not the UV channels that hold the wind pivots, so each material instance carries
AxisX/Y/ZandUnitScale. Their values are a guess until checked: if branches swing about the wrong point, change those four parameters on the instance. - Normals. AskrGarden writes normal maps in the OpenGL convention (+Y, green up). Unreal expects DirectX (−Y). Flip the green channel on import (Flip Green Channel) or in the material.
- Leaves use the Two Sided Foliage shading model, Masked, with dithered LOD transition.
- Nanite. AskrGarden puts crown ambient occlusion in the vertex colour's alpha, and Nanite foliage overwrites vertex alpha. Keep Nanite off for these meshes.
- Uniform scale only, and far from the world origin the wind can jitter (large worlds are not handled).
- LOD screen sizes. Unity's screen size is where a LOD ends; Unreal's is where each one starts. The numbers the script sets are a starting point.
Known gaps
No Pivot Painter data, no Nanite foliage profile, no normal rotation in the wind, no interaction with characters, and the impostor has no translucency and casts the shadow of a plain card.