Wednesday, May 1, 2013

Doom 3 - Volumetric Glow


This article moved to its own webspace! You can follow him by clicking this:

18 comments:

  1. Well the source code is out now, you can check it out.

    ReplyDelete
  2. He he, that's right. But I'm just a small artist and don't understand the code. But maybe we get lucky and a programmer will have a look on it :)

    ReplyDelete
    Replies
    1. You understand the way the algorithms and problem solving works.
      Most importantly you understand the aspect of what kind of property you want to be able to represent, and that you need to abstract it in order to render it with a GPU.
      It's a small step from there to actual code.

      Delete
  3. I haven't looked at the source but from what I can see on those images, basically what it does is calculated the silhouette (ie a list of all the edges that don't have a visible face on both sides from the POV of the player) and are thus the borders of the drawn object, and then "expand" them, drawing a polygon strip around them.

    Normally determining the silhouette and dynamically creating that strip would be somewhat complex and developers wouldn't implement it just for the sake of that effect, but for Doom 3 it wasn't a problem because it *already* uses silhouettes with polygon strips for its shadowing system (same principle, but from the POV of the light that's casting a shadow), so they just recycled the algorithm for an extra effect.

    ReplyDelete
    Replies
    1. That sounds logic to me but i think they must have extended the tech a bit because the base geometry for the light plane is just a quad. But the generated glow geometry is "round" at its corners. A shadow volume if the plane would be "hard-cornered" if you know what i mean.

      But i really like the idea that they used their shadow tech for doing these volumes.

      Delete
    2. True. Actually, as long as the polygon is flat you can precompute the silhouette (all edges are always gonna be visible if the poly is) and if it's convex you know you need the extra two triangles for each corner, so you can precompute the mesh for all convex shapes and then it's just a bit of vertex shader tinkering to get the effect (all lines orientations for a corner mesh are just dependent on the screen space positions of the two segments that form the corner. The two "exterior" lines are each perpendicular to a segment, the "interior" line is at the halfway angle between them)

      Delete
    3. Maybe you're interested that some guy implemented it into this engine:

      http://www.reddit.com/r/gamedev/comments/1djnql/doom_3_volumetric_glow/

      Delete
  4. simply beautifull.

    I love ID just because they solve usual and common problems just in their very own way. This use to make them very creative and technically alternative.

    Anyway I should recognize that sometimes they're right and sometimes not so...

    ReplyDelete
  5. Thanks for the great article - I really like this blog. There's some discussion on Reddit if you're interested http://www.reddit.com/r/gamedev/comments/1djnql/doom_3_volumetric_glow/

    ReplyDelete
    Replies
    1. Thanks man! I saw some clicks coming from reddit in my statistics and found it :) But it's very nice that you gave me the link! :)

      Delete
  6. This is one of Doom 3's effects that i also paid attention too since it provides "clean" results even without HDR.

    I haven't implemented it yet, but i think the idea is very simple: the polygon edges are projected in screen space and then they're extruded with a constant (screen space) distance from the (2D projected) center with one additional vertex for each corner (so they're round).

    Since Doom 3 does that only for visible "light" surfaces which face the camera (which is a very cheap test) and those lights are convex shapes, the geometry for this can be calculated at realtime).

    ~badsector

    ReplyDelete
    Replies
    1. I saw you post on reddit and answered there :)

      Delete
  7. Addendum to above:

    So i decided to try and implement this. Here it is running in RobGetOut's forward render path:

    http://badsector.minus.com/lbnqk1Rovw2adt

    and in the deferred render path:

    http://badsector.minus.com/lbgZeGZMVviPKX

    The forward path looks more like Doom 3's while the deferred looks more as if there was some blur pass with HDR (the light "bleeds" out thanks to the contrast filter).

    As an extra note, i had to bring the vertices back to camera space in order to do depth testing. Which makes me wonder if it would be easier to simply calculate scale from the projection matrix and do everything in world space.

    ReplyDelete
  8. wonder if it would look better with pixel vs vertex interpolation.

    ReplyDelete
    Replies
    1. Sure - or maybe with some more intersections in the "light mesh"...

      Delete
  9. Like the Haze effect, it sounds real amazing with a perfect glow behind the object. This would be a great while in capturing images and in specific in regards to photography.
    Hi Viz apparel

    ReplyDelete
    Replies
    1. Not sure if your link is really related to my article...

      Delete