Metal by Example was published as an e-book on Gumroad in October 2015. As of September 2016, you can name your own price. As of March 2023, after selling almost four thousand copies, I made the decision to remove Metal by Example from sale. You can download the PDF here for free. More than seven years after publication, it is quite out-of-date, but I will keep it here indefinitely for posterity.
Sample Code
The sample code for the book is available as MIT-licensed open source and is hosted on Github.
when will the book be available ?
and whats the price ?
When I know, you’ll know. The price of the book will be competitive with other technical books on the market, with the e-book selling for a little less than the paperback.
so i suppose between $40 and $50 then ?
Sorry, I’m not committing to a range before I know the production costs.
Eagerly waiting for this… any updates as to when it’s coming out?
We’re targeting mid-July for the e-book release, with the softcover to follow later. The July timeframe is entirely contingent on several factors: editing, e-book and softcover production, and how significant the changes announced at WWDC 2015 are.
Thanks for the reply. I am still waiting to pounce into your book!
G’day Warren.
Hate to bug, but I notice you mention a July target for the book, any updates there?
Cheers
That was overly ambitious. We’re looking at third week of October for the ePub release. Thanks for checking in!
Great. Thank you for the update =)
Cant wait to by the book
Will any of the code be in swift ?
I can convert it to for myself but then i might make it less efficiëntly working Since im not 100% familier with the metal api
The sample code for the book is in Obj-C, but the most recent article on Metal Performance Shaders has sample code in Swift. Fortunately, the concepts transfer pretty readily between the two.
Hiya,
Checking in again since May! Great to hear your book is almost ready! Like Kristof, I really would prefer that book in Swift. I know I’m only speaking for myself, but whether or not your book is in Swift is a crucial point for me.
(hoping you’ll convert to Swift)
Regards,
Kelvin
I respect that a lot of devs are using Swift now, and if I had it all to do again, I’d do the whole project in Swift. This release will be in Obj-C. Having said that, the sample code will be available under a pretty liberal license, so if someone wants to port it to Swift, I’d be open to that collaboration.
Thanks a lot, I can’t wait to read your book.
For me it is great it is an Objective-C book.
(I always code in Objective-C++ for the Apple platform for better cross-platform portability (and since I am a C++ nerd), so I can reuse BIG chunks of code on other platforms as well, and so Objective-C is great for me)
Hi there!
SUPER excited to see this book published!
Just curious if there were any updates on the publication of the book? 🙂
Thanks!
More details will be shared by the end of this week. Thanks for staying tuned!
I would love to see some expansion of the compute kernel section. Specifically I’m interested in operating on large arrays of complex data in parallel. Getting structs into metal without copying is somewhat of a challenge.
I try to run de examples, and I got these kind of errors? any idea?
Unknown type name ‘CAMetalLayer’; did you mean ‘CATextLayer’?
Unknown receiver ‘CAMetalLayer’; did you mean ‘CATextLayer’?
No type or protocol named ‘CAMetalDrawable’
Normally this error indicates you’re trying to run a Metal project in the iOS Simulator. Metal isn’t supported in the Simulator, so you’ll need to build with Generic Device or a physical device scheme selected.
Apple will remove OpenGL from iOS and macOS, which have scared me, my app will stop working later.
I hope that I can learn Metal quickly by reading your book, and rewrite them with Metal.
Thanks!
Hi I am a Chinese, how can I get this book? Thanks.
Hi! Do you have any tutorials or books on texturing 16-bit packed pixel formats? For example 5_5_5_1, 4_4_4_4 or 5_6_5.
Can you extend the book and describe how to make dropped shadows
I’ll talk all about shadows in the next book.
Very exciting to hear! Is there a timeline for the next book? Just bought the first one, I should probably finish that first…
Unfortunately, the new book project is shelved indefinitely. But I have recently revisited all of the book sample code (available on Github), and it’s fully updated for iOS 13, including the iOS Simulator.
Just wanted to thank you for the insightful blog posts and the original book. I hope that an opportunity arises where the new book project can be resumed since I find your explanations easier to understand than most. Thanks for helping people get a grasp on Metal and graphics programming.
What’s the difference between using Metal with Swift vs Objective C? Any performance differences?
I have heard anecdotally that Debug builds of Swift apps are substantially slower than Release builds, but I think the practical overhead of Swift relative to Objective-C in production is quite small (<5%). Most developers would be hesitant to do new development in Objective-C, so if you’re already using Swift, I think it’s a fine choice. Conversely, if you’re partial to Objective-C, you have more options when it comes to optimizing after eliminating all the obvious bottlenecks (disabling ARC, for instance, or rewriting performance-critical layers in C++).
Thank you. I’m new to iOS development. I have been learning both Objective C and Swift for quite sometime. But, didn’t know which one to pick for Metal development based on execution performance . So, my understanding here is, ObjC gives better options when it comes tweak the underlying layers? Is this a fair understanding?
I believe so, but that’s heavily colored by my own experience and preferences. And you have to weigh the fact that developing in Swift often takes less code and is actively encouraged and supported by Apple.
thanks
This is a great book, thanks for your generous.