Apple has outdone themselves again. Metal, a recent software development released by Apple for their iOS 8 devices, is taking a large step forward in terms of graphical fidelity for mobile devices. Metal will let you as a developer target Gpu power like never before. This article is an overview of Metal itself and how it can make graphics look better on mobile devices.
What is Metal for developers?
Simply put (in tech terms) Metal is a software update providing a single language and unified programming interface for both data-parallel computation workloads and graphics. It enables you to integrate graphics and computation tasks much more efficiently, without needing to use separate APIs and shader languages.
In more common language, Metal is a software tool that simplifies the processes that go into rendering 3D graphical models. It frees up a lot of processing power that would otherwise be used translating data back and forth between one languages to another. The overall result of this is to enable much greater graphical fidelity, especially in high-resource areas like particle effects (like smoke, fog, etc.) and bloom. Metal will help developers create more immersive games, and will help the user experience by reducing load time.
Metal’s framework provides a lot of benefits. The first thing it does is eliminate “hidden” performance bottlenecks by unifying the language that the GPU and the CPU use. It can also now use multi-heading efficiently to command buffers in parallel. It includes memory and research management, which works better to categorize and archive memory objects.
Storing them in a more efficient way improves loading times and allows more information to be kept at once. Additionally, Metal has integrated support for graphics and computing options, meaning that it enables resources to be shared between run time interfaces, graphics shaders, and computation functions. Finally, Metal supports precompiled shaders, which are compiled when an app is built and then loaded fully when it is run. Working in this sequence provides better code generation and supports easier debugging in the long run.
Steps to create an app with Metal
Creating an application with Metal is fairly simple. First, get a device that can support it (anything with iOS 8). Next, is the creation of a command queue using the MTLCommandQueue class. Then, create resources like shaders, buffers and textures that you’ll need for your app. After that, create a rendering pipeline, a sequence for initialization and configuration. Finally, use the subclass UIView to create a view for the app.
Drawing an app with Metal
Once you’ve created an app, you’ll want to draw in it to make sure it works and you can create content. First, create a command buffer using the MTLCommandBuffer object. Next, start a render pass. This can be tricky, so its best to look up the steps for it independent. Next, draw whatever you want in your app. And finally, commit your instructions to the command buffer.
Does Metal really make a difference?
See for yourself! This video includes a simplified definition of Metal and also an in-depth comparison between graphics on iOS 7 and iOS 8:
The video goes into a lot of detail about Metal and its changes to two different kinds of games. In particular, something I was interested in when the narrator pointed it out, was the emphasis on reflective surfaces and smoke. Despite the graphical stutter on the car in the Tokyo track, the differences between the iOS 7 and iOS 8 versions were particularly obvious when you could see the reflections of the buildings around the car, rather than just a flat black windscreen. What’s especially cool is that he shows the game performance side by side and, despite the new graphical features, the game runs just as smoothly as on iOS 7. That kind of seamless improvement in performance is pretty cool and one of the biggest reasons that Metal is worth your time as a developer and a consumer of mobile technology.