Sign in to follow this  

SampleLevel not returning alpha component

Recommended Posts

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
[code]float4 sample1 = Image.SampleLevel(samPoint, sampleCoords[0], 0, 0);[/code]
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.

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:
[code]ID3D10ShaderResourceView* texView = 0;
HRESULT hr = D3DX10CreateShaderResourceViewFromFile(m_device, fileName.c_str(), loadInfo, 0, &texView, 0);[/code]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this