Water Shaders & Mobile Compatibility - Project Viz - Dev Blog

Project Viz is a bit tricky as not only should everything look the best it can, but it needs to run smoothly and be compatible with mobile and tablet devices. This has not been more difficult than on the water shader.

 Fig 1: Mobile Compatible Open Ocean World

Fig 1: Mobile Compatible Open Ocean World

Typically, a water shader might make use of planar reflections coupled with tesselation to give a nice moving water effect. However for mobile this simply is not an option, working within the limitations of mobile can be difficult at times but nonetheless, perseverance pays off.

 Fig 2: Water Shader UE4 Blueprint

Fig 2: Water Shader UE4 Blueprint

The final result is fairly small in size, this is to reduce the total number of instructions for the device to compute. We make use of cheaper alternatives to Fresnel effects and tiling.

It is also important to note that on a mobile device the number of texture samples is much lower than what you might find on a desktop machine, so it was important to make multiple uses of the textures wherever possible. For example, the roughness channel is entirely calculated from the normal texture and fresnel effects, removing the need for a dedicated texture channel.

 Fig 3: Water Shader Colour, Roughness & Normal Map

Fig 3: Water Shader Colour, Roughness & Normal Map

The bulk of the work takes place above in the colour, roughness and normal calculations, this is what determines the colour of the water as well as the surface reflections and the height of the waves.

The secondary work takes place in the vertex tiling section of the shader, this efficiently tiles the textures using the meshes vertices instead of the pixels, massively improving the shaders performance across all platforms.

 Fig4: Water Shader Vertex Tiling

Fig4: Water Shader Vertex Tiling

Overall we are happy with the final result and we have discovered a large amount of limitations and information on mobile compatibility that we can take forward within the remainder of the project and ofcourse any techniques developed during the course of this project can be used in future releases of Project Viz.