Can Materials not assigned to entities be retrieved from a .reality file?

like:

let mat = try await ShaderGraphMaterial(named: "matname", from: "reality")

currently I use an USD file with materials like so and it works:

try await ShaderGraphMaterial(named: "/Root/matname", from: "file.usda", in: appBundle)

when i try it with .reality i get "NameNotFound". so is it possible or do i have to have a bunch of dummy entities with my materials assigned so i can find the entity>components>material?

or what's the best way to author materials in RCP3 for quick access in realitykit?

Answered by Vision Pro Engineer in 902797022

Hi @artecolote,

I'm not aware of any other ways to achieve this with Reality Composer Pro 3 aside from the method my colleague suggested above, so I'd really appreciated if you could file a ticket with Feedback Assistant regarding this issue! Once you file the feedback, please post the FB number here so I can directly pass it along to the appropriate team.

Thanks!

Hey @artecolote,

Personally, I've chosen to have placeholder entities with the materials. I exported the material on sphere entity, which has the added benefit of getting a preview of the material in Xcode when you look over the files. Then I do something like this to pull out the material from the Reality File:

func getShaderGraphMaterial() async throws -> ShaderGraphMaterial? {
    // Given a ConcreteEntity.reality:
    let scene = try await Entity(named: "ConcreteEntity")

    guard
        let sphere = scene.findEntity(named: "sphere"),
        let model = sphere.components[ModelComponent.self],
        let material = model.materials.first as? ShaderGraphMaterial
            else {
        return nil
    }

    return material
}

Hope this helps,
Michael

Well im doing the same except its not much of a choice. im more curious as to why there is no direct access to assets.

The data exists in the reality file, it seems like it should be retrievable. it doesnt feel very swifty to create roundabout ways of achieving what was possible with RCP2

so i guess before i commit to this design pattern i wanted to know if this is it? Is this as good as it gets?

Accepted Answer

Hi @artecolote,

I'm not aware of any other ways to achieve this with Reality Composer Pro 3 aside from the method my colleague suggested above, so I'd really appreciated if you could file a ticket with Feedback Assistant regarding this issue! Once you file the feedback, please post the FB number here so I can directly pass it along to the appropriate team.

Thanks!

Can Materials not assigned to entities be retrieved from a .reality file?
 
 
Q