lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
246 stars 17 forks source link

42225473: Non-opaque windows blend incorrectly with other windows when using MTKView #20096

Open openradar-mirror opened 6 years ago

openradar-mirror commented 6 years ago

Description

Area: AppKit

Summary: An MTKView with a non-opaque layer in a non-opaque window should blend its contents with the windows behind it according to the alpha value produced by the fragment shader, but it appears much more opaque than it should be.

The attached screenshot shows the modified HelloTriangle over a PixelMator window with a half black, half white image, demonstrating that black pixels are transformed to red while white is almost unchanged.

Steps to Reproduce:

Modify the HelloTriangle demo to:

  1. Set the MTKView's layer's opaque property to NO
  2. Set the window's opaque property to NO
  3. Set the window's hasShadow property to NO
  4. Set the window's backgroundColor to NSColor.clearColor
  5. Modify the fragment shader to return float4(1, 0, 0, 0.1)
  6. Run it and place it over a window that is part white, part black.

See the attached code.

Expected Results: The area inside the triangle should be 99% transparent, adding a barely noticeable red color to its contents. Pixels behind it that are white should be just barely pink, while pixels behind it that are black should be a very dark black.

Actual Results: Black pixels behind the triangle become bright red. White pixels are still nearly white (going from 255,255,255 to 255,254,255 according to digital color meter).

Version/Build: macOS 10.14 Beta (18A326h) Xcode Version 10.0 beta 3 (10L201y)

Configuration:


Apple Developer Relations July 17 2018, 9:37 AM We have determined that this is an issue for you to resolve.

The CoreAnimation compositor requires all of its inputs be premultipled by alpha. See these references for more information: https://en.wikipedia.org/wiki/Alpha_compositing https://blogs.msdn.microsoft.com/shawnhar/2009/11/06/premultiplied-alpha/

When RGB are premultipled by alpha, then any RGB component that is > the alpha component is undefined through the hardware’s blending.

Modifying your fragment shader to return (0.1, 0, 0, 0.1), which is “0.1 alpha, full red” produces the expected results.

Please let us know whether the issue is resolved for you by updating your bug report.

- Product Version: 10.14 beta 3 Created: 2018-07-16T03:26:19.621760 Originated: 2018-07-15T00:00:00 Open Radar Link: http://www.openradar.me/42225473

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970

openradar-mirror commented 6 years ago

Modified: 2018-07-20T02:16:42.912970