Behind the Scenes with Custom Empire Claims | Starborne

Behind the Scenes with Custom Empire Claims

Wed Oct 02 2019 (Updated: Tue Dec 15 2020) - 3 min read

Dev Blog

Greetings, Commanders!

As our Discord community already knows, we previously released a few concept images that depict hex claim painters.  They are intended to be empire cosmetics; some of which show off specific achievements, while others will be available for purchase by players to customize their empire.

It’s one thing to design concept art of what a feature could look like, but implementing it to work for up to 5,000 simultaneous players is a whole different animal.  

Our champion on the hex claim painters is, Solid CloudsJayDee.  JayDee is a Unity3d magician and he was kind enough to explain the work currently going on behind the scenes on the claim painter.

JD: I’m a front-end focused Developer who dabbles in technical art.  My sole purpose in life is to bring the ‘delight’ and ‘juiciness’ to the party.

Q: Can you explain the first difficulty of setting this up?

JD: Well I first needed to have an algorithm in place that could calculate the border positions of any area of claimed hexes. The maths to achieve this wasn’t exactly arbitrary, it essentially involved figuring out the perimeter hexes of the area, and then marching along this perimeter whilst keeping track of the direction of travel.

To check if I was on the right track, I used a simple line renderer to display the results, this was a messy business at first as the borders looked like blended spaghetti, but once I had accurately determined the relationship between hexes that gave me a neat crisp line around the hex perimeter.

The next step was to modify the algorithm to be able to generate a mesh. In order to do that the placement and ordering of the individual vertices needed to be precise, otherwise the mesh wouldn’t render properly and would result in all sorts of crazy occlusion and z-fighting.

To help visualise the problem, I populated the mesh with a small UI object that displayed the vertice’s index. This greatly helped me understand if the correct number of vertices were being created and position properly, it also allowed me to see the numerical relationship between indices, enabling me figure out the fewest  number of vertices necessary to create the triangles for the mesh, removing all redundant data in the process! I don’t know about you but I love perfectly optimised meshes!

The last stage was to create the colour gradient from the edge of the border to the center of the hex. To do this vertex colour data was added to the edges, whilst the center verts were marked transparent. The shader we use multiplies the vertex colour alpha by an exponent variable to give us the gradient thickness, and voila, that’s it, in all its glory!

Q: Finally - challenges you see for the future of this feature?

JD: We have some big plans for the claim borders, you may have seen some of the concepts. Some of these designs require bespoke solutions in order to be achieved, which then need to be tested for suitability in the game proper. We must be mindful of the holistic effect that these differing styles may have when combined together on a busy map, and ensure they don’t compromise the gameplay or the essence of the game’s style. That said, we are excited to expand on this feature and enable players to customise their territory so it feels like their own!

Thank you, JayDee!

Our team would like to give a big thanks to SC JayDee for giving us this update.  We are hyped about this feature; not just for the hex claim painters, but the potential of more hex manipulation going forward.

Keep an eye out on the Official Starborne Discord and stay tuned for another update from the team coming this week!

As always, fly safe, Commanders!

-Starborne Dev Team