DXGI_FORMAT_R8_UNORM for luminance gives me only red channel

Jan 18, 2013 at 2:54 AM


I am trying to load a texture with the DXGI_FORMAT_R8_UNORM to obtain its luminance version(grayScale), in D3D9 i was used D3DFMT_L8 and the result is okay but in D3D11 i only obtain the red channel, what i am doing wrong?

Rendered Color image: https://lh3.googleusercontent.com/-XQkhyZgmoNo/UPjGwzvLvQI/AAAAAAAABSc/bX0x59atZvo/s656/good.png

Render with DXGI_FORMAT_R8_UNORM(bad!!): https://lh6.googleusercontent.com/-InIUXxqj4Ys/UPjGcUscRII/AAAAAAAABSU/9ZS8sw6Z2UQ/s647/DXGI_FORMAT_R8_UNORM.png

here is the code:

D3DX11_IMAGE_INFO* pImgInfo = 0;
	HRESULT imghr = D3DX11GetImageInfoFromFile( L"Tiles.png", NULL, pImgInfo, NULL);
	D3DX11_IMAGE_LOAD_INFO imgLoadInfo;
		imgLoadInfo.Width = D3DX11_DEFAULT;
		imgLoadInfo.Height = D3DX11_DEFAULT;
		imgLoadInfo.Depth = D3DX11_DEFAULT;
		imgLoadInfo.FirstMipLevel = D3DX11_DEFAULT;
		imgLoadInfo.MipLevels = D3DX11_DEFAULT;
		imgLoadInfo.Usage = D3D11_USAGE_DEFAULT;
		imgLoadInfo.BindFlags = D3D11_BIND_SHADER_RESOURCE;
		imgLoadInfo.CpuAccessFlags = 0;
		imgLoadInfo.MiscFlags = 0;
		imgLoadInfo.Format = DXGI_FORMAT_R8_UNORM;
		//imgLoadInfo.Format = DXGI_FORMAT_R16G16B16A16_UNORM;
		imgLoadInfo.Filter = D3DX11_FILTER_NONE;
		imgLoadInfo.MipFilter = D3DX11_DEFAULT;
		imgLoadInfo.pSrcInfo = pImgInfo;

	m_Texture = m_pRenderer11->LoadTexture( L"Tiles.png", &imgLoadInfo  );

Feb 5, 2013 at 1:24 AM
I am not really familiar with automatic luminance calculations from loading a texture... Unfortunately, unless someone else has some insight into this issue then I would have to suggest performing a manual conversion to 8 bit luminance in a separate tool and then just load that texture and use the R channel as the luminance.

Has anyone else used this functionality in D3D9 and found a matching functionality in D3D11?
Feb 5, 2013 at 6:05 AM
Hey there. I believe that you made a thread about this particular issue? If you still need help with this let me know, and I can try to assist you.