How to add glow entity in visionOS using RealityKit?

I want to create a ModelEntity that can glow like lightsaber in Star wars. Here is the video https://x.com/devtom7/status/1819743159213031453/

Answered by Vision Pro Engineer in 798829022

Try creating an UnlitMaterial with UnlitMaterial.Program.blendMode set to .add: https://developer.apple.com/documentation/realitykit/unlitmaterial/program-swift.class/descriptor-swift.struct/blendmode

This will enable the additive blend mode on your material, so that it glows in on top of the background.

You can also use additive blending when you create a shader graph material in Reality Composer Pro. To do this, set Opacity to 0 and "Has Premultiplied Alpha" to true in your UnlitSurface node:

For an end-to-end example, I recommend you check out the sample code "Creating a spatial drawing app with RealityKit" and its companion talk "Build a spatial drawing app with RealityKit". The splash screen of the drawing app features a glowing effect similar to the one you provided.

Try creating an UnlitMaterial with UnlitMaterial.Program.blendMode set to .add: https://developer.apple.com/documentation/realitykit/unlitmaterial/program-swift.class/descriptor-swift.struct/blendmode

This will enable the additive blend mode on your material, so that it glows in on top of the background.

You can also use additive blending when you create a shader graph material in Reality Composer Pro. To do this, set Opacity to 0 and "Has Premultiplied Alpha" to true in your UnlitSurface node:

For an end-to-end example, I recommend you check out the sample code "Creating a spatial drawing app with RealityKit" and its companion talk "Build a spatial drawing app with RealityKit". The splash screen of the drawing app features a glowing effect similar to the one you provided.

How to add glow entity in visionOS using RealityKit?
 
 
Q