Using a UI Widget as a Texture

I didn’t find a lot of information on doing this, so thought I’d post my solution.

Suppose you have a UI that you want rendered onto an object as if it were a texture. This is different from the typical 3D UI workflow where you just drop a “Widget” component on your blueprint and get a 3D plane with your UI that you can place on top of things. Rendering the UI as a “texture” lets you wrap the UI around surfaces, chop it up using UV coords, etc.

The few bits of information I found online said to create a dynamic material instance in the blueprint, use Get Render Target on the Widget component, and set the material’s texture using that value. For me, it never worked, on engine version 5.3. The texture set on the material would never change to the UI’s render target.

I tried doing the logic in Construction Script and on Event BeginPlay, but the return value of Get Render Target was always null.

Turns out, the Widget would never have a render target until it was first rendered (i.e. visible on screen). Hence why it was always null during construction and BeginPlay.

I’m not sure if there’s a setting that makes Unreal always render it so that it has a Render Target available during startup. But my solution for now:

An early branch on Event Tick to keep performance cost low, and another branch so that it only executes the bulk of the graph once.

Same logic as usual, create a dynamic material, set the texture to the Widget’s render target, and make sure to set the material on the target (not sure if this is needed, saw it mentioned as needed in other posts).

And then you can set the Widget’s alpha to 0 so it isn’t visible. It’ll still render and give the needed texture like normal. In my case I’m applying it to a Screen material for a phone actor the player is holding.

Again, not sure if this is the right or most performant way to do this, but since I didn’t find any other solutions online … here’s mine.

2 Likes

Thanks for sharing. I couldn’t get this to work. Did you put this logic inside your character BP or widget BP? Where is the widget’s alpha located? Hope you can share screenshots of your model and texture results. Thanks

Hi sorry to reply an old post but… I found this as a solution for a visual bug i have in a world space widget I have… I plan to do something similar as you, a physical screen for a PC but it looks really blurry when I move the cursor inside it or even when the digits of the clock changes… Does this work for you!? I managed to make it work with the nodes you posted but it looks really blurry for me :frowning: