I have an array of images, I have to select one image at random based on the vertex, with metal I can achieve this MTLTexture2DArray.
But I use SceneKit and Custom SCNProgram, and the problem with it is that I could not pass MTLTexture to the metal fragment function.
If I set the image to SCNMaterial, it works, if I set the metal texture, it throws an exception.
let material = SCNMaterial()
material.program = program
material.setValue(metalTexture, forKey: "customTexture")
The problem is exactly the same as in this question
Passing Metal texture2d_array to the SceneKit shader modifier
but it uses a shader modifier, and here I use a custom shader.
Is it possible to pass an array of texture textures to a custom SCNProgram or is there another way to pass an array of images to shader functions in SCNProgram?
source
share