'Blend semi-transparent overlay over HDR content in OpenGL

The set up is the following:

The bottom layer will be an image or video, which sometimes will be HDR. It might run on Android or other hardware, so it's apparently a bit hard to know if the content showing is actually HDR.

The layer that is displayed above is a simple black overlay with 80% alpha.

I've looked into some of the APIs for DirectX etc and some of them provide a nit-level that you can multiply the overlay color with to get a similar result. But for OpenGL, I'm not sure how this should be done. Something tells me that there should be some way of blending the top layer with the SDR/HDR content to make sure that the 80% alpha stays consistent. Currently it gets too bright when it's above HDR.

Does anyone have any ideas? The color will just be black or a dark gray.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source