How to load image data as an IMaterial?

I’m not sure if this question needs it’s own thread, but here’s what I want to know:

Is it possible to load image data (such as the string generated by

render.Capture) as an IMaterial without having to save the image data and then load it again?

Currently I have to do this:



local data = render.Capture( {
	format = "jpeg",
	quality = 100,
	h = ScrH(),
	w = ScrW(),
	x = 0,
	y = 0,
} )

file.Write( 'lol.jpg', data )

RunConsoleCommand( 'mat_reloadmaterial', 'data/lol' )

local mat = Material( 'data/lol.jpg' )


But it’s very slow to run and it seems a bit stupid… I’d like to simply do something like



local data = render.Capture( {
	format = "jpeg",
	quality = 100,
	h = ScrH(),
	w = ScrW(),
	x = 0,
	y = 0,
} )

local mat = Material( data )


But that doesn’t work since Garry’s Mod always likes making things unnecessarily complicated

Also, it needs to be an IMaterial because I’m using

surface.SetMaterial to draw a textured rect with the material

Any help would be appreciated!

Sometimes you just have to make one giant ugly hack to get simple things don. I’m even unsure if I should release my clothes-addon based on how ugly the code is.

I guess the “easiest” and best way, is to use a html-page to render the texture. Something like BlackAwps solution.

IMaterial cannot contain texture data, so obviously you cannot give it texture data.

IMaterial represents .vmt file, ITexture represents .vtf

So are you saying it’s possible with an ITexture?