[Recommended blog post] Real-time rendering of seawater on Unity3D mobile terminal

[Recommended blog post] Real-time rendering of seawater on Unity3D mobile terminal

This blog post is from 51CTO blogger jxw167. If you have any questions, please go to the blogger's page for interactive discussion!

Blog address: http://jxwgame.blog..com/943299/1597183


Real-time simulation of seawater has always been a hot topic, and the simulation of seawater on mobile terminals is even more popular. There have been a lot of studies in this area, but the results are not very satisfactory. Here we introduce an algorithm for real-time drawing on mobile terminals, which meets the requirements of mobile terminal operation and can display highlights, reflections, and refraction effects on the sea surface, rolling waves and foam effects on the sea, as well as the upside-down effect of objects on the sea with the waves, which simulates the formation of waves more realistically.

The generation of waves on mobile devices is particularly limited. Here, we use grid blocks to achieve infinite terrain. GPU rendering also needs to be able to run on mobile devices. Here is a picture of the effect:

Reflection, refraction, and sea surface lighting are all available, and the foam effect is also achieved.

Next, we will analyze how it is achieved.

First we need to customize the generated grid blocks, then splice them together and generate a height map. The grid is as shown below.

The code looks like this:

Next, you need to render the sea surface highlights as shown below:

The code looks like this:

Since the rendering of reflection and refraction effects involves Shader programming, we implement the code as follows:

The following is the rolling of the waves and the foam effect:

The implementation code is as follows:

The above code is implemented using the Fourier algorithm, and its direction is set through enumeration.

Its rendering Shader is as follows:

The above realizes the real-time simulation of seawater on the mobile terminal. Finally, the effect diagram running on the mobile phone is shown below:

<<:  10 tech products that became popular before they were released in 2015

>>:  2015: A New Era of Mobile Payment

Recommend

A comprehensive guide to the event planning process!

Although event planning is very important, when w...

EU cracks down on Google: Who is jealous and resentful behind the scenes?

I thought the EU's proposal to split Google&#...

Summary of APP promotion terms, you may only know 10%

Every industry has its own professional terminolo...

Fission Methodology | Free Bait: Teach you how to swipe the screen like NetEase?

While I was busy this week, I was thinking about ...

Teacher Charlie's "Screenwriter Incubation Camp"

Charlie's "Screenwriter Incubation Camp&...

How do overseas Chinese restaurants obtain WeChat mini-program authentication?

Q: How do overseas Chinese restaurants authentica...

700 paying users and 1,000 UGC operation cases in 3 months, how did they do it?

I have seen many products that were poorly made. ...

Why are human organs asymmetrical? Cell chirality may provide the answer

Why do we look almost symmetrical on both sides, ...