| 1 | /**************************************************************************/ | 
|---|
| 2 | /*  light_storage.cpp                                                     */ | 
|---|
| 3 | /**************************************************************************/ | 
|---|
| 4 | /*                         This file is part of:                          */ | 
|---|
| 5 | /*                             GODOT ENGINE                               */ | 
|---|
| 6 | /*                        https://godotengine.org                         */ | 
|---|
| 7 | /**************************************************************************/ | 
|---|
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
|---|
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
|---|
| 10 | /*                                                                        */ | 
|---|
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
|---|
| 12 | /* a copy of this software and associated documentation files (the        */ | 
|---|
| 13 | /* "Software"), to deal in the Software without restriction, including    */ | 
|---|
| 14 | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
|---|
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
|---|
| 16 | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
|---|
| 17 | /* the following conditions:                                              */ | 
|---|
| 18 | /*                                                                        */ | 
|---|
| 19 | /* The above copyright notice and this permission notice shall be         */ | 
|---|
| 20 | /* included in all copies or substantial portions of the Software.        */ | 
|---|
| 21 | /*                                                                        */ | 
|---|
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
|---|
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
|---|
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
|---|
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
|---|
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
|---|
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
|---|
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
|---|
| 29 | /**************************************************************************/ | 
|---|
| 30 |  | 
|---|
| 31 | #ifdef GLES3_ENABLED | 
|---|
| 32 |  | 
|---|
| 33 | #include "light_storage.h" | 
|---|
| 34 | #include "config.h" | 
|---|
| 35 | #include "texture_storage.h" | 
|---|
| 36 |  | 
|---|
| 37 | using namespace GLES3; | 
|---|
| 38 |  | 
|---|
| 39 | LightStorage *LightStorage::singleton = nullptr; | 
|---|
| 40 |  | 
|---|
| 41 | LightStorage *LightStorage::get_singleton() { | 
|---|
| 42 | return singleton; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | LightStorage::LightStorage() { | 
|---|
| 46 | singleton = this; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | LightStorage::~LightStorage() { | 
|---|
| 50 | singleton = nullptr; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /* Light API */ | 
|---|
| 54 |  | 
|---|
| 55 | void LightStorage::_light_initialize(RID p_light, RS::LightType p_type) { | 
|---|
| 56 | Light light; | 
|---|
| 57 | light.type = p_type; | 
|---|
| 58 |  | 
|---|
| 59 | light.param[RS::LIGHT_PARAM_ENERGY] = 1.0; | 
|---|
| 60 | light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; | 
|---|
| 61 | light.param[RS::LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY] = 1.0; | 
|---|
| 62 | light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5; | 
|---|
| 63 | light.param[RS::LIGHT_PARAM_RANGE] = 1.0; | 
|---|
| 64 | light.param[RS::LIGHT_PARAM_SIZE] = 0.0; | 
|---|
| 65 | light.param[RS::LIGHT_PARAM_ATTENUATION] = 1.0; | 
|---|
| 66 | light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45; | 
|---|
| 67 | light.param[RS::LIGHT_PARAM_SPOT_ATTENUATION] = 1.0; | 
|---|
| 68 | light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0; | 
|---|
| 69 | light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1; | 
|---|
| 70 | light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; | 
|---|
| 71 | light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; | 
|---|
| 72 | light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8; | 
|---|
| 73 | light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 1.0; | 
|---|
| 74 | light.param[RS::LIGHT_PARAM_SHADOW_OPACITY] = 1.0; | 
|---|
| 75 | light.param[RS::LIGHT_PARAM_SHADOW_BIAS] = 0.02; | 
|---|
| 76 | light.param[RS::LIGHT_PARAM_SHADOW_BLUR] = 0; | 
|---|
| 77 | light.param[RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE] = 20.0; | 
|---|
| 78 | light.param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05; | 
|---|
| 79 | light.param[RS::LIGHT_PARAM_INTENSITY] = p_type == RS::LIGHT_DIRECTIONAL ? 100000.0 : 1000.0; | 
|---|
| 80 |  | 
|---|
| 81 | light_owner.initialize_rid(p_light, light); | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | RID LightStorage::directional_light_allocate() { | 
|---|
| 85 | return light_owner.allocate_rid(); | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | void LightStorage::directional_light_initialize(RID p_rid) { | 
|---|
| 89 | _light_initialize(p_rid, RS::LIGHT_DIRECTIONAL); | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 | RID LightStorage::omni_light_allocate() { | 
|---|
| 93 | return light_owner.allocate_rid(); | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | void LightStorage::omni_light_initialize(RID p_rid) { | 
|---|
| 97 | _light_initialize(p_rid, RS::LIGHT_OMNI); | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | RID LightStorage::spot_light_allocate() { | 
|---|
| 101 | return light_owner.allocate_rid(); | 
|---|
| 102 | } | 
|---|
| 103 |  | 
|---|
| 104 | void LightStorage::spot_light_initialize(RID p_rid) { | 
|---|
| 105 | _light_initialize(p_rid, RS::LIGHT_SPOT); | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | void LightStorage::light_free(RID p_rid) { | 
|---|
| 109 | light_set_projector(p_rid, RID()); //clear projector | 
|---|
| 110 |  | 
|---|
| 111 | // delete the texture | 
|---|
| 112 | Light *light = light_owner.get_or_null(p_rid); | 
|---|
| 113 | light->dependency.deleted_notify(p_rid); | 
|---|
| 114 | light_owner.free(p_rid); | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | void LightStorage::light_set_color(RID p_light, const Color &p_color) { | 
|---|
| 118 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 119 | ERR_FAIL_NULL(light); | 
|---|
| 120 |  | 
|---|
| 121 | light->color = p_color; | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | void LightStorage::light_set_param(RID p_light, RS::LightParam p_param, float p_value) { | 
|---|
| 125 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 126 | ERR_FAIL_NULL(light); | 
|---|
| 127 | ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX); | 
|---|
| 128 |  | 
|---|
| 129 | if (light->param[p_param] == p_value) { | 
|---|
| 130 | return; | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | switch (p_param) { | 
|---|
| 134 | case RS::LIGHT_PARAM_RANGE: | 
|---|
| 135 | case RS::LIGHT_PARAM_SPOT_ANGLE: | 
|---|
| 136 | case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE: | 
|---|
| 137 | case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET: | 
|---|
| 138 | case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET: | 
|---|
| 139 | case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET: | 
|---|
| 140 | case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS: | 
|---|
| 141 | case RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE: | 
|---|
| 142 | case RS::LIGHT_PARAM_SHADOW_BIAS: { | 
|---|
| 143 | light->version++; | 
|---|
| 144 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 145 | } break; | 
|---|
| 146 | case RS::LIGHT_PARAM_SIZE: { | 
|---|
| 147 | if ((light->param[p_param] > CMP_EPSILON) != (p_value > CMP_EPSILON)) { | 
|---|
| 148 | //changing from no size to size and the opposite | 
|---|
| 149 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR); | 
|---|
| 150 | } | 
|---|
| 151 | } break; | 
|---|
| 152 | default: { | 
|---|
| 153 | } | 
|---|
| 154 | } | 
|---|
| 155 |  | 
|---|
| 156 | light->param[p_param] = p_value; | 
|---|
| 157 | } | 
|---|
| 158 |  | 
|---|
| 159 | void LightStorage::light_set_shadow(RID p_light, bool p_enabled) { | 
|---|
| 160 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 161 | ERR_FAIL_NULL(light); | 
|---|
| 162 | light->shadow = p_enabled; | 
|---|
| 163 |  | 
|---|
| 164 | light->version++; | 
|---|
| 165 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 166 | } | 
|---|
| 167 |  | 
|---|
| 168 | void LightStorage::light_set_projector(RID p_light, RID p_texture) { | 
|---|
| 169 | GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton(); | 
|---|
| 170 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 171 | ERR_FAIL_NULL(light); | 
|---|
| 172 |  | 
|---|
| 173 | if (light->projector == p_texture) { | 
|---|
| 174 | return; | 
|---|
| 175 | } | 
|---|
| 176 |  | 
|---|
| 177 | if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) { | 
|---|
| 178 | texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI); | 
|---|
| 179 | } | 
|---|
| 180 |  | 
|---|
| 181 | light->projector = p_texture; | 
|---|
| 182 |  | 
|---|
| 183 | if (light->type != RS::LIGHT_DIRECTIONAL) { | 
|---|
| 184 | if (light->projector.is_valid()) { | 
|---|
| 185 | texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI); | 
|---|
| 186 | } | 
|---|
| 187 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR); | 
|---|
| 188 | } | 
|---|
| 189 | } | 
|---|
| 190 |  | 
|---|
| 191 | void LightStorage::light_set_negative(RID p_light, bool p_enable) { | 
|---|
| 192 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 193 | ERR_FAIL_NULL(light); | 
|---|
| 194 |  | 
|---|
| 195 | light->negative = p_enable; | 
|---|
| 196 | } | 
|---|
| 197 |  | 
|---|
| 198 | void LightStorage::light_set_cull_mask(RID p_light, uint32_t p_mask) { | 
|---|
| 199 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 200 | ERR_FAIL_NULL(light); | 
|---|
| 201 |  | 
|---|
| 202 | light->cull_mask = p_mask; | 
|---|
| 203 |  | 
|---|
| 204 | light->version++; | 
|---|
| 205 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 206 | } | 
|---|
| 207 |  | 
|---|
| 208 | void LightStorage::light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) { | 
|---|
| 209 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 210 | ERR_FAIL_NULL(light); | 
|---|
| 211 |  | 
|---|
| 212 | light->distance_fade = p_enabled; | 
|---|
| 213 | light->distance_fade_begin = p_begin; | 
|---|
| 214 | light->distance_fade_shadow = p_shadow; | 
|---|
| 215 | light->distance_fade_length = p_length; | 
|---|
| 216 | } | 
|---|
| 217 |  | 
|---|
| 218 | void LightStorage::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) { | 
|---|
| 219 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 220 | ERR_FAIL_NULL(light); | 
|---|
| 221 |  | 
|---|
| 222 | light->reverse_cull = p_enabled; | 
|---|
| 223 |  | 
|---|
| 224 | light->version++; | 
|---|
| 225 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 226 | } | 
|---|
| 227 |  | 
|---|
| 228 | void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) { | 
|---|
| 229 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 230 | ERR_FAIL_NULL(light); | 
|---|
| 231 |  | 
|---|
| 232 | light->bake_mode = p_bake_mode; | 
|---|
| 233 |  | 
|---|
| 234 | light->version++; | 
|---|
| 235 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 236 | } | 
|---|
| 237 |  | 
|---|
| 238 | void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) { | 
|---|
| 239 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 240 | ERR_FAIL_NULL(light); | 
|---|
| 241 |  | 
|---|
| 242 | light->omni_shadow_mode = p_mode; | 
|---|
| 243 |  | 
|---|
| 244 | light->version++; | 
|---|
| 245 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | RS::LightOmniShadowMode LightStorage::light_omni_get_shadow_mode(RID p_light) { | 
|---|
| 249 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 250 | ERR_FAIL_NULL_V(light, RS::LIGHT_OMNI_SHADOW_CUBE); | 
|---|
| 251 |  | 
|---|
| 252 | return light->omni_shadow_mode; | 
|---|
| 253 | } | 
|---|
| 254 |  | 
|---|
| 255 | void LightStorage::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) { | 
|---|
| 256 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 257 | ERR_FAIL_NULL(light); | 
|---|
| 258 |  | 
|---|
| 259 | light->directional_shadow_mode = p_mode; | 
|---|
| 260 | light->version++; | 
|---|
| 261 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | void LightStorage::light_directional_set_blend_splits(RID p_light, bool p_enable) { | 
|---|
| 265 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 266 | ERR_FAIL_NULL(light); | 
|---|
| 267 |  | 
|---|
| 268 | light->directional_blend_splits = p_enable; | 
|---|
| 269 | light->version++; | 
|---|
| 270 | light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT); | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | bool LightStorage::light_directional_get_blend_splits(RID p_light) const { | 
|---|
| 274 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 275 | ERR_FAIL_NULL_V(light, false); | 
|---|
| 276 |  | 
|---|
| 277 | return light->directional_blend_splits; | 
|---|
| 278 | } | 
|---|
| 279 |  | 
|---|
| 280 | void LightStorage::light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) { | 
|---|
| 281 | Light *light = light_owner.get_or_null(p_light); | 
|---|
| 282 | ERR_FAIL_NULL(light); | 
|---|
| 283 |  | 
|---|
| 284 | light->directional_sky_mode = p_mode; | 
|---|
| 285 | } | 
|---|
| 286 |  | 
|---|
| 287 | RS::LightDirectionalSkyMode LightStorage::light_directional_get_sky_mode(RID p_light) const { | 
|---|
| 288 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 289 | ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY); | 
|---|
| 290 |  | 
|---|
| 291 | return light->directional_sky_mode; | 
|---|
| 292 | } | 
|---|
| 293 |  | 
|---|
| 294 | RS::LightDirectionalShadowMode LightStorage::light_directional_get_shadow_mode(RID p_light) { | 
|---|
| 295 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 296 | ERR_FAIL_NULL_V(light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); | 
|---|
| 297 |  | 
|---|
| 298 | return light->directional_shadow_mode; | 
|---|
| 299 | } | 
|---|
| 300 |  | 
|---|
| 301 | RS::LightBakeMode LightStorage::light_get_bake_mode(RID p_light) { | 
|---|
| 302 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 303 | ERR_FAIL_NULL_V(light, RS::LIGHT_BAKE_DISABLED); | 
|---|
| 304 |  | 
|---|
| 305 | return light->bake_mode; | 
|---|
| 306 | } | 
|---|
| 307 |  | 
|---|
| 308 | uint64_t LightStorage::light_get_version(RID p_light) const { | 
|---|
| 309 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 310 | ERR_FAIL_NULL_V(light, 0); | 
|---|
| 311 |  | 
|---|
| 312 | return light->version; | 
|---|
| 313 | } | 
|---|
| 314 |  | 
|---|
| 315 | uint32_t LightStorage::light_get_cull_mask(RID p_light) const { | 
|---|
| 316 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 317 | ERR_FAIL_NULL_V(light, 0); | 
|---|
| 318 |  | 
|---|
| 319 | return light->cull_mask; | 
|---|
| 320 | } | 
|---|
| 321 |  | 
|---|
| 322 | AABB LightStorage::light_get_aabb(RID p_light) const { | 
|---|
| 323 | const Light *light = light_owner.get_or_null(p_light); | 
|---|
| 324 | ERR_FAIL_NULL_V(light, AABB()); | 
|---|
| 325 |  | 
|---|
| 326 | switch (light->type) { | 
|---|
| 327 | case RS::LIGHT_SPOT: { | 
|---|
| 328 | float len = light->param[RS::LIGHT_PARAM_RANGE]; | 
|---|
| 329 | float size = Math::tan(Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len; | 
|---|
| 330 | return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); | 
|---|
| 331 | }; | 
|---|
| 332 | case RS::LIGHT_OMNI: { | 
|---|
| 333 | float r = light->param[RS::LIGHT_PARAM_RANGE]; | 
|---|
| 334 | return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); | 
|---|
| 335 | }; | 
|---|
| 336 | case RS::LIGHT_DIRECTIONAL: { | 
|---|
| 337 | return AABB(); | 
|---|
| 338 | }; | 
|---|
| 339 | } | 
|---|
| 340 |  | 
|---|
| 341 | ERR_FAIL_V(AABB()); | 
|---|
| 342 | } | 
|---|
| 343 |  | 
|---|
| 344 | /* LIGHT INSTANCE API */ | 
|---|
| 345 |  | 
|---|
| 346 | RID LightStorage::light_instance_create(RID p_light) { | 
|---|
| 347 | RID li = light_instance_owner.make_rid(LightInstance()); | 
|---|
| 348 |  | 
|---|
| 349 | LightInstance *light_instance = light_instance_owner.get_or_null(li); | 
|---|
| 350 |  | 
|---|
| 351 | light_instance->self = li; | 
|---|
| 352 | light_instance->light = p_light; | 
|---|
| 353 | light_instance->light_type = light_get_type(p_light); | 
|---|
| 354 |  | 
|---|
| 355 | return li; | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | void LightStorage::light_instance_free(RID p_light_instance) { | 
|---|
| 359 | LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance); | 
|---|
| 360 | ERR_FAIL_NULL(light_instance); | 
|---|
| 361 | light_instance_owner.free(p_light_instance); | 
|---|
| 362 | } | 
|---|
| 363 |  | 
|---|
| 364 | void LightStorage::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) { | 
|---|
| 365 | LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance); | 
|---|
| 366 | ERR_FAIL_NULL(light_instance); | 
|---|
| 367 |  | 
|---|
| 368 | light_instance->transform = p_transform; | 
|---|
| 369 | } | 
|---|
| 370 |  | 
|---|
| 371 | void LightStorage::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) { | 
|---|
| 372 | LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance); | 
|---|
| 373 | ERR_FAIL_NULL(light_instance); | 
|---|
| 374 |  | 
|---|
| 375 | light_instance->aabb = p_aabb; | 
|---|
| 376 | } | 
|---|
| 377 |  | 
|---|
| 378 | void LightStorage::light_instance_set_shadow_transform(RID p_light_instance, const Projection &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) { | 
|---|
| 379 | } | 
|---|
| 380 |  | 
|---|
| 381 | void LightStorage::light_instance_mark_visible(RID p_light_instance) { | 
|---|
| 382 | } | 
|---|
| 383 |  | 
|---|
| 384 | /* PROBE API */ | 
|---|
| 385 |  | 
|---|
| 386 | RID LightStorage::reflection_probe_allocate() { | 
|---|
| 387 | return RID(); | 
|---|
| 388 | } | 
|---|
| 389 |  | 
|---|
| 390 | void LightStorage::reflection_probe_initialize(RID p_rid) { | 
|---|
| 391 | } | 
|---|
| 392 |  | 
|---|
| 393 | void LightStorage::reflection_probe_free(RID p_rid) { | 
|---|
| 394 | } | 
|---|
| 395 |  | 
|---|
| 396 | void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { | 
|---|
| 397 | } | 
|---|
| 398 |  | 
|---|
| 399 | void LightStorage::reflection_probe_set_intensity(RID p_probe, float p_intensity) { | 
|---|
| 400 | } | 
|---|
| 401 |  | 
|---|
| 402 | void LightStorage::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) { | 
|---|
| 403 | } | 
|---|
| 404 |  | 
|---|
| 405 | void LightStorage::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) { | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | void LightStorage::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) { | 
|---|
| 409 | } | 
|---|
| 410 |  | 
|---|
| 411 | void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distance) { | 
|---|
| 412 | } | 
|---|
| 413 |  | 
|---|
| 414 | void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size) { | 
|---|
| 415 | } | 
|---|
| 416 |  | 
|---|
| 417 | void LightStorage::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) { | 
|---|
| 418 | } | 
|---|
| 419 |  | 
|---|
| 420 | void LightStorage::reflection_probe_set_as_interior(RID p_probe, bool p_enable) { | 
|---|
| 421 | } | 
|---|
| 422 |  | 
|---|
| 423 | void LightStorage::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) { | 
|---|
| 424 | } | 
|---|
| 425 |  | 
|---|
| 426 | void LightStorage::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) { | 
|---|
| 427 | } | 
|---|
| 428 |  | 
|---|
| 429 | void LightStorage::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) { | 
|---|
| 430 | } | 
|---|
| 431 |  | 
|---|
| 432 | void LightStorage::reflection_probe_set_resolution(RID p_probe, int p_resolution) { | 
|---|
| 433 | } | 
|---|
| 434 |  | 
|---|
| 435 | AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const { | 
|---|
| 436 | return AABB(); | 
|---|
| 437 | } | 
|---|
| 438 |  | 
|---|
| 439 | RS::ReflectionProbeUpdateMode LightStorage::reflection_probe_get_update_mode(RID p_probe) const { | 
|---|
| 440 | return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; | 
|---|
| 441 | } | 
|---|
| 442 |  | 
|---|
| 443 | uint32_t LightStorage::reflection_probe_get_cull_mask(RID p_probe) const { | 
|---|
| 444 | return 0; | 
|---|
| 445 | } | 
|---|
| 446 |  | 
|---|
| 447 | Vector3 LightStorage::reflection_probe_get_size(RID p_probe) const { | 
|---|
| 448 | return Vector3(); | 
|---|
| 449 | } | 
|---|
| 450 |  | 
|---|
| 451 | Vector3 LightStorage::reflection_probe_get_origin_offset(RID p_probe) const { | 
|---|
| 452 | return Vector3(); | 
|---|
| 453 | } | 
|---|
| 454 |  | 
|---|
| 455 | float LightStorage::reflection_probe_get_origin_max_distance(RID p_probe) const { | 
|---|
| 456 | return 0.0; | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | bool LightStorage::reflection_probe_renders_shadows(RID p_probe) const { | 
|---|
| 460 | return false; | 
|---|
| 461 | } | 
|---|
| 462 |  | 
|---|
| 463 | void LightStorage::reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_ratio) { | 
|---|
| 464 | } | 
|---|
| 465 |  | 
|---|
| 466 | float LightStorage::reflection_probe_get_mesh_lod_threshold(RID p_probe) const { | 
|---|
| 467 | return 0.0; | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | /* REFLECTION ATLAS */ | 
|---|
| 471 |  | 
|---|
| 472 | RID LightStorage::reflection_atlas_create() { | 
|---|
| 473 | return RID(); | 
|---|
| 474 | } | 
|---|
| 475 |  | 
|---|
| 476 | void LightStorage::reflection_atlas_free(RID p_ref_atlas) { | 
|---|
| 477 | } | 
|---|
| 478 |  | 
|---|
| 479 | int LightStorage::reflection_atlas_get_size(RID p_ref_atlas) const { | 
|---|
| 480 | return 0; | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 | void LightStorage::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) { | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | /* REFLECTION PROBE INSTANCE */ | 
|---|
| 487 |  | 
|---|
| 488 | RID LightStorage::reflection_probe_instance_create(RID p_probe) { | 
|---|
| 489 | return RID(); | 
|---|
| 490 | } | 
|---|
| 491 |  | 
|---|
| 492 | void LightStorage::reflection_probe_instance_free(RID p_instance) { | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | void LightStorage::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) { | 
|---|
| 496 | } | 
|---|
| 497 |  | 
|---|
| 498 | void LightStorage::reflection_probe_release_atlas_index(RID p_instance) { | 
|---|
| 499 | } | 
|---|
| 500 |  | 
|---|
| 501 | bool LightStorage::reflection_probe_instance_needs_redraw(RID p_instance) { | 
|---|
| 502 | return false; | 
|---|
| 503 | } | 
|---|
| 504 |  | 
|---|
| 505 | bool LightStorage::reflection_probe_instance_has_reflection(RID p_instance) { | 
|---|
| 506 | return false; | 
|---|
| 507 | } | 
|---|
| 508 |  | 
|---|
| 509 | bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { | 
|---|
| 510 | return false; | 
|---|
| 511 | } | 
|---|
| 512 |  | 
|---|
| 513 | Ref<RenderSceneBuffers> LightStorage::reflection_probe_atlas_get_render_buffers(RID p_reflection_atlas) { | 
|---|
| 514 | return Ref<RenderSceneBuffers>(); | 
|---|
| 515 | } | 
|---|
| 516 |  | 
|---|
| 517 | bool LightStorage::reflection_probe_instance_postprocess_step(RID p_instance) { | 
|---|
| 518 | return true; | 
|---|
| 519 | } | 
|---|
| 520 |  | 
|---|
| 521 | /* LIGHTMAP CAPTURE */ | 
|---|
| 522 |  | 
|---|
| 523 | RID LightStorage::lightmap_allocate() { | 
|---|
| 524 | return lightmap_owner.allocate_rid(); | 
|---|
| 525 | } | 
|---|
| 526 |  | 
|---|
| 527 | void LightStorage::lightmap_initialize(RID p_rid) { | 
|---|
| 528 | lightmap_owner.initialize_rid(p_rid, Lightmap()); | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | void LightStorage::lightmap_free(RID p_rid) { | 
|---|
| 532 | Lightmap *lightmap = lightmap_owner.get_or_null(p_rid); | 
|---|
| 533 | lightmap->dependency.deleted_notify(p_rid); | 
|---|
| 534 | lightmap_owner.free(p_rid); | 
|---|
| 535 | } | 
|---|
| 536 |  | 
|---|
| 537 | void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) { | 
|---|
| 538 | } | 
|---|
| 539 |  | 
|---|
| 540 | void LightStorage::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) { | 
|---|
| 541 | } | 
|---|
| 542 |  | 
|---|
| 543 | void LightStorage::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) { | 
|---|
| 544 | } | 
|---|
| 545 |  | 
|---|
| 546 | void LightStorage::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) { | 
|---|
| 547 | } | 
|---|
| 548 |  | 
|---|
| 549 | void LightStorage::lightmap_set_baked_exposure_normalization(RID p_lightmap, float p_exposure) { | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | PackedVector3Array LightStorage::lightmap_get_probe_capture_points(RID p_lightmap) const { | 
|---|
| 553 | return PackedVector3Array(); | 
|---|
| 554 | } | 
|---|
| 555 |  | 
|---|
| 556 | PackedColorArray LightStorage::lightmap_get_probe_capture_sh(RID p_lightmap) const { | 
|---|
| 557 | return PackedColorArray(); | 
|---|
| 558 | } | 
|---|
| 559 |  | 
|---|
| 560 | PackedInt32Array LightStorage::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const { | 
|---|
| 561 | return PackedInt32Array(); | 
|---|
| 562 | } | 
|---|
| 563 |  | 
|---|
| 564 | PackedInt32Array LightStorage::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const { | 
|---|
| 565 | return PackedInt32Array(); | 
|---|
| 566 | } | 
|---|
| 567 |  | 
|---|
| 568 | AABB LightStorage::lightmap_get_aabb(RID p_lightmap) const { | 
|---|
| 569 | return AABB(); | 
|---|
| 570 | } | 
|---|
| 571 |  | 
|---|
| 572 | void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) { | 
|---|
| 573 | } | 
|---|
| 574 |  | 
|---|
| 575 | bool LightStorage::lightmap_is_interior(RID p_lightmap) const { | 
|---|
| 576 | return false; | 
|---|
| 577 | } | 
|---|
| 578 |  | 
|---|
| 579 | void LightStorage::lightmap_set_probe_capture_update_speed(float p_speed) { | 
|---|
| 580 | } | 
|---|
| 581 |  | 
|---|
| 582 | float LightStorage::lightmap_get_probe_capture_update_speed() const { | 
|---|
| 583 | return 0; | 
|---|
| 584 | } | 
|---|
| 585 |  | 
|---|
| 586 | /* LIGHTMAP INSTANCE */ | 
|---|
| 587 |  | 
|---|
| 588 | RID LightStorage::lightmap_instance_create(RID p_lightmap) { | 
|---|
| 589 | return RID(); | 
|---|
| 590 | } | 
|---|
| 591 |  | 
|---|
| 592 | void LightStorage::lightmap_instance_free(RID p_lightmap) { | 
|---|
| 593 | } | 
|---|
| 594 |  | 
|---|
| 595 | void LightStorage::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) { | 
|---|
| 596 | } | 
|---|
| 597 |  | 
|---|
| 598 | /* SHADOW ATLAS API */ | 
|---|
| 599 |  | 
|---|
| 600 | RID LightStorage::shadow_atlas_create() { | 
|---|
| 601 | return RID(); | 
|---|
| 602 | } | 
|---|
| 603 |  | 
|---|
| 604 | void LightStorage::shadow_atlas_free(RID p_atlas) { | 
|---|
| 605 | } | 
|---|
| 606 |  | 
|---|
| 607 | void LightStorage::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) { | 
|---|
| 608 | } | 
|---|
| 609 |  | 
|---|
| 610 | void LightStorage::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) { | 
|---|
| 611 | } | 
|---|
| 612 |  | 
|---|
| 613 | bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { | 
|---|
| 614 | return false; | 
|---|
| 615 | } | 
|---|
| 616 |  | 
|---|
| 617 | void LightStorage::shadow_atlas_update(RID p_atlas) { | 
|---|
| 618 | } | 
|---|
| 619 |  | 
|---|
| 620 | void LightStorage::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) { | 
|---|
| 621 | } | 
|---|
| 622 |  | 
|---|
| 623 | int LightStorage::get_directional_light_shadow_size(RID p_light_intance) { | 
|---|
| 624 | return 0; | 
|---|
| 625 | } | 
|---|
| 626 |  | 
|---|
| 627 | void LightStorage::set_directional_shadow_count(int p_count) { | 
|---|
| 628 | } | 
|---|
| 629 |  | 
|---|
| 630 | #endif // !GLES3_ENABLED | 
|---|
| 631 |  | 
|---|