How can I use UIImage contents as MDLMaterialProperty baseColor semantic?

How to set baseColor semantic of MDLMaterialProperty using UIImage contents.


//Here is the code

let scatterngFunction = MDLScatteringFunction()

let material = MDLMaterial(name: "objMaterial", scatteringFunction: scatterngFunction)

let property = MDLMaterialProperty(name: "texture1", semantic: .baseColor, url: URL(fileURLWithPath: "unwrapped_template.png"))

material.setProperty(property)


But I want to change baseColor semantic property dynamically loading 2d template image contents from memory not using URL as above.


Is there any alternative way to get this done?