By Yi Fei Boon, Field Engineer, Unity Technologies
Innovation is often used to describe the latest and greatest in technology. Less known is the inspired community behind this, that is intrinsically motivated to propel a cycle of solving problems, discovering new solutions, developing and commercialising products, which in turn, helps companies reinvest in the next generation of technology.
Unity is a case in point. Developers face new challenges as they push the limits of technology and platforms to bring their games to life, as more dynamic game engines are, in turn, being developed to empower developers. It is during this cycle that collaborative innovation is born. Developers turn to the engine developers for aid, leading to collaborative new and unique solutions to address issues faced during development, which is then later implemented into the engine.
At the recent Casual Connect Asia held at Resorts World Sentosa Singapore, from 16 to 18 May, I spoke about how this process of collaborative innovation solves some of these problems, as well as how this drives the growth and constant improvement of Unity’s game engine. Working as Unity’s technical consultant, I have been aiding clients in optimising their programme and helping address challenges encountered while using the game engine.
Collaborative innovation is crucial in today’s ecosystem. This pattern repeats itself time and again, and it is via this creativity that the engine is further developed. One such example would be the issue of having many characters within the same scene while maintaining a steady frame rate. From the likes of spectators in a crowded stadium to a busy bazaar filled with shoppers or even an endless zombie horde, developers tend to have a tough time with scenes involving a large number of characters.
Where traditional solutions would have developers using one draw call (an instruction sent to the GPU to draw something on screen) per character, the community came together to solve this problem. SkinnedMeshRenderers cannot be batched, which means one draw call per character, hence for 4,000 characters a minimum of 4,000 draw calls is needed. Adding Mecanim overhead and you get frame rates that are not usable, as you need to send relevant data to the GPU which is slow due to the slow CPU to GPU bus.
Looking to greatly improve performance, I was able to derive a solution by proposing to animate MeshRenderers with Vertex Shaders and take advantage of GPU instancing. As we can’t animate characters with Sine and CoSine functions, we instead needed a more elaborate way of passing the animation data to the Vertex Shaders. This was this solution that I shared with the community during Casual Connect Asia 2017.
Following this led to the solution of animating characters via textures, which can be used not just to store colour data, but pure data as well (such as surface normals). By mapping X Y Z (value of a vertex’s direction vector) to R G B (channel of a pixel stored in the texture) and calculating the vectors of movement on the GPU, it significantly reduced the stress on the CPU, allowing many characters to be simultaneously rendered at high frame rates. For every animation frame, we needed to find out the direction vector of the vertex, from the base position to a frame position, following which we baked it to the texture.
The Big Push to the Finish
While solutions and help like these are a boon for developers, it is ultimately the other benefits such as time-saving (being able to move faster to market) and development of new tools and solutions that are sought after. While solutions are often specialised where not one size fits all, these methods of bypassing current issues serve as the bedrock to the future of game engines. Developers and programmers alike can take inspiration from the creativity employed to develop new ways and solutions to issues they are facing.
Collaborative innovation is the future. As problems are raised by developers themselves, this platform gives Unity the opportunity to work on solutions that help Unity to build a stronger, more powerful platform on top of simpler yet more powerful tools, it helps take away the hassle of developers having to come up with intricate codes to develop their games. There may come a day whereby everyone would have the means of bringing their ideal games to life without needing the technical knowledge today. Being a part of this, it is an honour to be able to witness this first-hand and be able to work with a community who are shaping the future.
Yi Fei’s desire to be a one-man development team led him to take on multiple roles from Technical Artist to Gameplay Programmer. He had worked for various development teams before joining Unity as a Field Engineer and is now helping developers make awesome games with Unity.