BigFatTom
BigFatTom

Reputation: 149

What is the main difference between float4 and half4 in fragment shader function?

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 ?

Upvotes: 9

Views: 7064

Answers (1)

Hamid Yusifli
Hamid Yusifli

Reputation: 10137

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.

Upvotes: 3

Related Questions