UMG Dynamically Updating a Minimap as Objects are placed in world Using Canvas Render Textures - Very Optimized

Context:
My game map is 132 tiles by 132 tiles. I have a minimap that is 528x528 pixels. So every 4x4 pixels of the minimap represents 1 actual map tile. Every time a building is placed on a tile I want to paint a color over the corresponding minimap pixels.

The problem:
If I overlay 4x4pixel images over minimap by the hundreds( potentially thousands) I’m assuming there will be massive performance issues.

The questions:
What is the best way to do this performance-wise? I’ve explored canvas render targets, but I couldn’t figure out how to apply them to my UMG. Am I approaching the problem right?

Thanks in advance!

I just wanted to report back on my work - I think this will help future game devs. I have solved this in, what I believe is a very optimized way. Pros, please chime in if you feel there is a better way

This quick & dirty tutorial is for adding/removing icons, textures or drawing to a minimap dynamically during gameplay.

Here are the classes & assets I used:
classesAndassets
classesAndassets2
CRT_Minimap is a completely blank Canvas Render Texture BP Class
BP_Minimap is an Actor BP Class

testTexture2D2 is a blank & translucent .png at whatever image size i want my MM to be. I will be using this within my material.

M_MMText is a material I’m going to use to create a dynamic instance of that I will be applying the canvas drawing to.

-Make sure to add our translucent texture to a texture node and convert that to a parameter (by right clicking node) called ‘Texture’.

Now we need to use our BP_minimap functions to actually draw on our translucent canvas render target.


-Here we are initializing the canvas render target and creating a dynamic material instance, that we will be updating when anything needs to be added to minimap. DONT FORGET TO ADD THIS CLASS TO YOUR LEVEL


-This function will be used to add to the canvas. I’m currently only using it to paint white 10x10px squares at a random vector2d for testing. If you have more complicated footprints and specific locations you will have to work on that, which i plan to for my game


-Instead of white 10x10px boxes you can add icon textures or any other textures you may need.

Now we have to use it within our UMG


Add 2 images - one will be changed to the canvas whenever its updated and the other can be your static minimap background texture

Now on button click I have this randomly placing 10x10 square white boxes across my 594x594px texture

Last notes: I would not use this on tick unless you want to melt everyone’s computer. Also if you need to remove marks on the MM you can draw translucent boxes overtop of existing marks

Here’s a video of it in action:

It appears this strategy I put together is going to work really well for me. Can any pros chime in and comment on if there is a more industry standard way of doing this?

I dont want to put bad information out there if this isn’t a good route.

Also, if it is a good route will this post save for future indie devs?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.