Image Input for ShaderGraphMaterial

In RealityComposerPro, I've set up a Custom Material that receives an Image File as an input. When I manually select an image and upload it to RealityComposerPro as the input value, I'm able to easily drive the surface of my object/scene with this image.

However, I am unable to drive the value of this "cover" parameter via shaderGraphMaterial.setParameter(name: , value: ) in Swift since there is no way to supply an Image as a value of type MaterialParameters.Value.

When I print out shaderGraphMaterials.parameterNames I see both "color" and "cover", so I know this parameter is exposed.

Is this a feature that will be supported soon / is there a workaround? I assume that if something can be created as an input to Custom Material (in this case an Image File), there should be an equivalent way to drive it via Swift.

Thanks!

Replies

Here is what I did to send an image to ShaderGraphMaterial.

let img = getSomeUIImage()
let mat = getShaderGraphMaterial()
if let cgImg = img.cgImage {
    let texture = try TextureResource.generate(from: cgImg, options: TextureResource.CreateOptions.init(semantic: nil))
    try mat.setParameter(name: "cover", value: .textureResource(texture))
}