RenderView seems to omit the world on maps with 3D skybox
0 replies, posted
Hey all! As part of my next mod, I am including a currently crude mirror in the GUI element. Sadly, maps like gm_construct only display properly at certain angles, whereas the other angles omit the world in favor of the 3D skybox. Here is what I mean.
When facing away from an edge (optimal result)
https://files.facepunch.com/forum/upload/377014/e08f31e0-9351-4a80-9948-bd74745732b7/image.png
When facing towards an edge (keep in mind, the RenderView camera is not clipping. The player could theoretically move to it's position)
https://files.facepunch.com/forum/upload/377014/1970619c-0c31-4f11-87f1-ae7b3213c8fa/image.png
The render goes straight through the player and the map, and only renders the projected skybox. I'm really not sure why this is!
Here is a commented gist of my code:
hook.Add("HUDPaint", "DrawMirror", function()
if isDrawMirror then
local yvar = -20
local yvec = Vector(0,0,yvar) -- This is just a variable for players to tweak the height of the camera
local pos = LocalPlayer():GetShootPos() + Vector(LocalPlayer():GetForward().x, LocalPlayer():GetForward().y, 0)*75 + yvec
-- Setting the Z coordinate of GetForward to 0 makes sure that the camera stays level with the player's eyes by default
local facepos = LocalPlayer():GetShootPos() + yvec
local ang = (facepos-pos):GetNormalized():Angle()
playerDraw = true -- Make sure that the player gets rendered
-- Just a regular old renderview, nothing to see here
render.RenderView( {
origin = pos,
angles = ang,
x = 0, y = 0,
w = ScrW()/3, h = ScrH()/3
} )
playerDraw = false
end
end )
hook.Add("ShouldDrawLocalPlayer", "drawDapOverride", function()
cam.Start3D()
if playerDraw then return true end
cam.End3D()
end )
It's pretty simple, so I'm not sure if the code is entirely responsible. I suspect it's an engine error that I will have to work around, like the ShouldDrawLocalPlayer hook.
Again, any help is accepted. This seems like a relatively simple thing, I just don't know the answer.
Note: At the center of the map (not origin but physical center) all angles work fine.
Sorry, you need to Log In to post a reply to this thread.