Turn FSlateShaderResource into Texture/PNG?

Hi,

I’d like to create a plugin that takes given assets from content browser and saves their thumbnails as .png files. I was able to create a copy of thumbnails in my own editor window using MakeThumbnailWidget() function in FAssetThumbnail class, however I cannot figure out how (or if its even possible) to save its texture into file. I obviously need an array of pixels/colors and I know that I could get them from viewport that displays thumbnails but there is no access to it from FAssetThumbnail.

There is GetViewportRenderTargetTexture() which returns FSlateShaderResource but I’m not sure how/if I can get raw pixels/data from it.

I also digged around and noticed that if had my custom thumbnail renderer maybe I could capture raw data somewhere during the draw process. Although, it seems that thumbnails renderers are connected with a given class so I’m not sure if its a good idea.

Long story short:
How can I save any asset thumbnail as png file?

Any tips appreciated,

Thanks

Edit:

I’ve got it working! Plugin will be ready soon ; )

I have the same problem too.

use RenderThumbnail function can get the thumbnail of some assets (e.g. mesh asset).

Hello szyszek, I also do the same task as you. Notice that you have resolved this problem (I’ve got it working! Plugin will be ready soon ; )). Could you tell me how to do? I write the following code:

TSharedPtr< SWidget > pSwidget = AssetThumbnail->MakeThumbnailWidget();

pSwidget->Invalidate(EInvalidateWidget::Layout);

FSlateTexture2DRHIRef * Texture = InThumbnailPool->AccessTexture(theAsset, Width, Height);

const TSharedPtr TextureData = Texture->GetTextureData();

But the TextureData always is NULL.