Menu

#107 Different fog handling - sane media fog?

open
nobody
None
2012-12-02
2006-11-07
Solra Bizna
No

Okay. The way things are at the moment, there are two
separate fog settings, one for under-media and one for
above-media. But, currently, they are each chosen to
render the whole frame, depending on whether the
*camera* is under or above media. Naturally, this looks
pretty bad when looking from one to another.
However, the engine already renders "mixed" scenes in
two passes, one for below and one for above media. Why
not use the under-media fog when rendering the
under-media pass, and the above-media fog on the
surface and above media pass?
In addition, there's room here for considerably
improved realism with OpenGL and EXT_fog_coord. If
EXT_fog_coord is supported and the player is *outside*
media looking *in*, one could set the fog coordinate of
the vertices of the under-media geometry to the world
distance separating the vertex from the point on the
media surface between the eye and the vertex. Voila,
almost-free pretty-good-looking volumetric media fog.
And excluding incredibly degenerate cases and bizarre
geometry, the calculation is very simple. (A1 already
uses immediate mode rendering, does it not? Not much
extra overhead here for the calculation compared to that.)
When the camera is already under media, the fog
coordinate can be left unchanged. And for OpenGL
implementations that don't support EXT_fog_coord, you
can simply bypass that code and still get the
pretty-decent look of separate under-media and
above-media fog.
I might even implement this myself if someone with CVS
access would volunteer ahead of time to commit it.
-:sigma.SB
P.S. "Perfect" media fog would require a fragment
shader. The media depth won't *quite* vary linearly
across a surface. (This is the same reason that
per-pixel calculations are necessary even for
non-volumetric fog.) But, it's close enough under the
conditions specified that it will still look very good.
P.P.S. The specification for EXT_fog_coord:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/fog_coord.txt

Discussion

  • Gregory Smith

    Gregory Smith - 2006-11-07

    Logged In: YES
    user_id=373617

    Some levels of sophistication in fog:

    1) General depth-based fog, applied to the entire scene
    based on the player camera's (not the Lua camera's, teehee)
    position above/below media: this is Aleph One's current behavior

    2) Depth-based fog split between above/below media. Are
    these really rendered in separate passes!?

    3) Volumetric fog (EXT_fog_coord) applied uniformly above
    media, and uniformly below media. This would be slower than
    2) (though most hardware should be able to handle it), but
    would it look any better than 2)?

    4) Above/below media volumetric fog specified per polygon
    (or by region). This would require a lot of MML or a new map
    format. Also, 1) 2) or 3) would still need to be implemented
    for backward compatibility.

    It would be good to have the ability to drop back to depth
    based fog in the event that volumetric fog is unsupported or
    too slow.

    There's also the separate problem of how to handle landscapes.

    Which of these approaches would you be interested in doing?
    Does anybody actually like behavior 1) more than 2) or 3)?

    Getting patches into CVS isn't a problem so long as they
    don't break anything, and aren't egregiously ugly.

     
  • Solra Bizna

    Solra Bizna - 2006-11-07

    Logged In: YES
    user_id=810548

    2 and 3 both. 2 is downright trivial and universally compatible, and 3 can always fall back to 2.
    And believe me, it makes a huge difference.
    -:sigma.SB

     
  • Gregory Smith

    Gregory Smith - 2006-11-07

    Logged In: YES
    user_id=373617

    OK, upload the patches here when they're done :)

    We might sit on them for a while, though, waiting for the next release, depending on when we get them.

    Don't suppose you'd like to add a landscape fog bias (instead of our 0% or 100% fog landscapes) while you're in there
    hehe.

     

Log in to post a comment.