SampleLevel not returning alpha component

Started by
1 comment, last by BattleMetalChris 12 years ago
I'm sampling a texture in a Geometry shader. As you can't use Sample() in a GS, I'm using SampleLevel() and specifying the mip level (0 as I need to sample it at full resolution).

It's not picking up the alpha component of the texture though - the statement
float4 sample1 = Image.SampleLevel(samPoint, sampleCoords[0], 0, 0);
although the RGB components are correct, the alpha component is always 1.

The texture is a 32-bit .bmp with which I have created using another application I've written. I've checked the texture using the DirectX texture tool and the alpha channel is definitely present in the .bmp file.

I've also checked in my code in the debugger and also checked the format of the texture resource in pix and the texture is definitely being loaded as an R8G8B8A8_UNORM.



EDIT:
Actually, looking at the resource in Pix, the alpha channel is completely white, so it looks like the problem is to do with loading the texture rather than sampling it. Is there anything special I need to specify when I load the texture so it'll pick up the alpha channel from a 32 bit .bmp file?

This how I load my texture:
ID3D10ShaderResourceView* texView = 0;
HRESULT hr = D3DX10CreateShaderResourceViewFromFile(m_device, fileName.c_str(), loadInfo, 0, &texView, 0);
Advertisement
32bit bitmaps are kinda non-standard on Windows. Use the texture tool to convert it to DDS format.
haha, I feel like an idiot, I can't believe that didn't occur to me.

This topic is closed to new replies.

Advertisement