ios - SceneKit Material 中的玻璃效果

标签 ios swift scenekit ios11 arkit

我想在 SceneKit 中制作玻璃效果。 我在谷歌搜索但没有完美的答案。 所以我正在寻找可以清楚地解决我的问题的 SceneKit 战士。 我要制作一张图片。

Final

它应该看起来像真的。 玻璃效果、反射和阴影是这里的重点。 我已经有 obj 和 dae 文件了。

那么,有没有人可以帮助我?

最佳答案

创建一个 SCNMaterial 并配置以下属性并将其分配给 SCNNode 的瓶子几何形状:

.lightingModel = .blinn
.transparent.content = // an image/texture whose alpha channel defines
                       // the area of partial transparency (the glass)
                       // and the opaque part (the label).
.transparencyMode = .dualLayer
.fresnelExponent = 1.5
.isDoubleSide = true
.specular.contents = UIColor(white: 0.6, alpha: 1.0)
.diffuse.contents =    // texture image including the label (rest can be gray)
.shininess =           // somewhere between 25 and 100
.reflective.contents = // glass won’t look good unless it has something
                       // to reflect, so also configure this as well.
                       // To at least a gray color with value 0.7 
                       // but preferably an image.

根据场景中的其他内容、背景和使用的照明,您可能必须调整上述值以获得所需的结果。如果您想要一个没有标签的瓶子,请使用 .transparency 属性(将其内容设置为灰色)而不是 .transparent 属性。

关于ios - SceneKit Material 中的玻璃效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46721259/

相关文章:

swift - 如何在 SceneKit 中加载 Gigapixel 图像作为 Material ?

ios - 如何根据文本长度使 UITextView 高度动态?

ios - 即使没有 aps 环境也显示推送通知对话框

ios - 将对象映射到 TableView 部分的二维数组 Swift

swift - 在 Alamofire 中上传多张图片

ios - Apple Metal 中的 PBR 渲染

javascript - 删除类在 iOS 上不起作用

ios - 设置 SRC 值后图像被截断 (iOS)

swift - 使用 @ObservedObject 时是否可以在 Swift 中嵌套属性包装器?

ios - SCNNode 不在 SCNView 层次结构中,仍然显示并获取触摸和物理