DirectX11 可以将负值写入纹理格式的浮点数吗?

DirectX11 can write minus value to texture formatted float?

我想将正常值写入格式为 DXGI_FORMAT_R11G11B10_FLOAT 的纹理。 我知道写“0.5 * normal + 0.5”效果很好。 但是我的纹理格式是浮动的,所以我尝试写解压正常但它没有用。 DirectX11 是否支持负值纹理?

DXGI_FORMAT_R11G11B10_FLOAT 是一种唯一的格式。参见 Microsoft Docs

Three partial-precision floating-point numbers encoded into a single 32-bit value (a variant of s10e5, which is sign bit, 10-bit mantissa, and 5-bit biased (15) exponent). There are no sign bits, and there is a 5-bit biased (15) exponent for each channel, 6-bit mantissa for R and G, and a 5-bit mantissa for B, as shown in the following illustration.

如果要将负浮点值写入渲染目标,则需要使用不同的格式。

DXGI_FORMAT_R32G32B32A32_FLOAT
DXGI_FORMAT_R16G16B16A16_FLOAT

DXGI_FORMAT_R32G32B32_FLOAT 也是一个选项,但任何 Direct3D 硬件功能级别都不需要支持此格式作为渲染目标。您必须检查支持情况,并在不支持时进行回退。