We get a lot of bug reports showing strange reflections in the water. Some of these we can fix easily, and some will be more difficult, if not impossible. There are two fundamental constraints on the water-reflection code:

  • A reflective surface (read: water) must be approximately flat to be correct. This is just how the algorithm works. (If you want to see why a non-flat surface fails, try to draw a camera position opposite the reflection plane and trace rays through this “reflection camera”. Draw reflected objects that are close and far from the water and then observe the parallax error you get if the reflection plane curves.)
  • We need one “water camera” for each flat reflection plane. You can’t just statically offset when we have multiple elevations. (When drawing your diagrams, note how an elevation change causes a change in reflected angle, not just an offset.)

So the water will always have two problems: the earth is round (so nothing is really flat), and we can have lakes of multiple elevations (and we can’t afford to render a water reflection per lake).

X-Plane tries to get around the non-flat water problem by picking little bits of the water that are flat (and seem useful) and using them to define reflections. This algorithm will always have problems, but at least it can be tuned.

Now there are also some things that we can fix with the water:

  1. The math in beta 18 is simply wrong, something that will be fixed in beta 19.
  2. The ocean is built from polygons that are too large; this introduces approximation errors when we try to pick “a little bit” of water to use to figure out our reflection plane.

There is one more problem that I see, especially in airports like PAKT: if there are two water surfaces of different heights that are nearby, X-Plane uses a slanted water plane that tries to include both. This works very badly – the resulting slanted plane doesn’t look even remotely plausible. I’m not sure how soon we can tune this problem.

About Ben Supnik

Ben is a software engineer who works on X-Plane; he spends most of his days drinking coffee and swearing at the computer -- sometimes at the same time.