Garry's Mod Wiki




Material is a VGUI element that renders a VMT material.


Derives from Button.


Material:SetAlpha( number alpha )
Sets the alpha value of the Material panel.
Material:SetMaterial( string matname )
Sets the material used by the panel. If the material is not showing up as the correct size, try setting the Material panel's AutoSize variable to false


Creates a Material panel with TV static under a DModelPanel with a spinning Garry's Mod logo model.

-- Background panel BGPanel = vgui.Create("DPanel") BGPanel:SetSize(400, 400) BGPanel:Center() BGPanel:SetBackgroundColor(Color(0, 0, 0, 255)) -- Material panel with TV static local mat = vgui.Create("Material", BGPanel) mat:SetPos(10, 10) mat:SetSize(380, 380) mat:SetMaterial("effects/tvscreen_noise002a") -- Path to material VMT -- Set this to false to enable material stretching mat.AutoSize = false -- Model panel for GMod Logo local mdl = vgui.Create("DModelPanel", BGPanel) mdl:SetPos(10, 10) mdl:SetSize(380, 380) mdl:SetModel("models/maxofs2d/logo_gmod_b.mdl") mdl:SetCamPos(Vector(240, 0, 0)) mdl:SetLookAt(Vector(0, 0, 0)) mdl:SetFOV(40) -- Spin faster function mdl:LayoutEntity(ent) ent:SetAngles(Angle(0, RealTime()*100, 0)) end


Creates a custom material (using existing textures) of a Portal background with scrolling scan lines, and then displays that material in a Material panel in the center of the screen.

-- Background panel BGPanel = vgui.Create("DPanel") BGPanel:SetSize(720, 480) BGPanel:Center() BGPanel:SetBackgroundColor(Color(0, 0, 0, 255)) -- Material data for the scanline background local matdata = { ["$basetexture"]="vgui/appchooser/background_portal_widescreen", ["$texture2"]="dev/dev_scanline", ["Proxies"]={ ["TextureScroll"]={ ["texturescrollvar"]="$texture2transform", ["texturescrollrate"]=.06, ["texturescrollangle"]=-90 } } } -- Create material and recompute just in case local portal_scanlines = CreateMaterial("PortalScanlines", "UnlitTwoTexture", matdata) portal_scanlines:Recompute() -- Create material panel local mat = vgui.Create("Material", BGPanel) mat:SetPos(5, 5) mat:SetSize(710, 470) -- This has to be set manually since mat:SetMaterial only accepts string argument mat.Material = portal_scanlines -- Stretch to fit mat.AutoSize = false

Special Pages



Render Time: 49ms

DB GetPage 27
Generate Html 6
SaveChanges (1) 7
Render Body 0
Render Sidebar 7