Render Target Size Incorrect

So im creating a render target and drawing to it using the following code




local RenderTarget = GetRenderTarget("example", ScrW(), ScrH(), false)
local mat = CreateMaterial("!test","UnlitGeneric",{
	["$translucent"] = 1,
	["$vertexalpha"] = 1,
	["$alpha"] = 1,
})

hook.Add("HUDPaint", "test", function()
	local PreviousRT = render.GetRenderTarget() 

	render.PushRenderTarget(RenderTarget)
	render.Clear( 255, 0, 0, 255 )

	cam.Start2D()
		draw.RoundedBox(0,0,0, 100, 100, Color(255,255,255,255))
	cam.End2D()

	render.PopRenderTarget()
	render.SetRenderTarget(PreviousRT)  

	mat:SetTexture('$basetexture', RenderTarget)
	surface.SetDrawColor(Color(255,255,255,255)) 
	surface.SetMaterial(mat)
	surface.DrawTexturedRect(0, 0, ScrW(), ScrH())

	draw.RoundedBox(0,0, 100, 100, 100, Color(255,255,255,255))
end)


The issue is, is that the first box that is draw to the render target does not match the scale or position of the second box, that was draw directly to the screen instead of the render target first.
My goal is to try a box to a render target, then draw the render target over the screen like an overlay. Any idea why the rendertarget’s scale/position is offset? Thanks.

Heres an example btw, the top square is the render target, the bottom is not on the render target. Each box is draw with the same dimensions.

Also an interesting note, this issue does not happen on 4:3 aspect ratio.

This probably isn’t the problem but



render.PopRenderTarget()
render.SetRenderTarget(PreviousRT) -- This does the exact same thing as the thing above


Yeh i’m aware, I put it there just in case, seems I left it there.