Waves

From FlightGear wiki
Revision as of 18:50, 2 September 2017 by Hooray (talk | contribs) (Created page with "{{Stub}} If your external simulation can create waves for the physics you could feed those into a shader rendered local water surface (provided the waves can be described mat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.

If your external simulation can create waves for the physics you could feed those into a shader rendered local water surface (provided the waves can be described mathematically) to visualie them. AndersG has an unsophisticated example of that for his JSBSim ships (where the waves are defined by just a single sine function), see MTB_20m in my hangar at gitorious.org (see my signature for the link).

[1]

AndersG uses a separate local water object attached to the "aircraft" that overlies the terrain water. That way he gets to choose the shader and can get a dense enough mesh to get a useful result when displacing vertices. The terrain water shader uses bump mapping to give the illusion of geometric shape but that does not work that well when viewing it close up (which OTOH is rare in a flight simulator :). AndersG's shader should use more parts from the terrain shader to look as pretty, though, but he has not had time to work on that. It would be possible to let the shader draw the wake and propeller effects too - if one can find suitable mathematical descriptions of the effects. There are limits on how much data you can pass to a shader, however. It is also important to note that the shader is only a visualiation - the actual physical simulation for his ships is in the JSBSim files (System/hydrodynamics.xml and Systems/<vehicle name>-hydrodynamics.xml). Anders suspects it is rather feeble compared to a real ship simulation (he suggested static buoyancy on a smooth sea is reasonably well taken care of but the rest is more than a little hackish).[2]

He offsets his water object with half the wave amplitude (should have +epsilon there since I do get bleed through in the troughs).[3]

you will basically have (or be able to get) height values for (e.g.) a grid around your ship (from the cells on the fluid/air interface)? If you could get that information into the shader you'd be all set - but I think getting large amount of data into a shader on a per frame basis may be a bit tricky. I could imagine using a texture but it will have to be copied to or updated in the graphics card memory for each frame which probably is fairly expensive. OTOH you'd get wakes and all if you succeed. My waves are basically a continuous surface function ( = f(x,y, t)) where both the FDM and the shader uses the same function (the shader also uses the derivative of the function to compute normals).[4]


References

References
  1. AndersG  (Aug 7th, 2014).  Re: Export water/wave surface geometry .
  2. AndersG  (Aug 7th, 2014).  Re: Export water/wave surface geometry .
  3. AndersG  (Aug 8th, 2014).  Re: Export water/wave surface geometry .
  4. AndersG  (Aug 8th, 2014).  Re: Export water/wave surface geometry .