So im creating a render target and drawing to it using the following code
[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)
[/CODE]
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.
[IMG]https://i.gyazo.com/452657421101b6600d64c3b20cf6f5de.png[/IMG]
Also an interesting note, this issue does not happen on 4:3 aspect ratio.
This probably isn't the problem but
[CODE]
render.PopRenderTarget()
render.SetRenderTarget(PreviousRT) -- This does the exact same thing as the thing above
[/CODE]
[QUOTE=MPan1;52733707]This probably isn't the problem but
[CODE]
render.PopRenderTarget()
render.SetRenderTarget(PreviousRT) -- This does the exact same thing as the thing above
[/CODE][/QUOTE]
Yeh i'm aware, I put it there just in case, seems I left it there.
Sorry to necro a dead thread, but did you find a solution to this?
Sorry, you need to Log In to post a reply to this thread.