While working on the scan pulse effect, I tried experimenting with other approaches to achieve the same result. This version uses a SphereMask node, which takes a world position and an origin point and returns a gradient based on the distance between them.
The parameters are mostly the same as the previous version. We're using two vector parameters, Pulse Origin and Pulse Color, and two scalar parameters, Pulse Time and Pulse Speed. I'm going to set a default value of 2400 for Pulse Speed.
As with the previous version, we start with an Absolute World Position node and use it alongside the Pulse Origin parameter as inputs to a SphereMask node. The Pulse Time parameter is multiplied by Pulse Speed and fed into the Radius input to drive the expansion, and I'm setting a value of 10 for the Hardness.
The SphereMask returns a value of 1 at the center that gradually falls to 0 at the edge, with the Hardness parameter controlling how sharp that transition is. Running this gradient through a Sine node produces a ring pattern that emerges towards the edge of the sphere. A Clamp (0 to 1) then removes the negative portion of the sine output.
This result is multiplied by the Pulse Color parameter to apply the desired color for the scan effect. Next we add a SceneTexture node set to PostProcessInput0, which provides the existing rendered scene. Finally we add the colored ring result to this and connect it to Emissive Color to blend the effect over the scene.
To drive this effect at runtime, we first need a Post Process Volume in the level. If one doesn't exist already, add one and set it to Infinite Extent so it affects the entire scene. Next we're going to use a Blueprint to activate the effect and control its parameters at runtime.
We start by creating a Dynamic Material Instance from the scan pulse material on Begin Play. When the pulse is triggered, the Pulse Origin parameter of the material instance is set to the world position of the triggering actor, the material is added to the post process volume, and a timeline begins driving the Pulse Time parameter over its duration to expand the pulse outward. Once the timeline finishes the material is removed from the post process.
The result is a scan pulse that expands outward from the trigger point and lights up geometry as it passes through the scene, as shown below.
The project files for this and other Absolute World Position experiments are available on Github: https://github.com/RohitKotiveetil/UnrealEngine--WorldPositionExperiments







Comments
Post a Comment