我可以将纹理图像加载并查看为SCNMaterial
。如果我尝试使用同一张图片将SCNMaterial
替换为MDLMaterial
,则纹理无法正确呈现:
let scattering:MDLPhysicallyPlausibleScatteringFunction = MDLPhysicallyPlausibleScatteringFunction()
scattering.baseColor.textureSamplerValue = MDLTextureSampler()
scattering.baseColor.textureSamplerValue?.texture = MDLTexture(named: "art.scnassets/metal_bumpy_squares_Base_Color.png")
let mdlMaterial = MDLMaterial(name: "cube", scatteringFunction: scattering)
let node = SCNNode(geometry: SCNSphere(radius: 1))
node.geometry?.firstMaterial = SCNMaterial(MDLMaterial: mdlMaterial)
// With SCNMaterial works as expected
// node.geometry?.firstMaterial = SCNMaterial()
// node.geometry?.firstMaterial?.diffuse.contents = "art.scnassets/metal_bumpy_squares_Base_Color.png"
// node.position = SCNVector3Make(0,0,-3)
是否需要其他设置才能正确渲染图像?
最佳答案
并非模型I / O可以表示的所有内容都在SceneKit中可用。例如,基于物理的渲染是不支持的功能之一。
关于ios - MDLMaterial无法正确渲染相对纹理图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33918324/