MinicraftPlus / minicraft-plus-revived

Minicraft+, an extension of Notch's original minicraft project, with tons more features.
GNU General Public License v3.0
456 stars 92 forks source link

Minimally optimize light rendering #675

Closed BenCheung0422 closed 1 month ago

BenCheung0422 commented 2 months ago

This fixes #672 Currently, when there are enough amount of light sources, the mass amount of "lighting circles" can slow down rendering as each circle is rendered by gradients, handled by Java2D. This turn the light sources neighbouring other light sources in all 8 directions into a square of a tile (16-by-16 pixels) instead of a circle. This is done because when there are "circles" eventually overlapping the central circle, there is no difference when it is rendered only on itself. 16-by-16 square is chosen because it is intended to handle tile light sources. This cannot completely resolve the problem, but should be enough (from around 10 FPS raised up to over 50 on my end) to resolve the critical performance issue by light rendering. The resultant lighting behavior should have kept the same by this change. Different lighting mechanism may be used in the future.