Skip to content

Working with Particles in Metal

Today, we’re going to start a new series about particles in Metal. Since most of the time particles are tiny objects, we are not usually concerned about their geometry. This makes them fit for a compute shader because later on we will want to have granular control over particle-particle interactions and this is a case fit for a high degree of parallelism control which a compute shader allows us to have.… Read More »Working with Particles in Metal

Using ARKit with Metal part 2

As underlined last time, there are three layers in an ARKit application: Rendering, Tracking and Scene Understanding. Last time we analyzed in great detail how Rendering is done in Metal using a custom view. ARKit uses Visual Inertial Odometry for accurate Tracking of the world around it and to combine camera sensor data with CoreMotion data. No additional calibration is necessary for image stability while we are in motion. In this article we look at Scene Understanding – ways of describing scene attributes by using plane detection, hit-testing and light… Read More »Using ARKit with Metal part 2

Using ARKit with Metal

Augmented Reality provides a way of overlaying virtual content on top of real world views usually obtained from a mobile device camera. Last month at WWDC 2017 we were all thrilled to see Apple’s new ARKit framework which is a high level API that works with A9-powered devices or newer, running on iOS 11. Some of the ARKit experiments we’ve already seen are outstanding, such as this one below: There are three distinct layers in an ARKit application: Tracking – no external setup… Read More »Using ARKit with Metal

Introducing Metal 2

This year’s WWDC was probably the most important one ever, at least as far as we – the Metaldevelopers – are concerned. I can wholeheartedly say it was the best week of my life, for sure! Let’s get to the Games and Graphics news. The most unexpected trophy goes to the renaming of Metal to Metal 2. It has the most significant additions and enhancements since it was first announced in 2014, true, but let’s admit it: no one saw this one… Read More »Introducing Metal 2

Working with memory in Metal part 2

There are a couple of topics we need to discuss in more depth about working with memory. Last time we have seen that to create MTLBuffer objects we have 3 options: by creating a new memory allocation with new data, by copying data from an existing allocation into a new allocation and by reusing an existing storage allocation which does not copy data. Since we haven’t looked at the memory before, let’s… Read More »Working with memory in Metal part 2

Working with memory in Metal

Today we look at how memory is managed when working with the GPU. The Metal framework defines memory sources as MTLBuffer objects which are typeless and unformatted allocations of memory (any type of data), and MTLTexture objects which are formatted allocations of memory holding image data. We only look at buffers in this article. To create MTLBuffer objects we have 3 options: makeBuffer(length:options:) creates a MTLBuffer object with a new allocation. makeBuffer(bytes:length:options:) copies data from an existing allocation into a new allocation. makeBuffer(bytesNoCopy:length:options:deallocator:) reuses… Read More »Working with memory in Metal

Ambient Occlusion in Metal

Today we will be looking into ambient occlusion. We are going to work on the playground we used in Shadows in Metal part 2 and build up on that. First, let’s add a new object type – a rectangular box: Next, let’s also add a new distance function for our new struct: Then, update our scene to something new: What we did here was to first draw a sphere with a radius of 8,… Read More »Ambient Occlusion in Metal

Shadows in Metal part 2

In this second part of the series, we will be looking into soft shadows. We are going to work on the playground we used in Raymarching in Metal and build up on that because it was already set up for 3D objects. Let’s set up a basic scene that has a sphere, a plane, a light and a ray: Next, we create a few distance operation functions that help us determine distances between elements of the scene:… Read More »Shadows in Metal part 2

Shadows in Metal part 1

A quite important topic in Computer Graphics is lighting and shadows. This will be a first episode from a multi-part series about Shadows in Metal. We are going to work on the playground we used in Using metal part 15 and build up on that. Let’s set up a basic scene: We first created the differenceOp() function which returns the difference between two signed distances. This comes in handy when we want to carve shapes out of other shapes. Next, we created… Read More »Shadows in Metal part 1

Raymarching in Metal

Raymarching is a fast rendering method used in realtime graphics. The geometry is usually not passed to the renderer but rather created in the shader using Signed Distance Fields (SDF) functions that describe the shortest distance between a point and the surface of any object in the scene. The SDFreturns a negative number if the point is inside of an object. Also, SDFs are useful because they allow us to reduce the number of samples used… Read More »Raymarching in Metal