Animate transparency of blending property in RealityKit 2

Hello,

PhysicallyBasedMaterial in RealityKit 2 contains a blending property to adjust the transparency of a material. Is there a way to animate this over time to fade entities in and out?

I've tried the new FromToByAnimation API but could not figure out if there is a supported BindPath for the transparency.

Ideally what I would like to achieve is something similar to SceneKits SCNAction.fadeIn(duration: …) which also worked on a whole node.

I figured I could also go the route of a custom fragment shader here, though that seems overkill.

As RealityComposer also supports fade actions I would assume that this is at least supported behind the scenes.

Thanks for any help!

There is no way to animate the opacity with the API you specified. However, you could subscribe to your scene's update events, and animate the property yourself within there.

Hello!

There are a couple of different ways that you can do this, one is a custom shader as you mention, but it shouldn't be necessary for this problem.

The other way is to utilize the blending property of the PhysicallyBasedMaterial. Effectively, to "animate" this property, you can assign a new PhysicallyBasedMaterial.Blending value every frame that your animation is active (and update the materials property of the ModelComponent of the Entity per-frame with the "new" material). The new way to do "per-frame" things in RealityKit is to create a System. In the update method of this System, you are provided a context with the associated scene, and the deltaTime between frames. You can use this deltaTime to drive your animation. This System approach could also be extended to handle general, value based material property animations.

Animate transparency of blending property in RealityKit 2
 
 
Q