shader-graphvisionosreality-composer-progeometrymodifier

Possible bug in Reality Composer Pro GeometryModifier?


I don't have experience in Computer Graphics, so I am not sure how the GeometryModifier of the Reality Composer Pro works. But to me there seems to be a bug (Version 1.0 (385.2)).

To test, I created a scene with a flat box. Its center is placed at the origin, i.e. all its coordinates are on one side negative, on the other side positive.
The model uses a custom surface with a grey color, using a MaterialXPreviewSurface node. This node is required to show a preview, in the images below bottom right.

I added a GeometryModifier node to manipulate the Model Position Offset. Its input is thus connected to a Combine3 node that has x, y and z inputs. Without connected inputs, the default value 0 is used.

enter image description here

To make the cube's geometry dependent on the position of a point within the flat box, a Position node is added. Its output vector is decomposed by a Separate3 node to x, y, and z.

If now the x output is connected to the z input of the Combine3 node, the flat box is tilt as expected in the preview, and in the main viewport.

enter image description here

To make the box kinked in the middle, I connected an Absval node the the x output, and connected abs(x) to the z input of the Combine3 node. Now, the preview shows the kinked box, but in the main viewport, the flat box is neither tilt nor kinked, but flat and offset within z.

enter image description here

This seems to me to be a bug, although I am not sure because of the possibly used different coordinate systems, scaling factors, etc.


Solution

  • Poly Model resolution

    This isn't a bug, it's Reality Composer Pro primitives' resolution issue. The cube primitive in RCP has just 8 vertices, or in other words, 6 rect-faces (12 tri-faces). Your cube must have at least two faces along the X axis to apply the GeometryModifier. There are no center edges on your model where the fold line runs.

    enter image description here

    So, in a 3D authoring tool (like Maya 2024), create a custom cube primitive with, at least, two divisions on each axis, and then export it as a binary USD file. Now your GeometryModifier for MaterialX will work predictably.

    enter image description here

    Checking poly-Resolution in visionOS Simulator

    In Vision Pro Simulator, you can see RCP cube's 12 triangular faces if you run this code:

    import SwiftUI
    import RealityKit
    import RealityKitContent
    
    struct ContentView: View {
        var body: some View {
            RealityView { content in                
                if let scene = try? await Entity(named: "BoxScene", in: rkcb) {
                    let cube = scene.findEntity(named: "Cube") as! ModelEntity
                    cube.position = [0.0, 1.0,-2.5]
                    
                    var mat = UnlitMaterial(color: .yellow)
                    mat.triangleFillMode = .lines              // FILL MODE
                    cube.model?.materials = [mat]
                    content.add(scene)
                }
            }
        }
    }
    

    enter image description here