I am implementing a "glow" effect in RealityKit. I followed this open source library which is in SceneKit: https://github.com/laanlabs/SCNTechniqueGlow. The basic idea is to create a "mask" texture that includes all the nodes that we want to "glow", then do a gaussian blur (in both horizontal and vertical direction) of the mask, then combine the blurred mask and the original texture to create the effect.
I was able to replicate the same result in RealityKit using post-process. However, I am not sure how to apply the "glow" to only selected entities (For example, only those entities with a GlowComponent). In SceneKit, this can be easily done by includeCategoryMask, as documented here: https://developer.apple.com/documentation/scenekit/scntechnique:
A bitfield used for including nodes in the drawing pass if the draw key specifies DRAW_SCENE or DRAW_NODE. Defaults to all bits set. See Category Masks.
There doesn't seem to be similar API in RealityKit.
I have uploaded a sample project here: https://drive.google.com/file/d/1-CakPFTvc4ckbIWrirGxx8EQI94Q_051/view?usp=sharing
When you run it, you can see 2 views (screenshot): the top view is a SCNView that uses the SCNTechnique; the bottom view is a ARView that uses postprocess to achieve the same effect:
For SceneKit (top), the left box has the category bit mask specified in
includeCategoryMask, so only left box has the contour.For RealityKit (bottom), I'd like to only apply the contour to the left box which has a
GlowComponent, and leave the right box out (Right now it's applied to all entities)
masking. Creating an accurate mask requires from you a well-designed algorithm in the Metal kernel. I thinkcategory masksare useless in this case.rgb*aimage compositing).