Blending modes performance

  • Hello! Sorry my English, but I hope you will understand me right.

    While optimizing project I noticed some interesting (or strange) behavior of WebGL Blending mode effects.

    I have a layer with lights which uses WebGL Blend mode effect (multiply), and while testing scene on iPad Air I have about 34 fps (If I change it to screen or overlay, I have the same about 34 fps, even in almost empty scene).

    But, If I delete this WebGL blending effect and set this layer blend mode to Additive - I will have 60 fps.

    So, I think iPad Air doesn't have good WebGl acceleration and maybe it emulates it or something, but! In terms of "screen arithmetic" Addition and Multiply blend mode - is almost identical by calculation required...

    So, why in not WebGL layer blend modes (thats perform faster on this device) we don't have all other blending modes?

    Can I somehow achieve performance of non-WebGL Additive blend mode, while using WebGL blend modes?

    Yes on iPhone 8 on which I also test it - I have stable 60 fps and no problems at all, but I think it is will be very good to run smooth on not so new devices...

    Thank you!

    P.S.: Same on C3 and C2.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There's a difference between blending modes, and effects.

    Additive is a blending mode, and multiply is a shader.

  • There's a difference between blending modes, and effects.

    Additive is a blending mode, and multiply is a shader.

    Multiply is blending mode also, just working in C2 through a WebGL shader...

    So the question is still open - is there any way to get multiply (or in my case custom blending algorithm based on multiply fx), with performance of existing Additive blend mode (for better performance on older devices like iPad Air). Maybe by creating an extension for C2...?

  • Your answer is no. The html5 blend modes are far less complicated than shaders that require a lot of sampling.

    The best you could do is try to find an fx that's less expensive, but Ios compatibility is spotty at best.

  • newt is right - despite the fact they appear to do similar things (background blending with a formula), blend modes are implemented completely differently to shader effects. A blend mode is a simple switch between different blends in the GPU's fixed function pipeline, but there's a limited set to choose between. A shader is a small, custom-written program that is executed by the GPU on the programmable pipeline, and can do more or less anything. Also due to the way GPUs work we have to take a slower path for programmable background-blending effects which includes an additional surface copy at the end. Additive is one of the few fixed function blends, but for everything else (like multiply) we use programmable shaders.

    So yes, there's a performance difference, but it comes down to the architecture of the GPU hardware. We can't program around that.

  • newt

    Ashley

    big thank you guys for clarifying this moment of how it work "inside".

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)