SSAO with HRD texture causes color precision loss

SSAO2 with HDR texture causes color to “posterize”:

If you toggle “use hrd texture” off, this does not happen and image is smooth.

Yes, you should use the hdr=true setting because as you could see you don’t have enough dynamic range in ldr (the texture is a half float/float type in hdr and uint8 in ldr).

This error appears with hdr=true. Thats why I think this is a bug.

Somehow SSAO does not work correctly in hdr mode now…

You’re right! That’s because the texture format used by the SSAO2 post process is UINT, which is ok for non hdr because the gamma correction is applied before writing to the texture but is not ok for hdr because we clamp values to the 0…1 range.

Here’s a PR that fixes the problem:

When merged, you can pass the texture type used by the post processes (6th parameter of the constructor). Using BABYLON.Constants.TEXTURETYPE_FLOAT will fix the problem.