精選文章

SmallBurger Asset Home

  SmallBurger

2025年5月12日 星期一

An Overview of FFTOcean

 


FFTOcean is one of the most complex challenges I’ve faced in my game development career. This project involves multiple technical aspects, including ocean simulation, Fourier transform algorithms, projected grids, rendering pipeline planning, and water lighting simulation. In particular, improper handling of the MRT texture rendering and RenderPass operation flow can lead to performance issues. The main goal of this project is to ensure smooth operation on mobile platforms.


From left to right, and top to bottom, the first four images are displacement maps, followed by two slope maps, and the final one is a Jacobian foam map. The entire process uses Fourier transform to calculate the RenderTexture results.

To support ScreenSpaceDecals, it’s necessary to generate depth textures for the ocean. Considering that this project will run on platforms supporting OpenGLES 3.0 and above, we adopted the CopyDepthPass approach. However, since this method causes issues when running in the Editor (which uses its own independent RenderTexture), we implemented AppendDepthPass to address the problem.

Another noteworthy aspect is the integration of planar reflection textures in the distance. The rendering result transitions to the reflection based on the camera’s distance, achieving a seamless blend with the sky at far distances and avoiding visible edge lines.


In the image above, there is no visible edge line where the ocean surface meets the skybox.

As for the lighting effects, standard BRDF is used with no particular differences. However, it’s worth mentioning that sub-surface scattering is simulated here, resulting in a gem-like green tint visible on the water surface.


Additionally, a special mode called Infinity Quad Mode is provided. This mode uses only four vertices to render the entire infinite water body. It can be beneficial for hardware sensitive to vertex count or scenes with excessive triangle numbers, potentially improving performance.


Throughout the implementation process, Ceto and CRest provided a wealth of reference material. You can find their GitHub links below:

Relevant videos are as follows:


Actual performance on mobile devices:



You can find it here:

沒有留言:

張貼留言