简体   繁体   English

是否可以在iPad Swift Playground中使用Metal着色器代码?

[英]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? 是否可以在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? 如果是这样,如何将* .metal文件或代码(或其预编译对象)保存到iPad上以与Playground和Swift代码一起使用? Is the use of Xcode on a Mac required to help? 在Mac上使用Xcode是否需要帮助?

(this question is not about using the built-in performance shaders, or about running stuff in a Playground on a Mac) (此问题与使用内置性能着色器无关,或与在Mac上的Playground中运行内容无关)

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 ; 您有两种选择:要么在Xcode中创建一个iOS游乐场,然后将其发送到iPad,但是您就不能编辑.metal文件,只需阅读该文件即可,如本例所示 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. 或者,您可以将着色器文件创建为多行字符串(在Swift 4和Xcode 9 beta中现在可以使用),然后从该字符串创建库。 A more cumbersome way is to concatenate string lines in Xcode 8/Swift 3 like in this example . 更加麻烦的方法是像本例中那样在Xcode 8 / Swift 3中连接字符串行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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