Materials spaz out when used with surface.DrawPoly.

Could someone inform me on what I’m doing wrong? I’ve created a 32x32 plain white vtf/vmt image that I want to use for the background of a surface.DrawPoly. Although when I look at it in game, it will spaz between the colors white grey and black in a million different lines and flickering patterns.

I’m using the example code from the wiki for a triangle as well.
triangletex = surface.GetTextureID(“hud_display/white_block”) – this is our triangles texture, try to find your own
centerx = ScrW()/2 --this is the middle x cordinate
centery = ScrH()/2 --this is the middle y cordinate
trianglevertex = {{ },{ },{ }} --create the two dimensional table

–First Vertex
trianglevertex[1][“x”] = centerx
trianglevertex[1][“y”] = centery
trianglevertex[1][“u”] = 0 //Top Left
trianglevertex[1][“v”] = 0

–Second Vertex
trianglevertex[2][“x”] = centerx + 50
trianglevertex[2][“y”] = centery
trianglevertex[2][“u”] = 1 //Top Right
trianglevertex[2][“v”] = 0

–Third Vertex
trianglevertex[3][“x”] = centerx
trianglevertex[3][“y”] = centery + 50
trianglevertex[3][“u”] = 0 //Bottom Left
trianglevertex[3][“v”] = 1

HUD_DISPLAY.HUD = function()

surface.SetTexture( triangletex ) --set the texture of the triangle
surface.SetDrawColor( 255, 255, 255, 255 ) --set the additive color
surface.DrawPoly( trianglevertex ) --draw the triangle with our triangle table

hook.Add(“HUDPaint”, “Draw a trifecta.”, HUD_DISPLAY.HUD)

You should use my triangle example.
if SERVER then
function surface.DrawFilledTriangle(ax, ay, bx, by, cx, cy, col)
local triangle = {
{x = ax, y = ay},
{x = bx, y = by},
{x = cx, y = cy}

hook.Add("HUDPaint", "SurfaceTriangle", function()
	surface.DrawFilledTriangle(100, 100, 50, 150, 150, 150, Color(255,255,255,255))


Also, make sure that the vmt type is an UnlitGeneric.

How would I make it UnlitGeneric, I don’t see a flag for that and I’m new to making materials and using this vtf editor? Also is that what is causing the issue for my flickering image? As well I switched to the code you’ve given me, thanks.

You should see this when you go to your VTF edit.

Then when you’re making the VMT file.

An alternative would be to just open your VMT with VTF edit and just edit the top part here:


Ok cool I got it working! Thanks for the help.