I have a trivial macOS app that has an MTKView--it is just an MTKView inside a window. The fragment shader always does:
return float4(1, 0, 0, 0.01)
That's red with 1% alpha.
The CAMetalLayer belonging to the MTKView is non-opaque, as is the window:
_mtkView.layer.opaque = NO;
_mtkView.window.opaque = NO;
_mtkView.window.backgroundColor = [NSColor clearColor];
_mtkView.window.hasShadow = NO;
When I put this window over another app's window, I would expect the other app's pixels to show through unchanged. Instead, I see that black pixels turn red and white pixels are mostly unchanged.
In the screenshot below, the triangle has color float4(1,0,0,0.01) and there's a half-black half-white image in another window showing through it:
I would have expected black ever-so-slightly tinged with red, not bright red, in the left half of the triangle.
If my fragment shader is changed to do this:
return float4(1, 0, 0, 0.001);
Then it is completely transparent: pixels from other windows show through completely unchanged. This makes me think I'm hitting a not-well-tested code path in the window server, but I'm hoping there's something I can do to make it work.
What I tried
- Changing the appearance of the NSThemeFrame (had no effect)
- Turning on presentsWithTransaction (no effect)
- The GPU debugger confirms the drawable has the expected value