Ways to speed up GLSL in game engine?

Hello all,

are there any good ways of speed GLSL mode in the Blender Game Engine? I have turned of shadows for my lamps and that made it much faster, however it is still a bit laggy. My computer is a moderate one.

Thanks!

-Use lambert and phong shading for materials, I’ve heard before that these shading models are the fastest.

-Split up large highpoly objects (such as the level geometry), this will result in less geometry being rendered at once due to frustum culling.

-Make sure that the backface culling is only turned off for materials that need it like billboards and windows.

-If you have large blocking objects in your scene, enable occlusion culling and start placing occluders in your scene, all objects behind the occluders will not be rendered.

-Cut out unnecessary polygons by dissolving edge loops and other edges, the BGE will not care if a static object has Ngons in edit mode and there’s the chance that a high-poly object has polygons or loops contributing almost nothing to the detail

-Use the decimation modifier to create LOD levels for certain objects, the modifier now preserves UV data so it’s now a lot easier to do.

You could also try getting a better PC.
It’s mostly lagging because of the graphics card and Processor, try getting a Nvidia GT430 graphics card and a 4 core processor and you’re all set :wink:

I would always choose optimizing over “just getting a better hardware” though. If you optimize things well, you can keep pushing graphics upwards anyway, no matter how good hardware you have.

Bake Textures and get rid of all the light sources, it looks much better and works faster.

These all seem like good general advice but they are skipping the most important part of optimizing.

  1. Profile the code and see what is causing the slow down.
  2. Optimize the biggest contributor first.
  3. Repeat as needed.

Have you actually measured the code to see if it is your GLSL shaders causing problems? Have you turned on the profiler and seen that most of your time is spent in the rasterizer?

Remember to have all your files in the same folder as your blend. Random trick, but I was lagging like crazy on my game today until I packed everything into one file.

The best and easy way to speed up GLSL is to reduce the dimension of the textures to the minimum,for example for little objects make the texture dimension be 200X200 and for bigger objects make the texture dimension be 450 or 500X500

Smaller Images run faster = right.
The Numbers you mentioned… Duuude!! ô_ô

Always use Numbers in the Power of 2: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768… okay, you probably shouldn’t get into those high-numbered Areas… but always use such Values, because the Graphics Card can read them faster.

True. also recommended to split complex objects to several different objects. and to split large surface textures to different image files. in general maximum size for an image file should be no more then 1024x1024, if you can get away with maximum 512x512 go for it.

What about using dds?

Thanks for the tip, I used to join my level meshes together once I finish placing them,… so it’s faster when they’re separate then :slight_smile:

BTW are the areas outside the camera view makes it slow too?

Keep in mind that the game engine can process separate data blocks (objects, external files, etc.) at the same time, so if you have many smaller elements in your scene it will be rendered much faster then one big complex element.

How could I animate shadows if they are baked?

That helps, however if still feels laggy if I add a Normal Map

Well, you cannot. But why would you want to animate shadows? unless you are using moving light sources. in that case, baking textures will not be a good idea, because it’s not just the shadows, the objects shading should be animated as well.

In that case, You might be asking too much of your moderate PC. Game engines are quite demanding and there is a limit to how much you can optimize your scene.

Power of two textures are not as important … Modern GPU have no problem with them at all…

#My tips.
•Use DDS texture ,because they can stay compressed in the memory (less VRAM usage)
•When you can ,disable specularity on the lamps.
•Disable Color Management .
•Do not overuse objects with Alpha textures.
•For now it is best not to use more than 2 samples for 2D filters in general.
•Make sure small objects with lots pos polygons are merged ,it is easier for the GPU.
•Large objects with lots of polygons must be split ,otherwise the camera view culling won’t help.
•Use an LOD for objects. Far = no specular/normal maps ,low polygons.
•Now you Realtime shadows can have a lower resolution ,rather than 512.
•Make sure to disable shadow casting in materials for objects that don’t need to cast shadows.
Hope everyone found them useful.