Skip to content

Instantly share code, notes, and snippets.

@wyozi
Created April 13, 2014 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wyozi/10576674 to your computer and use it in GitHub Desktop.
Save wyozi/10576674 to your computer and use it in GitHub Desktop.
gmod rendertargets
local rt1 = GetRenderTarget("TestRT1", 500, 500)
local rt2 = GetRenderTarget("TestRT2", 500, 500)
local rt_mat = Material("models/weapons/v_toolgun/screen")
hook.Add("HUDPaint", "TestRTHook", function()
render.PushRenderTarget(rt1)
render.Clear(0, 0, 0, 255)
cam.Start2D()
surface.SetDrawColor(HSVToColor(CurTime()*50, 0.95, 0.5))
local x, y = 250+math.cos(CurTime())*200, 250+math.sin(CurTime())*200
surface.DrawRect(x-10, y-10, 20, 20)
cam.End2D()
render.PopRenderTarget()
render.PushRenderTarget(rt2)
render.Clear(0, 0, 0, 255)
cam.Start2D()
surface.SetDrawColor(255, 255, 255)
rt_mat:SetTexture("$basetexture", rt1)
surface.SetMaterial(rt_mat)
surface.DrawTexturedRect(100, 100, 300, 300)
cam.End2D()
render.PopRenderTarget()
rt_mat:SetTexture("$basetexture", rt2)
surface.SetMaterial(rt_mat)
surface.DrawTexturedRect(100, 100, 500, 500)
end)
@Velkon
Copy link

Velkon commented Dec 5, 2015

1

@notcake
Copy link

notcake commented Dec 5, 2015

-i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment