HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Fixed Next update] BUG: Lights Slow Frame Rate Even When Hidden  (Read 1543 times)

jcsmith562

  • General Accounts
  • *
  • Posts: 190
    • View Profile

We found what we believe is a new bug recently when implementing some client side lighting options. We introduced a Light Quantity setting and put in a system to hide or unhide lights on the client based on the time of day and your settings. Then we placed a lot of new lights in an area but having them be hidden except in the highest setting.

What we noticed was that while we did get a frame rate gain from switching between Minimal and Maximum light settings (Minimal rendering only a few lights, and Maximum rendering about 60) in our city, the frame rate was always significantly lower if the lights didn't exist at all. By manually hiding every light in the scene through the Assets Panel the frame rate was 45 frames per second with dynamic shadows on, even though those lights weren't being rendered. Deleting all of those hidden lights the frame rate lept to 60 frames per second.

So it appears that even if lights are hidden they are being calculated by the engine.
« Last Edit: Mar 11, 14, 12:22:17 PM by HE-Cooper »
Logged

jcsmith562

  • General Accounts
  • *
  • Posts: 190
    • View Profile
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #1 on: Nov 14, 13, 05:59:37 AM »

We did a bit of investigation on this today and have some information which may help pinpoint the problem. We began experimenting with settings because in our tests the other day we had noticed that something made the frame root shoot up to the same numbers as when all lights were deleted. We figured out today what it was.

If you move all of the lights into a non-visible room then they will not be drawn at all. That doesn't do any good for using any client side manipulation however, as you won't have the ability to move them back and forth on the client. But it may help pinpoint the issue.
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #2 on: Nov 14, 13, 07:53:27 AM »

Question though, the engine server side has to still do those calculations, cause as you point out, each client could have a different hidden or not hidden setting. The server though is going to run the same calculations each time, from there it's probably still sending the light / shadow information to the client. It's then the client that just chooses to not render the data it was sent.

Would probably have to figure a way to stop that data replication of the light data from the server before it reached the client. Even if you are client side saying don't bother rendering, you still getting the data sent to your GPU that then says don't draw this.

Which would also explain why you are seeing performance gains from min vs max. Cause the GPU isn't having to actually do any of the draws. It still however is getting the data.

Now in regards to hiding the lights on the server side with the assets panel, that is left for some debate.

Also did you test this with the player client?
CAsue heroblade runs tons of data gathering, info tracking, etc that the player client doesn't. Could just be it's something Heroblade is tracking for editor reasons / scene analysis that wouldn't affect client performance.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #3 on: Nov 14, 13, 09:59:15 AM »

@Keeper

I doubt that is it.  As I understand, rendering and graphics processing is all done client side; the server does not have a graphical representation of the world, but only a simulated one.  So it would not have anything to do with lighting calculations.

I am curious as to whether the lag is due to the extra stuff involved in using the HeroBlade vs the player client.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #4 on: Nov 14, 13, 12:41:58 PM »

but since lights create shadows which are reflective of the physics system, wouldn't that make them part of the physics engine's calculations?

Since for example the wind calculation against a tree, moves the tree, which changes the shadows, which rely on light data, wouldn't it be possible the light data calculations end up being part of the server data package that gets sent to the 

But I'm not sure and I've asked in the past about how the light sources affect prim counts, cause the wiki states any object hit by a light source, will double it's prim count or something to that effect, and my question back was if it was the whole object or just the prims touched by the light.

So there is a bit of vagueness on how lights are handled rendering wise.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

jcsmith562

  • General Accounts
  • *
  • Posts: 190
    • View Profile
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #5 on: Nov 15, 13, 03:19:07 AM »

I would expect all the rendering to happen on the client, but as you mentioned I'm really not sure how things work under the hood here. We also had a system in place which would handle the hiding and unhiding of lights on the server for day/night changes, but it wasn't helpful for customizing the number of lights in a scene.

We tested this in both the player client and in Hero Blade with similar results. Without taking a look at packets, my interpretation of how things would work here (and it could be completely off) would bet that the server is sending you information on what is in currently visible rooms. I reach that assumption because when your on the player client you seem to get less harsh load hits when areas are roomed, but you have some smaller load hits when they come into view.

Moving the lights into a separate room that you can't see would basically be the same in that case as the light not existing at all. A hidden light is still passed to the clients however, as they are able to unhide them. What I did in this case was start all lights as hidden to take advantage of that (so they would default to not showing across seams). Some rendering information may be getting passed from the server, but would all be interpreted on the client. I'd guess the client probably feeds itself based on the simple data the server sent to it.

An educated (but very likely wrong) guess here would be that most likely when it passes the shadows for rendering it simply is ignoring the the fact that they are hidden and performing some level of calculations on them, or factoring them into the scenegraph when they don't need to be. There is some gain from hiding and unhiding lights here, but there is a far larger gain from simply deleting all the lights from the scene, as opposed to hiding them all. So most likely the shadow data that gets passed to the shadow shaders probably is just feeding some data that it doesn't need to.

This of course is just a guess.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #6 on: Nov 15, 13, 07:38:15 AM »

I just had a thought.  I am not sure if this is possible, but maybe the lights can be used with the spatial awareness system (assuming these are positional lights rather than directional).  If so, then only the lights within a character's awareness will be replicated to their client, and when leaving awareness they are removed from the client.

Something to try out, anyways.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: BUG: Lights Slow Frame Rate Even When Hidden
« Reply #7 on: Feb 14, 14, 01:14:54 PM »

Fixed in the next update
Logged