DOTS ejecuta el juego futurista Megacity en celulares

Nordeus: Caso de estudio de un desarrollador 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.

  • The project

    Demostrar periódicamente las últimas evoluciones de nuestra iniciativa "Rendimiento por defecto"/DOTS
    l

  • The goal

    Mejorar el rendimiento de código multitarea para todos los desarrolladores Unity
    l

  • Platforms

    Android, iOS, PC

  • Miembros del equipo

    3 para Megacity, 20 para Battle Demo

  • Ubicación

    Belgrado, Serbia

El código DOTS orientado a los datos permite llevar Megacity a los dispositivos móviles rápidamente

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
Conectando DOTS a un hackatón

Un equipo internacional y altamente creativo

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.”

Conectando DOTS a un hackatón

“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.

Despidiéndose de la programación orientada a los objetos

Pasarse a una programación orientada a los datos es un cambio significativo y puede parecer intimidatorio en un principio. Sin embargo, según Srdja: "DOTS exige un modo de pensar diferente, pero en una o dos semanas logramos entenderlo y fuimos capaces de escribir un código mucho mejor. Y cuando tenemos que integrar un código viejo, el ECS nos permite hacerlo de una forma bastante sencilla".

Una parte integral de DOTS es el sistema de trabajos de C#, que escribe códigos seguros para subprocesos, administra condiciones de ejecución (procesos que se ejecutan en orden inesperado y causan resultados inesperados) y optimiza el cambio de contextos para ganar casi el 100 % del uso de los múltiples núcleos. Otro componente es el compilador Burst, una tecnología de compilación basada en LLVM que toma trabajos de C# y produce un código de máquina altamente optimizado para las capacidades particulares de la plataforma meta.

Según Joachim Ante: "Nuestro compilador Burst comprende las matemáticas y la geometría en un nivel profundo y puede realizar optimizaciones matemáticas imposibles para otros. Vectoriza automáticamente el código C# y genera las instrucciones vectorizadas para una plataforma meta específica. Como resultado, un código puede ejecutarse muchísimo más rápido". El compilador Burst también elimina un número significativo de bugs de integración que, de otro modo, habría que solucionar en la etapa de control de calidad.

Ganando la batalla de 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.”

LWRP lleva una metrópolis a un dispositivo móvil

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 anidados e inmersión en DOTS

"La demostración de Megacity también fue nuestro primer acercamiento al nuevo sistema Prefabs anidados de Unity, y a nuestros artistas les encantó", cuenta Jozef. Por ejemplo, con Prefabs anidados, un edificio grande puede contener varios Prefabs de ambientes, que a su vez puede contener múltiples Prefabs de muebles, y así sucesivamente. Los desarrolladores pueden dividir los Prefabs en diferentes entidades para una mejor eficacia, reutilizar cualquier contenido, ya sea pequeño o grande, y trabajar en distintas partes del contenido simultáneamente.

El mapa de productos de Nordeus es ambicioso y está comprometido con Unity y el sistema de codificación de DOTS en un 100 %. Como declara Srdja: "Si estás pensando en adoptar DOTS de Unity, no lo dudes. ¡Y no temas olvidar mucho de lo que sabes sobre la programación orientada a los objetos!".

Srdja Stetic-Kozic, Senior Software Engineer

"DOTS exige un modo de pensar diferente, pero en una o dos semanas logramos entenderlo y fuimos capaces de escribir un código mucho mejor. Y cuando tenemos que integrar un código viejo, el ECS nos permite hacerlo de una forma bastante sencilla".

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

"Apenas nos enteramos de DOTS, nos contactamos con Unity para probarlo y ver si podíamos colaborar. Queremos brindarles a nuestros jugadores la mejor experiencia de usuario posible, y una jugabilidad fluida es muy importante para eso. Naturalmente, tenemos especial interés en todo lo que ayude a que nuestros juegos se ejecuten de forma más rápida".

Jozef Oros, Software Engineer

Usamos cookies para brindarte la mejor experiencia en nuestro sitio web. Visita nuestra página de política de cookies si deseas más información.

Listo