Dynamic texturing API for SceneKit or ARKit

Is it possible with ARKit/SceneKit to texture a DAE/SCN model programatically, on-the-fly?


Use case is: I will have 1 model that I would like to "skin" with potentially thousands of similar-yet-different textures. And I can either:


  • Texture the models ahead of time and force either my app or my backend to host thousands of bulky textured model files (the all use the same heavier 3D model/mesh file and each combine it with a different lighter 2D texture file); or
  • Allow my app/backend to ship with 1 heavy/bulky 3D mesh/model file, and thousands of lighter 2D texture files, and then use some SceneKit/ARKit API to apply the correct texture to the model in-memory, on-the-fly


Is this dynamic texturing capablity possible? If so, how? If not, then why (curious!)?

Replies

Hi hotmeatballsoup,
Have you solve this problem or do you have any update?
I'm facing the same one and it's reallu frustrated..
Thank you;)

You can change materials on the fly programmatically.


a SCNNode's geometry (the model) has an array of materials. A material has various properties, say you want to change the diffuse on a node, it would be something like:


myNode.geometry!.materials![0].diffuse.contents = myTexture.cgImage


I do this for a handfull of models and make the change a few times a second and it doesn't slow things down. I have NOT tried to update models' textures sixty times a second, I would worry that that would slow things down if much else was going on.


Note that I use a handful of textures that I keep loaded in memory. "Thousands" may slow things down, dozens would probably be doable if they were not too large.


It may go without saying, but you will most likely have to wrap the change in SCNTransactions to actually make the change occur when you want it to.