How can i spawn actors based on an image mask?

Using blueprints, is it possible to spawn actors based on an image mask?

The mask image would be Black and White. I would like to spawn a list of actors on either the black or white areas.
Is that possible in blueprints?

it should be possible in theory though its not easy and may require some c++ or plugins. i tried something similar with limited success a while back. basically you need to get the pixel position and multiply it so it matches a predetermined grid, so say each pixel represents 100x100uu in world space. then you need to read the value of the pixel and round it to the nearest whole number to eliminate issues from gray. the colors should be a vector 4 so it shouldnt be too much of an issue there. then use the color value with a equal node or a in range node to determine is a spawn is needed.

when i attempted this i was actually making a voxel style world and placing cubes (z axis) based on the value of the pixel

hmmm last reply didnt post lets try this again. below is a working example of what your attempting to do which uses Rama’s victory plugin. do note that while making this example my editor crashed several times so be cautious.

now this spawner actor works by: getting the pixels from the input texture and adding them to an array. then we get each pixel based on its position. we then get the red channel (arbitrary decision) since its a black and white image and see if its value is in a range of 0-0.5 or black. if the pixel is black we spawn a actor. the actors location is based on the pixels position multiplied by the grid size (100uu in this case). i then based the origin of the spawned actors on the location of spawner actor. i executed this script based on a custom event which can be called in the editor, see the details panel on the right.

Hi,
Your blueprint is something that I was looking for. I’m tring to make static mesh spawn (scatter) based on image mask. I made some modifications but unfortunatly unreal still crash when I add image in editor. When I add mesh there is no problem. Maybe you can solve this problem - what am I doing wrong in this script?

the script in the picture doesn’t immediately show anything that should cause a crash unless there are hardware limitations. there is a few small things that would affect your result / placement.

you mention when you add image in editor, what do you mean by that? also how are you calling this function? and is there any errors that are being reported? what are the symptoms of the crash? freezing? program close? infinte loop? also which engine version (i used 4.17)?

last below is a alternate method that may be suitable for your purposes. it incorporates spawning a limited number of objects and takes random samples from the image to scatter the spawn locations.

Hi,
I’m a landscape designer and I use Unreal to my garden projects visualizations. It is the best software I ever had for my projects. Right now I’m want to add efficiency to my work using blueprints. When I have specific group of plants in my project it is time consuming to put them in right place. I made for example plant spline array – it is perfect for hedges, plants in row. I ad variables to specify the spacing between plants, add specific rotation and scale difference. So the plant in row look more natural. Now I want to do similar solution like I used in vue infinity - - YouTube

I want to populate (array, spawn) plants on a given surface (for example plane) using texture mask. So when I add black/white texture to blueprint plants will be only for example on white part. Spacing of plants, rotation and scale variables of course should be also in this solution.
I mange to make this possible with Houdini based on this tutorial - Houdini Training - Copying/Instancing 01 - Copying Geometry by Rules - YouTube

But in Unreal cooking after every change in scale, rotation is a nightmare – it take ages.
I will try solution that you sent – I see that you use event graph. I understand that I can change it to construction script?

About my previous script – I use Unreal 4.20. I tried to make something similar to my spline plant array but with texture mask. When I insert texture to Image Variable the Unreal crash and there is information:
You do not have any debugging symbols required to display the callstack for this crash.
In theory it should work. Maybe you have idea how to make it possible?
In attachment are:

  1. spline_plant_blueprint.png – working blueprint for mesh spline distribution
  2. spline_plant_editor.png – how spline plant distribution work in editor
  3. static_mesh_spawn_crash.png – picture when unreal crash – after adding image to variable

Hi,
By mistake I posted information below - not as a commnet.

i don’t know why but i feel like running this from the construction script would be a bad idea. maybe try making it a custom event that can be called in editor. also i haven’t used streams (random x from stream) much so im not sure about the intricacies of that aspect.

so heres what i would do: first try making the script run from a custom event called in editor. second pare down the script to the bare minimum eliminating the random bits and test to get the spawning working, then add in the other bits piece by piece. basically just run small pieces of the script to try to locate whats causing the crash.

as for the error you get when the crash occurs, well to display the crash information (log) there is more to the program to be installed at least i believe thats the case from my understanding. that may be another thing to try as well. below is a link to the forums which talks about crashes and debugging.

https://forums.unrealengine.com/development-discussion/content-creation/79782-getting-editor-symbols-for-debugging

Hi,
I found interesting blueprint that do almost that I’m looking for:

It works great with scattering static mesh.
Now I thinking is it possibility to add texture masking the population?
I’m surprised that there is no such feature so far in Unreal - scattering with masking is in every 3d software.

Hi, can you write to my on Fb? I have a private question about posibilty of blueprint writnig.

Hi, OK I made a mistake and forget that it is Vector 2D.

Hi,
I don’t know how to get one SET with two variables? Also Location variable is random stream type?

yup thats a vector 2 variable.

sorry i don’t have / use facebook.

Ok. Then can you write to me by email: skarzynski.daniel@gmail.com.
I want to know if you can write this type of blueprint for me as an paid order or maybe you know someone who can?

theres a section on the forum for that kind of thing.

https://forums.unrealengine.com/community/got-skills-looking-for-talent