How to render meshes to hud?

Hi,

my game needs to render items (which are visually represented by static meshes) to the hud.
I already read, that it is not possible to render meshes directly to the hud.
I then began experimenting with SceneCaptures:

  • Try to get a UTexture2D from AThumbnailMaker for the specified AItem
  • If there is no thumbnail for this AItem yet, then…
    1. Set the mesh of the UStaticMeshComponent in AThumbnailMaker to the mesh of AItem
    1. Update the content of the USceneCaptureComponent2D in AThumbnailMaker
    1. Use ConstructTexture2D on the updated UTextureRenderTarget2D
    1. Store the created “thumbnail” in a “TMAP (UClass*, UTexture2D*)”
    1. Return the thumbnail for rendering

But that is a rather hacky way of doing such a thing.

I then realized that the content browser creates thumbnails of meshes too and started messing around with
UStaticMeshThumbnailRenderer.

It is actually exactly what I need but I couldn’t get it to work, trying to NewObject() a UStaticMeshThumbnailRenderer results in linker errors.
I included almost anything I could find related to thumbnails and searched for helper classes that would actually create a UStaticMeshThumbnailRenderer for me, but had no luck with that.

If there is already - or will be - a better way to do this using UMG I would use that too (using 4.4 preview currently).

I just need to render meshes to the hud, it doesn’t actually matter “how”.
I hope you guys have some suggestions or ideas for this.

Thanks in advance,

1 Like

I just saw that UMG actually has the feature I need, namely the Viewport Widget.
Unfortunately it completely rages on my video memory.
I then realized that I was using the DebugGame Editor configuration and switched back to Development Editor.
That at least prevented my screen from going black and instead showing an error message:

D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.4\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11Util.cpp(217): Fatal error:
Direct3DDevice->CreateTexture2D(TextureDesc,SubResourceData,OutTexture2D) failed 
 at D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.4\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11Texture.cpp:433 
 with error E_OUTOFMEMORY, 
 Size=1024x1024x1 Format=DXGI_FORMAT_R16G16B16A16_FLOAT(0x0000000A), NumMips=1, Flags=D3D11_BIND_RENDER_TARGET D3D11_BIND_SHADER_RESOURCE 

This error occurs while dragging the Viewport Widget.

So I guess I have to wait for a newer version of UMG or until it goes final.
I will also open a bug report about this.

Hi ,

It looks like the bug report you posted has already been addressed. A lot of improvements have been made internally with UMG, and with Viewport Widgets specifically. UMG is still in experimental status, and Viewport Widgets are considered extremely experimental. However, you will see some big improvements coming soon.

Thanks for the info!

I am looking forward to a more stable version of UMG and its Viewport Widget. By now I worked with a few different engines and have to say, that Unreal Engine 4 is the best I used yet and think that open source and the new pricing model are the future and really boost the growth of this “epic” community.

I’ll be patiently waiting for new updates on this and continue work with all the other features that are still to explore.

Thanks,