1. Background technology
In the H5 environment, the performance consumption of drawing a large number of terrain preforms with the same grid is huge. Each single preform requires a DrawCall. Excessive drawing will lead to a decrease in execution efficiency, which is finally shown as a low frame rate and running lag.
2. Solutions
The core problem encountered above is that the communication time between CPU and GPU is too long when a large number of pieces of terrain are drawn. The game is stuck, in order to solve this problem. On the basis of Instanced Arrays of WebGL, the visual performance part and physical simulation part are separated through classification and batch processing management of terrain data, and the rendering of multiple terrain prefab is completed by invoking only one time using instantiation technology. This scheme can improve rendering efficiency, reduce performance consumption and support smooth operation on the mobile terminal in a large number of spliced terrain scenes.
To solve the above problems, the following solutions include:
1. Data editor for splicing terrain.
2. Batch management of terrain data rendering.
3. Physical separation of terrain data.
4. State change of terrain data.
3. Basic structure
4. Implementation
(1) data editor
The project uses Unity engine for production, using design-oriented EmptyGo architecture. Offers a wealth of editable plot features.
The exported data looks like:
(2) batch management of terrain data rendering
(3) terrain number splitting
Terrain representation design based on entity-component idea
5. Performance comparison
At 30 by 30
Common mode:
Instantiate render mode: