2

I can load and view a texture image into an SCNMaterial. If I try to replace SCNMaterial with MDLMaterial using the same image, the texture is not correctly rendered:

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)

Do I need additional settings to render the image correctly?

chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31

1 Answers1

0

not everything that Model I/O can represent is available in SceneKit. Physically based rendering, for instance, is one of the features that are not supported.

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • As of iOS 10, SceneKit now supports physically-based rendering, and I believe it works just fine with Model I/O's representation of PBR. – CIFilter Jul 06 '16 at 17:08