Hide area of an SCNMaterial

324 Views Asked by At

I'm using SceneKit and ARKit 1.5, once a surface has been mapped I apply a material to it.

I would like to only show what's under the camera in a certain radius with an alpha effect. I want to keep the material static meaning that it does not move when the camera moves, only the radius shape will move.

What kind of technique could I use for this ?

ArCore by Google does this perfectly.

Actual rendering: enter image description here

Desired Rendering: enter image description here

ARCore example: (click to see GIF)

enter image description here

Thank you!

1

There are 1 best solutions below

3
On

I would use a shader modifier to achieve that.

Using the .surface entry point you could set _surface.transparent to a value that depends on the distance between the shaded point and the point of view:

_surface.transparent = attenuation(length(_surface.position));