DOTS fait tourner la futuriste Megacity sur mobile

Nordeus : Étude de cas d’un développeur Unity

What inspires wow-factor demos like Megacity at Unity community events? Are they just eye-candy or are there real benefits for Unity developers? Belgrade-based Nordeus has been a featured studio at many Unite developer conferences, demoing work drawn from their hit games. But their cutting-edge clips aren’t about showing off – they’re about demonstrating new Unity capabilities that will dramatically change what you can achieve both creatively and programmatically.

  • Le projet

    Démontrer régulièrement les dernières évolutions de notre initiative "performances par défaut" / DOTS

  • L'objectif

    améliorer les performances du code multithreadé pour tous les développeurs Unity

  • Plateformes

    Android, iOS, PC

  • Membres de l'équipe

    3 pour Megacity, 20 pour Battle Demo

  • Lieu

    Belgrade, Serbie

La programmation DOTS permet de lancer rapidement Megacity sur mobile

With CPUs trending towards more and more cores, high-performance multithreading is an essential feature of any modern computing engine. The Unity solution to multiple cores and threads is the Data-Oriented Technology Stack (DOTS), an umbrella term for the Entity Component System (ECS), the C# Job System, and the Burst Compiler.

Consistently wowing Unite audiences from Los Angeles to Berlin, Nordeus has demonstrated the benefits of these and other Unity features such as the Lightweight Render Pipeline (LWRP) and nested Prefabs.

The results:

  • Easy-to-write and efficient multithreaded code
  • Optimized rendering for lower-performance platforms like mobile
  • Faster QA with substantially fewer integration bugs
Relier les DOTS lors d'un hackathon

Une équipe internationale et extrêmement créative

Founded in 2010 by ex-Microsoft engineers Branko Milutinovic, Milan Jovovic, and Ivan Stojisavljevic, Nordeus first published Top Eleven – Be a Soccer Manager (“Football” outside the US), a freemium team-management game. It was enormously successful on Facebook, becoming profitable in three weeks, and was ported to Android and iOS in 2011. Since then, the company has published Golden Boot on iOS and Android, has Heroic: Magic Duel in soft launch, and numerous other games in development stages.

Nordeus has drawn talent from 22 countries to its headquarters in Belgrade, a locale extraordinarily rich in culture and history. They’re routinely cited as a top workplace in Europe and are known as generous contributors to a number of philanthropic organizations.

Two of their top software engineers are Belgrade locals: Jozef Oros and Srdja Stetic-Kozic, who work in the Nordeus Central Tech team with eight others. They are responsible for fostering the tools and techniques used in all Nordeus games, and as Srdja notes, “All of our games are made in Unity.”

Relier les DOTS lors d'un hackathon

“As soon as we heard about DOTS, we contacted Unity to try it out and see if we could collaborate,” said Jozef. “We always want to give our players the best possible user experience, and smooth gameplay is a big part of that. Naturally, we’re especially interested in anything that can help our games run faster.”

The collaboration started with a meeting in Belgrade between the Unity and Nordeus CTOs. Nordeus welcomed help in getting familiar with the new technologies, and Unity wanted a real-world application that would test DOTS to its limits. Srdja added, “We also wanted to make something cool and epic to be showcased by Joachim Ante (a Unity co-founder). So for Unite Austin (2017), we thought ‘let's take a Heroic: Magic Duel battle, supersize it to 100K units, and then blow them all up!’ It was super exciting for us.”

Jozef and Srdja were the first DOTS users at Nordeus. They estimate having spent 90% of their time writing gameplay systems, in particular for rendering, unit movement, and logic. Jozef said, “Unity’s DOTS lets us make some really cool spells that explode at scale – effects that we knew would blow the audience’s minds.”

The team completed the Nordeus Battle Demo for Unite Austin in two months, with the first four weeks devoted to programming and prototyping. They spent one of those weeks in Copenhagen with a Unity team, working together hackathon-style in one room. “Sitting with Joe and his team was an awesome experience. We learned, direct from the source, a tremendous amount about ECS, the C# Job System, the Burst Compiler, and data-oriented programming in general,” Jozef added.

Dire au revoir à la programmation orientée objet

Passer à la programmation orientée données est un changement important et peut être intimidant à première vue. Cependant, d'après Srdja, "DOTS est en réalité une façon différente de penser, mais au bout d'une semaine ou deux le déclic s'est fait et notre code s'est nettement amélioré. Et lorsqu'il a fallu intégrer du code plus ancien, ECS nous a permis de le faire assez facilement."

Le système de tâches en C# fait partie intégrante de DOTS. Celui-ci permet d'écrire du code compatible avec les systèmes multi threads, gère les conditions de concurrence (threads tournant dans un ordre inattendu, entraînant des résultats inattendus), et optimise les changements de contexte pour tirer presque 100 % de performances des multiples cœurs. Le compilateur Burst est un compilateur en LLVM mathématique, qui part des tâches C# pour produire du code machine hautement optimisé pour les capacités de la plateforme cible.

Selon Joachim Ante, "notre compilateur Burst a une profonde compréhension des maths et de la géométrie et peut opérer des optimisations mathématiques dont les autres compilateurs ne sont simplement pas capables. Il vectorise automatiquement le code en C# et génère ces instructions vectorisées pour une plateforme-cible donnée. Le code peut par conséquent tourner beaucoup, beaucoup plus vite." Le compilateur Burst élimine également une quantité significative de bugs d'intégration qui devraient normalement être trouvés à l'étape de la QA.

Gagner la bataille pour Megacity

The Battle Demo shown at Unite Austin used components from Heroic: Magic Duel. The Nordeus team applied its DOTS expertise primarily on dynamic gameplay elements, with huge numbers of animated units on a limited-size terrain.

This paved the way for its next challenge, as Nordeus took on Megacity, which is a big, open world with 4.5 million objects that need to be rendered, culled, and loaded, 5,000 flying cars needing to be simulated, and 100,000 audio sources that had to be played simultaneously. And all of this needs to work on mobile as well as PC. Jozef said, “For Megacity, Unity’s DOTS was used for everything, like new rendering and animation techniques, UI systems, and even audio. We can use all of this in our existing games, as well as those in development.”

Le LWRP permet de mettre une métropole sur mobile

Joachim Ante’s keynote address at Unite LA 2018 included an astonishingly complex live demo from Megacity. The demo contains 4.5M mesh renderers, 5,000 dynamic vehicles and 200,000 unique building objects. The vehicles fly on spline-based traffic lanes, never colliding, and there are 100,000 unique audio sources, including neon signs, air-conditioning fans, and cars producing unique sounds to form a rich, realistic audioscape. And it all runs smoothly on smartphones.

“For the Megacity demo, we wanted to show our complex graphics on a mobile version with a very fast frame rate. We used LWRP plus a few custom shader tweaks to make it resemble the PC version as much as possible,” said Jozef. Srdja added, “When you are working on a game that is supposed to stretch the limits of PCs, and then you decide to port it to mobile later, you usually have to rework large parts of it due to performance limitations of mobile platforms. This was not the case with Megacity. DOTS enabled us to use the exact same code running gameplay logic and rendering on a PC and seamlessly scale it down to mobile platforms.”

The Unity Lightweight Render Pipeline optimizes real-time performance on mobile devices by making tradeoffs with lighting and shading. It performs single-pass forward-rendering with one real-time shadow light and light culling per-object (with all lights shaded) in a single pass, minimizing draw calls.

Prefabs imbriqués et plongée dans DOTS

"La démo Megacity a également été notre premier contact avec le nouveau système de prefab imbriqués de Unity, et nos artistes ont vraiment adoré," d'après Jozef. Par exemple, avec les prefab imbriqués, vous pouvez désormais intégrer plusieurs petites pièces dans un grand bâtiment prefab, chacune composée de différents meubles prefab, etc. Les développeurs peuvent diviser les prefabs en de multiples entités pour plus d'efficacité, réutiliser le contenu quelle que soit sa taille, et travailler simultanément sur différentes parties du contenu.

La feuille de route produit de Nordeus est ambitieuse, et s'engage à 100 % avec Unity et l'approche DOTS en ce qui concerne le code. Comme l'a dit Srdja, "si vous songez à adopter Unity DOTS, foncez. Et n'ayez pas peur de désapprendre une grande partie de ce que vous avez appris sur la programmation orientée objet !"

Srdja Stetic-Kozic, Senior Software Engineer

DOTS est en réalité une façon différente de penser, mais au bout d'une semaine ou deux le déclic s'est fait et notre code s'est nettement amélioré. Et lorsqu'il a fallu intégrer du code plus ancien, ECS nous a permis de le faire assez facilement."

Srdja Stetic-Kozic, Senior Software Engineer
Jozef Oros, Software Engineer

"Dès que nous avons entendu parler de DOTS, nous avons contacté Unity pour l'essayer et voir si nous pouvions collaborer. Nous cherchons toujours à donner à nos joueurs la meilleure expérience utilisateur possible, et la fluidité du gameplay en fait partie. Naturellement, nous sommes particulièrement intéressés par tout ce qui peut permettre à nos jeux de tourner plus rapidement."

Jozef Oros, Software Engineer

Ce site utilise des cookies dans le but de vous offrir la meilleure expérience possible. Consultez notre politique de cookies pour en savoir plus.

Compris