Geometry Caches in CRYENGINE allow the storing and playback of arbitrary animated geometry (similar to a video).
Some use-cases are: complex destruction animations, complicated cloth motion or special effects that cannot be achieved with CRYENGINE's particle system.
Alembic is a very flexible format that is designed to be extensible for almost any conceivable custom pipeline.
As such, many 3D applications export Alembic slightly differently, this makes it tricky to import caches from different sources.
For this reason, some guidelines need to be followed when creating Alembic caches for GeomCaches:
CRYENGINE requires per-face material assignment so that it can set sub-materials to geometry.
Alembic can export this information as face-sets (aka ShadingEngines or ShadingGroups in Maya).
The importer will look for the first integer number in such a face-set name and use it as the material ID.
So, generally it is good practice to name your materials like this:
It's recommended to avoid using lambert1!
You can create animated or passive physics proxies by including one of the strings in the name of the mesh... see the following list. The surface-type is derived from the assigned material. Note: Physics proxies will not be rendered.
Please refer to the manual pages in regards to setting any User Defined Properties (UDPs) for CRYENGINE physics proxies in Maya or 3ds Max
We use the built-in Maya 2016 Alembic Exporter and the "CryAbc" script from the Crytek shelf.
Make sure that you have installed the Maya Alembic export plugin: from Maya's Main Menu bar -> Windows -> Settings/Preferences -> Plug-In Manager, tick the "Loaded" and "Auto-load" checkbox for the "AbcExport.mll".
1. Run the AbcMat script (inside the Crytek Shelf) to prepare your scene for export. This script slightly modifies your scene to work around some limitations in Maya's Alembic exporter.
2. Now bring up the Maya Alembic exporter GUI.
3. Under the advanced Options, (scroll to the bottom) and make sure to have the essential flags enabled - as in the picture below.
After you have set the options in step 3. Do not use the "Alembic Export" Options window -> "Export Selection" (or "Export All" ) buttons at the bottom! Otherwise you will loose the material IDs you have set and end up with just ONE material ID for your Alembic asset.
Once you have set these flags, click the close button and go to the Crytek Exporter!
4. Just select the mesh nodes that you wish to export and click the "CryAbc" shelf button. A file dialog will pop up and ask you to set the file location and file name for the Alembic file.
Beginning with version 2016, 3ds Max officially features an Alembic exporter. However, it will not export deforming meshes that are readable for CRYENGINE, rather only "rigid bodies" with animated transforms. Therefore, if you want deforming meshes, for e.g. cloth objects, blendshape animations, etc..., then you must export to an Alembic file from 3ds Max 2016. To do this, re-import the *.abc file into Maya. Then set the materials as per the Maya Alembic (according to the CRYENGINE workflow) and get the scene exported with CryAbc using the Alembic exporter that is available from the crytek shelf. (Follow the guide section above)
Running the resource compiler from the command line allows for batch conversion of multiple *.abc files in a row.
This can be useful for automatic asset builds or manually updating all *.cax files after installing a new Engine version.
Here's an example for using the resource compiler via the command line to convert all *.abc files in the SDK:
rc.exe /refresh /threads *.abc
The import process is straight forward:
Drag&drop your alembic (.abc) file into the Asset Browser to create a Geometry Cache asset.
The asset will be imported with default settings, which can be changed later in the relevant Asset Editor.
Holding Ctrl while dragging & dropping opens the importing dialog:
Double click on the asset to edit.
These settings do the following:
Setting | Description |
---|---|
Y/Z-axis up | Set this according to which axis is up in your source file. |
Playback from Memory | Will load the entire cache into memory (instead of streaming it). Useful for small, looping caches. |
Face Set Numbering |
|
Block Compression | Lossless compression for the entire file.
|
Precision | Lossy compression of vertex positions. Higher values = smaller file, but more jittering. |
Use Mesh Prediction | Lossless compression of mesh-data. Disable to quickly compile complex caches for testing. |
Use Bi-Directional Prediction | Lossless compression of motion-data. Disable to quickly compile complex caches for testing. |
Index Frame Distance | Interval at which to place key-frames. Larger/smaller can improve compression for some caches. |
The entity itself can be used, similar to an AnimObject in Trackview and Flow Graph.
The properties in detail:
With the appropriate settings, the entity can be used as a looping animated prop without extra game logic.
Here's an example of an independent GeomCache prop from Ryse that loads and unloads as the player moves closer to or further away from:
Since complex GeomCaches are too large to be fully pre-loaded, their animation data is streamed a few seconds before being played.
Smaller GeomCaches can be completely loaded into memory by enabling the "playback from memory" flag on import.
Because of this it is important to keep an eye on the data-rate of individual caches and the combined amount of GeomCache data currently in memory.
These values have been used for Ryse on XboxOne:
Most of the time working with GeomCaches comes down to a trade-off between draw-calls and data-rate.
Using many non-deforming meshes with animated transforms results in a low data-rate, but high draw-call numbers and vice-versa.
Some techniques to help GeomCaches perform well are:
This sequence illustrates how different techniques affect draw-calls and data-rate using "e_GeomCacheDebugDrawMode 3" to color instances:
The overall memory consumption and streaming performance of all active GeomCaches can be profiled using "e_GeomCacheDebug 1".
Individual GeomCaches can be profiled with the mesh statistics overlay.
This is how the individual values affect performance:
The Statistics Overlay can be enabled in the preferences:
Issue | Possible Solutions |
---|---|
GeomCache won't play |
|
Animation stutters/skips frames |
|
UVs or vertex colors look wrong |
|
Material IDs look wrong |
|
e_GeomCacheDebug - displays GeomCache streaming debug information. Avoid having a full streaming buffer, since it will lead to animation stalls:
e_GeomCacheDebugFilter - show debug info only caches with this string in its name.
e_GeomCacheDebugDrawMode - debug draw to identify static geometry, deforming geometry and instances: