How do I add alpha to a material for use as a 2d sprite?

(I hope this goes here)

Basically, i want to take a picture, cut a part out, make the background alpha and the picture visible. But not as a spray, it’ll be used with DrawQuadEasy. I need to know:

Is it done like a spray? if so, i have that part done
What should the VMT file contain, and does it even need a vmt file?

Yes it needs a VMT file and it should be like this:


$basetexture "path/texture"
$translucent 1

The $translucent bit enables the aplha. The alpha is just the transparent parts of a picture if you have a transparent background when you remove the unwanted parts of the image. If your image is imported as an animated VTF file like for a spray then yes that’s fine.

Edited to correct shader type - very important that the shader is right else it will be inviisble.

you also forgot the squigly brackets i believe. but thank you, i’ll try it out


the way i did it was create an alpha channel using photoshop and saved it as a vtf, are you saying it just needs the transparent background, no alpha channel?


Error: Material “hostilespace/ship1” uses unknown shader “UnitlitGeneric”


I believe you meant “UnlitGeneric”?

Ah yes I did forget the brackets, bugger :frowning:

$basetexture "path/texture"
$translucent 1

There that should work (actually checked up on what the shader is this time instead of trying to remember it ^^;)

Edit: Had a look at some other sprite VMTs and they use “$alphatest 1” instead of “$translucent 1” so if it doesn’t work try that.

The transparent background is the alpha channel :stuck_out_tongue:

Can you PM me your steamname so i can add you can discuss this further?

I still haven’t got this working right, i created an alpha channel in photoshop, filled the area that is not invisible with white, and left the rest black, i saved it as a vtf with default settings, i used both $alphatest and $translucent in my vmt, none of them will work

Saving it as a .vtf with the default settings won’t keep the alpha channel. Change the preset to “Compressed texture with alpha” instead of “Compressed texture”. It’ll use DXT5 compression, which retains alpha channel information.