Metal
by
Tutorials
By Caroline Begbie & Marius Horga
Metal by Tutorials
By Caroline Begbie & Marius Horga
Copyright 2019 Razeware LLC.
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an as is basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of their own respective owners.
About the Cover
The comb jellyfish or Ctenophora has been swimming in both shallow and deep waters for nearly 500 million years.
While just as seemingly alien as other jelly species, comb jellies are especially unusual, boasting a completely transparent body with groups of cilia or "combs" arranged in rows along the axis of the jelly's body. While appearing to be a bioluminescent species, these jellies only appear to glow as their moving cilia scatter the light, causing a glowing rainbow-like effect.
Perhaps most incredibly and much like Metal's own low-level, low-overhead features these jellies' bodies use only what they need to live and produce their amazing shading effects: They have no stomach, intestines or lungs, and they are known to have one of the most basic nervous systems of any multicellular animal on the planet.
You can learn more about comb jellies and see them in action in this video clip: https://www.youtube.com/watch?v=sTFskdKVNs4
Dedications
"To Warren Moore, who first made it possible for me to learn Metal, to my wonderful children Robin and Kayla, and to my best friends who patiently waited for me to indulge my dream."
Caroline Begbie
"To my wife, Adina, and my son, Victor Nicholas, without whose patience, support and understanding I could not have made it. To Warren Moore who first whet my appetite for Metal, offered his advice when needed and motivated me to get involved with Metal too. To Chris Wood who taught me that most of the times all you need to render is a ray, a camera and a few distance fields. To Simon Gladman whose amazing work with compute kernels inspired me to write more about particles and fluid dynamics. To Jeff Biggus who keeps the GPU programming community in Chicago alive. Our daily conversations motivate me to stay hungry for more. To everyone else who believes in me. A huge Thanks to all of you!"
Marius Horga
About the Authors
Caroline Begbie is a co-author of this book. Caroline is an indie iOS developer. When she's not developing, she's playing around with 2D and 3D animation software, or learning Arduino and electronics. She has previously taught the elderly how to use their computers, done marionette shows for pre-schools, and created accounting and stock control systems for mining companies.
Marius Horga is a co-author of this book. Marius is an iOS developer and Metal API blogger. He is also a computer scientist. He has more than a decade of experience with systems, support, integration and development. You can often see him on Twitter talking about Metal, GPGPU, games and 3D graphics. When he's away from computers, he enjoys music, biking or stargazing.
About the Editors
Adrian Strahan is the technical editor of this book. Adrian is a freelance iOS developer and Project Manager living in the South West of England. He's worked on iPhone and iPad apps since 2010 (iOS3) and specializes in mobile- and web-based application development.
Tammy Coron is the final pass editor of this book. Tammy is an independent creative professional and the host of Roundabout: Creative Chaos. Shes also the founder of Just Write Code. Find out more at tammycoron.com.
About the Artist
Vicki Wenderlich is the designer and artist of the cover of this book. She is Rays wife and business partner. She is a digital artist who creates illustrations, game art and a lot of other art or design work for the tutorials and books on raywenderlich.com. When shes not making art, she loves hiking, a good glass of wine and attempting to create the perfect cheese plate.
What you need
To follow along with the tutorials in this book, you need the following:
A Metal-capable Mac running macOS Catalina 10.15 or later. All Macs built since 2012 should run Metal, although not all of them will be able to run the most recent features in Metal 2. Nvidia GPUs will have issues, in some cases serious, as drivers have not been updated since macOS High Sierra.
Xcode 11.0 or later.
[optional] A Metal-capable iPhone or iPad running iOS 13 or later. Any iOS device running the A7 chip or later will run Metal. The latest features, such as tile shading and imageblocks, will only run on the A11 (or later) chipset. The projects will build and run on macOS, and most of them will run on the iOS Simulator, so using an iOS device is optional. If you wish to make an iOS game, the game engine you build while reading this book will have an iOS target as well. The Metal API, with a few exceptions, works the same on macOS as it does on iOS so it wont be difficult to add an iOS target to your project later on.
Book license
By purchasing Metal by Tutorials, you have the following license:
You are allowed to use and/or modify the source code in Metal by Tutorials in as many apps as you want, with no attribution required.
You are allowed to use and/or modify all art, images and designs that are included in Metal by Tutorials in as many apps as you want, but must include this attribution line somewhere inside your app: Artwork/images/designs: from Metal by Tutorials, available at www.raywenderlich.com.
The source code included in Metal by Tutorials is for your personal use only. You are NOT allowed to distribute or sell the source code in Metal by Tutorials without prior authorization.
This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies.
Next page