Categories
Uncategorized

Using MetalKit part 8

By now, you might have all noticed I am in love with Swift. I am also an avid user of Xcodeplaygrounds. This week we will take our Metal code and put it into a playground. Huzzah, for Metalprototyping in the playgrounds! Let’s start by creating a new Xcode playground for OS X. Once created, click the Show the Assistant editor button and also press Command + […]

Categories
Uncategorized

Using MetalKit part 7

One of our readers contacted me about an apparently weird behavior he was seeing: when running the code from our tutorial the MTLLibrary returned nil after a few hundred draw calls. That made me realize I was not taking into consideration the fact that some of the Metal objects are transient and some are not, according to the Metal documentation. […]

Categories
Uncategorized

Using MetalKit part 6

Let’s see what are the differences between using the newer MetalKit framework as opposed to using the earlier Metal framework. They are both still coexisting, however, MetalKit introduces a few powerful features such as: Easy texture loading (even asynchronous loading with a few lines of code). Efficient data transfer between Model I/O meshes and Metal buffers. MTKView – a convenient Metal-aware view (we’ll look at it in more detail). I […]

Categories
Uncategorized

Using MetalKit part 5

Last time we described the graphics pipeline and the Metal pipeline. It is time we looked deeper inside the pipeline, and understand how vertices are really processed at a lower level. For this, we need to learn a few 3D math concepts such as transformations. In the world of 3D graphics we often think in terms of 3 or 4 dimensions for our data. As you remember […]

Categories
Uncategorized

Using MetalKit part 4

Last time we looked at the Metal Shading Language basics. Before we look into more advanced topics, I just thought now is a good time to revisit what we have learned so far, especially about the graphics pipeline which I admit, I might have gone too fast on that topic (thank you, anonymous reader, for your suggestion and valuable […]

Categories
Uncategorized

Using MetalKit part 3

In the previous part I promised we will learn more about the Metal shading language. Before that, first let’s do some code cleaning and structuring since we are already getting into the habit of doing this from previous episodes. Start by downloading the source code from the previous episode. We want to refactor the huge render() function, to start with. […]

Categories
Uncategorized

Using MetalKit part 2

In the first part of this series we introduced the MetalKit framework. Let’s reuse the project from part 1 and pick up where we left off. If you look again at the render() function, it was looking like this: Let’s improve this code a bit. First, since our class subclasses MTKView, it already has its own device so there is no need […]

Categories
Uncategorized

Using MetalKit part 1

The MetalKit framework was announced at the WWDC 2015 and it brings a great deal of improvements and new features for Metal. Meet MTKView, a subclass of NSView/UIView. It comes with an embedded Metal layer, and it also manages the framebuffer and its render target attachments, as well as takes care of the draw loop. Let’s create a new Cocoa Application (since iOS simulators do not support Metal). Make […]

Categories
Uncategorized

Introducing the Metal framework

The Metal framework that was announced at WWDC 2014 for iOS and at WWDC 2015 also for OS X and tvOS. Metal is an interface for programming the Graphics Processing Unit (GPU) in your computer. The main advantages of using Metal are: provides the lowest overhead access to the GPU, hence it reduces all bottlenecks usually caused by data transferring between the CPU and GPU in other frameworks. provides up to 10 times the number of draw calls compared […]