Search public documentation:
Fluid Surfaces are flat objects that visualize waves by moving the vertices up and down and/or by animating a normalmap texture that can be used in the material. Each of these features only affect a smaller rectangular part of the whole fluid. Normally, these rectangles will be centered around the main player and the rest of the fluid will remain flat and unaffected by any forces. As a designer, you'll want to keep these rectangles as large and finely tessellated as you can, while still maintaining good memory and performance. Fluid Surfaces are commonly used to simulate water. There are two types of Fluid Surfaces: FluidSurfaceActor and FluidSurfaceActorMovable. The only difference is that the latter can be moved around by Matinee.
As mentioned, only a part of a FluidSurfaceActor has some detail. The rest is just a flat quad. The Simulation and Detail sub-grids move around within the FluidSurfaceActor, trying to center themselves around their respective "targets". When the TargetSimulation and TargetDetail properties are empty, they will center around the player. You can see where the Simulation or Detail sub-grids are located within the FluidSurfaceActor by turning on bShowSimulationPosition or bShowDetailPosition. They will show up as rectangles. Since they move around and follows a target, you will probably want to test this in-game or in PIE. You can turn these on in-game with the "set" exec command. E.g:
set fluidsurfacecomponent bShowSimulationPosition 1Since Simulation grid uses vertex animation to visualize waves and ripples, that sub-grid will be highly tessellated and contain a lot of vertices. The Detail grid only moves around a normalmap texture and don't need any extra vertices. The Simulation grid is simulated on the CPU in a separate thread. The Detail grid is simulated purely on the GPU, animating a normalmap texture.
Fluids can be activated and deactivated. In the activate state, waves and ripples are simulated and the fluid are using up the required memory and performance. In the deactivated state, fluids use only a minimal amount of memory and they cost no extra performance other than rendering a static flat quad with the specified material. Fluids start up as deactivated, but will be activated automatically if the player is within DeactivationDistance (as measured from the closest FluidSurfaceActor edge - not the Simulation or Detail edges) and a force is applied to a point within the Simulation or Detail grid. Any force that are applied outside these sub-grids will simply be ignored and the fluid stays in the deactivated state. Once a fluid is activated, it will be deactivated automatically 10 seconds after the player moves outside the DeactivationDistance, no more forces are applied to the Simulation or Detail grids, and the fluid has settled down.
There are two ways of generating waves in a fluid: manual FluidSurfaceInfluenceActors or automatic physical interaction. Automatic interaction are handled by normal Touch events (this can also be hooked up in Kismet). Whenever an actor touches the fluid plane, an impact force is applied. The strength will be derived from the ForceImpact property, as well as the size and velocity of the touching actor. While the touching actor moves around on the fluid plane, a different (continuous) force is applied. This type of interaction uses the FluidContinuous property to determine the strength of the continuous force. Note that the TestRipple uses the FluidImpact property for its impulses (when TestRippleFrequency is greater than 0). When TestRippleFrequency is 0, it will apply a continuous force using the ForceContinuous property. Any force that is applied to a location outside the Simulation or Detail rectangles is ignored. As a general tip for visual quality, a larger impact radius will normally generate nicer, smoother wave. A larger radius have a stabilizing effect on the simulation since more cells are affected by the force.
Select FluidSurfaceActor under the "Actor Classes" tab in the Generic Browser. Right-click somewhere in the world in a viewport and select "Add FluidSurfaceActor Here". Position and resize it as desired using the widgets and hit F4 (or double-click the actor, or right-click and select "FluidSurfaceActor Properties"). FluidSurfaceActors have 4 categories of properties: Fluid, FluidDebug, FluidDetail and FluidSurfaceComponent. While reviewing the property settings, keep that in mind that fluids have two ways of animating - moving vertices up/down and/or animating a normalmap texture. The former is usually referred to as "simulation" and the latter as "detail". Note that the simulation is processed on the CPU (in a separate thread) and the detail is processed on the GPU.
We recommend using vertex-animation only for larger surfaces and normalmap-animation only for smaller surfaces like puddles. Using features at the same time can become cumbersome to tweak and will only waste memory and performance for little gain. While the FluidSurfaceActor can be as large as you want, using large simulation or detail sub-grids can use up a lot of memory and hurt performance. The key is to have as large GridSpacing as you can without hurting the smoothness too much. Start with a high value (like 50) and gradually make it smaller until you're satisfied with the quality. Then adjust the size of the simulation grid with SimulationQuadsX and SimulationQuadsY until you have as large active rectangle as you need. Still, using larger grid than 300x300 will use up a lot of memory. Turn on the "Test Rippple" to tweak the fluid properties in the editor and use Realtime Udate. The test ripple will activate the fluid so you can estimate the quality of your settings. Remember to use the lowest possible settings without hurting the quality too much, to keep memory and performance cost low. Wave travel speed is affected by the resolution (GridSpacing/SimulationQuadsX/SimulationQuadsX or DetailSize/DetailResolution), FluidUpdateRate/DetailUpdateRate and FluidTravelSpeed/DetailTravelSpeed. Once you have a set the resolution for decent smooth waves, you want to tweak the wave speed with FluidTravelSpeed/DetailTravelSpeed. You should try to keep the update rates around 30 (lower will make the animation jerky, higher will cost performance). Any force you apply to a fluid shouldn't have too small radius. Larger radius will make the waves look smoother.
- togglefluids will turn all fluid simulation on/off and free up almost all memory it uses. This can be used to compare memory usage and performance hit.
- stat fluids will display memory and performance statistics. Remember that the statistics can vary greatly per platform!