Home Technical Talk

Selective depth of field on ironsights (i.e. COD4)

polycounter lvl 18
Offline / Send Message
JKMakowka polycounter lvl 18
Example:
http://i177.photobucket.com/albums/w240/jonstoner/iw3mp2007-11-2319-40-52-57.jpg
(big image!)

How is that done? Am I guessing right that there is a weapon specific mask texture with a blur shader that gets only activated when switching to the irosights?
Or is that some fancy engine coding work?

Replies

  • rooster
    Offline / Send Message
    rooster mod
    not that I know anything on the subject so this is just a guess- I think they can control it via distance from the player's position. I think i've seen close up grass blurred too when crawling through it
  • Keg
    Offline / Send Message
    Keg polycounter lvl 18
    General setup for blur is having an area of focus which doesn't have to begin where the camera is. You can set a starting and ending distance for where things are not blurred.
  • Joshua Stubbles
    Offline / Send Message
    Joshua Stubbles polycounter lvl 19
    This isn't using a standard distance setting though. The hand is in focus on the left, while the gun at the same distance is blurry. It's very inconsistent. My guess is that they're using a mask of some sort. Or a full screen shader that samples zbuffer and guesstimates the depth? I dunno..
    The object in front of the player, to the left of the hand, as an odd blurry halo around it. It's like more is being blurred than should be.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    I pretty much think the gun blur is just a blurred texture mask, like suggested before.

    the scene itself gets a realtime DOF effect, using depth for blur strength. The inconsistency of the "hand", as vassago said, supports his theory.
  • JKMakowka
    Offline / Send Message
    JKMakowka polycounter lvl 18
    Ahh thanks for the opinions.

    A mask texture seems like a quick and easy way to do it without having to fiddle with all that engine specific stuff.

    On a related note: I am currently trying to implement a similar effect with GLSL in the Sauerbraten engine and I can currently think of three ways to implement it in theory:

    1. Fullscreen shader with gradient masked texture
    Pros: fastest?, can have blur effect at the outer border of the screen too, no modifcations on the weapon model, easy to fade in when switching to irosights.
    Cons: if weapon moves it will get out of the mask some times. slowest, because the full screen is effected in code?, needs a hand drawn gradient texture

    2. Simple 2D masked texture as part of the model.
    Pros: moves with the model, doesn't effect the whole screen in code
    cons: needs a hand drawn mask texture, in strong movement cases the weapon might still gets out of the shader area. Not so easy to fade in when switching to ironsights.

    3. simplified geometry overlay that parially wraps around the mesh
    Pros: Moves with the mesh, only needs the blur shader and no texture, fastest to render?, weapon can never get out of the shader effect.
    cons: needs extra geometry, harder to fade in, no gradient at the borders

    I am currently thinking option number 3 is the best, but I am really quite new to this stuff and some experienced insights would be great.
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    They wrote an article in GPU Gems 3 about DOF. They set the near/far blur ranges independently for the POV guns separately from the world. I'd say the reason the hand is in focus because it's about the same distance from the eye as the iron sight are. The world has it's own DOF settings: if they didn't the near stuff would be way too sharp, you'd never get any foreground blurring if you wanted any part of your weapon sharp as well.

    To sort the different types, they used negatives depths in the depth texture to differentiate the guns from the worlds, since they only needed a single bit (the sign) to change the blur settings (very clever).
Sign In or Register to comment.