Instruction
Creating Scenes in Reality Composer Pro
Similar to Interface Builder for UIKit apps, Reality Composer Pro houses a lot of easily accessible tools and settings to create entities, configure components, create materials, add spatial audio, and pack these into scenes which are represented by Universal Scene Description (USD) files. Composing scenes in Reality Composer Pro is much more straightforward, and you’ll see why Apple recommends using this tool.
You can create a stand alone Reality Composer Pro file, but you can easily create one in your project with the Vision Pro template in Xcode. This adds a Swift Package to the project that contains the RealityKit content.
Inside the RealityKit content package, you’ll find one or more scene USD files. The scene files and any content will be compiled into the project, if they are inside the RealityKitContent.rkassets. In Xcode, you can preview the files and the associated package in Xcode’s Project Navigator. Simply click the Open in Reality Composer Pro to launch the app and open the files.
In Reality Composer Pro, you’ll find the Viewport in the center, Hierarchy Panel on the left, Inspector Panel on the right, and Editor Panel on the bottom, which contains the Project Browser.
You can import assets into the Project Browser and then add them to the scene hierarchy. In the scene hierarchy, assets can be organized into groups. Assets here are references, so they can easily be replaced if needed.
In the Inspector Panel, you can quickly adjust an entity’s properties, like position, rotation and scale. Here you can also attach RealityKit components to an entity in the scene.
In RealityKit, you saw that you can add components and configure the properties in code. In Reality Composer Pro, you can add components to a selected entity and tweak the settings and properties right in the Inspector.
For example, to be able to interact with the objects directly or indirectly, you can add an input target component. For a collision component, you can adjust the shape to match the model and set size of the collision target. You can also add a physics body to the entity, set it to static, dynamic or kinematic as you did in code in the previous lessons. You can also change the properties at runtime in code, but it’s as easy as using a pulldown, checkbox or input field in Reality Composer Pro. You’re less likely to enter the wrong code than you might be if coding by hand in Xcode.
As you saw in code with RealityKit, in the inspector you can also set the friction values, add mass, even adjust an object’s velocity when it’s tapped. You’ll do this last part in the next lesson.
In Reality Composer Pro, you can create materials or import some ready-to-use entities and materials from the Content Library. Once you’ve composed the scene, preview it in the Viewport.
If you have a Vision Pro device paired with your Mac, you can preview the scene on the device. Get up and move around the preview scene rendered in front of your eyes.
As you learned in the first two lessons, materials are made up of shaders. These can simply be a color, they can use the Physical Based Rendering (PBR), or they can be made of images that contain information about the roughness and depth of the surface. You will use a leather material in the demo.
Roll Your Own Material
You can also create your own PBR materials and assemble them in Reality Composer Pro. To do this you start with a color photo that you use as the Diffuse color. Then, use an online service or a program like Photoshop to create a Normal map. This is a special image that shows the high and low points of your texture.
From the Filter menu in Photoshop, choose 3D ▸ Generate Normal Map.... While you’re there, make a Specular image map too. This describes how light reflects off your texture. Dark is more reflective than light. For example, metal is shiny and chalk is matte.
Lastly, make a Roughness map to show how rough the surface is. Specular and roughness source images are black and white, and you can adjust the contrast by lowering it to tweak the effect.
Pro Tip: It’s best to have an image that wraps when tiled. You can find web sites that use AI to adjust the four sides so that the texture will wrap seamlessly. For an example, check out https://www.imgonline.com.ua/eng/make-seamless-texture.php.
To create the material in Reality Composer Pro, click the + at the bottom of the hierarchy and choose Material ▸ Physically Based. Give the material a suitable name. You can also make a folder in the Project Browser to hold your source images. Drag your images into the folder so you can find them easily later.
With your new material selected in the hierarchy, use the Inspector to assign the images to material properties. In the Inspector you will see rows for each of diffuse, roughness and metallic. Click the icon on the right of each row to choose the relevant image. Diffuse and roughness are straightforward. Specular goes in the metallic slot.
Now, apply your material to an object as a material binding in the Inspector.
Demo Time
Head over to the demo next to see how you can use Reality Composer Pro to compose a scene and modify the behavior and properties of your entities.