Allow changing the maximum renderable elements in the scene.
Created by: haasanen
Fixes #30597
The problem:
Setting a value in the project settings for: rendering/limits/rendering/max_renderable_elements
does not lift the maximum number of elements that can be drawn. For example when loading 50,000 objects to the scene the total number of objects is loaded fine, but only a fixed number is drawn (see screenshot below). This prevents rendering/showing large numbers of e.g. people in a city or a building. Altering the max_renderable_elements value to 1,000,000 makes no difference.
There is a hard-coded value MAX_INSTANCE_CULL
in visual_server_scene.h
file that cannot be edited through the editor or through code at runtime. It is used to allocate a fixed size array for storing drawable elements. It is related to the DEFAULT_MAX_ELEMENTS
value that was exposed in a previous pull request: #1339. For large scenes it is necessary to increase both values.
The solution:
This commit exposes (and renames) the MAX_INSTANCE_CULL
, DEFAULT_MAX_LIGHTS_CULLED
and DEFAULT_MAX_REFLECTION_PROBES_CULLED
to match the previously exposed and related values DEFAULT_MAX_ELEMENTS
, DEFAULT_MAX_LIGHTS
and DEFAULT_MAX_REFLECTIONS
.
These are the enum values in visual_server_scene.h
:
MAX_INSTANCE_CULL = 65536
MAX_LIGHTS_CULLED = 4096
MAX_REFLECTION_PROBES_CULLED = 4096
MAX_ROOM_CULL = 32
MAX_EXTERIOR_PORTALS = 128
The last two are never used (now removed) and the first three could not be previously edited through the editor or through code.
Note: the tooltip texts for the ProjectSettings.xml
may need rewording. The tooltips from the related values were re-used with an extra explanation.
TL;DR:
Allow changing some hard-coded limits (values) through the editor. No default values have been changed. No difference to anyone who can already work within the hard limits. However, anyone who needs to render large numbers of objects needs this patch (we are using this in-house).