Lua Materials

Hey, I’m looking to make some materials via lua

meharryp posted some code that, if I understand it correctly, takes a screenshot of a 2d cam of the original texture, draws on itl, then makes it into a new texture by saving it to the disk and reloading it as a material
http://forum.facepunch.com/showthread.php?t=1548067&p=52492951&viewfull=1#post52492951

Is this the only way to do it? Is there a better way?

Ideally I’d like to draw arbitrarily over another material, if that makes a difference

I’d appreciate any help here

It all depends on what you want to do.

First of all you might want to take a look at this half-finished (or less) guide that I started writing before abandoning: http://wiki.garrysmod.com/page/Materials_and_Textures

It’s important to understand what’s what, and understand what you actually need to do.

You can create a brand new texture or acquire an existing one with

GetRenderTarget, which you can then put into

render.PushRenderTarget to draw into it or modify it.

You can acquire an existing material with

Material or create a brand new one with

CreateMaterial, which you can then modify using the various material functions, most importantly

IMaterial:SetTexture.

https://gist.github.com/meepdarknessmeep/a2bb9c61e2cca03e2a37b2d305b1e0e0

[editline]23rd July 2017[/editline]

You can open materials with this after you’ve written then to the data folder