[DOWNLOAD RIPPLE EFFECT EXAMPLE PROJECT]
The Ripple Effect example uses Render Targets and Material Editors to create amazing ripple effects. In this doc we’ll explain how this complex effect works in a few steps. Let’s get started!
First, when you import the asset and set the Preview to Hand Palm Moving, you’ll see the ripple effect being activated.
Camera Arrangement
There 3 enabled cameras are set up to make the ripple effect together.
Color Camera produces a black and white depth texture which is used as the ‘source’ of where the ripple comes from.
Feedback Camera uses a material which has 2 inputs, depth texture (from the Color Camera) and its own Render Target, then it runs a series of calculations to produce the Feedback Render Target result.
You can see this approach in detail in the Ripple Feedback Material, where depth texture is added by its feedback texture (created by this material), and multiplied by custom damping number, then added a clear buffer setting.
Every new frame this material will render out a new material based on the result of feedback material from the last frame and its depth texture input.
You can view each camera’s render target with the Debug Camera.
The Feedback Render Target is used as an input texture into the Ripple material where the colors are being used to affect pixel position offsets to create the final ripple result.
This is a similar approach to a vertex shader where inputs are not manipulating colors of each pixel, but position of the pixels themselves. Learn more about vertex shader here.
Hand Color Materials
The Hand Color Materials creates a 'threshold' on when would ripple be originated in this project. This threshold can be altered by changing the Distance Threshold parameter on the Hand Distance Helper script attached to the Right and Left Distance Helper object in scene.
This will directly alter the threshold in the Hand Material, which will result in the material rendering and hiding effects based on hand distance to the camera.
Other Examples
Besides using 3D Hand Tracking, we can also use other references as input to trigger the ripple effect.
Try enabling other default examples or adding your own in the Color Camera!