evolvio4all / evolvio4JavaScript

MIT License
10 stars 2 forks source link

Apparently, rendering takes about 20-30ms #27

Closed Air1N closed 4 years ago

Air1N commented 5 years ago

Obviously this is not good.

ghost commented 5 years ago

Splitting the rendering up shows the tile rendering takes up almost all of it. There's 150x150 tiles which is 22,500 altogether. I tried it with 100x100 and it was a little bit faster, and with 50x50 was a lot faster but then it starts to get less interesting too.

I can think of 3 potential options so far:

  1. At the beginning, calculate rectangles that cover the land tiles with as little water as possible then only render those
  2. Try a webgl context instead of a 2d context - no idea about performance though
  3. Instead of tiles, have one background food level and multiple food areas that cover a larger area than a tile but are small enough to still be interesting. They could be circular or oval too, but that would involve more calculations to decide which area(s) each creature is over though
Air1N commented 5 years ago
  1. This seems like it would be nice, but the problem is that it will change things drastically and likely make things less interesting and accurate. I will try to come up with some other optimization ideas.

  2. I like the idea of WebGL, however it is needlessly complex and may not even provide much of a benefit on some systems. WebGL also requires shader use and, again, makes the whole process of drawing stuff needlessly complex.

  3. It's probably partially drawing and stroking 100+ circles. Also, the outline on the map may be extremely expensive (since each line is stroked individually). I think sorting the outline so that we can have them all connected and stroked at once would be pretty beneficial, however, this becomes complex with multiple islands — I still think it's doable.

ghost commented 5 years ago

Think it would help to separate out all the drawing so it's easier to tell how long each part is taking

Air1N commented 5 years ago

This is still an issue

Air1N commented 4 years ago

At this point rendering isn't really an issue. The simulation can run 50 creatures at about 40x speed, which is pretty good. Runs at about 20x speed with 80 creatures. Rendering hardly takes up enough time to matter since it isn't being run at these high speeds.