blenderrealitykitreality-converter

Object conversion from Blender to RealityKit


I am quite new to Blender (using 4.2.1) and I am creating some models I want to use inside a RealityKit scene. In one case, I am creating a pole with a PBR material that I want to convert to .usdz format with Reality Converter. However, the preview in RC does not match the visual I have from the model in Blender.

Blender viewport

Reality Converter preview

If you notice, the top face of the pole is not rendering correctly in RC, and the inside face is showing to the front, while the back face is not being covered by the inside face.

For this output, I have baked the textures in Blender, and exported the object as .obj, then linking the texture files back in RC. I have also tried the direct export from Blender as .usd (same result) and .gltf or .glb (latter fail to load in RC with "unknown error").

The model in Blender is UV mapped correctly, with seams to divide the inner, outer, top and bottom faces.

Before I go and learn Maya, do you have any suggestions on which workflow could fix this?


Solution

  • This issue is called Reversed Face Normals. You can flip the normals back in RealityKit using faceCulling instance property. Choose between .front and .none.

    import SwiftUI
    import RealityKit
    
    struct ContentView : View {
        var body: some View {
            RealityView { rvc in
                let tube = try! await Entity(named: "tubeReversed")
                rvc.add(tube)
                print(tube)
                
                var pbr = PhysicallyBasedMaterial()
                pbr.faceCulling = .front
                let cyl = tube.findEntity(named: "cylinder") as! ModelEntity
                cyl.model?.materials[0] = pbr
            }
            .ignoresSafeArea()
            .backgroundStyle(.black)
        }
    }
    

    enter image description here

    enter image description here

    enter image description here

    enter image description here