Geometry Caches in CRYENGINE allow storing and playing back arbitrarily animated geometry, similar to a video, but for geometry.
Some use-cases are: complex destruction animations, complicated cloth motion, or special effects that cannot be achieved with CRYENGINE's particle system.
More information can be found here: Production Details and Technology Details.
Alembic is a very flexible format, designed to be extensible for any custom pipeline conceivable.
As such many 3d applications export Alembic slightly differently, making it tricky to import caches from different sources.
A few guidelines need to be followed when creating Alembic caches for GeomCaches:
CRYENGINE requires per-face material assignment to be able to 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's good practice to name your materials something like:
It's recommended to avoid using lambert1!
You can create animated, passive, physics proxies by including one of the strings in the following list in the name of a mesh. The surface-type is derived from the assigned material. Physics proxies will not be rendered.
Please refer to the manual pages how to set any 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 you loaded 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. Bring up the Maya Alembic exporter GUI first.
3. Under the advanced Options, (scroll to the bottom) & make sure to have the essential flags enabled, as in the picture below.
After you set the options on step 3. do not use Maya's "Alembic Export" Options window -> "Export Selection" ( or "Export All" ) button on the bottom! Otherwise, you will loose the material IDs you set and end with just ONE material ID for your Alembic asset.
Once you have set these flags, click the close button & go to the Crytek Exporter!
4. Just select the mesh nodes 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. Although, it will not export deforming meshes readable for the CryEngine, but only "rigid bodies" with animated transforms. If you want to have deforming meshes, e. g. cloth objects, blendshape animations, etc. , you must export to an Alembic file from Max 2016, re-import the *.abc file in Maya, set the materials according to the Maya Alembic to CRYENGINE workflow and get the scene exported with CryAbc, the Alembic exporter from the crytek shelf. ( Follow the guide section above! )
One alternative is the Exocortex Crate plugin.
These are the essential exporter settings:
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 getting a new engine version.
Here's an example for using the resource compiler via command line to convert all *.abc files in the SDK:
rc.exe /refresh /threads *.abc
The import process is straight-forward:
Create a GeomCache entity from Entity > Render > GeomCache
Load up your *.abc file in the "File" field:
Set up your import properties. There are presets for most use-cases that you'll encounter in production:
The settings in detail:
The entity itself can be used similar to an AnimObject in Trackview and Flowgraph.
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 or further:
Coordinating game logic with GeomCaches requires a couple of extra steps to work efficiently.
In the following example picture of a looping animation of a GeomCache, the “resting or start” frame of the animation is at frame zero.
After a game event triggers a GeomCache to stop playing, (proximity trigger, gametoken modified, mission complete etc...(debug inputkey in this case))… we hook into certain inputs on the GeomCache Flowgraph node to handle how the entity stops playing correctly.
We call through flowgraph the SetTime input, this resets the timeline of the animation back to frame zero (using the Math:SetNumber node). But since this GeomCache is set to play a looping animation, setting the time back to this “resting” frame is not enough, as the loop will continue on from frame zero.
Since complex GeomCaches are too large to be fully pre-loaded, their animation data is streamed in 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 performing well:
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: