top of page

​Real-time Water Interaction

deep water.gif
Pool_Interaction.gif
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.
Assets List.png
Assets List2.png
Assets List2.png
Assets List2.png
Assets List3.png
Assets List4.png
Assets List5.png
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:
map.png
​Blueprint:
construction.png

​Construction Script

collision detection.png

​Collision Detection & Create RT

part 1.png

Get Player's Location and Speed & Draw Wave Source to RT

part 2.png

​RT Loop & Wave Simulation

part 3.png

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.
camera location.png
屏幕截图 2024-08-13 114411.png
屏幕截图 2024-08-13 114446.png

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.png
屏幕截图 2024-08-13 114411.png
sceneCapture.gif
deep water.gif
shallow water.gif

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_ForcePaint.png

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.
Equation.png

​Formula

M_WaveSim.png

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_Normal.png

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.png
M_Water2.png

M_Water

bottom of page