精選文章

SmallBurger Asset Home

  SmallBurger

2023年12月16日 星期六

InifityQuadOcean(My first unity asset package)

InifityQuadOcean is my first Unity plugin. Due to my continuous dedication to graphic rendering techniques for mobile games, I have observed that the number of vertices significantly affects the performance of mobile devices. Therefore, the primary goal here is to address the challenges of rendering an infinite ocean using a single Quad. This involves meeting basic requirements such as Bidirectional Reflectance Distribution Function (BRDF) lighting, undulating surfaces on the water near the shore, and handling waves and foam.

The relevant plugin links are as follows:InifityQuadOcean

The first challenge lies in simulating waves. Here, we primarily use a method based on the flow of flat water normals. However, dealing with the undulating motion near the shore is not as straightforward. To address this, we use the technique of dynamic pull depth texture inverse world position. Those interested in further details can refer to my GitHub repository for this project.DynamicPullDepthMap


Next is the noise module, where we employ the overlay of second-order Value Noise to achieve a more undulating effect. Additionally, we intensify the disturbance to enhance the overall appearance, resulting in the following effect:

The relevant reference links for noise are as follows: 1D, 2D & 3D Value Noise

Next is the lighting effect, where we calculate the depth based on the depth information to determine the relevant colors for diffuse and subsurface scattering (SSS). We then overlay the refraction processing, specular reflection, and foam color. Finally, we calculate the lighting based on the Fresnel effect, resulting in the following effect:


Regarding the details of foam, there are currently three types of foam effects: Wave, Edge, and FX (Interactive water waves). For the FX part, we employ the method of splatting particle weight maps. Finally, these are overlaid to create the FoamMask, resulting in the following effect:

In addition, we have added a caustic effect. For performance considerations, we have opted for a simple flowing texture approach, resulting in the following effect:


Here, I'll explain the issue regarding the intersection between the distant view and the skybox. To address this, we gradually fade out based on the camera distance, blending into the background color to avoid the problem. The effect is as follows:


Finally, I've included the full showcase video. Please pay special attention to the WireFrame display, where you can see that the water surface is represented by only four points. This is why the plugin is called InifityQuadOcean. The video is provided below:



沒有留言:

張貼留言