1

I am trying to render a smooth gradient from 0% to 10% gray across the screen of Asus Rog Phone 2 which supposedly has an HDR10 screen. In standard (8bit?) rendering mode I can clearly see banding between the gradient levels.

I followed the instructions from Android to modify the Vulkan tutorial sample code in the following way:

  • Added android:colorMode="wideColorGamut to AndroidManifest.xml.
  • Changed VkSwapchainCreateInfoKHR.imageFormat, VkAttachmentDescription.format and VkImageViewCreateInfo.format to VK_FORMAT_R16G16B16A16_SFLOAT (everything to setup swapchain).
  • Changed VkSwapchainCreateInfoKHR.imageColorSpace to VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT.

I render the gradient dynamically in a custom fragment shader as a function of texturing coordinates mapped to a full-screen quad:

layout (location = 0) in vec2 texcoord;
layout (location = 0) out vec4 uFragColor;
void main() {
   uFragColor = vec4(vec3(texcoord.x*0.1), 1.0);
}

As a result I observe absolutely no difference from the original 8bit(?) mode. I am not quite sure how to debug it and what to try.

I also tried to implement the same effect in Unity with HDR options enabled. There I see that all the intermediate rendering passes (in Forward mode) render to Float16 but the last extra pass likely converts it into RGB8. The visual result is the same banding again.

This makes me wonder whether this is not caused by some missing setting. In another thread I saw discussion of Window.setFormat(PixelFormat) or SurfaceHolder.setFormat(PixelFormat) but I am not sure how this related to a Native Android app. I cannot see a way how to call such function and I am not even sure if it would make sense.

Thank you for any suggestions.

erkil1452
  • 21
  • 2
  • Check this answer: https://stackoverflow.com/questions/49776684/android-emulator-color-banding-with-hardware-acceleration-opengl-es-3-0 – PerracoLabs Apr 04 '21 at 22:02
  • @PerracoLabs Thank you but my issue seems different. The bands I observe are distributed uniformly so I do not suspect that gamma is the issue. I see 25 and bands for the grayscale range 0 -- 0.1 which is what I would expect with 8bit display. My hope is to achieve the 10bit display mode and make the steps imperceptible. – erkil1452 Apr 05 '21 at 03:19

1 Answers1

0

Where are you setting HDR? HDR is PQ transfer function, neither 10 bit, not BT.2020 has anything to do with HDR.

https://developer.android.com/training/wide-color-gamut

This talks only about WCG.

This should be used to trigger HDR. https://developer.android.com/ndk/reference/struct/a-hdr-metadata-smpte2086

For Java this should be used to check whether HDR is there. https://developer.android.com/reference/android/view/Display.HdrCapabilities?hl=en

See this question with further links What is the difference between Display.HdrCapabilities and configuration.isScreenHdr