Face becomes white with ARKit and TrueDepth camera

Hello, I’d like to ‘transform’ my face with ARKit, SceneKit and TrueDepth camera.

One example is here : https://twitter.com/yt/status/1078534130416013312


To implement this, two images (Y and CbCr) are sent to a Metal shader, and they are converted to RGB in the shader as next document says.


Displaying an AR Experience with Metal | Apple Developer Documentation

https://developer.apple.com/documentation/arkit/displaying_an_ar_experience_with_metal?language=objc


But the face drawn by my shader becomes a little bit whiter than other (See the example video).


I set some SCNLightingModel to face’s SCNMaterial object, but this did not work.


The conversion from YCbCr to RGB is not enough? Do I need to do something more?


Thanks in advance.

Replies

Hello,


I changed the view to be drawn from ARSCNView to MTKView (MetalKit).

So I had to write much more code for pipeline, buffers, render encoder … 🙂


Then the image became what I expected!


Both fragment shaders are the same, just transform YCbCr to RGB.


Before : https://twitter.com/yt/status/1087230742017454080

After : https://twitter.com/yt/status/1089768732023390208


Thanks.