|
@@ -35,6 +35,7 @@
|
|
|
#include "core/io/resource_loader.h"
|
|
|
#include "core/math/math_defs.h"
|
|
|
#include "renderer_compositor_rd.h"
|
|
|
+#include "servers/rendering/renderer_rd/storage_rd/light_storage.h"
|
|
|
#include "servers/rendering/renderer_rd/storage_rd/mesh_storage.h"
|
|
|
#include "servers/rendering/renderer_rd/storage_rd/texture_storage.h"
|
|
|
#include "servers/rendering/rendering_server_globals.h"
|
|
@@ -1926,520 +1927,7 @@ void RendererStorageRD::visibility_notifier_call(RID p_notifier, bool p_enter, b
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* LIGHT */
|
|
|
-
|
|
|
-void RendererStorageRD::_light_initialize(RID p_light, RS::LightType p_type) {
|
|
|
- Light light;
|
|
|
- light.type = p_type;
|
|
|
-
|
|
|
- light.param[RS::LIGHT_PARAM_ENERGY] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5;
|
|
|
- light.param[RS::LIGHT_PARAM_RANGE] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SIZE] = 0.0;
|
|
|
- light.param[RS::LIGHT_PARAM_ATTENUATION] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45;
|
|
|
- light.param[RS::LIGHT_PARAM_SPOT_ATTENUATION] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 1.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_BIAS] = 0.02;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_BLUR] = 0;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE] = 20.0;
|
|
|
- light.param[RS::LIGHT_PARAM_SHADOW_VOLUMETRIC_FOG_FADE] = 0.1;
|
|
|
- light.param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05;
|
|
|
-
|
|
|
- light_owner.initialize_rid(p_light, light);
|
|
|
-}
|
|
|
-
|
|
|
-RID RendererStorageRD::directional_light_allocate() {
|
|
|
- return light_owner.allocate_rid();
|
|
|
-}
|
|
|
-void RendererStorageRD::directional_light_initialize(RID p_light) {
|
|
|
- _light_initialize(p_light, RS::LIGHT_DIRECTIONAL);
|
|
|
-}
|
|
|
-
|
|
|
-RID RendererStorageRD::omni_light_allocate() {
|
|
|
- return light_owner.allocate_rid();
|
|
|
-}
|
|
|
-void RendererStorageRD::omni_light_initialize(RID p_light) {
|
|
|
- _light_initialize(p_light, RS::LIGHT_OMNI);
|
|
|
-}
|
|
|
-
|
|
|
-RID RendererStorageRD::spot_light_allocate() {
|
|
|
- return light_owner.allocate_rid();
|
|
|
-}
|
|
|
-void RendererStorageRD::spot_light_initialize(RID p_light) {
|
|
|
- _light_initialize(p_light, RS::LIGHT_SPOT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_color(RID p_light, const Color &p_color) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->color = p_color;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
- ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
|
|
|
-
|
|
|
- if (light->param[p_param] == p_value) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- switch (p_param) {
|
|
|
- case RS::LIGHT_PARAM_RANGE:
|
|
|
- case RS::LIGHT_PARAM_SPOT_ANGLE:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE:
|
|
|
- case RS::LIGHT_PARAM_SHADOW_BIAS: {
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
- } break;
|
|
|
- case RS::LIGHT_PARAM_SIZE: {
|
|
|
- if ((light->param[p_param] > CMP_EPSILON) != (p_value > CMP_EPSILON)) {
|
|
|
- //changing from no size to size and the opposite
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
|
|
|
- }
|
|
|
- } break;
|
|
|
- default: {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- light->param[p_param] = p_value;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
- light->shadow = p_enabled;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) {
|
|
|
- RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- if (light->projector == p_texture) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) {
|
|
|
- texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
|
|
|
- }
|
|
|
-
|
|
|
- light->projector = p_texture;
|
|
|
-
|
|
|
- if (light->type != RS::LIGHT_DIRECTIONAL) {
|
|
|
- if (light->projector.is_valid()) {
|
|
|
- texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
|
|
|
- }
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_negative(RID p_light, bool p_enable) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->negative = p_enable;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->cull_mask = p_mask;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->distance_fade = p_enabled;
|
|
|
- light->distance_fade_begin = p_begin;
|
|
|
- light->distance_fade_shadow = p_shadow;
|
|
|
- light->distance_fade_length = p_length;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->reverse_cull = p_enabled;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->bake_mode = p_bake_mode;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->max_sdfgi_cascade = p_cascade;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->omni_shadow_mode = p_mode;
|
|
|
-
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-RS::LightOmniShadowMode RendererStorageRD::light_omni_get_shadow_mode(RID p_light) {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
|
|
|
-
|
|
|
- return light->omni_shadow_mode;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->directional_shadow_mode = p_mode;
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_directional_set_blend_splits(RID p_light, bool p_enable) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->directional_blend_splits = p_enable;
|
|
|
- light->version++;
|
|
|
- light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT);
|
|
|
-}
|
|
|
-
|
|
|
-bool RendererStorageRD::light_directional_get_blend_splits(RID p_light) const {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, false);
|
|
|
-
|
|
|
- return light->directional_blend_splits;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) {
|
|
|
- Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND(!light);
|
|
|
-
|
|
|
- light->directional_sky_mode = p_mode;
|
|
|
-}
|
|
|
-
|
|
|
-RS::LightDirectionalSkyMode RendererStorageRD::light_directional_get_sky_mode(RID p_light) const {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
|
|
|
-
|
|
|
- return light->directional_sky_mode;
|
|
|
-}
|
|
|
-
|
|
|
-RS::LightDirectionalShadowMode RendererStorageRD::light_directional_get_shadow_mode(RID p_light) {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
|
|
|
-
|
|
|
- return light->directional_shadow_mode;
|
|
|
-}
|
|
|
-
|
|
|
-uint32_t RendererStorageRD::light_get_max_sdfgi_cascade(RID p_light) {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, 0);
|
|
|
-
|
|
|
- return light->max_sdfgi_cascade;
|
|
|
-}
|
|
|
-
|
|
|
-RS::LightBakeMode RendererStorageRD::light_get_bake_mode(RID p_light) {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, RS::LIGHT_BAKE_DISABLED);
|
|
|
-
|
|
|
- return light->bake_mode;
|
|
|
-}
|
|
|
-
|
|
|
-uint64_t RendererStorageRD::light_get_version(RID p_light) const {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, 0);
|
|
|
-
|
|
|
- return light->version;
|
|
|
-}
|
|
|
-
|
|
|
-AABB RendererStorageRD::light_get_aabb(RID p_light) const {
|
|
|
- const Light *light = light_owner.get_or_null(p_light);
|
|
|
- ERR_FAIL_COND_V(!light, AABB());
|
|
|
-
|
|
|
- switch (light->type) {
|
|
|
- case RS::LIGHT_SPOT: {
|
|
|
- float len = light->param[RS::LIGHT_PARAM_RANGE];
|
|
|
- float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
|
|
|
- return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
|
|
|
- };
|
|
|
- case RS::LIGHT_OMNI: {
|
|
|
- float r = light->param[RS::LIGHT_PARAM_RANGE];
|
|
|
- return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
|
|
|
- };
|
|
|
- case RS::LIGHT_DIRECTIONAL: {
|
|
|
- return AABB();
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- ERR_FAIL_V(AABB());
|
|
|
-}
|
|
|
-
|
|
|
-/* REFLECTION PROBE */
|
|
|
-
|
|
|
-RID RendererStorageRD::reflection_probe_allocate() {
|
|
|
- return reflection_probe_owner.allocate_rid();
|
|
|
-}
|
|
|
-void RendererStorageRD::reflection_probe_initialize(RID p_reflection_probe) {
|
|
|
- reflection_probe_owner.initialize_rid(p_reflection_probe, ReflectionProbe());
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->update_mode = p_mode;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->intensity = p_intensity;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->ambient_mode = p_mode;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->ambient_color = p_color;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->ambient_color_energy = p_energy;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->max_distance = p_distance;
|
|
|
-
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- if (reflection_probe->extents == p_extents) {
|
|
|
- return;
|
|
|
- }
|
|
|
- reflection_probe->extents = p_extents;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->origin_offset = p_offset;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->interior = p_enable;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->box_projection = p_enable;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->enable_shadows = p_enable;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->cull_mask = p_layers;
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
- ERR_FAIL_COND(p_resolution < 32);
|
|
|
-
|
|
|
- reflection_probe->resolution = p_resolution;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_ratio) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND(!reflection_probe);
|
|
|
-
|
|
|
- reflection_probe->mesh_lod_threshold = p_ratio;
|
|
|
-
|
|
|
- reflection_probe->dependency.changed_notify(DEPENDENCY_CHANGED_REFLECTION_PROBE);
|
|
|
-}
|
|
|
-
|
|
|
-AABB RendererStorageRD::reflection_probe_get_aabb(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, AABB());
|
|
|
-
|
|
|
- AABB aabb;
|
|
|
- aabb.position = -reflection_probe->extents;
|
|
|
- aabb.size = reflection_probe->extents * 2.0;
|
|
|
-
|
|
|
- return aabb;
|
|
|
-}
|
|
|
-
|
|
|
-RS::ReflectionProbeUpdateMode RendererStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
|
|
|
-
|
|
|
- return reflection_probe->update_mode;
|
|
|
-}
|
|
|
-
|
|
|
-uint32_t RendererStorageRD::reflection_probe_get_cull_mask(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->cull_mask;
|
|
|
-}
|
|
|
-
|
|
|
-Vector3 RendererStorageRD::reflection_probe_get_extents(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
|
|
-
|
|
|
- return reflection_probe->extents;
|
|
|
-}
|
|
|
-
|
|
|
-Vector3 RendererStorageRD::reflection_probe_get_origin_offset(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
|
|
-
|
|
|
- return reflection_probe->origin_offset;
|
|
|
-}
|
|
|
-
|
|
|
-bool RendererStorageRD::reflection_probe_renders_shadows(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, false);
|
|
|
-
|
|
|
- return reflection_probe->enable_shadows;
|
|
|
-}
|
|
|
-
|
|
|
-float RendererStorageRD::reflection_probe_get_origin_max_distance(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->max_distance;
|
|
|
-}
|
|
|
-
|
|
|
-float RendererStorageRD::reflection_probe_get_mesh_lod_threshold(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->mesh_lod_threshold;
|
|
|
-}
|
|
|
-
|
|
|
-int RendererStorageRD::reflection_probe_get_resolution(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->resolution;
|
|
|
-}
|
|
|
-
|
|
|
-float RendererStorageRD::reflection_probe_get_intensity(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->intensity;
|
|
|
-}
|
|
|
-
|
|
|
-bool RendererStorageRD::reflection_probe_is_interior(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, false);
|
|
|
-
|
|
|
- return reflection_probe->interior;
|
|
|
-}
|
|
|
-
|
|
|
-bool RendererStorageRD::reflection_probe_is_box_projection(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, false);
|
|
|
-
|
|
|
- return reflection_probe->box_projection;
|
|
|
-}
|
|
|
-
|
|
|
-RS::ReflectionProbeAmbientMode RendererStorageRD::reflection_probe_get_ambient_mode(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_AMBIENT_DISABLED);
|
|
|
- return reflection_probe->ambient_mode;
|
|
|
-}
|
|
|
-
|
|
|
-Color RendererStorageRD::reflection_probe_get_ambient_color(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, Color());
|
|
|
-
|
|
|
- return reflection_probe->ambient_color;
|
|
|
-}
|
|
|
-float RendererStorageRD::reflection_probe_get_ambient_color_energy(RID p_probe) const {
|
|
|
- const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
|
|
|
- ERR_FAIL_COND_V(!reflection_probe, 0);
|
|
|
-
|
|
|
- return reflection_probe->ambient_color_energy;
|
|
|
-}
|
|
|
+/* VOXEL GI */
|
|
|
|
|
|
RID RendererStorageRD::voxel_gi_allocate() {
|
|
|
return voxel_gi_owner.allocate_rid();
|
|
@@ -2769,185 +2257,6 @@ RID RendererStorageRD::voxel_gi_get_sdf_texture(RID p_voxel_gi) {
|
|
|
return voxel_gi->sdf_texture;
|
|
|
}
|
|
|
|
|
|
-/* LIGHTMAP API */
|
|
|
-
|
|
|
-RID RendererStorageRD::lightmap_allocate() {
|
|
|
- return lightmap_owner.allocate_rid();
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_initialize(RID p_lightmap) {
|
|
|
- lightmap_owner.initialize_rid(p_lightmap, Lightmap());
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
|
|
|
- RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
|
|
|
-
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND(!lm);
|
|
|
-
|
|
|
- lightmap_array_version++;
|
|
|
-
|
|
|
- //erase lightmap users
|
|
|
- if (lm->light_texture.is_valid()) {
|
|
|
- RendererRD::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(lm->light_texture);
|
|
|
- if (t) {
|
|
|
- t->lightmap_users.erase(p_lightmap);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- RendererRD::Texture *t = RendererRD::TextureStorage::get_singleton()->get_texture(p_light);
|
|
|
- lm->light_texture = p_light;
|
|
|
- lm->uses_spherical_harmonics = p_uses_spherical_haromics;
|
|
|
-
|
|
|
- RID default_2d_array = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
|
|
- if (!t) {
|
|
|
- if (using_lightmap_array) {
|
|
|
- if (lm->array_index >= 0) {
|
|
|
- lightmap_textures.write[lm->array_index] = default_2d_array;
|
|
|
- lm->array_index = -1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- t->lightmap_users.insert(p_lightmap);
|
|
|
-
|
|
|
- if (using_lightmap_array) {
|
|
|
- if (lm->array_index < 0) {
|
|
|
- //not in array, try to put in array
|
|
|
- for (int i = 0; i < lightmap_textures.size(); i++) {
|
|
|
- if (lightmap_textures[i] == default_2d_array) {
|
|
|
- lm->array_index = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ERR_FAIL_COND_MSG(lm->array_index < 0, "Maximum amount of lightmaps in use (" + itos(lightmap_textures.size()) + ") has been exceeded, lightmap will nod display properly.");
|
|
|
-
|
|
|
- lightmap_textures.write[lm->array_index] = t->rd_texture;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND(!lm);
|
|
|
- lm->bounds = p_bounds;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND(!lm);
|
|
|
- lm->interior = p_interior;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND(!lm);
|
|
|
-
|
|
|
- if (p_points.size()) {
|
|
|
- ERR_FAIL_COND(p_points.size() * 9 != p_point_sh.size());
|
|
|
- ERR_FAIL_COND((p_tetrahedra.size() % 4) != 0);
|
|
|
- ERR_FAIL_COND((p_bsp_tree.size() % 6) != 0);
|
|
|
- }
|
|
|
-
|
|
|
- lm->points = p_points;
|
|
|
- lm->bsp_tree = p_bsp_tree;
|
|
|
- lm->point_sh = p_point_sh;
|
|
|
- lm->tetrahedra = p_tetrahedra;
|
|
|
-}
|
|
|
-
|
|
|
-PackedVector3Array RendererStorageRD::lightmap_get_probe_capture_points(RID p_lightmap) const {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, PackedVector3Array());
|
|
|
-
|
|
|
- return lm->points;
|
|
|
-}
|
|
|
-
|
|
|
-PackedColorArray RendererStorageRD::lightmap_get_probe_capture_sh(RID p_lightmap) const {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, PackedColorArray());
|
|
|
- return lm->point_sh;
|
|
|
-}
|
|
|
-
|
|
|
-PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, PackedInt32Array());
|
|
|
- return lm->tetrahedra;
|
|
|
-}
|
|
|
-
|
|
|
-PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, PackedInt32Array());
|
|
|
- return lm->bsp_tree;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_set_probe_capture_update_speed(float p_speed) {
|
|
|
- lightmap_probe_capture_update_speed = p_speed;
|
|
|
-}
|
|
|
-
|
|
|
-void RendererStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND(!lm);
|
|
|
-
|
|
|
- for (int i = 0; i < 9; i++) {
|
|
|
- r_sh[i] = Color(0, 0, 0, 0);
|
|
|
- }
|
|
|
-
|
|
|
- if (!lm->points.size() || !lm->bsp_tree.size() || !lm->tetrahedra.size()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- static_assert(sizeof(Lightmap::BSP) == 24);
|
|
|
-
|
|
|
- const Lightmap::BSP *bsp = (const Lightmap::BSP *)lm->bsp_tree.ptr();
|
|
|
- int32_t node = 0;
|
|
|
- while (node >= 0) {
|
|
|
- if (Plane(bsp[node].plane[0], bsp[node].plane[1], bsp[node].plane[2], bsp[node].plane[3]).is_point_over(p_point)) {
|
|
|
-#ifdef DEBUG_ENABLED
|
|
|
- ERR_FAIL_COND(bsp[node].over >= 0 && bsp[node].over < node);
|
|
|
-#endif
|
|
|
-
|
|
|
- node = bsp[node].over;
|
|
|
- } else {
|
|
|
-#ifdef DEBUG_ENABLED
|
|
|
- ERR_FAIL_COND(bsp[node].under >= 0 && bsp[node].under < node);
|
|
|
-#endif
|
|
|
- node = bsp[node].under;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (node == Lightmap::BSP::EMPTY_LEAF) {
|
|
|
- return; //nothing could be done
|
|
|
- }
|
|
|
-
|
|
|
- node = ABS(node) - 1;
|
|
|
-
|
|
|
- uint32_t *tetrahedron = (uint32_t *)&lm->tetrahedra[node * 4];
|
|
|
- Vector3 points[4] = { lm->points[tetrahedron[0]], lm->points[tetrahedron[1]], lm->points[tetrahedron[2]], lm->points[tetrahedron[3]] };
|
|
|
- const Color *sh_colors[4]{ &lm->point_sh[tetrahedron[0] * 9], &lm->point_sh[tetrahedron[1] * 9], &lm->point_sh[tetrahedron[2] * 9], &lm->point_sh[tetrahedron[3] * 9] };
|
|
|
- Color barycentric = Geometry3D::tetrahedron_get_barycentric_coords(points[0], points[1], points[2], points[3], p_point);
|
|
|
-
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
- float c = CLAMP(barycentric[i], 0.0, 1.0);
|
|
|
- for (int j = 0; j < 9; j++) {
|
|
|
- r_sh[j] += sh_colors[i][j] * c;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-bool RendererStorageRD::lightmap_is_interior(RID p_lightmap) const {
|
|
|
- const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, false);
|
|
|
- return lm->interior;
|
|
|
-}
|
|
|
-
|
|
|
-AABB RendererStorageRD::lightmap_get_aabb(RID p_lightmap) const {
|
|
|
- const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
|
|
|
- ERR_FAIL_COND_V(!lm, AABB());
|
|
|
- return lm->bounds;
|
|
|
-}
|
|
|
-
|
|
|
void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_instance) {
|
|
|
if (RendererRD::MeshStorage::get_singleton()->owns_mesh(p_base)) {
|
|
|
RendererRD::Mesh *mesh = RendererRD::MeshStorage::get_singleton()->get_mesh(p_base);
|
|
@@ -2958,8 +2267,8 @@ void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_
|
|
|
if (multimesh->mesh.is_valid()) {
|
|
|
base_update_dependency(multimesh->mesh, p_instance);
|
|
|
}
|
|
|
- } else if (reflection_probe_owner.owns(p_base)) {
|
|
|
- ReflectionProbe *rp = reflection_probe_owner.get_or_null(p_base);
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_reflection_probe(p_base)) {
|
|
|
+ RendererRD::ReflectionProbe *rp = RendererRD::LightStorage::get_singleton()->get_reflection_probe(p_base);
|
|
|
p_instance->update_dependency(&rp->dependency);
|
|
|
} else if (RendererRD::TextureStorage::get_singleton()->owns_decal(p_base)) {
|
|
|
RendererRD::Decal *decal = RendererRD::TextureStorage::get_singleton()->get_decal(p_base);
|
|
@@ -2967,11 +2276,11 @@ void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_
|
|
|
} else if (voxel_gi_owner.owns(p_base)) {
|
|
|
VoxelGI *gip = voxel_gi_owner.get_or_null(p_base);
|
|
|
p_instance->update_dependency(&gip->dependency);
|
|
|
- } else if (lightmap_owner.owns(p_base)) {
|
|
|
- Lightmap *lm = lightmap_owner.get_or_null(p_base);
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_lightmap(p_base)) {
|
|
|
+ RendererRD::Lightmap *lm = RendererRD::LightStorage::get_singleton()->get_lightmap(p_base);
|
|
|
p_instance->update_dependency(&lm->dependency);
|
|
|
- } else if (light_owner.owns(p_base)) {
|
|
|
- Light *l = light_owner.get_or_null(p_base);
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_light(p_base)) {
|
|
|
+ RendererRD::Light *l = RendererRD::LightStorage::get_singleton()->get_light(p_base);
|
|
|
p_instance->update_dependency(&l->dependency);
|
|
|
} else if (particles_owner.owns(p_base)) {
|
|
|
Particles *p = particles_owner.get_or_null(p_base);
|
|
@@ -2995,7 +2304,7 @@ RS::InstanceType RendererStorageRD::get_base_type(RID p_rid) const {
|
|
|
if (RendererRD::MeshStorage::get_singleton()->owns_multimesh(p_rid)) {
|
|
|
return RS::INSTANCE_MULTIMESH;
|
|
|
}
|
|
|
- if (reflection_probe_owner.owns(p_rid)) {
|
|
|
+ if (RendererRD::LightStorage::get_singleton()->owns_reflection_probe(p_rid)) {
|
|
|
return RS::INSTANCE_REFLECTION_PROBE;
|
|
|
}
|
|
|
if (RendererRD::TextureStorage::get_singleton()->owns_decal(p_rid)) {
|
|
@@ -3004,10 +2313,10 @@ RS::InstanceType RendererStorageRD::get_base_type(RID p_rid) const {
|
|
|
if (voxel_gi_owner.owns(p_rid)) {
|
|
|
return RS::INSTANCE_VOXEL_GI;
|
|
|
}
|
|
|
- if (light_owner.owns(p_rid)) {
|
|
|
+ if (RendererRD::LightStorage::get_singleton()->owns_light(p_rid)) {
|
|
|
return RS::INSTANCE_LIGHT;
|
|
|
}
|
|
|
- if (lightmap_owner.owns(p_rid)) {
|
|
|
+ if (RendererRD::LightStorage::get_singleton()->owns_lightmap(p_rid)) {
|
|
|
return RS::INSTANCE_LIGHTMAP;
|
|
|
}
|
|
|
if (particles_owner.owns(p_rid)) {
|
|
@@ -3071,10 +2380,8 @@ bool RendererStorageRD::free(RID p_rid) {
|
|
|
RendererRD::MeshStorage::get_singleton()->multimesh_free(p_rid);
|
|
|
} else if (RendererRD::MeshStorage::get_singleton()->owns_skeleton(p_rid)) {
|
|
|
RendererRD::MeshStorage::get_singleton()->skeleton_free(p_rid);
|
|
|
- } else if (reflection_probe_owner.owns(p_rid)) {
|
|
|
- ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_rid);
|
|
|
- reflection_probe->dependency.deleted_notify(p_rid);
|
|
|
- reflection_probe_owner.free(p_rid);
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_reflection_probe(p_rid)) {
|
|
|
+ RendererRD::LightStorage::get_singleton()->reflection_probe_free(p_rid);
|
|
|
} else if (RendererRD::TextureStorage::get_singleton()->owns_decal(p_rid)) {
|
|
|
RendererRD::TextureStorage::get_singleton()->decal_free(p_rid);
|
|
|
} else if (voxel_gi_owner.owns(p_rid)) {
|
|
@@ -3082,19 +2389,10 @@ bool RendererStorageRD::free(RID p_rid) {
|
|
|
VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_rid);
|
|
|
voxel_gi->dependency.deleted_notify(p_rid);
|
|
|
voxel_gi_owner.free(p_rid);
|
|
|
- } else if (lightmap_owner.owns(p_rid)) {
|
|
|
- lightmap_set_textures(p_rid, RID(), false);
|
|
|
- Lightmap *lightmap = lightmap_owner.get_or_null(p_rid);
|
|
|
- lightmap->dependency.deleted_notify(p_rid);
|
|
|
- lightmap_owner.free(p_rid);
|
|
|
-
|
|
|
- } else if (light_owner.owns(p_rid)) {
|
|
|
- light_set_projector(p_rid, RID()); //clear projector
|
|
|
- // delete the texture
|
|
|
- Light *light = light_owner.get_or_null(p_rid);
|
|
|
- light->dependency.deleted_notify(p_rid);
|
|
|
- light_owner.free(p_rid);
|
|
|
-
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_lightmap(p_rid)) {
|
|
|
+ RendererRD::LightStorage::get_singleton()->lightmap_free(p_rid);
|
|
|
+ } else if (RendererRD::LightStorage::get_singleton()->owns_light(p_rid)) {
|
|
|
+ RendererRD::LightStorage::get_singleton()->light_free(p_rid);
|
|
|
} else if (particles_owner.owns(p_rid)) {
|
|
|
update_particles();
|
|
|
Particles *particles = particles_owner.get_or_null(p_rid);
|
|
@@ -3198,7 +2496,6 @@ RendererStorageRD *RendererStorageRD::base_singleton = nullptr;
|
|
|
RendererStorageRD::RendererStorageRD() {
|
|
|
base_singleton = this;
|
|
|
|
|
|
- RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton();
|
|
|
RendererRD::MaterialStorage *material_storage = RendererRD::MaterialStorage::get_singleton();
|
|
|
|
|
|
//default samplers
|
|
@@ -3289,23 +2586,6 @@ RendererStorageRD::RendererStorageRD() {
|
|
|
//custom sampler
|
|
|
sampler_rd_configure_custom(0.0f);
|
|
|
|
|
|
- using_lightmap_array = true; // high end
|
|
|
- if (using_lightmap_array) {
|
|
|
- uint64_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE);
|
|
|
-
|
|
|
- if (textures_per_stage <= 256) {
|
|
|
- lightmap_textures.resize(32);
|
|
|
- } else {
|
|
|
- lightmap_textures.resize(1024);
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < lightmap_textures.size(); i++) {
|
|
|
- lightmap_textures.write[i] = texture_storage->texture_rd_get_default(RendererRD::DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- lightmap_probe_capture_update_speed = GLOBAL_GET("rendering/lightmapping/probe_capture/update_speed");
|
|
|
-
|
|
|
/* Particles */
|
|
|
|
|
|
{
|