Distorted texture with surface.DrawTexturedRect()

Hey guys, I’ve seen someone mention this before in the big help thread, although there were no replies. So I’m not the only one having this issue.

Basically it’s a 170x30 image and this is what the source looks like and the one in Garry’s Mod:

If you look zoomed right in you’ll see just how horrible GMOD renders it.

This is the code in its most simple form:

local tr = Material(“razor/roles/role_traitor.png”, “nocull”)

//In a HUD drawing function
surface.DrawTexturedRect(0, 0, 170, 30)

I don’t really see why it looks remarkably different, is this some kind of filter applied to the texture blurring it and such? If so how can I turn this off.


I can see the edges of that TexturedRectangle I think, it’s like the texture you have doesn’t cover the rectangle entirely. surface.SetDrawColor(Color(255,255,255,255)) Sets the rectangle’s color to black and no transparency.

I wonder what would happen if you made it surface.SetDrawColor(Color(255, 0, 0, 0)) The worst thing that could happen is that the texture disappear, if that is so you could try to color the rectangle red so that it looks like it’s a part of the texture. surface.SetDrawColor(Color(255 ,0 , 0, 255))

The edges of the one of the right are black as it is taken from in-game, it’s whatever is behind it at the time.

It’s the strange distortion causing all my issues, the edges are fine (except the distorted one has slightly badly formed edges.

You have to draw it with the same width and height as the file itself.

You might just need to use some different settings when creating that .vtf file.

According to this thread I found, these settings in VTFEdit give good results:

Point Sample
No minimum Mipmap

  • Defaults

local tr = Material(“razor/roles/role_traitor**.png**”, “nocull”)
You don’t need to create vtf files now. Just place a png and you’re good to go. However, I don’t know what is causing that distortion.

Oh, well that’s handy. Didn’t even know you could do that…

I’ll try turning it into a vtf with those settings, perhaps it will override this distorted looking filter.

I can’t seem to get the .vtf to display, even though the client successfully downloads a copy. There’s so many settings for the VTF and the file size is a bit insane.

Is there a better way to display an image on the screen?

Id make a transparent PNG with a width of 256 and a height of 32 and just paste that button in it… save it and load it in game, make sure the image sizing in the code reflects the actual image size of 256x32…

had the same problem as you’re having before, and this is how i fixed it. :slight_smile:


//In a HUD drawing function
surface.DrawTexturedRect(0, 0, 256, 32)


Thank you, it looks perfect now.