当前位置:网站首页>UE4 exports the picture + text combination diagram through ucanvasrendertarget2d

UE4 exports the picture + text combination diagram through ucanvasrendertarget2d

2022-07-07 15:43:00 WhiteTian

Original article , Reprint please indicate the source .

Preface

Updated date 2021-10-29 11:23:25
Made a plug-in , Download address
About how to use plug-ins ,EKExportImageLibrary.cpp Two static export methods are provided in

UEKCRT2DExportImageLibrary::EKCRT2DExportByPath
UEKCRT2DExportImageLibrary::EKCRT2DExportByTexture2D

By monitoring EKCRT2D_Delegates.h Medium FOnExportImageSuccessDelegate::OnExportImageSuccessDelegate The agent can be notified of the completion of the export .

Generate QR code pictures through programs , And mark a string of text under the QR code image ( QR codes are all the same , It's hard for the naked eye to distinguish , So add text ), After exporting the picture , It can be printed and pasted in the corresponding room .

In about UE4 The image in is as follows
 Insert picture description here

The exported image is as follows , It can be HDR、Png
 Insert picture description here

Get started

The following resources are needed , You can quickly complete this function . Of course, this is a demonstration , Blueprints for blogging , It will be more intuitive to show you . If it is used in the project, it still needs to be encapsulated .
 Insert picture description here

establish 1>CanvasRenderTarget2D, To realize it

 Insert picture description here
 Insert picture description here

establish 2> Shader

 Insert picture description here

 Insert picture description here

establish 3> Material examples

 Insert picture description here
 Insert picture description here

establish 4> texture of material Actor, There is one in it Box, In order to see the effect , In fact, this can not participate in visual interaction . Remember to put this Actor Drag into the world .

 Insert picture description here
 Insert picture description here
 Insert picture description here

establish 5>RenderTarget

 Insert picture description here

effect

You can see a picture in the folder
 Insert picture description here

Add

This article only introduces DrawTexture and DrawText, In fact, many effects can be drawn .
 Insert picture description here

Because the above is a demonstration , Imperfect , The following contents need to be improved when used in the project

1> How to adjust the background color of the exported picture ?( It's black now )
2> Image source material on the exported image 、 Text content A parameterized ;
3> The size of the exported picture , adjustment CreateCanvasRenderTarget2D The canvas size passed in when calling ;
4> The text above the exported image 、 Where is the position of the picture ?
5> Text has more effects , Color 、 size , Whether it's fuzzy ?
6> Export format you want PNG still JPG perhaps HDR? Find the corresponding code in this function

UKismetRenderingLibrary::ExportRenderTarget

7> Do you consider packaging into C++ To do it ?

Last , If you can't follow the steps , Please leave me a message .

thank you , It's not easy to create , Great Xia, please stay … Move your lovely hands , Give me a compliment before you go <( ̄︶ ̄)>

原网站

版权声明
本文为[WhiteTian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130611315814.html