The impact of the Shadow Light plugin and the behavior of Shadow Caster on the CPU on mobile devices

  • Good afternoon Ashley, I am currently testing the Shadow Light plugin and the behavior of Shadow Caster. I have a question about the effect on the processor. I'm using penumbra mode, and I've noticed that when you increase the layout size (50000x50000) and add a large number of objects with shadow caster behavior, the CPU load increases.

    Explain in more detail how this plugin works. As I understand it, the plugin calculates shadows for all objects in the layout at once, even for those objects that are already in the shadow?

    If this is the case, it may make sense to review the work of this plugin and make a calculation of shadows from a certain number of objects that are outside the viewport, just as it is implemented with the calculation of collisions in Construct 3 (collision cells). Or add the option to manually set the distance in the plugin at which the condition for casting shadows will be triggered.

    In the last screenshot, I disabled Penumbra mode for clarity.

    I think this will help us save CPU on mobile devices.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The easiest way to help is to share a minimal project that demonstrates what you're talking about, and then I can open it and take a look.

  • Ashley I made an example for you. Which shows that the CPU is spent on calculating shadows from objects that are already in the shadow and far beyond the viewport.

    drive.google.com/open

  • If an object is outside of the expected culling area, should it be able to cast shadows into the viewing area?

  • That's right, it's difficult to optimise because if the shadow light was actually in the bottom-right corner of the layout while the view is in the top-left, it might still be casting shadows in to the viewport, so it has to look over a very large area.

  • I understand you Ashley. But if you look at the examples that I made, you can see that the size of the layout and the length of the shadow does not greatly affect the CPU consumption.

    The CPU is affected by the number of ShadowCaster objects. the ShadowLight plugin continues to calculate shadows for objects that are already in the shadow. Please note that I am now talking about Penumbra mode (Light height=0). To optimize, we need to remove the shadow calculation for objects that are in the shadow.

    I understand that this may be a difficult task for you, but 2 years ago I could not even dream of the weights that Construct 3 can now easily do with its large optimization. The community needs to optimize ShadowLight for using shadows on mobile devices.

  • AshleyI'll leave it here. If you have time, read it.

    simblob.blogspot.com/2012/07/2d-visibility.html

  • To optimize, we need to remove the shadow calculation for objects that are in the shadow.

    It's possible that will actually be slower, since it is potentially a lot of extra work to do raycasting and intersection-with-visibility tests, compared to ignoring that and just processing all the objects.

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