Performance improvement techniques in M3G games

Source: Internet
Author: User
Tags mathematical functions

Jsr184 M3G (mobile 3D graphicstm) is a concise 3D API set for mobile 3D applications. This set is supported by Motorola e680/e680i/a780. M3G is only an advanced Java interface. The underlying implementation in e680, e680i, and a780 is completed by the swerve 3D engine developed by superscape, it is a high-performance 3D engine for ARM/XScale processors.

The following are some technical skills to improve the performance of the j2_3d game. Remember, gamers are concerned with the final effect of the game, rather than how to achieve it.

Basic concepts in M3G

In M3G, The graphics3d rendering interface, world is the entire 3D scenario, and camera is the viewpoint. 3D objects are organized in a tree structure and defined by vertices, polygon, and Web. Transformation, such as moving, rotating, and proportional scaling, is achieved by multiplying the matrix.

Technical Skills

Limit the total number of polygon

For Motorola e680/e680i/a780, it is strongly recommended that the total number of polygon in a 3D scenario (including characters, objects, and environments) cannot exceed 1500.

Hybrid 2D and 3D objects

In a j2_3d game, a 2D Object consumes much less resources than a 3D object, but sometimes the effect looks very similar. It is a good idea to use 2D clips to replace some 3D objects in the game. For example, wooyun, snowflake, or billboard can easily be converted into 2D images. Sometimes, drawing directly on the background image can also reduce resource consumption.

Use texture to simulate Animation

In 3D games, some small objects need relatively complex animations to make them more realistic. For example, to draw a picture of a car running in a small-screen game, you need some animation effects to let players know that the car is actually running. However, it is not necessary and impractical to use real 3D models to simulate this action. One available way is to change the object texture to make it look like it is running.

Divide a large area into several parts

Swerve engines used in e680, e680i, and a780 support geometric elimination (or mesh elimination ). For example, some invisible faces of cubes in the viewport can be ignored. However, a network can be ignored only when all the networks are invisible.

More specifically, if you have an infinite area (such as a road) covered by a network and export it as a network object, if you divide this area into some subnet areas, the performance will be better, because you only need to calculate and render the subnet area in the viewport.

However, you need to find a balance point in dividing objects into multiple parts. The more parts, the more processing is required, because the scenario tree is larger. The fewer parts are divided, the larger objects are only visible, and cannot be excluded. Finding a balance point requires constant experimentation.

Use a hash table to replace mathematical functions

E680/e680i/a780 uses XScale MHz as their processor. In fact, like the CPU in most mobile phones, the CPU in the e680/e680i/a780 does not have a floating point processor. That is to say, the CPU has to use Integers to simulate floating points, which takes a lot of time.

Functions such as Division, sin, cos, and square root occupy a large amount of computing resources. In mobile 3D games, the precision requirements of functions are very low. Using a hash table (a function variable as a key) and a function result as a value instead of a real function will improve the performance of floating point operations.

Key)

Value)

Sin (0)

0

Sin (5 π/180)

0.087155743

Sin (10 π/180)

0.173648178

Sin (15 π/180)

0.258819045

...

...

Key)

Value)

Sin (0)

0

Sin (5 π/180)

0.087155743

Sin (10 π/180)

0.173648178

Sin (15 π/180)

0.258819045

...

...

Table 1: hash table simulation sin

Use self-emitting texture instead of Light Source

Figure 1 material and vertex color pipeline-images in JSR 184 document

The luminous indicator is based on the material. Light-or even direction-requires a lot of resources. If the object is illuminated, consider creating your texture instead.

Note:

In mobile phones, memory and computing resources are limited. Therefore, the key to a good j2_3d game is to strike a balance between the scenario, effect, and performance. To get this balance point, it is always necessary to conduct continuous tests on actual mobile phones.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.