InfinityQuadOcean is my first Unity plugin. Due to my ongoing dedication to graphic rendering techniques for mobile games, I’ve noticed that the number of vertices significantly impacts the performance of mobile devices. Therefore, the primary goal here is to tackle the challenges of rendering an infinite ocean using a single Quad. This involves meeting basic requirements such as the Bidirectional Reflectance Distribution Function (BRDF) lighting, undulating surfaces on the water near the shore, and handling waves and foam.
The first challenge lies in simulating waves. For this, we primarily employ a method based on the flow of flat water normals. However, addressing the undulating motion near the shore is not as straightforward. To tackle this, we utilize the technique of depth edge flow. Those interested in more details can refer to my GitHub repository for this project.
Next is the noise module, where we use the overlay of second-order Value Noise to achieve a more undulating effect. Additionally, we enhance the disturbance to intensify the overall appearance, resulting in the following effect:
The relevant reference links for noise are as follows:
Moving on to the lighting effect, we calculate depth information to determine the relevant colors for diffuse and subsurface scattering (SSS). Subsequently, we integrate refraction processing, specular reflection, and foam color overlay. Finally, we compute the lighting based on the Fresnel effect, resulting in the following effect:
As for the foam details, there are currently three types of foam effects: Wave, Edge, and FX (Interactive water waves). For the FX part, we utilize the method of splatting particle weight maps. Ultimately, these are overlaid to generate the FoamMask, resulting in the following effect:
Furthermore, we’ve incorporated a caustic effect. Considering performance, we’ve chosen a straightforward approach using flowing textures, resulting in the following effect:
Now, I’ll address the issue related to the intersection between the distant view and the skybox. To resolve this, we implement a gradual fade-out based on the camera distance, smoothly blending into the background color to avoid the problem. The resulting effect is as follows:
Lastly, I’ve included the full showcase video. Pay special attention to the WireFrame display, where you can observe that the water surface is represented by only four points. This is the reason behind naming the plugin InifityQuadOcean. The video is available below:
沒有留言:
張貼留言