Rounded RenderView?

I want to make scopes for some weapons. How the hell do I go about doing this so the scopes are circles? At present I’m drawing a regular, square RenderView over the viewmodel’s scope and then using a texture to hide the fact that it’s a square, drawing a thick border around the edge of the scope.

How would I go about just making the RenderView round? I’ve been lead to believe I could use Stencils to do this but I don’t understand how to use them. I’m alost struggling with RenderTargets. Can anyone guide me or give any hints?

Usually when creating scopes, you adjust the fov for zoomed-in effect, and you display a texture on screen. You can also draw different crosshairs using lines, textures, etc as well.

If you’re talking about rendering a scope on the weapon viewmodel, and worldmodel, it’s something entirely different.

  • Create rendertarget
  • Render “RenderView” onto it
  • Store rendertarget, unset it
  • Set current surface material to rendertarget material
  • Draw a predefined circular polygon onto the viewmodel using a 2d3d camera, it has to have correct UV coordinates

The way the addons that do this work is by replacing the $basetexture of the scope material with a render target and then rendering the view to it. If the models you are using support this, it should be the way you approach it.

The alternate way is to use stencils and mask a circle out in the shape of your scope, but this might not look as good.

I’d prefer to use stencils. I just cannot find any guides that explain how to use stencils to do that.

Have you tried my method?

I have not. I’m horrible with UV maps. Stencils look less complex, but with even less documentation.

u v maps aren’t really that hard. Just imagine the uv as the fractional position of each point within the window that bounds the polygon. You can actually write code fairly easily to automatically calculate these fractional values:
local u = ( x - windowx ) / windoww