How do i create a render target scope for a swep

As the title says, i really need help making my sweps scope render as a render target screen, just like the FA:S Alpha 2 SWEPs do. I have tried so many things but cannot figure it out in the slighest.

First off, what weapons are you making the scopes for

I am creating a weapon based off of base, and using FA:S 2.0 Alpha weapon models, its the m82.

Yeah, I don’t know. What is your prior experience in Lua?

Im pretty good with lua, just not incredibly good with glua yet.

Hmm. Well you might be able to do this then.
I wouldn’t count on it though, Spy’s stuff is historically somewhat difficult to modify (base code wise)

You’re basically interested in

The cam library

And the render library

the models, specifically the lense texture of the scope needs to be modified to a defined texture that the base can recognize and render onto. however iirc sleek weapon base does not have support for RT scopes. if you want a base that works with weapons from cs:s and uses render targets, I’d suggest extra customizable weaponry however there’s some issues with that in that it takes longer to set up and isn’t as optimized as FAS:2 sweps or SWB.

I personally have no experience making render target scopes but if I were to want to make one the first example I would deconstruct would not be Spy’s, but Residual Grub’s in this pack:

The RT scope in here is not as complex as Spy’s and thus would be a good starting place.

[editline]26th June 2014[/editline]

I thought spy overhauled the texture replacement system and made one using pure lua?

Well, the model and textures are modified for the render, as the exact same model has a render target scope in FA:S2, ill hopefully figure it out soon though :stuck_out_tongue: Thanks guys

If that ends up being how you need to do it a thing you could try is parenting a circular ClientSide model to the viewmodel’s scope (clock01 works well for this) and replace that texture. Although given you’re using an M82 skin I dont think that’ll be an issue.

I’m not sure, I don’t know lua but I know when I compiled the scopes models I changed the lense textures to point to a placeholder rt texture which he rendered onto. same thing with fas:2, though that was already done for me.

Yeah, FA:S 2’s system made a break from CSTM’s texture replacement method. Think he has a video called “new scope behavior” that coincides with this change.

Create a render target of a given square size.

Change the $basetexture of the scope on your model to $basetexture of the rt.

Before drawing the view model, set the render target to that one, create a viewport of the same size, and call render.RenderView, then restore the viewport and RT.