Jump to content
  • Advertisement
Sign in to follow this  
Shael

HLSL Texture Samplers

This topic is 3052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know what value gets put into the alpha channel if you try sample a texture that doesn't have an alpha channel? Eg. if I have a bitmap loaded in and I sample it in the shader with: float4 tex = tex2D(TextureSampler, TextureCoords) What gets put into tex.a? 0? I ask because I want a good way to determine if in a specular map, the power/gloss value has been put into the alpha channel, and if not, use a default value.

Share this post


Link to post
Share on other sites
Advertisement

I'm not sure, but I think this is one of the areas where no predictable behavior is guaranteed (like behavior when setting a texture to null). It might be a more robust option to convert your textures to use an alpha channel with the default value. That way you don't need extra code for special cases, which as I got told is always a good thing [smile]

Share this post


Link to post
Share on other sites
To my knowledge, the behaviour is indeed specified. The default result of a texture access is (0, 0, 0, 1). So if you access a one-channel texture, you'll get (r, 0, 0, 1) as a result.

You might want to reread it in the documentation, though.

Share this post


Link to post
Share on other sites
Thanks. The documentation doesn't really specify what is returned.

http://msdn.microsoft.com/en-us/library/ee418491(VS.85).aspx

I guess I'll just have to test it out and see what happens.

Share this post


Link to post
Share on other sites
Quote:
Original post by Shael
I guess I'll just have to test it out and see what happens.


Unless you have every GPU and driver made in the last 7 years that you can test on, I wouldn't recommend that approach.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!