Closed srmainwaring closed 2 years ago
This section will be periodically updated to track progress on this issue.
WIP on branch https://github.com/srmainwaring/asv_wave_sim/tree/feature/ign-garden-wip
Initial version of static FFT generated waves:
ogre2
metal
Investigated a number of options for dynamic meshes in Ignition with the Ogre2 render engine
Ogre::v1::MeshManager::createManual
is not recommended Drawing a Flexible Object made of Vertices (FAST), further the Ogre2 render engine converts these to Ogre2 meshes using Ogre::Mesh::importV1
so the previous method for updating the mesh will not work (and will be slow).rendering::Ogre2DynamicRenderable
object that does support triangle lists, however there are no index buffers used in this class, so that requires each tile vertex to be inserted multiple times (once for each triangle). Furthermore the class does not have methods to set the normals and tangent vectors (the normals are calculated internally, tangents are not calculated). An implementation using rendering::Ogre2DynamicRenderable
is available as an example and to provide a base level benchmark. The clip below shows the technique, the waves look tessellated because each face has it's own vertices and they carry the normal for the face (i.e. there is no averaging of the normals) rendering::Ogre2DynamicRenderable
that adds texture coords and tangent vectors. Single OceanTile with dynamic FFT waves and averaged normals using a modified version of rendering::Ogre2DynamicRenderable
as described above. Plenty of scope for increased efficiency in the implementation, but even an initial version is running acceptably well.
Ignition Garden has support for custom shaders using the ShaderParam
system plugin for the <visual>
element. However it turns out that only one plugin is processed from the <visual>
element (multiple may be specified, but only one is loaded).
There are a number of places where changes are required. The following may not be exhaustive:
GzSceneManager
only captures one plugin per visual https://github.com/ignitionrobotics/ign-gazebo/blob/49d0673f318fd1d29dc1a75e9be5de2f829217ab/src/gui/plugins/scene_manager/GzSceneManager.cc#L114-L148A proper solution is to modify ignition-gazebo to support multiple visual plugin elements. In the interim a work-around is to re-implement the ShaderParams
logic in the Wave
system plugin.
Fix-it list
RenderUtils
or SceneManager
ShaderParams
system plugin - what is going on?A number of changes in order to support PBS materials. Custom shaders are still not working, but improved visuals are available using PBS materials which supply the bump map and environment map (the mixture of shallow and deep colours is not available with this approach).
VES_TANGENT
vertex element). The common::SubMesh
does not store tangent vectors so we subclass and populate the extended common::SubMeshWithTangents
instead. To use we pass the sub-mesh to common::Mesh
using the std::move
interface instead of the copy by value which ensures the stored sub-mesh retains it's vtable.VES_BINORMAL
vertex element, in fact if this is attempted Ogre will report a runtime error concerning attribute indices exceeding a permitted value (< 32).There are initial versions of all three plugins which allow objects of various shapes to interact with the wave field. There is much to be improved, but the bulk of the conceptual work required to migrate to Ignition is in place.
The waves model system plugin holds a wavefield object and its parameters. The entity component system makes it simpler to manage these objects than in legacy Gazebo. A new component for the wavefield is used to store a weak pointer to the wavefield and then this is registered with a new entity. It can then be retrieved by name from the ECM.
This approach appears to work quite well, and eliminates the need for a separate wavefield entity object derived from the physics base model.
Outstanding tasks
The hydrodynamics system plugin is also substantially reworked from the original. It uses the ECM to retrieve the wavefield component registered by the wave model plugin. The collision shapes are obtained from the collision component using the same approach used in the buoyancy system plugin.
Outstanding tasks
For larger models (ships) the ocean will need to be scaled accordingly, while retaining sufficient detail to make the local wave field interesting. Investigate the following:
Some of the ideas listed above are investigated in this ogre-next branch: ogre-next - feature/v2-2-osrf-mac-ocean-compute2
Using textures to store the displacement, normal and tangent maps the trochoid wave example may be extended to a 10km x 10km region using 512m x 512m tiles. In this example the textures are updated in CPU and uploaded to GPU. The underlying vertex structure is a 128 x 128 segment Ogre plane repeated 2*10+1 times in each direction (i.e. 441 tiles).
FFT generated wave textures with 256m x 256m tiles and 200 x 200 grid segments using 256 x 256 FFT samples. There are some repetition artefacts which are mitigated to some extent by the tile size and viewpoint.
Closing as the main aspects of the initial migration have been dealt with in the following PRs: #16, #18, #19, #23, #24, #25, #26, #27, #28, #29, #31, #32, #33, #34, #36, #37, #38, #39, #40
New Feature
This issue is to track the migration of the wave simulation and hydrodynamics plugins to Ignition (Garden).
Desired behaviour
The wave visuals and physics behaviour are available in Ignition using the
ogre2
render engine. There should be support for both Linux and macOS (the latter using Metal graphics API).Implementation suggestion
The model and visual plugins from legacy Gazebo will be replaced with system plugins in Ignition. As before three plugins are required:
wave visuals
The wave visuals are perhaps the most challenging change as they require migration to the Ogre2 render engine and integration into the ignition-rendering framework. As with legacy Gazebo, there is no direct support for modifying meshes at run time, with the exception perhaps of the
DynamicRenderable
objects for Ogre and Ogre2 which sit outside the main mesh frameworks fromignition-common
andignition-rendering
.The proposed approach is to first create visuals for a static wave field, which can be done staying within the available mesh and rendering framework and will use the vertex generation from the existing
OceanTile
. Static waves will allow the following to be migrated:[x] wave generation methods
[x] materials and shaders
[x] parameter interfaces
wave physics
[x] Enable switching between the existing trochoid wave and development branch FFT wave algorithms
hydrodynamics physics
[x] No changes in functionality planned.
[x] Clarify use of different vector and mesh types (CGAL vs Ogre vs Ignition)
Other changes
The migration to Ignition requires such a significant change, it could be regarded as a complete reworking of the library. Other changes that may be included as sub-issues are:
Progress