Families as a WebGL optimization technique? (Answered: NO)

Discussion and feedback on Construct 2

Post » Sun Oct 05, 2014 2:37 pm

Hi guys,

So I noticed that you can set effects and behaviors on families. Does this have a similar effect as mention on the performance tips page in regards to putting things with the same effects on the same layers?

3. Place objects using the same blend modes or effects on the same layer. For example, if you have a lot of objects using the Additive blend mode (commonly used for explosions, lasers and other effects), make sure all those objects are placed on their own layer. Also make sure they are created on that layer if the objects are spawned or created at runtime. Switching between effects can reduce performance, and doing this will ensures all objects using the same effect are drawn at the same time. This is described in more detail in the blog post How the Construct 2 WebGL renderer works.
~https://www.scirra.com/manual/134/performance-tips
Last edited by TheWyrm on Sun Oct 05, 2014 4:10 pm, edited 1 time in total.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Sun Oct 05, 2014 2:42 pm

No, it doesn't matter whether anything is in a family, it only matters what is drawn and in which order. For more information see this blog post on the WebGL renderer.
Scirra Founder
B
399
S
236
G
89
Posts: 24,543
Reputation: 195,430

Post » Sun Oct 05, 2014 4:01 pm

Ok thanks. I see how it's purely about Z order. Well at least families can make managing objects that use the same effect easier. I have quoted the relevant information below for others.

The key is to make sure wherever possible objects with the same texture, opacity and blend mode appear consecutively in the Z order. A good way to do this is simply to organise everything in to layers. In the previous example, if SpriteA and SpriteB are all on the same layer, they could easily end up in mixed Z order and end up with the long batch. However if SpriteA is only ever created on Layer 1, and SpriteB is only ever created on Layer 2, then they will always be together in Z order and the renderer can keep the same texture set while rendering each layer. Of course, this may affect the display of your game, animations might mean the objects are showing different textures anyway, and the batch can still be split up by changing blend mode or opacity. So this is not always easy to achieve.

Similarly, putting objects with the same blend mode on the same layer allows the batch to reduce the number of "set blend mode" commands. The Space Blaster example puts all objects with "additive" blend (various explosions, lasers etc.) on the same layer. This means that layer can always be rendered with a single "set blend mode", avoiding the possibility of having a batch full of commands alternating back and forth between "additive" and "normal". For the same reason, you might want to avoid giving every object a different opacity (e.g. assigning a random opacity to lots of objects).
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 15 guests