How do you call the effect where the edges around the central image gradually become transparent? This effect is also seen when viewing immersive mode of spatial photos in Vision Pro. How can I achieve this effect using SwiftUI or ShaderGraph? I want to use this effect when displaying images in my app.
Hi @NahtanMak
I was able to achieve a similar effect using shader graph. I adjust each pixel's opacity based on its distance from the center of the image. I used texture coordinates to calculate that distance.
Here's how to setup the graph:
- Add an
Imagenode. Connect itsOutto thecolorproperty on anUnlitSurface. - Add a
TextureCoordinatesnode. Connect itsOutto theInof aRemapnode. - For both columns of the
Remapnode, change:Out Lowto -1 andOut Highto 1. Drag itsOutto theInofMagnitudenode. - Drag the
Outof theMagnitudenode to a newRemapnode. SetOut Lowto 1 andOut Highto 0. Drag theOuttoOpacityon theUnlitSurfaceyou created in the first step. - Note: you can change the
In Lowproperty on theRemapnode you created in the previous step to control when the gradient begins. If you set it to 0 the gradient will start in the center of the image. If you set it to 0.5 the gradient will start 50% from the center of the image. If you set it to 1, there will be no gradient.
Please accept the answer if it works for you. Otherwise follow up with questions so I can help you achieve your goal!