Is there any way to get render.RenderView to draw on a surface like a camera? Or do I have to use rendertargets? I tried:
[lua] cam.Start3D2D(self:GetPos() + (self:GetForward()*4), Ang + Angle(0,90,90), 2.4)
local CamData = {}
CamData.angles = Angle(90,LocalPlayer():EyeAngles().yaw,0)
CamData.origin = LocalPlayer():GetPos()+Vector(0,0,500)
CamData.x = 0
CamData.y = 0
CamData.w = ScrW() / 3
CamData.h = ScrH() / 3
render.RenderView( CamData )
cam.End3D2D()
[/lua]
Which just seemed to mess up the skybox a bit.
[lua]
local TEXTURE_FLAGS_CLAMP_S = 0x0004
local TEXTURE_FLAGS_CLAMP_T = 0x0008
local rt = GetRenderTargetEx("testRT",
512,
512,
RT_SIZE_NO_CHANGE,
MATERIAL_RT_DEPTH_SEPERATE,
TEXTURE_FLAGS_CLAMP_S | TEXTURE_FLAGS_CLAMP_T,
CREATERENDERTARGETFLAGS_UNFILTERABLE_OK
)
local drawMaterial = CreateMaterial("TestRT","UnlitGeneric",{
["$ignorez"] = 1,
["$vertexcolor"] = 1,
["$vertexalpha"] = 1,
["$nolod"] = 1,
["$basetexture"] = rt:GetName()
})
local view = {
angles = Angle(),
origin = Vector(),
x = 0,
y = 0,
w = 512,
h = 512,
drawhud = false,
drawviewmodel = false,
}
local inDraw = false
function ENT:Draw()
self:DrawModel()
if(inDraw) then
return
end
inDraw = true
local pos = self:GetPos()
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Forward(), 90)
ang:RotateAroundAxis(ang:Right(), 90)
local oldRT = render.GetRenderTarget()
render.SetRenderTarget(rt)
render.Clear(0, 0, 0, 255)
render.ClearDepth()
local w, h = ScrW(), ScrH()
render.SetViewPort(0, 0, 512, 512)
cam.Start2D()
render.RenderView(view)
surface.SetDrawColor((math.cos(math.rad(RealTime()*120))+1)*127.5)
surface.DrawRect(0, 0, 4, 4)
cam.End2D()
render.SetViewPort(0, 0, w, h)
render.SetRenderTarget(oldRT)
cam.Start3D2D(pos, ang, 1)
surface.SetMaterial(drawMaterial)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(0, 0, 512, 512)
cam.End3D2D()
inDraw = false
end
[/lua]
I wrote this a while ago, you just need to customize the code in order to make it work for whatever you need it.
Thanks!
But do I have to create a new rendertarget material every time I want a new view? Dunno if that's good considering I might have up to 40 of these...
If you have 40 of these your game will end up being unplayable.
And no, you can essentially use the same.
[QUOTE=Wizard of Ass;37280647]If you have 40 of these your game will end up being unplayable.
And no, you can essentially use the same.[/QUOTE]
Well then again only 4-5 are likely to be rendered at one time...
Anyway, thanks! You're awesome!
Sorry, you need to Log In to post a reply to this thread.