   Circular viewport for a sniper scope view
  Hi all, I am trying to implemented a sniper scope view. Rather than rendering the scope fullscreen, I want to show it in a small circular viewport (so the normal view is still rendered as the "background"...so to speak)I think I can achieve this by using a alpha map or stenciling, but I am not sure where exactly to start. I need to render both normal and zoomed view, with the later one on top...How do I actually make portions of the rectangle viewport transparent so only the circular part of it is rendered on top of the normal view?TIA for any suggestions!   
  How about using alpha-testing and using a transparent circular center? This would work best as a full frame sprite.   ;  you need 2 fullscreen quads:the first one(which has a larger depth value) with the zoomed viewand the second one(which has a smaller depth value) with the usual view and a alpha texture applied(which has a transparent circle in the middle).regards,m4gnus   ;  ...that or write the scope's circle to the stencil buffer, render the background with stencil reading one way so that pixels inside the circle are not drawn, then flip the stencil and write the inside of the scope, so that pixels outside of the circle are not drawn.This method draws the minimum amount of pixels - instead of rendering the entire background and overlaying the scope on top, but it requires the added overhead of a stencil buffer.   ;Quote:Original post by m4gnusyou need 2 fullscreen quads:the first one(which has a larger depth value) with the zoomed viewand the second one(which has a smaller depth value) with the usual view and a alpha texture applied(which has a transparent circle in the middle).regards,m4gnusThank you for the replay (and Gary Poole and Source too). Technically I understand your solution, however I am not sure how to implement it. I know it is noobish, but please bare with me.I know how to create two fullscreen quads and apply alpha channel, but how do I "apply" the quad to my normal and zoomed scenes? Do I render my scenes to the quads?Also if I use an alpha it sounds that the the circle of transparence is more likely hard coded in the texture...so what if the zoomed view changes (size or position)?Thank you again for you time and effort   ;Quote:Original post by Source...that or write the scope's circle to the stencil buffer, render the background with stencil reading one way so that pixels inside the circle are not drawn, then flip the stencil and write the inside of the scope, so that pixels outside of the circle are not drawn.This method draws the minimum amount of pixels - instead of rendering the entire background and overlaying the scope on top, but it requires the added overhead of a stencil buffer.Thank you Source. Between fullscreen alpha blending and stenciling, which is more expensive?;  Render the scope view into a small render target texture, then blend that over the main view using a predefined circular alpha texture. This will allow you to have a soft edge to your sniper view, which you won't be able to get by directly drawing onto the main view.   ;Quote:Original post by plasm1dThank you Source. Between fullscreen alpha blending and stenciling, which is more expensive?In this case, this isn't the tradeoff between the two techniques: The stencilling technique is a simple masking of pixels, which should have *virtually* no performance degradation, and will also mean you are only drawing pixels you actually see, which in a fill-rate limited application is preferrable.The other technique requires you to render at least one of your scene views to a seperate render-target (the zoomed-in view), and usually means you'll be rendering the whole of the other scene. If your sniper view is very large, then this is quite a waste of fill-time.It really comes down to the effects you are looking for: If you just want crisp edges, then using stencilling coupled with some HUD-overlays to snazz things up a bit will suffice. If you want the sniper view to "fade out" at the edges, or be projected onto a gun-model or some such, then rendering the sniper-view to a texture is the only method - it gives you more control, but is slower and more complex to achieve.