DOTS executa o jogo futurístico, Megacity, no celular

Nordeus – Um estudo de caso do desenvolvedor 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.

  • O projeto

    Demonstrar frequentemente a evolução mais recente de nossa iniciativa de “Desempenho por padrão” / DOTS

  • O objetivo

    Melhorar o desempenho de código multithread para todos os desenvolvedores Unity

  • Plataformas

    Android, iOS, PC

  • Membros da equipe

    3 para Megacity, 20 para Battle Demo

  • Lugar

    Belgrado, Sérvia

Codificação DOTS orientada a dados coloca o Megacity em dispositivos móveis rapidamente

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 em um hackathon

Uma equipe internacional e altamente criativa

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 em um 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.

Dizendo adeus à programação orientada a objetos

Mudar para uma programação orientada a dados é algo muito significativo e chega a ser intimidador em um primeiro momento. Entretanto, de acordo com Srdja, “DOTS realmente exige uma maneira diferente de pensar, mas depois de uma semana ou duas, finalmente entendemos tudo e conseguimos escrever um código muito melhor. E quando temos que integrar códigos antigos, ECS nos ajuda a fazer isso facilmente.”

Uma parte integral do DOTS é o sistema de trabalho em C#, que escreve códigos seguros para threads, gerencia condições de execução (threads executando em ordens inesperadas, causando resultados inesperados) e otimiza alterações de contexto com um ganho de quase 100% do uso de núcleos múltiplos. Outro componente é o compilador Burst, uma tecnologia baseada em LLVM e sensível à matemática, capaz de processar trabalhos em C# e produzir um código de máquina altamente otimizado para as capacidades específicas da plataforma-alvo.

De acordo com Joachim Ante, “nosso compilador Burst compreende a matemática e geometria a fundo e pode realizar otimizações matemáticas que outros compiladores simplesmente não conseguem. Ele vetoriza automaticamente códigos em C# e gera estas instruções vetorizadas para uma plataforma-alvo específica. Como resultado, o código pode ser executado com muito mais rapidez.” O compilador Burst elimina uma quantidade significativa de bugs de integração que, geralmente, são detectados pelo controle de qualidade.

Ganhando a batalha do 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 ajuda a colocar uma metrópole no celular

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 aninhados e imersão no DOTS

“A demo do Megacity também foi a primeira vez que entramos em contato com o novo sistema de Prefabs aninhados do Unity, e nossos artistas se encantaram com ele”, de acordo com Jozef. Por exemplo, com os Prefabs aninhados, um edifício grande pode ser composto por vários Prefabs de ambientes pequenos, os quais, por sua vez, podem ser constituídos por vários Prefabs de peças de mobiliário e assim por diante. Os desenvolvedores podem dividir Prefabs em várias entidades para uma melhor eficiência, reutilizar qualquer conteúdo, seja ele pequeno ou grande, e trabalhar em diferentes partes do conteúdo simultaneamente.

O roteiro de produtos da Nordeus é ambicioso, com um comprometimento de 100% com Unity e com a abordagem DOTS para escrever código. Como Srdja diz, “se você está pensando em adotar Unity DOTS, mergulhe nessa. E não tenha medo de desaprender muito do que sabe sobre programação orientada a objetos!”

Srdja Stetic-Kozic, Senior Software Engineer

“DOTS realmente exige uma maneira diferente de pensar, mas depois de uma semana ou duas, finalmente entendemos tudo e conseguimos escrever um código muito melhor. E quando temos que integrar códigos antigos, ECS nos ajuda a fazer isso facilmente.”

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

“Assim que ficamos sabendo do DOTS, entramos em contato com Unity para testá-lo e ver se formávamos uma parceria. Queremos dar aos nossos jogadores a melhor experiência do usuário possível e uma jogabilidade descomplicada faz parte desta experiência. É claro que estamos particularmente interessados em qualquer coisa que ajude nossos jogos a rodar mais rápido.”

Jozef Oros, Software Engineer

Usamos cookies para garantir a melhor experiência no nosso site. Visite nossa página da política de cookies para obter mais informações.

Eu entendi