Looking to live-edit drawn Textures on a Derma panel

Hi! I’m looking to draw some textures (extensions .vmt and .vtf to clarify precisely what I mean) and have have their colors dimmed, so the texture looks grey-scaled. I’m using surface.SetTexture, with the texture’s ID as its one argument, in a button’s Paint() function. My code currently looks like the following:

but.Paint = function()
surface.SetDrawColor(255, 255, 255)
surface.DrawTexturedRect(1, 1, buttonWidth - 1, buttonHeight - 1)
return true

I have edited most vars’ names so you understand what my intentions with them are.

From my understanding, and this has worked well for me in the past with Materials (so .png’s and .jpg’s), editing the RGB values in surface.SetDrawColor changes what RGB is used when drawing the Material (but in my case I want to draw a texture). If I want the Material’s colors to be dull, I can set the RGB values to half of what I otherwise want them to be (in most cases, 255 for all 3) and, as most people reading this know, the picture will look a lot more grey/black/dull.

Out of the 8 *textures *I’ve tried “editing” with surface.SetDrawColor, only 1 of them has seen any effect. Only 1 of the textures would change its colors when I edited surface.SetDrawColor, the other 7 remained the exact same color. This brings me to a screeching halt because I don’t quite know where to proceed next.

Utilizing the Gmod wiki, I know Materials can be changed far more drastically using Post-Processing Materials, but the page is about Materials and not Textures.

So… what do? Can I still utilize the same post-processing materials for textures? And if so, what does it look like? Thanks for any help.

surface.SetMaterial works with VTF / VMT files. You can just use that. For example:

local vtf = Material( "dev/dev_measurecrate01" ) -- This is a VMT / VTF

hook.Add( "HUDPaint", "VTFTest", function()
	surface.SetMaterial( vtf )
	surface.SetDrawColor( 255, 255, 255 )
	surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end )

I don’t have the slightest clue what

surface.SetTexture is meant to be used for. All it has given me so far is pain and suffering.

[editline]17th October 2017[/editline]

Or, in your case:

but.Paint = function()
    surface.SetDrawColor( 255, 255, 255 )
    surface.SetMaterial( TextureIDHere )
    surface.DrawTexturedRect( 1, 1, buttonWidth - 1, buttonHeight - 1 )
    return true

You are right, I just tested, I can use Material with VMTs/VTFs, but, my problem remains the same. 7 of the 8 material’s/texture’s colors remain unchanged with surface.SetDrawColor(10, 10, 10). With that being said, does that then mean I can apply some post-processing materials, as I’m now drawing a material?

Also, due to the circumstances in which the textures are being drawn, it’s more efficient (from what I can tell) for me to use SetTexture, as SetMaterial requires redundancy checks. Is there any way I can edit a texture drawn with SetTexture, similar to above, or do I have to work with a Material?