top of page
Real-time Water Interaction
Platform: PC
Duration: 4 Weeks
Tools: Unreal Engine 5, Blueprints, Material Editor
- Solo Project
Assets List:
I primarily used one blueprint, five materials, and five render targets to achieve the effect.
Render Targets:
RT01, RT02, RT03:
the main render targets, continuously looping each frame.
RT_Normal:
the render target used for normal mapping.
the render target used for scene capture.
RT_SceneCapture:
Materials:
M_Water:
the material for the water surface itself.
draws the wave sources based on the position from RT_SceneCapture, rendering them onto the three RTs.
M_SceneCapture:
M_WaveSim:
simulates the generation of water waves and renders them onto the three RTs.
M_NormalSim:
calculates the normals of water waves and renders them onto RT_Normal.
M_DepthCapture:
the post-processing material attached to the camera.
Logic:
Blueprint:
Construction Script
Collision Detection & Create RT
Get Player's Location and Speed & Draw Wave Source to RT
RT Loop & Wave Simulation
Draw Waves on Canvas & Calculate Normal
Scene Capture:
I placed the scene capture camera a few centimeters below the water surface, facing downward, and assigned RT_SceneCapture to it.
SceneCapture RT
Camera Location
I Attached the DepthCapture material to the camera as a post-processing material. This would capture the closest point in the camera's line of sight (i.e., the player's position), thus obtaining the actual shape of where the player interacted with the water surface.
M_DepthCapture
Deep Water Wave
Player's Shape on RT_SceneCapture
The shape of the water waves varies depending on where the player interacts with the water surface, so different water depths will generate different wave patterns.
Shallow Water Wave
Materials:
M_SceneCapture: The captureLocation parameter of this material is set to the player's position, causing the UV coordinates of RT_SceneCapture to shift accordingly. The forceIntensity parameter is set to the player's speed, affecting the intensity of the wave source (i.e., different speeds generate different wave shapes). Finally, this material is continuously rendered onto the current frame's RT to draw the wave sources.
M_SceneCapture
M_WaveSim: This material simulates water wave generation, and it is updated frame by frame under the control of blueprint. According to a simplified water wave simulation formula, the amplitude of each pixel in the current frame is calculated by taking half of the sum of the amplitudes of the four neighboring pixels (up, down, left, and right) from the previous frame, subtracting the amplitude of the same pixel in the previous frame, and then multiplying by an energy decay factor. This process determines the energy of the pixel in the current frame.
Formula
M_WaveSim
M_NormalSim: This material is used to calculate the normals of the water waves. It subtracts pairs of the four neighboring pixels (up, down, left, and right), takes the cross product of the resulting two vectors to obtain the normal, and then renders it to RT_Normal.
M_NormalSim
M_Water: This is the material applied to the water surface, used to display the final effect. Its Normal uses the values from RT_Normal, while its World Position Offset uses the values from the current frame's RT.
M_Water
bottom of page