- Home /
Zooming part of the screen without Render to texture
[source files lost. However, the responses are still useful]
Answer by Sixakoo_ · Dec 09, 2012 at 11:14 PM
I assume this is for aiming down a scope in an FPS game, isn't it? To be honest I don't really have the answer if you don't use the render to texture but consider this, most current FPS games that I play they don't use Render to texture technique but instead they just in lower the FOV for the whole camera, and some might add some blur outside the scope or mask it black for sniper rifle. I think they don't use render to texture to have better performance I guess. Here are some examples:-
Sorry that I could only give a suggestion instead of a real solution.
perhaps he could attach a second camera and have it in the center of the screen in a layer above the main camera? then he could manipulate the zoom on the second camera
Yeah, you could do that, but the problem is that it would be square ins$$anonymous$$d of round. Although you could somehow mask the zoom camera, or place another game mesh on top of the screen but have make sure to cover all the square edge which would require a very wide scope rim. Another thing is the transition of ai$$anonymous$$g down scope would be abrupt due to no animation on transitioning second camera onto the main camera.
transfor$$anonymous$$g the scale of the viewport of cam 2 with Time.deltaTime could possibly resolve that. He would, however need a very good animation going on in the main cam to make it look realistic
Answer by Bunny83 · Dec 10, 2012 at 12:31 AM
Just use a second camera and adjust the screen rect (either rect with viewport coordinates (0..1) or pixelRect which is in pixels). Make sure your second camera (the smaller one) is drawn after the main camera by setting the depth value of your second camera to a higher value than the main cam.
If the scope graphics is just a texture, place it at the right spot. If you really want to use a model, you have to add a mesh that masks the whole screen except the hole. Use the **depthmask shader** on that mesh to mask out unwanted things. Using a model will probably require you to use another camera (so you have 3). It's not that complicated but requires a bit of fiddling with layermasks and renderorders.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
FPS sniper zoom effect without black texture? 3 Answers
Crosshair Fade on Zoom 0 Answers
Sniper Demo: When zoom the raycast change its aim ! 0 Answers
Rounding up Damage to an Int 2 Answers
gun scope cam not working 3 Answers