Created
April 13, 2014 09:39
-
-
Save wyozi/10576674 to your computer and use it in GitHub Desktop.
gmod rendertargets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1