TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

RealityKit and Reality Composer Pro: Custom Shader Material

Forums > iOS

Hello! I posted this in Stack Overflow, but I thought someone here might also be able to help.

I have a few questions about using RealityKit on iPadOS and Mac Catalyst.

I currently have a model in Cinema 4D that has no materials added to it. I need to add a couple of simple materials to everything.

My goal is to move my model from Cinema 4D to my RealityKit app. The model can load fine in the app. However, I'm having issues with the materials.

First, when I export from Cinema 4D as a USD, the materials don't seem to come with it. I thought materials came with the model. I just get a pink striped model (no materials), which is not ideal. So, that crossed out making materials in Cinema 4D for me.

Here's a test model with materials added:

Here's what it looks like when exported as a USDA in Reality Composer Pro. It looks the same when exported as a USDZ:

I checked materials when exporting from Cinema 4D, so I don't know what I am doing wrong. So, I thought of another idea instead of making materials in Cinema 4D.

What if I used Apple's new Reality Composer Pro app to add materials to my model? You can add physically based materials or even custom shader materials with nodes.

I thought that would work, and it does. When I export the model as a USDZ with physically based materials, they appear fine and work in my app.

However, what about custom shader materials?

Whenever I play with a custom shader material and apply it to my model, I am left with problems.

Look at this image. This is my model in Reality Composer Pro with two types of materials added from the app. The water and sand on the beach are created with physically based materials in the app. No nodes. The gold/metal ball is created with a custom shader material with nodes. Looks fine, right?

When I drag an exported USDZ of this into my Xcode project, it even looks good in the Xcode preview of the file under Resources. (Note I am not adding the USDZ as an . rkassets as Apple suggests as .rkassets folders are only available for visionOS. This is an iPadOS + Catalyst app.)

However, when I run the actual app, only the physically based materials actually display correctly:

Besides the lighting in the scene, the physically based materials look good. However, the metal ball that used a custom shader material? It looks gray.

Why? How can I fix this?

I guarantee this is not a problem with my app or its lighting setup etc. I tried loading a custom shader material in a visionOS simulator and it worked! But, not for this.

I know Reality Composer Pro seems to be very focused on visionOS right now, but this is still just a USDZ file. Why aren't these custom shaders working?

I've been working on this problem for at least 24+ hours, so I've tried as much as I could imagine.

I thought Reality Composer Pro would be good to do textures in as it would be less error prone when moving the model over to Xcode, compared to moving materials from Cinema 4D to Xcode, and I kind of proved that with my second photo.

For RealityKit on iPadOS + Catalyst, how should I be applying materials? What am I doing wrong?

P.S. Yes, this is a nonAR project with a virtual camera, which is possible for RealityKit.

Thanks for the help! :)


Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.