'CustomMaterial' is unavailable in xrOS

Hi

I created the VisionOS demo app and tried to use custom material shader for a box model. But I failed to compile the project. XCode says that "'CustomMaterial' is unavailable in xrOS". Is there possible way to use custom shader for ModelEntity of RealityKit in VisionOS?

Answered by Graphics and Games Engineer in 757200022

I don't have an example handy, although I believe some of our sample projects should use MaterialX. You can also watch this session on Reality Composer Pro https://developer.apple.com/videos/play/wwdc2023/10202/.

You can use ShaderGraphMaterial, and create a MaterialX shader graph in Reality Composer Pro.

@Graphics and Games Engineer . Thank you for your reply. I tried to make a example file in Reality Composer Pro and load it in the code as follow. let shader = try ShaderGraphMaterial.load(named: "Material", from: "Untitled.usda", in: Bundle.main) But, it throws an exception. Can you make a example for me?

Accepted Answer

I don't have an example handy, although I believe some of our sample projects should use MaterialX. You can also watch this session on Reality Composer Pro https://developer.apple.com/videos/play/wwdc2023/10202/.

You might take a look at this session video where she goes over working with content from Reality Composer Pro in Xcode (https://developer.apple.com/videos/play/wwdc2023/10273/?time=1818) including materials (toward the end of video).

And the Diorama sample code is available here (https://developer.apple.com/documentation/visionos/diorama), which also might be helpful, specifically the DioramaView where the RealityKitContent is loaded and how they navigate the hierarchy of the Reality Composer Pro scene.

Maybe a workaround for lack of CustomMaterial support: I saw that we can replace a TextureRource with a drawable queue. But I need an example of the shader interface as the RealityKit::surface do not exists anymore on visionOs. Maybe an Apple engineer have a sample somewhere ?

'CustomMaterial' is unavailable in xrOS
 
 
Q