Does anybody know how an RT scope works? Surely it’s possible, since I remember there was an Insurgency pack that had them.
You could look through the Insurgency SWEPs and see how they are done. I did myself once but I got confused and gave up, there’s something in the code that handles the drawing of the RT texture I think, and it just made no sense to me at the time
I think those got removed, but I probably still have the Winrar for it. I’ll check.
I found an article in the SDK Wiki regarding RT Scopes. It was a little different than this one, but maybe they updated it.
If you want and have TF2, you could try looking at the sniper rifle and see how it works. Not saying steal the code, but see how it renders through the scope.
It uhhh…doesn’t. the scope you see on the world/ viewmodel is just reflecting the nearest cubemap it can find like any specular surface. The scope you see zoomed in is nothing more than an fancy overlay.
Do you mean something that’s like Customizable Weaponry? It has something to make the ACOG scope use RT
Do what X6Z said, it has the code right at the top of the base.
What I did was rendering the world on a rendertarget then drawing a quad(or a 3d2d cam) on the scopes position with the render target as material, worked perfectly fine.
[editline]23rd June 2011[/editline]
As an extend, the result would be a squared scope which can be fixed using the stencil buffer.
-First you create your own render target
-Create a material that uses your rendertarget as $basetexture
1:When drawing your swep(PostDrawViewmodel) you have to do the following:
2:Set the render target to your new one
3:Enable the stencil buffer
4:Set a reference value and set the comparision mode to always
5:Draw a polygon in circle shape(textures will NOT work for that)
6:Set compare mode to equal and the reference value to your previous one
7:Render view with zoom or whatever you want(maybe add an overlay to blur the egdes)
8:Disable stencil buffer
10a:Start a 3d2d cam and and draw a rect with your rendertarget material
10b:Draw a quad using the rendertarget material
Using this methode also allows you to lower the update rate, you can for example update the scope every 2 or 3 frames instead of redoing it every frame to save performance.