Material masks. TF2 style healthbars?

Hey I am trying to fill a complex shape part way to represent the amount of fuel going into a rocket. How is this done in games such as TF2 where the cross fills up depending on how much health you have. Is there some sort of masking system source has?


I think this is a lua question seeing as it is HUD design if I’m wrong sorry!

Take a look at surface.DrawPoly. Specifying a u/v value less than 1 will crop the texture you’re drawing.

So create an inside texture for the shapes “fill” and an outline and crop the fill?


I cant use DrawPoly. It STILL has that bug where it chops of 75% of your framerate. Any other way to crop it?

Have you looked into…

What’s wrong with DrawPoly? it works fine for me.

I fixed it. Was something to do with gamemode_reload_cl

Only problem now is I swear you used to be able to do this:
surface.DrawTexturedRect( 0, 0, 200, 200 )

The texture is ALWAYS white. Anyway I can change it in lua? I don’t want to make two textures for two different teams. Also the colour won’t work even if I put constants in it.


Gotcha. Used the $color paramater and made it a material object.

I’ve had a similar problem where you can’t use other textured besides “color/white” with surface.DrawPoly. How exactly did you work around it? Like, what did you do with the $color parameter?

Look at one of the VMT files from gui/silkicons/.

	"$basetexture"		"gui/silkicons/box"
	"$ignorez"			1
	"$vertexcolor" 		1
	"$vertexalpha" 		1
	"$nolod" 			1

Just like that and I’ll be ok? (changing $basetexture of course)