UMG widget render target for material?

I’ve been trying for sometime to find an answer and only found this example but no clear way to do it. Id like to take whatever render target source the widget outputs and use that for custom materials and effects, like for example having a control panel display in game that also shows up on other displays.

I know i could point a camera and get the render target that way but its not really good for performance so i hope someone could please help. Thanks!

The only way I found to get it working was to create a Widget component in your actor, and either jam it off-screen somehow, or scale it down to 0. Then you can pull off the render target information from that. The caveat being that you have to have the widget being rendered [somewhere] for the RT to update.

Managed to get this working on a cellphone mesh, with a UMG interactive display.

Interesting so where do i find the render target that’s being created as i’ve looked all the usual places i think and unless im missing something i can’t find it. Im still learning the editor and haven’t used it for over a year now. Thanks.

If you grab the widget component into your blueprint graph, you should be able to pick up which RT its using. Alternatively you can just grab the material proper and assign it to your mesh.

Just testing i added a cube and on begin play it set it to the material from the widget but it only shows a blank “Widget3DPassThrough_Masked_OneSided” material. Not the test image the widget should be displaying.

I also tried to do something with the get render target instead of the material and im not sure how to make a material out of it as it won’t input into anything it seems. Not sure what chain is needed to do that.

I also need to use it outside of the actual widget bp as a normal material instance else where in game to apply to various surfaces. If its not too much to ask could you please give a short guide or example image of what i should be doing? It would be really appreciated and it’s such a useful thing im sure others would also. Thanks.

Sure thing. Last engine version I had this working in was 4.19, so assuming nothing’s changed since then I should be able to get a working example.

Okay, this is working.

However, I’ve had to introduce a 1 second delay into the setup since Unreal seems to have a delay between creating the widget component and attaching a dynamic material instance. You can probably bring this value down a little if needed.

NewMaterial is just a regular PBR shader with a texture parameter called ‘SlateUI’ plugged into the emissive channel. You can name this parameter whatever you like, just ensure the blueprint is pointing to the same parameter.

If you want to use it on other objects, you need promote that RenderTarget to a global variable and have other blueprints access it from there. IIRC you can set the widget to tick offscreen, and it should work fine.

Also to note: for best results, set your draw size on your Widget component to something sensible. It’ll affect the size of the render target, so if your UI has a lot of small text you may need to have this sit at a fairly high value (1024x1024 for example). You can then set the transform scale on that component to {0,0,0} to make it ‘invisble’.

Seriously thanks for all the help it’s now working! :slight_smile:

I made a variable from rt and set it to public but in another test cube bp i have nothing to target it as self doesn’t work. Is it possible to create instead a render target for various materials that doesn’t require a bp for each mesh?

What I’d probably do is setup a container blueprint class for your widget stuff, and have it store the RT as a variable there. All your ‘screen’ actors would then need to point to this container BP and pull the RT variable from that. I don’t have time to build a demo of it right now, but if you’re still struggling I may be able to knock something up this afternoon.

I don’t mind having a bp for each mesh but im having trouble with making it publicly available and accessing it in other bp.

I get this and not sure what target needs to point to?

It’s not ideal, but you want to create a new variable in your level blueprint. In your Widget container BP, you want to set the variable in the level blueprint to the RT, rather than the local variable on the BP itself.

Then, any new instances that want to use that RT can just get the variable value from the level blueprint instead of having a separate actor for each mesh instance. Does that make sense?

Is it possible to create another render target or material based off the main one and change the resolution? I found “create render target 2D” but when i plug the original render target into it or from widget then plug that into the dynamic material the test cube is now black?

Hi, found that interesenting, but don’t get it. The material don’t need more setups? Is a TextureSampleParameter2D right?
Also you know if works over skeletal mesh instead static mesh?

Thanks in advanced!

Off the top of my head, I think this is possible. I think there’s a weird issue where things happen too quickly under the hood for everything to get linked up correctly. Its hacky AF, but try adding a short delay between your creation and assignment operations and see if that makes a difference.

–deleted -

couple of things about this:
you don’t have to hide the widget into fark corners of the world or scale it down. You can go to the widget settings and uncheck “render in main pass” this is nice as you can keep the widget in the right place and have it still be interactive for example if that is needed.

But I have questions: Mips. How do we get a clean looking text in this kind of render target? Any strategies on how to organize this so that you can auto generate mips?