Chris
Chris

Reputation: 2907

Apply a Shader on RealityKit Scene

Is there a way to apply a full screen shader to a RealityKit scene (Swift/iOS)?

I know I can do this with SCNTechnique in SceneKit/ARSCNView, but I'm dealing with an ARView.

With an ARSCNView I can apply a shader to run over the output of a scene, just like: https://medium.com/ar-tips-and-tricks/arkit-theory-an-introduction-to-scntechniques-710e024bc91e

But with RealityKit, I'm dealing with an ARView which doesn't have a SCNTechnique property

Thanks :-)

Upvotes: 2

Views: 1934

Answers (2)

Andy Jazz
Andy Jazz

Reputation: 58563

iOS RealityKit

In RealityKit for iOS you can apply not only background environmental image but also a HDR image for image based lighting (IBL). For applying environmental image use skybox(:_) type method.

func skybox(_ resource: EnvironmentResource) -> ARView.Environment.Background

This static method uses EnvironmentResource object that contains background data for your scene. You can read about it here and in my story on Medium.

Also, in RealityKit for iOS you are capable of applying a vertex/fragment shader (via CustomMaterial) and get the rendered scene as a texture (like you could do in SceneKit+Metal).

To find out how to disable a default environment lighting in ARView read this post.


visionOS RealityKit

Use RealityRenderer object to get access to customization of environment image and IBL:

RealityRenderer().lighting.resource = try! .load(named: "env")

This post, shows you how to enable a custom environment lighting in visionOS app.

Upvotes: 3

Niklas
Niklas

Reputation: 1331

There's a whole pipeline now for post processing, with CIFilters, SpriteKit or Metal Performance shaders. See this talk: https://developer.apple.com/videos/play/wwdc2021/10075/

Upvotes: 0

Related Questions