我创建了一个MTLTexture
使用UIImage
数据,如下所示。
var texture = metalView.currentDrawable!.texture
let uiImg = createImageFromCurrentDrawable()
guard let device = metalView.device else {
fatalError("Device not created. Run on a physical device")
}
let textureLoader = MTKTextureLoader(device: device)
let imageData: NSData = UIImagePNGRepresentation(uiImg)! as NSData
texture = try! textureLoader.newTexture(data: imageData as Data, options: [MTKTextureLoader.Option.allocateMipmaps: (false as NSNumber)])
我需要做的是改变像素颜色MTLTexture
。不是所有的人。那么,是否可以MTLtexture
在 Metal 中访问一组特定的像素并写入其中?