Download

auto generated static meshes based on texture mask

What would be the way to add static meshes on the white parts of this grid texture. I am looking to create a blueprint that can “fill” the white parts with rectangular meshes by dragging a similar texture in a variable parameter to auto generate the meshes? Is there anyone who knows of a tutorial or has done something similar that can point me in the right direction…thx

Procedural meshes… I guess this is part of digital image processing. You will need to find the edges in the image. You could use a derivative filter for that (https://theailearner.com/2019/05/24/…dge-detection/). Running the filter in x- and y-direction should give you the vertices, at least in this particular case. But this is nothing you would do at the runtime of a game. This is too costly. Also UE is not the right tool for finding the right parameters for those filters. MATLAB or Mathematica would be. And no chance with blueprints, this is C++.

Maybe there is a better way or a workaround, but I don’t know one.

Thanx I’ll check into it…this is for in editor not at runtime…once calculated I plan to merge actors…so cost not so important…but thx

So are you trying to randomize the level setup by picturing it in the texture? It would be much easier to populate a level from blueprint with a similar concept, just not reading from a texture…

The texture is important because I generate it from a render target so I need to use specific textures…it seems overlay complicated is there no way to add static meshes based on black and white values…?

The derivative filter works better as I thought. Ran through the texture in each of the 4 directions:

It finds the vertices of the rectangles. Now (I did not make this, I don’t know how exactly it works) you could draw the material to a render target. Then you could go pixel by pixel through the rows of the render target even with blueprints (very slow) and find the white parts (vertices) and draw the static meshes with a procedural mesh. The algorithm may need some thinking but it should be possible.

But I don’t know how to make assets out of the procedural meshes.

wow…thanks will give it a go thnx…!

Hi, I don’t know how much use this will be for you, but another way you could try would be using a landscape with procedural foliage spawner and editor scripting.

Basically create a landscape with the same resolution as your texture, and resize the landscape to the size you want. Then create a new layer inside the landscape and apply the texture as landscape layer info. Then use the procedural foliage spawner and limit it to that layer. So it will only spawn the meshes on the white parts of your texture.

Then depending on what you wanna do you could use editor scripting to access the transform of the meshes spawned by the procedural foliage spawner and replace them with static meshes and then merge those static meshes.

.perhaps its an easier way…I’ll give it a shot…Thanks…

what do you mean that’s too costly, Minecraft does this constantly, none of the item models is anything but a texture that at runtime is converted to a mesh