to make it short: I want to create a ‘Manhattan Voronoi pattern’ and use that data to make selectable tiles.
OR find another solution that generates a random collection of shapes that I can address, ideally project on a landscape-mesh and reference.
Now as of right now I think that would be an almost impossible task using blueprints, but maybe one of you disagrees and enlightens me.^^
In theory, the pieces are there. I’d have to define some points, do the ‘mystical calculation’ that will return coordinates for vertices and build meshes out of those that somehow would need to be separate selectable Objects. Or a million other possible approaces.
It just seems, that doing. i.e. voronoi calculations is extremely taxing - I cant wrap my head around using fortunes algorithm (if thats even possible in Blueprints). The Topic seems so big I don’t quite know where to start. I am willing to extend on my mediocre c++ skills (as I fear that might be nessecary) - but at this point I am not even sure if unreal is even the right program to even do this kind of “pixelbased” almost shader programming. I dunno. Any Ideas?
I am happy for other solutions aswell. or just general Ideas on how to approach this.
I have i.e. considered a hexagonal grid that is somehow displaced (however I would realize that), though then every country would share the same amount of borders with other countries…
Hey. Voronoi manhatten is maybe (I might be wrong) already in the engine because of chaos destruction. To your question/problem: You could create a voronoi texture with a lot of different colors. This would be the pattern where you choose a single country with a color picker (to highlight it). This color picker would create a mask and this could be used in a world wide decal (create the mask, update the material or use a render target). You could even use the voronoi as your country borders (decal that is always present to show the borders). But I don’t know how you would e.g. place country names (struct or datatable with all colors and their specific data like population/humidty/biome …) You could also use your landscape as a heightmap and subtract this from your voronoi (clamp in your preferred range so you don’t have countries in the water). I created an example for you with a voronoi texture. The color picker might sometimes select multiple countries, so you’d have to adjust the threshold or - when you click on a map - translate this coordinate to the texture coordinate and create a sphere mask so that you just pick a color in this sphere. Or you need a better grid/color palette CountryBorders.zip - Google Drive
Hey man,
that’s a great approach, and thanks for even taking the time to prepare and send me a project!
It works pretty well for randomization.
I was wondering how I could “select” a country during gameplay if I don’t have access to the color palette in the Blueprints. But I guess since it is on world coordinates it would be possible to - as you said - feed the cursor location into the material, grab the color underneath it and compare it to the color of the pattern as a whole gut get the cell underneath the mouse…
IF that works the only other thing is that the blueprint itself would not really be able to work with the shapes as it doesn’t really know the boundaries I guess… hmm
But it gives me a lot to try out
Hey.
You can select the colors with a rendertarget. I created 3 textures. 1 shows the borders. 2 is created for the rendertarget as the “colorpicker”. 3 shows the highlighted area. In the map are now 2 decals. Decal 1 shows the border texture. Decal 2 will highlight the country when you click on it. I made a mistake with the rendertarget so the countries are somehow rotated(? one the one edge of the map the color does not match). CountryBorders_Selectable.zip - Google Drive Have fun
Ha, thanks for your fast reply. In the meantime I actually also tried some stuff out and came up with this.
I’d just need to do the same comparison as in your original material to filter out the correct country.
Your approach of course has the advantage that it works on terrain - mine only works on a flat plane rn.
I never worked with render targets - but at first glance it seems pretty much exactly like what I could need right here.
And thanks again for yet another project. I’ll dive into it and find out how well this approach works
Yes - I think that’s what I have been looking for! With the render target stuff I can just grab the rgb value and reference a ‘country list’ with color values to find out what I clicked on. Great!
Now I need to watch a couple tutorials on the subject matter ^^
Another good thing is flexibility. If I’d want to switch to hand-drawn layouts I should b able to do that in this setup. And i think even if I ever get around to make a manhattan-Voronoi HLSL-custom node I could just put it in the material.
Hey Nawrot, thanks for your answer!
That Stackoverflow thread solves the problem of selecting a mesh without having separate objects, which is a lot more streamlined - given that I would first find a way of calculating the pattern that returns actual points/vectors rather than the current shader-based solution.
I have yet to understand how to get there.
I am trying to make sense of some shadertoy.com voronoi setups. If I can translate them into code i am not sure though what kind of data such an algorithm returns. Points? Vectorlines? Distances? I guess I’ll see.