Scenekit - 矢量/切线位移图

时间:2017-12-12 23:12:18

标签: ios swift xcode scenekit

重要提示:请注意此问题与VECTOR地图有关。不是高度图。

我正在尝试在Scenekit中实现Vector置换,如Apple演示文稿所述:

https://www.youtube.com/watch?v=uli814Qugm8&app=desktop

Apple presentation on Scenekit vector displacement

我的代码是:

    material?.diffuse.contents = UIImage(named: "\(materialFilePrefix)-albedo.jpg") 

材料?.displacement.contents = UIImage(名称:“(materialFilePrefix)-displacement.exr”)   材料?.displacement.textureComponents = .all

我的Xcode项目: enter image description here

但是我没有得到位移......代码有什么问题吗?

1 个答案:

答案 0 :(得分:0)

通过查看SCNMaterial的标题和演示文稿,您可能需要在节点的几何图形上启用曲面细分才能使位移生效。那看起来像这样:

let tessellator = SCNGeometryTesselator()
tessellator.edgeTessellationFactor = 2 // may not need this line (default is 1), or may need to set it higher to get a smooth result
tessellator.edgeTessellationFactor = 2 // ditto
sphereNode.geometry?.tessellator = tessellator