Babylon Native not rendering HDR to Render Target Texture

Hi All, Im noticing that HDR rendering isnt working in Native . See the two screenshots.
** from browser
browser

** from babylon native
native

the ABXY buttons from native is duller than what we are seeing on the browser. (post processing, material, lighting setup is identical… its the same code).
Also for post processing we are using scene.imageProcessingConfiguration NOT defaultRenderingPipeline.

There is some colored text and a transparent bubble over it which is reflecting a HDR .env. its the transparent HDR .env that adds the brightness to the ABXY buttons because of alpha blending. I dont think this has anything to do with the renderer but rather the RTT. We were using DXGI_FORMAT_R8G8B8A8_UNORM which is 8 bit so thought this just needs to be 16 or 32bpp.

so i changed this to DXGI_FORMAT_R16G16B16A16_UNORM but that wasnt it. I also tried
DXGI_FORMAT_R32G32B32A16_UNORM. That resulted in a washed out looking image even though i was gamma correcting in the end like this:

Oh and I know the drill with a repro, i’ll try to get something going, but figured id post incase anything obvious stands out :slight_smile:

Any thoughts?
@bghgary @sebavan

Can you capture a frame with RenderDoc and send it to me privately?

1 Like

@bghgary sent.

Unfortunately, I don’t think I can figure this out from just the RenderDoc output. I tried but there are many draw calls and it’s difficult without source or something to compare with. I need to be able to compare a working version on the web that I can use Spector.js and compare with the native version with RenderDoc.

HDRFiltering does not work on Android phones - Bugs - Babylon.js (babylonjs.com)

Environmental reflection problem of gltf model - Questions - Babylon.js (babylonjs.com)

Reading both pages, I guess this should be the same issue.

thanks so much for investigating. i think ive tracked this down to a more fundamental problem with the renderer that manifests its self also on the browser side and how reflections are blended/composited. So i dont think this has anything to do with Native afterall (apologies for the oversight), so yes its also happening on the regular engine. Im putting together a PG right now that clearly illustrates the issue. this is good news as at least we can repro this in an environment we can both work in. :slight_smile: I suspect @sebavan may have some thoughts. This thread contains hints of this issue as well. Enabling HDR in defaultPipeline disables AA

@bghgary @sebavan here is the repro:

  • if you disable the default rendering pipeline, note that the abxy buttons render darker.
  • if you diable HDR rendering in the rendering pipeline, the abxy buttons render darker. as you would expect.

i assume if we dont have a rendering pipeline its using scene.imageProcessConiguration. I thought the renderer by default is in “HDR mode” … am i correct? mabey there is a flag that needs to be set to get the scene to render in HDR? I have combed the docs and cannot find a way to turn on HDR which leads me to assume it should just work.

also i have a feeling some of this is my own confusion on the difference between scene.imageProcessConiguration and DefaultRenderingPipeline. I thought they should look exactly the same except that DefaultRenderingPipeline is a post process that is applied to everything (the RTT) where as imageProcessConiguration is per material.

in the end… we want scene.imageProcessConiguration to look identical to DefaultRenderingPipeline. we also would like to use scene.imageProcessConiguration for the brunt of post processing moving forward, but need the refelctions to look like how it looks when using DefaultRenderingPipeline in HDR mode.

1 Like

TL/DR it is not possible as the canvas itself does not allow hdr so far so the rendering is limited to 0…1 with 8 bits per chanel.

But in your case the difference comes from the blending, As this scene uses transparency, one is doing blending in linear and the other in gamma space resulting in the difference you observed between with and without pipeline.

Finally about why the pipeline in ldr does not work like hdr, it is because we internally rely on imageProcessing only as an optim if the pipeline is ldr :slight_smile:

got it. Looks like we have to use DefaultRenderingPipeline.
Guessing there is no way to get 8bpp to blend in linear space?
Also, just to be clear, you are saying the real limitation is that browers dont support greater than 8bpp on the canvas element? (that would make sense)

Blending in linear space would require sRGB support for the canvas back buffer I guess. HDR would be a plus but not mandatory. This is a coincidence that it works in hdr in the PG. It is only related to the extra pass done in linear space.