How can I print out shader modifier output in ARKit?

173 views Asked by At

I'm using SCNMaterial and set it diffuse.contents using surface shader modifier. I want to log some color values that is being fed to shader but I couldn't find to do that. Is there a way I can read and print _surface.diffuse.rgba after the execution of the shader modifier?

We show a video with green background on a SCNPlane and we want this to know the exact rendered color of that green. It's created as (0,220,0,1) but somehow it's read by shader modifier as different green and we can't mask it out as we can mask out full green (0,255,0,1) bg videos.

1

There are 1 answers

1
mnuages On

Xcode has a GPU debugger to investigate what’s happening on the GPU for a specific frame, see https://developer.apple.com/documentation/metal/shader_authoring/developing_and_debugging_metal_shaders

As to why the color appears differently, it may be a color space issue. When you provide color components to SceneKit shader modifiers it’s important to have them in the correct color space. See https://stackoverflow.com/a/44045637/2997825