- Category: Blueprints
- Update: 1.2 (12-09-2020)
- Unreal Engine: 4.23 - 4.25
- Platforms: PC, Console
Infinity Weather is a powerful and clean system designed for weather control in Unreal Engine.
The package is a combination of 7 systems that could be divided into separate packages: wind, displacement, landscape, precipitation, footsteps, fog, post-process now available as a configurable unified system.
- configurable displacement capture blueprint
- top-down projection of displacements rendered using shape definition in the shader (sphere, capsule, box, cylinder, decal, trace-sphere)
- skeletal mesh displacement supports
- interface for easy integration with all types of actors
- area of displacement move dynamically with the actor or camera
- time-based accumulation of snow
- build functions can be used for multiple other effects (like grass interaction)
- displacement material functions ( snow, mud, sand, grass)
- small world texture (1024×1024) can handle even 150x150m area
- two materials with fast dynamic switching between material permutations
- post-process effects (raindrops, frozen, sharpen/blur)
- pre-translucent effects (rain circles, heat haze, experimental glitter)
- reacts dynamically on weather conditions
- supports character and sequencer camera
- notify based footsteps detection system
- example footstep types (SFX, VFX) snow, rain, mud
- physics material support
- configurable footstep component adjustable per character
- footstep volumes with priorities and conditional spawning
- defined effects of snow, rain, dust, hail
- GPU friendly and efficient, implemented on single material and mesh.
- up to 65000 particles per emitter with high performance
- occlusion maps
- crossfade wind and rain sound effects
- basic example materials (snow, mud, sand)
- advanced landscape material prepared for mixing displacement and dynamic weather.
- virtual texturing and layered landscape materials.
- multiple example ground layers (rock, grass, mud, sand)
- weather controller actor
- spherical volumetric fog area and atmosphere and temperature
- weather surface material function (snow/wet layer)
- spline-based rainbow mesh with camera facing,
- water puddle decal
- directional light clouds shadow reacts on wind direction.
- wind reactive effects like precipitation, ground dust, flag, trees, bushes, grass, emitters
- example maps: Snow, Sand, Rain, World
- character reaction to strong wind
Make sure that the Infinity Weather package version is up to date. The current newest version is described at the top of the documentation.
The package requires a procedural mesh component to work so make sure that it’s enabled.
I’ve decided to make this project downloadable content that can be added to the project. Unreal Engine does not support sending config files in downloadable content so users have to add footsteps configuration in the project that uses pack to make it work properly. The process is really simple:
- Open the project configuration Edit->Project Settings
- Select tab Engine->Physics and scroll down
- Add physical surface types: Snow, Sand, Mud, Rock
The package works perfectly with the TPP input config files. if you have used another template then probably you will have to add inputs into your project for package testing:
[/Script/Engine.InputSettings] +AxisMappings=(AxisName="MoveForward",Key=W,Scale=1.000000) +AxisMappings=(AxisName="MoveForward",Key=S,Scale=-1.000000) +AxisMappings=(AxisName="MoveForward",Key=Up,Scale=1.000000) +AxisMappings=(AxisName="MoveForward",Key=Down,Scale=-1.000000) +AxisMappings=(AxisName="MoveRight",Key=A,Scale=-1.000000) +AxisMappings=(AxisName="MoveRight",Key=D,Scale=1.000000) +AxisMappings=(AxisName="Turn",Key=MouseX,Scale=1.000000) +AxisMappings=(AxisName="LookUp",Key=MouseY,Scale=-1.000000)
The package is now ready!
Every user of this package should start by checking all examples delivered with the product. Example maps can be found in the InfinityWeather/Demo/Maps folder.
There are available multiple examples that preset different configurations:
- SnowMap – simple snow effects with lightweight landscape material.
- RainMap – simple rain and mud effects with lightweight landscape material.
- DesertMap – simple desert and sunny weather with lightweight landscape material.
- WorldMap – advanced multi-layered material with mixed landscape effects.
The example character interaction with the Infinity Weather world is implemented in Demo/Mannequin/BP_DemoCharacter by four basic components added to it:
- BP_InfinityFootstepComponent – spawns footsteps effect from notifiers
- BP_InfinityDisplacementComponent – renders shapes for ground displacement
- BP_InfinityPostProcessComponent – controls post-process and controller communication.
- BP_InfinityPawnComponent – additional effects on a character like breath particle when it’s cold.
The most important element of the pack is the InfinityWeather/BP_InfinityWeatherController blueprint that gives the users possibility to control the weather conditions like fog, wind direction, precipitation, and accumulation.
Drag and drop BP_InfinityWeatherController on your level to start controlling the weather.
Atmosphere effects requires Exponential Height Fog plugged into the BP_InfinityWeatherControllers to work properly. Remembet to polace height fog actor on your map and set the attribute of weather controller.
A list of weather controller attributes looks simple but it’s a very powerful tool. For testing try to set some rainy windy weather using parameters like below:
The system can be controlled dynamically by blending between parameters during the game using the functions below.
The precipitation system is the most advanced part of this pack. It is based on a single material combined with a single mesh (no Niagara or Cascade). The effect of billboarding is computed in vertex shader in the local space of the camera. That means the system has almost no PCU cost and works ultra-fast.
There are a few predefined effects of precipitation defined in the project (/InfinityWeather/Precipitation/)
The precipitation effect can be used without a weather controller. You can drag and drop the blueprint of the chosen effect on the map to use it as static volume.
A manually placed actor can be configured and limited by the area of precipitation. Users also can set multiple weather types visible locally in some areas of the map. All parameters are described in editor hints.
You can create your own precipitation effect classes for specific rain/snow configuration by extending the base class and changing attributes. That newly created class will be available on the Precipitation Effect Class list in weather controller.
The /InfinityWeather/Precipitation/BP_InfinityPrecipitationOcclusion is a specific type of actor that contains render target texture used for calculating precipitation collision with the roofs and other cached meshes. After placing this actor on the scene you will notice that in the area of the occlusion map the rain and snow are not rendered under the meshes.
Currently supported is only one occlusion map per level but its planned to implement switching between multiple occlusion maps dynamically.
The wind is based on the integration of multiple effects that react to a simple wind direction vector.
Currently, the wind effects can be controlled globally on the full scene using the Wind Direction vector in BP_InfinityWeatherController.
Most of the objects that react to wind use the Environment/Functions/MF_InfinityWind material function that returns all important information about current wind status. It’s the simplest way to get global wind data.
List of implemented effects and objects that reacts to the wind force.
- Precipitation direction – Attribute Wind Force in precipitation blueprint scales how much it affects
- Vegetation – MF_WindBush, MF_WindTreeLeafs, MF_WindTreeTrunk, MF_WindGrass nodes implements the effects of wind on vegetation.
- Flags – specific implementation of flag material M_Flag.
- Cascade particle emitters (Wind Affected Emitters attribute in Weather Controller is a list of emitters that should use Wind Direction and Wind Intensity parameters to react. (Example Environment/Dust/PS_SnowBlowingLarge)
- Dust – predefined planar dust effects that rotate and fade based on wind direction.
- Grass – MF_WindGrass material node.
- Landscape dust – MF_GroundDust effect on the sandy landscape.
- Clouds shadow – M_CloudsShadow
The BP_InfinityFog actor can be used for changing fog settings in some areas. Fog actor is divided into two parts
- Fog volume – The volumetric shape of fog is rendered as overlay mesh.
- Fog atmospherics – Atmospherics settings. When the camera is inside the Fog volume the controller uses those settings to blend into new parameters based on the Weight attribute value.
Currently supported is only the ellipsoidal shape of fog.
Accumulation is the group of parameters that controls coverage of snow and wetness of meshes that uses the MF_InfinityWeatherSurface node in the master material.
MF_InfinityWeatherSurface is an advanced node that adjusts base color, normal, and roughness values to current weather conditions set by the two basic parameters that are used in the material.
- Weather.Controller.WetSurface – Controls wetness of the surface
- Weather.Controller.SnowySurface – Controls the snow shell on the surface.
An example of MF_InfinityWeatherSurface use is presented in the rocks material M_RockSnowMaterial. Drag and drop rocks mesh(/InfinityWeather/Demo/Environment/Rock/SM_Rock ) on your map to check how weather conditions affect the material. Notice that the combination of wetness and snowy material can result in a nice-looking effect of icy snow.
Additionally, meshes can be painted by vertex color (red channel) to mask the effect on meshes that are hidden under the occluders.
A more detailed description of additional parameters can be found in the landscape and displacement section.
The Infinity Weather system introduces an advanced displacement material system based on render targets. In short, the BP_InfinityDisplacementCapture actor is searching for actors around the focus point, that implements BPI_DisplacementShape. BPI_DisplacementShape implementation adds the list of shapes (a type of shape and transform) to the stack. In the final stage stack of shapes is rendered to displacement texture. The iteration is repeated every frame with some random offset.
3 elements are needed to make the system work:
- Displacement receiver landscape with the material that supports displacements. (MI_LandscapeSnow/MI_LandscapeMud/MI_LandscapeSand, MI_LandscapeCombined)
- Displacement capture actor placed on the map (BP_InfinityDisplacementCapture), set to capture landscape ground.
- Displacement mesh actor or component that will affect the ground (BP_InfinityDisplacementStaticMeshActor)
The video below shows how to combine all these tools and make them work:
Landscape material is an advanced topic because requires basic knowledge about an unreal material system to inject them into the project.
Example content (Landscape/Materials) comes with a few examples of the landscape configurations to make this step easier. There are simple materials that cover the landscape fully by a single type of displacement:
- M_LandscapeSnow (uses MF_InfinitySnow)
- M_LandscapeMud (uses MF_InfinityMud)
- M_LandscapeSand (uses MF_InfinitySand)
There is also an advanced version of the material that is a combination of all three effects in one landscape. Additionally, the extended version supports the MF_InfnityWeather. Available in two versions virtual texturing and multilayered
Let’s take a look at the example Sand (M_LandscapeSand) material used on DesertMap:
The material is a combination of four nodes:
MF_GroundDand – it’s the base material layer of sand that contains a color map, normal map roughness, etc. It can be replaced by any material for example created from GameTextures/Example Project/Any pack.
- MF_InfinityDisplacement – is a base node that reads displacement render target and returns data from it. As an input, it takes the displacement layer intensity. It’s the layer that will be used to paint the landscape.
- MF_InfinitySand – combines data from displacement and ground layer. Additionally, this node implements some additional effects like coloring displaced ground. There are another two nodes that could be used here to achieve another effect MF_InfinityMud, MF_InfinitySnow.
- MF_InfinityWeather – adding the overlay effect of a wet surface that can be controlled by the weather controller.
The BP_InfinityDisplacementCapture is the main actor that prepares displacement depth textures for landscape. Below is a simple explanation of how the algorithm of this actor works:
- Displacement capture actor is searching for actors that overlap the area of displacement.
- If an actor that supports the displacement interface is detected then he is asked about list shapes to displace ground.
- New generated shapes are added to the stack.
- In the final step, the displacement capture actor renders all shapes added to the stack.
A simple configuration of the scene with displacements is presented below:
- Drag and drop BP_InfinityDisplacementCapture on the map.
- Add the Landscape actor to BP_InfinityDisplacementCapture.GroundMeshes.
it’s an important step to notify the system about the receiver of the displacements.
Select landscape and use the material that supports displacements for example M_LandscapeSand.
- Edit the landscape and paint the layer of displacement on it.
For optimization, displacements are rendered only in the area of the focus point. The focus point is taken from BP_InfinityDisplacementCapture.CaptureActor. If the CaptureActor is null then it uses the character Pawn as the focus. If Pawn is null then it uses camera location.
Two types of render targets are defined in the system. Both area sizes can be changed in the capture displacement actors.
- Capture Render Target – cache shapes around the focus point. Modify the CatureTextureSize attribute.
- World Render Target – combines all cached data. Modify the render target TR_Persistent.resolution to adjust the size of history.
Simple static shapes
The displacement map rendering is based on ray tracing shapes in the shader to get the best possible efficiency but it’s also limited to the number of shapes predefined in shaders. The shapes that can displace the ground are defined in the /InfinityWeather/Displacement/Blueprints/Shapes/ folder:
- BP_DisplacementDecal (heightmap mapping on the ground)
All of them can be placed on the map and scaled.
Use Debug Option in BP_InfinityDisplacementCapture to preview shapes that are rendered by capture displacement
BP_InfinityDisplacementComponent is a component that allows attaching a list of shapes that affect displacement ground.
The example implementation of displacement component in clean mannequin character presented on the video below:
Adding displacements to your character is easy:
- Open character blueprint, add BP_InfinityDisplacementComponent to your character.
- Select the component and set Displacement Shapes data asset. You can use full ragdoll (DS_MannequinRagdoll) or foot (DS_MannequinFoots) implementation that is faster and prepared for walking.
- Select “Class Settings” on the top bar and add the BPI_DisplacementShape interface to the list of Implemented Interfaces. It should look as on the screen:
- Now implement the interface function called AddDisplacementShapeData.
After those few steps character will be detected and ready to work.
Custom collision type
The Infinity Weather displacement capture system uses box collision volume during searching the actors that should be captured in displacement buffer. The overlap detection requires a specific collision type for filtering collision shapes. The engine has no option to include custom collision type into the external marketplace package because it’s defined in the configuration files.
By default, Infinity Weather takes advantage of using predefined destructible collision type but it’s not the best solution for every project, this collision type can be occupied by other functionalities and turned off for specific actors like characters.
The best way to overcome this problem and also improve performance during overlap test is by creating a custom collision type and using it to detect shapes that should be detected in the displacement area This solution will also fix all issues with ALS ragdoll detection and other strange behaviors that could occur after placing BP_InfinityDisplacement actor on the map.
Creating custom collision type is described in the Unreal Engine 4 documentation and the explanation below shows how to apply this knowledge with Infinity Weather:
1. Find Edit->ProcectSettings->Collision
2. Open the ObjectChannels tab and add a New Object Channel type called “InfinityCapture“, set to ignore by default.
Now you have to set a new collision type in the displacement capture actor.
It’s good practice to inherit BP_DisplacementCapture class and edit the child class instead of changing package assets. If you do tit this way then the next package update will not break your project.
- Open BP_DisplacementCapture (or child instance) and find CaptureVolume component.
- In CaptureVolume->DetailPanel->Collision->CollisionPresets->ObjectType set the InfinityCapture type.
Since now every actor that has set Collision Response->InfinityCapture->Overlap true will be considered during the displacement detection process.
- Find character class select collision component that should be detected (CapsuleComponent or Mesh)
- In details panel find Collision tab -> Collision presets
- If the collision preset type is “Custom…” then just switch InfinityCapture->Overlap to true.
- Otherwise, you will have to set custom or edit existing preset the same way in project collision settings.
- Remember to repeat these steps for all actors that should be detected by displacement capture like BP_InfinityDisplacementStaticMeshActor.
You can use debug option in BP_InfinityDisplacement actior to see if the actor is detected.
Displacement data asset
The configuration of displacement shapes attached to actors is stored in Data assets (PDS_DisplacementShapes).
Infinity weather contains a few examples of data assets for mannequins and vehicles but any user can create custom data assets that will work with specific skeletal mesh. Creating a displacement data asset is simple:
- Press the right mouse button in the content browser
- Select Miscellaneous->DataAsset
- Pick PDS_DisplacementShapes and create
- Set name of newly created data asset “DS_ExampleDataAsset” for future use.
Newly created data assets can be used in the characters but we still need some shapes definition. Shapes can be added by hand but Infinity Weather comes with a simple editor that helps preview how shapes are attached.
- Drag and drop editor class on map (BPU_InfinityDisplacementShapesEditor).
- Select editor, and chose newly created data assed (DS_ExampleDataAsset) in Data attribute.
- Pick the skeletal/static mesh reference that will be a visual representation of the shape that makes displacement. It can be your character or car.
- Press Load and now you can add shapes to the List. The shape structure is described below.
- After the working press “Save” to save changes. Remember to apply the newly created data asset in DisplacementComponent.
|Socket||Bone or socket name used as an attachment transform. The system will uses component transform if the socket name is not defined.|
|Shape.Type||Shape type. Currently supported: Box/Sphere/Cylinder/Capsule/Decal, Trail Wheel, Trail Sphere|
|Shape.Intensity||Scale the intensity of interaction (not implemented yet)|
|Shape.Transform||Relative transform in space of attachment.|
|Shape.Pattern||The texture is used as a pattern in the displacement decal.|
Weather System also supports the advanced footstep system integration based on notifiers placed in animation.
Working with footstep system:
- Add BP_InfinityFootstepComponent component to a character. The configuration of components contains default predefined templates of effects and attachments for the mannequin.
- Add BP_NotifyFootstep to the animation of walking/running in place when the foot hits the ground. Chose the left or right foot in the properties.
- Add BP_FootstepVolume on your scene and select the preset of footstep that should be spawned inside of the volume.
The engine sometimes wrongly detects the footstep ground because of limited landscape layers blending during ground tracing. Footstep volumes BP_FootstepVolume can solve this problem easily. When the character is inside the volume then the system uses the footstep set in the volume definition so the incorrect footstep effect is overridden.
The priority and Required conditions are taken into account to choose the most relevant footstep effect. It can be even filtered. The example below shows how to config volume on second priority (higher priority more important) that spawns snow and will be visible only when there is at least 0.1% of the weather displacement active.
The BP_InfinityPostProcessComponent placed into an actor that contains the camera component will add automatically the post-process material and communicate with the weather controller to get info about the current conditions.
Three types of post-process views objects are supported:
- Postprocess camera – by default system search for the camera in owner.
- Postporcess component – if there is no camera in the owner then the system search for a component.
- Postprocess Volume – custom volume can be set for the character on the scene by setting the Postprocess volume attribute.
A custom post-process object can be also set by the function SetPostProcessView.
- Raindrops and circles show only when the precipitation actor has IneractWeather > 0.0. That means raindrop shows only inside the rain volume.
- Screen raindrops fade after some time. The duration of the fade can be controlled by BP_InfinityPostProcessComponent.Rain parameters.
- When the camera is under the cover it’s not getting wet and raindrops are not appearing.
- Freezing and heat haze distortion are calculated locally from the weather controller and fog actor’s atmosphere. (temperature, distortion)
The screen effects are implemented using two post-process materials.
MI_InfinityPreTranslucent – a group of effects rendered before the translucency layer.
- Rain Circles – Enables automatically when rain precipitation is active.
- Distortion – Heat Haze effect that enables when
- Glittering – Experimental disabled effect of glittering rendered on snow and sand.
MI_InfinityPostProcess – a group of effects rendered after the tone-mapping.
- Sharpening – Additional sharpening effect that improves the quality of close objects (can be disabled) by UseSharpening.
- Drops – Animated raindrops on-screen are visible only if the camera is exposed to rain.
- Frozen – Frozen screen edges.
The replication of the weather is implemented on the server-side. That means all functions from BP_InfinityWeatherController that controls weather should be activated on the server and then the state will be automatically sent to clients. The state of the weather is also replicated when the player joins to game after some time.
Displacement render targets are not replicated but only calculated locally around the focus point of displacement capture actor that follows the local player 0. That means if multiple actors are walking in the same area at the same time then the result will be calculated locally and similar for all of them. It behaves this way not because it’s replicated but because it’s simulated locally with the same data.
During testing displacements in multiplayer be sure to run it in separate instances of the game, otherwise, UE4 shares the memory of ground texture and there are bugs because multiple displacement actors render the same displacement texture at the same. This issue does not affect the final released game so don’t worry. Use option SingleProcess=false for testing the game in the editor with proper displacements in multiple windows.
Future features that will be implemented for multiplayer games:
- Local weather controllers are not supported yet but it’s something on my roadmap.
- Replicated foodprint decals that will be sent to clients and activated when displacement actors close.
Advanced Locomotion System
The most important part is implementing a custom collision type that will solve most of the problems related to ALS and IW volume overlapping. You can find detailed descriptions of this step in the chapter called “Custom Collision Type”.
After you finish this collision configuration then additionally it is worth setting Climbable = Ignored in Trace Responses of Capture volume component because it’s not needed. The final configuration of the InfinityCapture actor should look like below:
It’s also important to update ALS_character collision preset in the project config. InfinityCapture channel should be set to overlap.
When the collision setup is ready then it’s time for ragdoll. During ALS ragdoll mode capsule overlap is not detected and that is why displacements are not rendered by default. There are two possible methods to fix it and choose is on your side:
- Select ALS Character Mesh and switch Generate Overlap Events = true, and InfinityCapture channel to Overlap.
- Alternative more general method. ALS_Character -> Add Component ->Sphere Collision to character actor and configure attributes as presented on the screen below:
There is another important thing about ragdolls that is switching between presets ragdoll/feets.
The DS_MannequinRagdoll preset is slower and more precise, the DS_MannequinFoots preset works perfectly in low FPS because it supports continuous movement. Fortunately, ALS can support this feature very easily ALS_AnimMan_CharacterBP has functions RagdollStart and RagdollEnd that perfectly fits the requirements of switching.
Use SetDisplacementShapesDataAsset on the DisplacementComponent.
- RagdollStart should set DS_MannequinRagdoll asset as a parameter
- RagdollEndshould set DS_MannequinFoots asset as a parameter
Questions & Answers
I can’t see any precipitations under the 0.0 of the level.
Add BP_InfinityPrecipitationOcclusion on your map.
Explanation: The system by default reads 0.0 as the default occluder. BP_InfinityPrecipitationOcclusion will analyze your level occlusion and update the height of the ground.
Why landscape is flickering after painting the displacement
Solution: Use a geometry brush on the landscape to displace mesh a bit and mesh will not disappear anymore.
Explanation: It's an engine bug, that I can't overcome but it's easy to fix in your project. The only way to fix this is to increase the size of the landscape component bound box by editing the ground. The bug is related to the bounding box of landscape fragments. If landscape bounds are hidden under displacement mesh (extruded using vertex offset|) then the occlusion system removes the fragment of landscape. It flickers because the occlusion is probably calculated based on the previous frame and in the previous frame, the component visibility was the opposite.