Cloaking VFX | Blueprint Documentation

Thanks for checking out my Cloaking VFX project! On this page you’ll find a technical breakdown that will help you integrate the effect and its associated systems into your own projects.

If you have any questions or concerns you may find them addressed in the Frequently Asked Questions section at the bottom of this page. If you can’t find what you’re looking for, you can reach me at nick@techarthub.com or by joining the techarthub Community Discord server.

BP_CloakingDevice

This Component is where most of the magic happens. When attached to an Actor it will create the necessary Material Instances that drive the effect and assign them to any Mesh Component that has the CloakComponent Component Tag. You can find several examples of these in action within the CloakingVFX Demo level that comes with the project.

I decided to use an Actor Component because I felt it made it easier to add a Cloaking Device to any mesh object, and it’s part of a framework I’d like to use for more modular upgrades in the future.

Functions

Cloak/Decloak

Sets the target Cloak Radius (ie. the overall size of the effect) to either its maximum value (Cloak) or zero (Decloak) before setting bCloaking to true to start animating the Materials.

Get Cloak Components

Loops through all of the Owning Actor’s components and adds any with the CloakComponent tag to an array of Cloak Components.

Create Materials

Creates the required Material Instances for the effect (based on your Material Settings values) and applies them to your Cloak Components.

Create Sound

Spawns and attaches an Audio Component to the Owning Actor from which we can play a looping cloak sound.

The Create Materials, Create Sound, and Get Cloak Components functions only need to fire once on Event Begin Play.

Randomize Cloak Origin

Generates a new randomly placed origin point for the Cloaking effect by tracing inwards from the edge of the Owning Actor’s bounds.

If you’d like the Cloaking effect to always start from a specific position you can bypass this function and just set the Cloak Origin value directly.

Update Origin

Updates the Origin vector value across all Materials. This is usually only fired when the Origin location changes (via the Randomise Cloak Origin function) or when the object is moving.

Update Cloak

Interpolates the Cloak’s Mask Radius towards its target, and updates the sound volume/pitch to match.

Draw Debug Objects

An optional function which will update some debug spheres to help illustrate what’s happening underneath the hood. Set the bDebug bool to true to enable them.

Settings

All of the variables in the project have been given internal descriptions, but if something doesn’t make sense you’re probably not the only one so please let me know!

Sound Settings

NameDescription
SoundThe looping Sound Cue that will play when the effect is active.
VolumeThe maximum volume of the cloaking sound.
Volume CurveA Float Curve that defines the volume of the cloaking sound over the duration of the effect.
Pitch MinThe minimum pitch of the cloaking sound.
Pitch MaxThe maximum pitch of the cloaking sound.
Pitch CurveA Float Curve that controls the pitch of the sound over the duration of the effect (bound by the Pitch Min and Pitch Max values.)

Material Settings

These are the values that govern the Material side of the effect.

NameDescription
Base MaterialsA map of Materials and Material IDs that correspond to each of the meshes that will have the effect applied. These Materials will be used to create the Instances used by the Cloaking effect.
Cloak MaterialThe Material to use for when the Cloaking effect is visible.
Base Normal MapAn optional normal map that can be added to the Cloak Material, which is blended with Cloak Pattern normal.
Edge TintThe color of the edge between Cloaked and not-Cloaked parts of the mesh.
Edge WidthThe width of the edge in centimeters between the cloaked and not-cloaked parts of the mesh.
Distortion MapThe texture used to drive the edge distortion.
Distortion ScaleThe world space scale of the Distortion Map.
Distortion IntensityThe intensity of the edge distortion.
Distortion SpeedHow fast the Distortion Map coordinates should pan, making the effect animate even if the Cloak Radius isn’t being updated.
Distortion OffsetOffsets the Distortion Map’s coordinates. This is useful if you’ve got multiple identical meshes lined up (like I did in the Demo level) and you want the distortion effect to be different for each Actor.

Other Settings

NameDescription
bDebugEnables a few debug spheres that help illustrate how the effect works, which can be useful when fine-tuning the effect.
SpeedThe speed of the cloaking transition.
Cloak Radius MinThe minimum size of the Cloaking Radius. This value is also used to offset the sphere mask from the object within the Randomize Cloak Origin function.
Cloak Radius MaxThe maximum size of the Cloaking Radius. This will be specific to your particular use case.

Frequently Asked Questions

Does this effect work in Unreal 5.0?

Yes and no. I am taking advantage of a new feature in Unreal 5.1 called an Overlay Material (it’s so new I don’t even think it has official documentation yet) which lets me draw a transparent cloaking pattern Material underneath a masked base Material.

Without this feature the effect is still doable, but we’d have to use multiple meshes to get the same result. If you’re still keen to get it to work, shoot me an email. If there is enough interest I’d be happy to make a variant for UE5.0.