• Lua Materials
    2 replies, posted
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 [url]https://facepunch.com/showthread.php?t=1548067&p=52492951&viewfull=1#post52492951[/url] 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: [url]http://wiki.garrysmod.com/page/Materials_and_Textures[/url] It's important to understand what's what, and understand what you actually need to do. You can create a brand new [b]texture[/b] or acquire an existing one with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/GetRenderTarget]GetRenderTarget[/url], which you can then put into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/PushRenderTarget]render.PushRenderTarget[/url] to draw into it or modify it. You can acquire an existing [b]material[/b] with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Material]Material[/url] or create a brand new one with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CreateMaterial]CreateMaterial[/url], which you can then modify using [url=http://wiki.garrysmod.com/page/Category:IMaterial]the various material functions[/url], most importantly [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetTexture]IMaterial:SetTexture[/url].
[url]https://gist.github.com/meepdarknessmeep/a2bb9c61e2cca03e2a37b2d305b1e0e0[/url] [editline]23rd July 2017[/editline] You can open materials with this after you've written then to the data folder
Sorry, you need to Log In to post a reply to this thread.