0

将纹理作为 opacity.png 应用到 material.transparent.contents 时,模型仍然没有将它应用到漫反射内容上。

从漫反射内容中删除 alpha 有点工作,但仍然缺少似乎不起作用的透明纹理。

结果: https ://imgur.com/a/QfwI3Ha

它需要什么: https ://imgur.com/a/ax9Fr9A

      let material = SCNMaterial() // init material object
      textures.forEach {
          guard let imageURLPath = $0.url,
                let imageURL = URL(string: imageURLPath),
                let data = try? Data(contentsOf: imageURL),
                let image: UIImage = UIImage(data: data)
          else {
              print("[CreateMaterial:ERROR] couldn't get image from file")
              return
          }

          switch $0.semantic {
          case 0: // baseColor texture
              material.diffuse.contents = image
          case 15: // opacity texture
              material.blendMode = .add
              material.transparencyMode = .dualLayer
          case 18: // normal texture
              material.normal.contents = image
          case 999: // ambientOcclusion, metalness, roughness texture
              let toBeChanneledImage = image
              let channeledImage = channeledImage(toBeChanneledImage)

              channeledImage.forEach {
                  switch $0.channel {
                  case .red:
                      material.ambientOcclusion.contents = $0.image
                  case .blue:
                      material.metalness.contents = $0.image
                  case .green:
                      material.roughness.contents = $0.image
                  }

              }
          default:
              break
          }
      }
      material.isDoubleSided = true
      materials.append(material)
      return materials
4

0 回答 0