0
ID3D11Texture3D* pTexture3D;
D3D11_SUBRESOURCE_DATA initialData;
initialData.pSysMem = data;
initialData.SysMemPitch = 32 * 2;
initialData.SysMemSlicePitch = 32 * 32 * 2;
hr = g_pd3dDevice->CreateTexture3D( &texDesc, &initialData, &pTexture3D );

Like the code show that i want to load a data to a 3D texture, and the initialData loaded data from a file and the value are all positive. But when i sampling the 3D texture, i got a negative value. sampling code is:

g_Texture3D.SampleLevel(BilinearWrappedSampler, uvw, 0);
Doc.Q
  • 3
  • 4
  • What's the resource format? What's the resource view format? – Chuck Walbourn Aug 12 '17 at 23:31
  • The data I loaded from a file, and all the values are unsigned short, and the texture format I set DXGI_FORMAT_R16_FLOAT. I tried to load the same file with a 3D texture in OpenGL, the inner format of this texture I set RED, and the external format and type are RED and SHORT, but every value I sampled is positive. – Doc.Q Aug 14 '17 at 01:46
  • ``DXGI_FORMAT_R16_FLOAT`` is going to interpret each 16-bit word as a ``float16`` which is signed. You probably want ``DXGI_FORMAT_R16_UNORM`` or ``DXGI_FORMAT_R16_UINT`` depending of you want to work with the numbers as normalized in your shader or not. – Chuck Walbourn Aug 14 '17 at 02:49
  • Yes, I got it. But, the data external format change to the inner format of texture. UNSIGNED SHORT --> FLOAT16, if I set normalize, the external data will divide the max number of unsigned short and all the value will map to [0, 1], is it right? So, what is the time that the value will be negative when UNSIGNED SHORT(external format) -> FLOAT16(inner format) . – Doc.Q Aug 15 '17 at 01:19

0 Answers0