Swift Playgrounds: How to add HDRI in a non AR RealityKit project?

114 Views Asked by At

I am creating a RealityKit project on Swift Playgrounds in Xcode, but I am using it in a perhaps less common way. I am using RealityKit but without AR, which is possible by an initializer of ARView.

As such, I am not using the camera at all. Thus, I need my own lighting in a virtual scene just like a SceneKit project. There are a couple of lighting options in RealityKit, but the best one for my use cases is using an HDRI (image based lighting).

I found this documentation on how to add one in a typical Xcode project:

https://developer.apple.com/documentation/realitykit/environmentresource#Creating-a-Skybox-Folder

It states:

  • I need to create a folder with a .skybox extension. I can do that, of course.
  • I need to place a single image inside the folder, my HDRI file. No problem.
  • I need to drag this folder to the Xcode project file navigator. Alright...

I have a problem.

I am prompted to create a folder reference (not a group) and add it to my app's target.

"At build time, Xcode compiles the image for use as an environment resource and inserts the result into the app bundle."

I don't know what to do. I am not using an Xcode project. I am using an Xcode Playground app playground (swiftpm).

The typical prompt when adding the folder to the project file navigator does not show up. Does this matter? Is there another way to add an HDRI to Xcode so I can use this for an app playground?

I really do not want to manually add lighting in RealityKit, and don't even know if that could replicate an HDRI.

Any thoughts on this? Other ways to achieve this? Mixing SceneKit? That sounds like a nightmare. I've thought about some very creative solutions!

Edit: Could I do something with the model I import? I am using Cinema 4D. Could I also perhaps do something in Reality Composer or even Reality Converter? Reality Composer Pro? (this isn't a visionOS app though). What other options could I use to replicate an HDRI in RealityKit? HDRIs are particularly useful because they're simple and manual lighting just doesn't seem to replicate it.

0

There are 0 best solutions below