While working on the game Front Line Zero with the METATEK game developement studio, I’ve used the Unreal Engine 4 game engine for some years now.
I’d like to share some knowledge about the pitfalls and neat tricks I got to discover under the form of short, easily-readable blog posts.
Today’s topic : how to create an utility that draws the result of a material into a render target asset in the Unreal editor.
Blutility is dead
I will try to keep this post short and to the point.
Broadly, I have the memory that some years ago, the (fairly simple) task of rendering the result of a material instance into a render target asset could be done very easily using an Unreal Editor tooling solution called Blutility (short for Blueprint Utilities).
It was an experimental feature for a very long time, and to be honest, it wasn’t working very well and had all sorts of bugs and faulty behaviors (hell, even the documentation is broken now !). But it did work for that particular use case.
I left Blutility alone since then because it didn’t prove to be a very reliable tool. But a few days ago, I tried to achieve the same thing as before, storing the render of a material inside a render target, but this time using the shiny new Unreal Engine 4.26 version.
And to my dismay, Blutilities, which don’t seem to have received a lot of love from Unreal Engine’s devs, are now dead and buried as the team now moved on to new objects replacing them, namely the Editor Utility Widgets and Editor Utility Blueprints.
Where to go from here ?
The problem is that the whole Internet is actually filled with old information and questions about « how to do it with Blutility ? », since this thing has been around in experimental state for so long, and that I think it was left « half-broken » in a quite recent version (probably on purpose).
I actually don’t have much more to add than this very well hidden, poorly-referenced piece of Unreal documentation that walks you through the process of doing it « the new way ».
It basically boils down to creating an Editor Utility Actor, setting it the right Input variables, and then declare a custom event that is going to bake the render target, which you call in the Construction Script of the Utility Actor. Then, their solution to build the render target is to drop it in a level and move slightly the actor when you want to rebuild it, triggering the C.S. .
I personally think it’s a very ugly way to do it! Frankly, I preferred the old Blutility approach that actually seemed to address the issue in a more Level-independent, Editor-only way, which is what we actually want! I don’t understand why we should drop an actor into a level and wiggle it around just to accomplish a task that should be purely Editor-side (that actor is useless to the level).
I guess the other way would be to create a nice Editor window with an Editor Utility Widget, but really, for such a simple tool like that where a quick’n’dirty solution would probably be just fine, who would want to roll out a full-fledged UMG interface « just for that » ?! It seems insane…
A few things to note however :
- The documentation screenshots seem to be out-of-date. The Draw Material to Render Target takes in a World Context Object node now, and as a matter of fact you should let it unconnected. I tried to connect it to the « Get Game World » node and curiously, it didn’t work until I removed it.
- In Unreal, the construction script of an object is called a lot and in a lot of different situations, so I’m really not sure this is a great idea. But for an unknown reason, making the custom event « Call In Editor » so that it creates a button in the Details of the Actor that you can click, instead of connecting it to the Construction Script, did not work. The button just doesn’t show up. Maybe it’s a bug ?
- I’m actually not sure if that’s required or not for this task, but I enabled the « Editor Scripting Utilities » plugin, which is disabled by default, before working on this. I think it’s unnecessary.
I hope this blog post will help some of you figuring out what actually happened to Blutility and what is « the right way » to do this kind of stuff with recent versions of Unreal now, because it was a lot of confusing searches and dealing with conflicting informations on my side. Hope it helps !
Une réflexion sur « Unreal Engine Tips – Bake a Material to Render Target »
I found a more elegant way to do this! If you use the « call in editor » tickbox you don’t have to move the actor for the construction script to run 😀
But still I had a problem with Editor Utility Blueprints specifically when inheriting from Asset Action Utility, because this asset cannot be dropped on the level I had to hack my way into a World Context Object reference using the « Get All Level Actors » node and picking the first actor 0.o