Search code examples
floating-pointpixeldirect3dhlsl

Direct3D conversion of float to 8-bit channel


If i have A8R8G8B8 render target and assign float number to alpha in return of pixel shader, how in this case 32-bit float would be converted to fit 8-bit?


Solution

  • The A8R8G8B8 format specifies a 4-channel color with 8 bits per channel. Direct3D automatically converts return values to the specified destination format, typically in the UNORM range for render targets. For 8 bits, UNORM encodes 256 evenly-spaced values between 0.0 and 1.0, inclusive. The default rounding behavior is round-nearest, ties-to-even.