Jump to content

  • Log In with Google      Sign In   
  • Create Account


SampleLevel not returning alpha component


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BattleMetalChris   Members   -  Reputation: 157

Like
0Likes
Like

Posted 07 April 2012 - 03:31 AM

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);


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 26967

Like
0Likes
Like

Posted 07 April 2012 - 03:41 AM

32bit bitmaps are kinda non-standard on Windows. Use the texture tool to convert it to DDS format.

#3 BattleMetalChris   Members   -  Reputation: 157

Like
0Likes
Like

Posted 07 April 2012 - 04:11 AM

haha, I feel like an idiot, I can't believe that didn't occur to me.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS