How to create sea water effect in Reality Composer Pro?

I have no clue at all. Any suggestions are welcome. Thank you.

Hi @jamesic

You can create a water effect in Reality Composer Pro by offsetting the vertices of a plane mesh with noise in Shader Graph. Here's a rough outline of how you might go about doing this:

  1. Create a new Shader Graph Material.
  2. Add a noise node, such as Noise2D, WorleyNoise2D, or even FractalNoise3D.
  3. Take a TextureCoordinates node and add Time to it with an Add node. Consider multiplying the output of TextureCoordinates by a constant float value before you add Time to alter the scale of the waves.
  4. Plug the output of the previous step (i.e. scaled texture coordinates that move over time) into the noise node of your choosing.
  5. Take the output of the noise node and plug it into the y input of a Combine3 node. This will give you a vector offset along the y-axis that varies over time with your noise function.
  6. Plug the output of the Combine3 node into the Model Position Offset input of a GeometryModifier node.
  7. Plug the output of the GeometryModifier node into the Custom Geometry Modifier input of the Outputs node.

Set the Shader Graph preview window to preview your shader on a plane, and you should see the vertices of the plane moving up and down over time, somewhat resembling waves. In order to really sell this effect, you'll likely want to use multiple frequencies or kinds of noise layered on top of each other. You can also use layered sine waves instead of noise to create more ocean-like waves (a search for "Gerstner waves" should provide some results in that direction).

There are a couple caveats that come with this approach. For one, the plane mesh you apply this Shader Graph Material to needs to have a high density of vertices since the shader works by offsetting the vertices of the mesh to form the waves. Additionally, if you don't recompute the normal directions of the vertices after offsetting their positions the lighting may look off, so it's a good idea to estimate the new vertex normals in the Shader Graph by calculating the change in the noise function in the x and y directions for each vertex.

Another option would be to use the new LowLevelMesh API, which enables you to update the vertices of a mesh with the GPU by dispatching custom Metal compute shaders. This approach would give you full control over the water simulation, and would even allow you to create water that responds to a person's interactions with it. If you are interested in sample code demonstrating an approach such as this one, please file a feedback request at https://feedbackassistant.apple.com and post the FB number here so I can take a look or forward it to the relevant engineers. Thanks!

Thanks for your reply. This information is very useful. However, I don't have much experience, but I will try my best to implement it.

I have also filed a feedback request at https://feedbackassistant.apple.com/feedback/15404407

It would be great if there are some sample code to have a look. Thanks again.

How to create sea water effect in Reality Composer Pro?
 
 
Q