Build your own low-level game engine in Metal! Metal is a unified application programming interface (API) for the graphics processing unit, or GPU. It’s unified because it applies to both 3D graphics and data-parallel computation paradigms. Metal is a low-level API because it provides programmers near…
iOS & Swift
Chapter in Metal by Tutorials
Introduction
Nov 21 2025 · Chapter
Welcome to Metal by Tutorials! Metal is a unified, low-level, low-overhead application programming interface (API) for the graphics processing unit, or GPU. It’s unified because it applies to both 3D graphics and data-parallel computation paradigms. Metal is a low-level API because it provides programmers near…
iOS & Swift
Chapter in Metal by Tutorials
Hello, Metal!
Nov 21 2025 · Chapter
…this chapter, you'll get an introduction to Metal as you render your first primitive object. You'll also learn why you would use Metal over other graphics frameworks…
iOS & Swift
Chapter in Metal by Tutorials
Best Practices
Nov 21 2025 · Chapter
…this chapter, you’ll review the best practices to follow when creating your Metal apps — from choosing the right resolution to compressing textures, no best practice stone is unturned in this chapter…
iOS & Swift
Chapter in Metal by Tutorials
The Rendering Pipeline
Nov 21 2025 · Chapter
…this chapter, you’ll go further with Metal by creating a macOS app from scratch, where you’ll learn how the rendering pipeline works to create the beautiful graphics you see onscreen…
iOS & Swift
Chapter in Metal by Tutorials
3D Models
Nov 21 2025 · Chapter
…dive into the world of 3D models, learning how to work with them in Blender, and how to render them on the screen with Metal…
iOS & Swift
Chapter in Metal by Tutorials
Metal Performance Shaders
Nov 21 2025 · Chapter
…this chapter, you’ll dive a bit deeper into the world of the Metal Performance Shaders (MPS) framework. The MPS kernels are optimized shaders that you can slot into your rendering pipeline…
iOS & Swift
Chapter in Metal by Tutorials
Image-Based Lighting
Nov 21 2025 · Chapter
…chapter. Common.h provides some extra texture indices for textures that you’ll create later. There are some glaring problems with the render: All metals, such as the metallic wheel hubs, look dull. Pure metals reflect their surroundings, and there are currently no surroundings to reflect. Where the light doesn…
iOS & Swift
Chapter in Metal by Tutorials
Profiling
Nov 21 2025 · Chapter
…which is a powerful app that profiles both CPU and GPU performance. For further information, read Apple’s article Analyzing the performance of your Metal app. Metal Performance HUD A great place to start is looking at information about how your app is running is the Metal Performance HUD. ➤ Select…
iOS & Swift
Chapter in Metal by Tutorials
Managing Resources
Nov 21 2025 · Chapter
…submesh, you currently send up to six textures and a material individually to the GPU for the fragment shader: Base color, normal, roughness, metalness, ambient occlusion and opacity textures. During the frame render loop, each of the textures requires a renderEncoder.setFragmentTexture(texture:at:) command. A barrel draw call…
iOS & Swift
Chapter in Metal by Tutorials
The Fragment Function
Nov 21 2025 · Chapter
…uses its own shader language. The principles are the same, so if you find a GLSL shader you like, you can recreate it in Metal’s MSL. The Starter Project The starter project shows an example of using multiple pipeline states with different vertex functions, depending on whether you render…
iOS & Swift
Chapter in Metal by Tutorials
GPU Command Encoding
Nov 21 2025 · Chapter
…model data. ➤ In the Shaders folder, create a new header file called SceneData.h. In this file, you’ll define the necessary structures for both Metal and Swift. ➤ Before #endif, add this code: #if __METAL_VERSION__ // MARK: - Metal Shading Language #include <metal_stdlib> using namespace metal; struct SceneData { constant…
iOS & Swift
Chapter in Metal by Tutorials
Geometry Creation with Mesh Shaders
Nov 21 2025 · Chapter
…mesh function. However, you don’t need that here. ➤ At the end of the file, define the mesh shader output structure: using MeshTriangle = metal::mesh< VertexOut, void, 3, 1, metal::topology::triangle>; metal::mesh<V, P, NV, NP, t> is a struct type that represents…
iOS & Swift
Chapter in Metal by Tutorials
Textures
Nov 21 2025 · Chapter
…into custom vertex buffers and submesh groups. Model now contains an array of Meshs in place of a single MTKMesh. Abstracting away from the Metal API allows for greater flexibility when generating models that don’t use Model I/O and MetalKit. Remember, it’s your engine, so you can choose…
iOS & Swift
Chapter in Metal by Tutorials
Coordinate Spaces
Nov 21 2025 · Chapter
…this chapter, you'll get an introduction to some of the mathematical concepts used in Metal, and how to find your way around the scene using Metal's coordinate system…
iOS & Swift
Chapter in Metal by Tutorials
Maps & Materials
Nov 21 2025 · Chapter
…light falls on them. Some objects have a smooth surface, and some have a rough surface. Heck, some might even be shiny metal! Take for example, this sphere with a brick texture. The render on the left shows a simple color texture with Phong shading. The physically based render…
iOS & Swift
Chapter in Metal by Tutorials
Tessellation & Terrains
Nov 21 2025 · Chapter
…draw patches instead of vertices, you’ll need to create the tessellation kernel. The Tessellation Kernel Function ➤ In the Shaders folder, create a new Metal file named Tessellation.metal, and add this: #import "Common.h" kernel void tessellation_main( constant float *edge_factors [[buffer(0)]], constant float *inside_factors [[buffer(1)]], device…
iOS & Swift
Chapter in Metal by Tutorials
The Vertex Function
Nov 21 2025 · Chapter
…this chapter, you'll get a look at the first of two programmable stages in Metal, the vertex stage and the vertex function…
iOS & Swift
Chapter in Metal by Tutorials
Lighting Fundamentals
Nov 21 2025 · Chapter
…light shading in the fragment function so you’ll need to pass the array of lights to that function. Metal Shading Language doesn’t have a dynamic array feature, and there is no way to find out the number of items in an array. You’ll pass this value…
iOS & Swift
Chapter in Metal by Tutorials
Character Animation
Nov 21 2025 · Chapter
…then iterate through the joint paths, retrieving the joint’s pose from the skeleton’s array of joint matrices, and storing them into the Metal buffer. ➤ Open Model.swift, and in update(deltaTime:), replace the existing animation code: for index in 0..<meshes.count { meshes[index].transform?.getCurrentTransform(at: currentTime) } ➤ With…