我可以将纹理图像加载并查看到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)
我是否需要其他设置才能正确渲染图像?