Hi there,
I am having some issues with renderView. The basic idea is: I want to override the scene rendering using a custom function. The code is the following:
local function RenderScene( Origin, Angles )
local CamData = {}
CamData.angles = Angles
CamData.origin = Origin
CamData.x = 0
CamData.y = 0
CamData.w = ScrW()
CamData.h = ScrH()
local fov = LocalPlayer():GetFOV()
if(ValidEntity(LocalPlayer():GetActiveWeapon()) and (LocalPlayer():GetActiveWeapon():GetClass() == "gmod_camera")) then
local weap = LocalPlayer():GetActiveWeapon()
fov = weap.CameraZoom
end
CamData.viewmodelfov = 62
CamData.fov = fov
CamData.znear = 1
CamData.drawhud = true
render.RenderView( CamData )
return true;
end
local function GenerateHook()
hook.Add( "RenderScene", "RenderWithDifferentNearPlane", RenderScene );
end
timer.Simple(2, GenerateHook )
First of all… the wait of two seconds is on intention… if it overrides rendering immediately (when you spawn) some errors sometimes occur so it’s basically just a simple workaround. The difference to the normal code is: the near plane (CamData.znear) is much closer than it normally is (for player resizer) - thanks to Jinto for giving me this command it is admittedly undocumented (default value seems to be about 3 if you want to play with it).
However: while that code completely overrides scene rendering it comes with downsides. For some reason whenever RenderView is rendering the scene water surfaces mess up. To try this yourself: look at a water surface and enable Super DOF (also uses RenderView).
So let’s look at the water in rp_resort without render.RenderView code:
http://l0nk.org/render-nrv.jpg
And now with render view enabled:
http://l0nk.org/render-wrv.jpg
Well, obviously everything under the water surface is moved instead of being refracted. Any way to get water surfaces rendered correctly with RenderView?
Thank you!