Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

weapon sight really close to camera, problems with near clip plane

Discussion in 'General Discussion' started by BIGTIMEMASTER, Jan 25, 2020.

  1. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    Not actually a weapon but same difference. I want to look through the very small notched sight of this compass. Even with camera near clip plane set to minimum, it's not possible to do.

    I've seen in some games it looks like an image of the rear sight is overlayed on the screen when ADS. That seems like the thing to do here. Add a blurry image of the rear sight that goes over the screen. I can't fake the entire thing with an image, because it is important to use that rotating compass dial.

    Any opinions or experience with this sort of things?
    upload_2020-1-25_15-36-15.png Annotation 2020-01-25 153445.jpg
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    I'm not seeing a clipplane error on your screens. Clip plane problem means the object is sliced off and you're seeing inside of it. This does not seem to be happening in your example.

    An obvious solution would be to hide the part of the notched sight when the weapon gets close to the camrea and use overlay.

    Another thing is that in order to see the compass through the small sight, you'll need large FOV.
     
  3. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    the first image shows the clipping issue.
     
  4. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,009
    It looks like your model is actually 'embedded' in the camera. In which case you can't really solve it without moving the compass forward.

    I would suggest moving the compass forward and using a low FOV when aiming, which will make the compass feel much closer to the eye (while also making objects downrange seem bigger, which is good because that's where you're looking).
     
    BIGTIMEMASTER likes this.
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    Can you open scene view in wireframe (while the game is playing) and check what's going on from the side? Most likely the geometry does not allow camera to get close enough to keep compass visible with your current FOV setting.

    You can use camera stacking to render the weapon at different fov. This used to be a common trick in the past However, nowadays t is sort expected that the weapon should be affected by environmental shadows, and that makes things a bit more complicated.
     
    Ryiah and BIGTIMEMASTER like this.
  6. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    It gets a little complicated because you need to be able to see through the sight, but also see the compass dial below. It's not easy to get a picture of, but here's one.

    unnamed.jpg
    In real life, your eye can see clearly through the peep hole, and by looking downwards you also see the full dial.

    I think an overlay image would be best, but I wanted to get opinions from here because i've never done anything like this before.
     
  7. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,009
    Another option would be to have the aiming part as a 3D model and the compass part separated and maybe overlaid at a higher point than it is now.
     
    BIGTIMEMASTER likes this.
  8. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    Here's the thing. In real life you can rotate head and eyes independently.
    In a video game you can only rotate your head. So you can't look downwards at the dial while looking forward.
    Additionally, real life eye has ridiculous resolution and FOV.
    https://en.wikipedia.org/wiki/Field_of_view
    Basically, RL eye has 150 degree horizontal FOV and 120 degree vertical one, with reduced fidelity closer to edge. Videogames often have 60-90 degree vertical FOV.

    Now, you CAN introduce a "look at dial" control that would allow camera to "glance" at the weapon while keeping the weapon pointing forward, if you really want to, but that might be inconvenient for the player.
     
  9. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    right now i have it so that you can tilt the head, and also freely adjust FOV, even when the compass is brought up to ADS mode. This works pretty good and isn't inconvenient, the only issue is the clipping, basically.

    If we do an overlay image, though, then I probbaly need to lock camera otherwise it won't make sense.
     
  10. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,083
    I'd just go for a camera overl
    Not necessarily. You could make it so that you have a separate camera for the compass entirely where you have an exceptionally close near clipping plane, but also a close far clip plane so you don't run into too many depth issues, as can be a problem. There's also a way to do this using a single camera and some matrix transforms, but I'm afraid that math is beyond me. If you do it that way, you don't need a second post-processing stack, if you're doing any post work though.
     
    Ryiah and BIGTIMEMASTER like this.
  11. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,009
    If you've got all that going on, what about simply moving the compass forward? If the player needs to see a larger peephole they can just lower the FOV.

    I would also say that it's probably a good idea to try lifting the compass lid further toward the vertical, because after all the part that is causing problems is not even a useful part of the compass. You don't want to create massive changes in your setup to fix a problem on an irrelevant part of the visuals.
     
    BIGTIMEMASTER likes this.
  12. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    good points. i'll consider all this when i'm working it out. the main thing about the position of the compass is simply a need for authenticity. As much as possible I want to do things exactly as they are done in real life -- game being a milsim and all. But.. yeah no reason to overthink something like this. If there is simple way i try that first.
     
    Billy4184 likes this.
  13. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,009
    It's almost never a good idea though to have important information not on the screen at all times. In real life you can just swivel your eyeballs, but in games moving the camera requires non-instinctive, purposeful action that creates a very strong break with whatever was happening in the viewport just before it.

    So maybe in real life your eyeballs go between the compass and the peephole, but in a game I don't think this works at all. It's the same thing with cockpits - ideally you might have instruments all around you, but paying attention to them in a game is much harder than eyeball scanning in real life. So you end up with everything important on the screen all at once because that just makes sense for playing games on a monitor.
     
  14. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    i should have a small demo in time for the next feedback friday. To me, the tiny movement from peep sight to compass dial feels normal, and hard to explain why but I feel the deliberate need to do so adds an immersive quality. But I'll see what other people say too.

    In this game, you have only two instruments to pay attention. And just as in real life, you must stop moving and look at them deliberately. It's a lot to explain, but if you play it you'll get it. It's a simulation, first and foremost, and the way you use your tools is important part of the pacing.

    The circle lens you see the compass dial through is actually supposed to be magnifying, which will probably eliminate need to move camera at all. I just haven't got a shader setup yet to do that.
     
    Billy4184 likes this.
  15. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Does rendering of this object actually need to share the depth buffer with the rest of your scene? If not I would use an additional camera with depth clearing, and then tweak the frustum and position of the object/camera to achieve the visual result you want.
     
    BIGTIMEMASTER and Ryiah like this.
  16. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    That's what I meant when I said camera stacking.

    However, in modern games it is expected that in-hand weapon reacts to environmental lighting and shadows. And if you render it with camera stacking, I believe, shadows wont' be rendered correctly.
     
  17. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    If you are doing screen-space effects then you may have trouble, yes - but for some games, light probes and/or shadow proxies may be a possible solution.