For the final experiment in the Screen Position series, we're creating a damage overlay effect. It builds a red vignette at the screen edges that responds to a damage intensity value, with the edge detail generated procedurally through a noise function rather than a hardcoded texture.
We start by setting the material domain to User Interface and blend mode to TranslucentGreyTransmittance.
The Screen Position node's ViewportUV output is used as the UV source. We Subtract 0.5 from it to shift the origin from the top-left corner to the center of the screen.
The centered coordinates are fed into a Length node, which gives us the radial distance from the center.
This distance is then passed through a SmoothStep node (Min 0.17, Max 0.57) to produce a soft radial gradient that's strongest at the screen edges and falls off toward the center.
For the noise, we take the Screen Position XY and append a Z value of 0 to construct a Vector3, which is fed into a Noise node. The output is multiplied by 0.05 to keep the distortion subtle.
The noise and SmoothStep outputs are added together and passed through a Saturate node. The noise has the most visible impact in the lower transition range of the gradient where base values are small, and progressively diminishes toward the upper end.
We create a DamageIntensity parameter and feed it through a Power node with an exponent of 0.5. Without this, the effect at an intensity of 0.5 felt too weak compared to 1, and the Power node brings the mid range response closer to what you'd expect.
The output from the Saturate node is then passed through a Lerp node with the Power output driving the Alpha to create the opacity mask.
Finally, the opacity mask connects to Opacity Override and a dark red Color node (R=0.14) connects to Final Color.
The material is then assigned to an image widget that fills the entire screen. The result is a red vignette effect with procedurally generated noise, with the intensity of the effect controlled through the DamageIntensity parameter, as shown in the screenshot below.
And that brings the Screen Position experiment series to a close. The project files for this and other experiments are available on Github: https://github.com/RohitKotiveetil/UnrealEngine--ScreenPositionExperiments





Comments
Post a Comment