Reality Composer Pro | UnlitSurface and opacity maps error

Hello all -

I'm experiencing a shading error when I have two UnlitSurface shaders using images for color and opacity. When the shaders are applied to two mesh planes, one placed in front of the other, the shader in front will render and the plane mesh will mask out and not render what is behind.

Basically - it looks like the opacity map on the shader in front is creating a 'mask'.

I've attached some images here to help explain.

Has anyone experienced this error? And how can I go about fixing this - thx!

Hello,

I'm not 100% confident in this diagnosis at this point, but this sounds like a rendering order issue to me, that is, the rendered result depends on which plane is drawn by the system first. If it is a rendering order issue, then you may be able to resolve this explicitly by using ModelSortGroupComponent. If that doesn't help and you don't think it is a rendering order issue, then I'd need to see the RCP project to help further.

Do you have an example of adding a component to a ModelSortGroup and then setting the order?

something like: let myGroup = ModelSortGroup(depthPass: ModelSortGroup.DepthPass.postPass) let mySort = ModelSortGroupComponent(group: myGroup, order: 2)

How do I setup the group to let the sort order know what components to reference when I set the order?

@KevinTho any luck here? What did you learn or discover?

Thanks in advance for sharing.

Here is an example that uses ModelSortGroup:

import SwiftUI
import RealityKit

struct ContentView: View {
    
    let group = ModelSortGroup(depthPass: .postPass)

    var body: some View {
        VStack {
            RealityView { content in
                
                let innerBox = ModelEntity(mesh: .generateBox(size: 0.05), materials: [SimpleMaterial(color: .red, isMetallic: false)])
                
                let outterBox = ModelEntity(mesh: .generateBox(size: 0.1), materials: [SimpleMaterial(color: .blue, isMetallic: false)])
                
                innerBox.components.set(ModelSortGroupComponent(group: group, order: 1))
                outterBox.components.set(ModelSortGroupComponent(group: group, order: 0))
                
                innerBox.components.set(OpacityComponent(opacity: 0.5))
                outterBox.components.set(OpacityComponent(opacity: 0.5))
                
                let entity = Entity()
                entity.addChild(innerBox)
                entity.addChild(outterBox)
                            
                content.add(entity)
            }
        }
    }
}

Curious to see if the depth group answer solved this issue for you?

Reality Composer Pro | UnlitSurface and opacity maps error
 
 
Q