• RT Scope Rendering Problem
    1 replies, posted
I created an rt scope for the sniper I am working on. The scope works fine but this reflective film is appearing on my screen. It acts just like an rt screen but much more transparent. Example: [url]http://puu.sh/3mLsB.png[/url] Another weird thing is that the scope wont render till I edit the code. I am still pretty new to using RT. Here are my variables [code]SWEP.mat = Material( "models/v_models/ResidualGrub/mosin/lense" ) SWEP.RenderTarget = GetRenderTarget( "Mosin_scope", 1000, 1000, false) SWEP.mat:SetTexture( "$basetexture", SWEP.RenderTarget )[/code] Here is where I draw the RT [code]function SWEP:ViewModelDrawn( ViewModel ) if ( CLIENT ) then local old = render.GetRenderTarget( ) local ply = LocalPlayer() CamData = {} CamData.angles = ply:GetAimVector():Angle() CamData.origin = ply:GetShootPos() CamData.x = 0 CamData.y = 0 CamData.w = 1000 CamData.h = 1000 CamData.fov = 4 CamData.drawviewmodel = false CamData.drawhud = false CamData.ortho = false CamData.dopostprocess = false render.SetRenderTarget( self.RenderTarget ) cam.Start2D() render.RenderView(CamData) cam.End2D() render.SetRenderTarget( old ) end end[/code] Thanks in advance.
So I fixed the film overlaying the screen by moving it into the RenderScene hook. But I am still having the problem of the RT cam not starting on its own. To turn it on I have to make a small edit, such as a space, and save the lua file. Would anyone know how to fix this? New code: [code]function RO_RT_Scope_RenderScene() ply = LocalPlayer() Wep = ply:GetActiveWeapon() old = render.GetRenderTarget() if IsValid(Wep) then if Wep.RO_Sniper then CamData = {} CamData.angles = EyeAngles() CamData.origin = ply:GetShootPos() CamData.x = 0 CamData.y = 0 CamData.w = 300 CamData.h = 300 CamData.fov = 4 CamData.drawviewmodel = false CamData.drawhud = false render.SetRenderTarget( Wep.RenderTarget ) cam.Start2D() render.RenderView(CamData) cam.End2D() render.SetRenderTarget(old) end end end hook.Add("RenderScene", "RO_RT_Scope_RenderScene", RO_RT_Scope_RenderScene)[/code] This is running in a lua file in the path autorun/client
Sorry, you need to Log In to post a reply to this thread.