Render Metal texture in SceneKit

Hi

I am trying to render a texture genereated by a Metal pipeline in a SceneKit scene. I have seen how you can create Scenekit a texture using a CALayer, but Im wondering if theres a way to do this by creating a SceneKit texture directly from a MTLTexture object. I think it would be a bit more effient to avoid rendering to the CAMetalLayer. Would greatly appreciate any help or pointers with this.

Thank you

You can set any of your geometry's material's SCNMaterialProperty attributes (eg, 'diffuse', 'ambient', etc) to have a 'contents' that's just a MTLTexture directly.


From the headers:


public class SCNMaterialProperty : NSObject, SCNAnimatable, NSSecureCoding {

...

public var contents: AnyObject?

...

Specifies the receiver's contents. This can be a color (NSColor, UIColor, CGColorRef), an image (NSImage, UIImage, CGImageRef), a layer (CALayer), a path (NSString or NSURL), a SpriteKit scene (SKScene), a texture (SKTexture, id<MTLTexture> or GLKTextureInfo), or a floating value between 0 and 1 (NSNumber) for metalness and roughness properties. Animatable when set to a color.

...

}

Render Metal texture in SceneKit
 
 
Q