9

I try to set render pipeline and MTKView color attachment pixel format of MTLPixelFormatRGBA16Float.

However, it seem same with MTLPixelFormatBGRA8Unorm_sRGB.

I just want to make the render color range higher(HDR).

Is the return type of the fragment function important?

What should I set to realize a high dynamic range in metal ?

BigFatTom
  • 149
  • 1
  • 6
  • Are you actually producing color values outside the [0, 1] range? Are you applying any kind of tone-mapping process? It sounds like you've succeeded in creating an HDR rendering target, but are you doing any HDR drawing? – warrenm Jul 13 '18 at 15:35
  • Yes. I use a MTLPixelFormatRGBA16Float and MTLPixelFormatBGRA8Unorm_sRGB format texture to store some color values outside [0,1] in one render pass. After that, I use some simple tone-mapping algorithm to map it inside [0,1] in another render pass. – BigFatTom Jul 16 '18 at 06:18
  • Is that HDR mean the color can store outside [0,1] range in the middle render pass and map inside [0,1] range in the last render pass? Thanks for your help. @warrenm – BigFatTom Jul 16 '18 at 06:20
  • That's an important part of it, yes. Using higher-precision intermediate targets is what enables things like bloom, depth-of-field, etc., which are often considered to be big components of the HDR "look." – warrenm Jul 16 '18 at 07:34
  • By the way, use `half4` as your fragment function return type when possible, especially on mobile. – warrenm Jul 16 '18 at 07:35

1 Answers1

3

Based on this Metal Shading Language Specification

float:

A 32-bit floating-point. The float data type must conform to the IEEE 754 single precision storage format.

Full float precision is generally used for world space positions, texture coordinates, or scalar computations involving complex functions such as trigonometry or power/exponentiation.

half:

A 16-bit floating-point. The half data type must conform to the IEEE 754 binary16 storage format.

Half precision is useful for short vectors, directions, object space positions, high dynamic range colors.

Hamid Yusifli
  • 9,688
  • 2
  • 24
  • 48