This project introduces wet spots from rain VFX
result-to-show.mp4
The idea was to create a realistic surface response to the VFX. This involved generating a screen-space mask that highlights wet areas, which is then sampled in materials using screen UV coordinates of the pixel currently being rendered.
The source code includes a module (/Source/SceneViewExtModule
) responsible for executing the core algorithm. This algorithm leverages Unreal Engine's Scene View Extension feature to listen for the PreRenderView_renderThread()
function. Within this function, a custom pass (referred to as Rain mask pass in code and debug tools) renders a wetness screen mask before the base pass, ensuring the mask is available within the same frame. In the project, the mask is sampled in material graphs using screen UV coordinates.
- Copy the module folder
/Source/SceneViewExtModule
and paste it into your project's source folder. - Add the following code line to both
/Source/<project name>.Target.cs
and/Source/<project name>Editor.Target.cs
:
ExtraModuleNames.Add("SceneViewExtModule");
- In the
<project name>.uproject
file, add this to the module list
{
"Name": "SceneViewExtModule",
"Type": "Runtime",
"LoadingPhase": "PostConfigInit"
}
- Build the project
You should now be able to use the RainDropOperator
class directly within blueprints.
- Create an instance of
RainDropOperator
, call theCreateRainDropExtension()
function and assign the output render target.
This output render target will be referenced in materials as a mask.
- Export relevant data from a VFX and send it to a blueprint.
In our case, this is only the position of a raindrop
- Receive the data and store it in the
RainDropOperator
object's arrays.
- Reference the mask within materials to apply effects.