Game Development Community

HLSL tex2d question

by William Todd Scott · in Torque Game Engine Advanced · 11/07/2006 (9:32 am) · 3 replies

Hi,

I am trying to understand what happens in the following (very simple) case.

I set a 24-bit RGB texture and in the pixel shader do this:

float 4 col = tex2d(tex01, IN.texCoord);

What is put in the alpha channel and why?

It appears that the alpha channel will be set to 1.0f, but I'm not sure how/why that is happening.

Thanks
Todd

#1
11/07/2006 (2:07 pm)
1.0 is the default value for alpha if no alpha channel is provided.

On a side note, most cards do not natively support RGB textures. They are generally padded in the driver into RGBA textures with 1.0 in the alpha channel.

Why 1.0? 1.0 alpha implies a completely opaque texture, which is presumably what you want by specifying an RGB texture.
#2
11/07/2006 (6:48 pm)
Alex,

Thank you!

Todd
#3
11/07/2006 (8:29 pm)
This should probably find it's way into a FAQ on TDN.