简体   繁体   中英

Is it possible to use Metal shader code in an iPad Swift Playground?

Is it possible to use custom Metal shader code in an iPad Swift Playground?

If so, how does one get the *.metal file or code (or its pre-compiled object) onto an iPad to use with a Playground and Swift code? Is the use of Xcode on a Mac required to help?

(this question is not about using the built-in performance shaders, or about running stuff in a Playground on a Mac)

You have two options: either create an iOS playground in Xcode and send it to your iPad but then you are not allowed to edit the .metal file, just read it, like in this example ; or you can create your shaders file as a multiline string (now possible in Swift 4 and Xcode 9 beta) and create your library from that string. A more cumbersome way is to concatenate string lines in Xcode 8/Swift 3 like in this example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM