Performance tips
A) Speed Database Technology. The Speed
Technology can improve performance significantly. Sometimes 10 times or more !
Version6 offers a
much improved and more reliable technology.
B) Group Bitmaps. Use the group_bitmaps utility. Version6 can greatly benefit from this utility. Group most of the bitmaps into groups of 1024x1024 or 256x256.
C) Check 3DSTATE log frequently. This file is created automatically in the directory
of the executable. It contains various statistics.
The two most important figures are the average time of 3DSTATE_engine_render() and
the program cycle time. Make sure that at least 85% of your program time is spent
by 3DSTATE_engine_render(). The program cycle time covers the rendering time
plus the time spent outside the 3D engine. The closest to each other these figures are, the better.
D) Disabling the cursor. When rendering on a window, call ShowCursor(FALSE).
It will double the speed !!!
E) Using atmospheric effects (fog, night, or day light). Using heavy fog can
dramatically increase the speed. This is because there is less visibility.
The engine can ignore all the far objects that are not seen. To set the color and the
intensity of the fog, use these functions: 3DSTATE_engine_set_atmospheric_effect_intensity() ,
3DSTATE_engine_set_atmospheric_effect().
Setting the atmospheric color to black (RGB 0,0,0) will simulate night time.
Setting it to a bright color will simulate a sunny day.
Grey colors will simulate fog.
Use blue to create the illusion of being under the water.
F) Don't use Editor mode. If speed is
important then use VIEWER_MODE (the default). Use EDITOR_MODE only if you are
writing a 3D graphic editor (for a graphic editor you don't need a high Frames
Per Second rate). In version 6 of the engine Viewer mode is much more flexible
and can do almost every thing that is done in EDITOR_MODE
G) Disabling fog. If you decided not to use fog then it is a good idea to make sure
that it is switched off entirely. Do it by calling 3DSTATE_engine_set_atmospheric_effect(0)
with a zero value. A very weak atmospheric effect could slow the engine down by 20%.
On the other hand, a very heavy fog in a big world can double and triple the speed.
Make various tests and check 3dstate.log to assess the benefit of each change.
Please note that disabling fog will increase performance only from version 5.0
and above.
H) Use LOD. For example when having a car racing game make about 4-5 different
models for each car. Only the one or two cars that are closest to the camera should
be using highest polygon count model.
I) Dynamic objects take more time to render than static polygons.
J) engine_set_bsp_precision().
Keep track of the number of polygons that are added to the world in Viewer mode.
When the world is loaded in Viewer Mode (the default) the engine needs
to build a BSP data structure. During this process many polygons are cut into
smaller pieces. For example, if a tree is stuck into the ground in a way that the
ground intersects one of the polygons of the tree then this polygon or the polygon
of the ground will be cut into two pieces, adding to the number of total polygons
in the world. To avoid that, it is recommended that polygons in your world should not
intersect with each other. Nevertheless, even if no polygon intersects others, the engine
might need to split some of the polygons. In the 3DSTATE log file it says how many
polygons were added. Keep track of this number. If it is more than 10 percent of the
total number of polygons then you should discover the cause for this and fix your world
accordingly.
If you can't decrease the number of add polygons then use the new function (Version 5.0):
3DSTATE_engine_set_bsp_precision(). (For more details, see the function's help).
K) camera_set_distance_from_eye(). In some cases increasing the number can improve the rendering speed dramatically.
For more details see the 3DSTATE.H
L) 3DSTATE.h. If you are not sure about the specific operation of a certain 3DSTATE function
then you can also check the help for this function written in the 3DSTATE.h file.
M) STATE_engine_get_computer_speed_factor().
As from version 6, it is recommended to use this function in order to keep the same speed all the time even if the frames per second rate changes.
We recommend on doing the following:
A) | After loading the world call STATE_object_set_speed_units(UNITS_PER_RENDER) |
B) | In order to have your program run the same on all computers and have the same speed in all parts of your world do
factor=STATE_engine_get_computer_speed_factor() in every render cycle. Factor all your objects
speed like that new_speed=original_speed*factor; |
Going according to our recommendation will give you the following benefits:
1) Your program will be faster.
2) The object will move smoother.
3) Your program will move at the same speed in all parts of your world and in all computers.
4) Calling STATE_object_cancel_collision_test_for_chase_physics() will have no undesired effect on the speed units.
N) STATE_object_cancel_collision_test_for_chase_physics(). When
using CHASE_PHYSICS (which is very useful) you should cancel the automatic
collision detection if you are not making use of it. Sometimes there is no need
to have a full collision detection and decision making can be based on the
location of the object.
Important !
Canceling the collision detection also changes the speed units to
UNITS_PER_RENDER (this is a design bug in the engine that wasn't fix in order to maintain backwards compatibility).
We recommend that you call STATE_object_set_speed_units(UNITS_PER_RENDER) after
loading your world and use STATE_engine_get_computer_speed_factor() to make
your program works at the same speed on all times and all computers.
See the "STATE_engine_get_computer_speed_factor()" tip above.
O) Light. When lighting objects you will get the best results when the object has bright colors.
(This tip is about achieving good graphics quality. It has no effect on the
rendering speed).
The 3DSTATE Team.