2
0

light_storage.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. #ifdef GLES3_ENABLED
  31. #include "light_storage.h"
  32. #include "config.h"
  33. #include "texture_storage.h"
  34. using namespace GLES3;
  35. LightStorage *LightStorage::singleton = nullptr;
  36. LightStorage *LightStorage::get_singleton() {
  37. return singleton;
  38. }
  39. LightStorage::LightStorage() {
  40. singleton = this;
  41. }
  42. LightStorage::~LightStorage() {
  43. singleton = nullptr;
  44. }
  45. /* Light API */
  46. void LightStorage::_light_initialize(RID p_light, RS::LightType p_type) {
  47. Light light;
  48. light.type = p_type;
  49. light.param[RS::LIGHT_PARAM_ENERGY] = 1.0;
  50. light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
  51. light.param[RS::LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY] = 1.0;
  52. light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5;
  53. light.param[RS::LIGHT_PARAM_RANGE] = 1.0;
  54. light.param[RS::LIGHT_PARAM_SIZE] = 0.0;
  55. light.param[RS::LIGHT_PARAM_ATTENUATION] = 1.0;
  56. light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45;
  57. light.param[RS::LIGHT_PARAM_SPOT_ATTENUATION] = 1.0;
  58. light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
  59. light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
  60. light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
  61. light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
  62. light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
  63. light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 1.0;
  64. light.param[RS::LIGHT_PARAM_SHADOW_OPACITY] = 1.0;
  65. light.param[RS::LIGHT_PARAM_SHADOW_BIAS] = 0.02;
  66. light.param[RS::LIGHT_PARAM_SHADOW_BLUR] = 0;
  67. light.param[RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE] = 20.0;
  68. light.param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] = 0.05;
  69. light_owner.initialize_rid(p_light, light);
  70. }
  71. RID LightStorage::directional_light_allocate() {
  72. return light_owner.allocate_rid();
  73. }
  74. void LightStorage::directional_light_initialize(RID p_rid) {
  75. _light_initialize(p_rid, RS::LIGHT_DIRECTIONAL);
  76. }
  77. RID LightStorage::omni_light_allocate() {
  78. return light_owner.allocate_rid();
  79. }
  80. void LightStorage::omni_light_initialize(RID p_rid) {
  81. _light_initialize(p_rid, RS::LIGHT_OMNI);
  82. }
  83. RID LightStorage::spot_light_allocate() {
  84. return light_owner.allocate_rid();
  85. }
  86. void LightStorage::spot_light_initialize(RID p_rid) {
  87. _light_initialize(p_rid, RS::LIGHT_SPOT);
  88. }
  89. void LightStorage::light_free(RID p_rid) {
  90. light_set_projector(p_rid, RID()); //clear projector
  91. // delete the texture
  92. Light *light = light_owner.get_or_null(p_rid);
  93. light->dependency.deleted_notify(p_rid);
  94. light_owner.free(p_rid);
  95. }
  96. void LightStorage::light_set_color(RID p_light, const Color &p_color) {
  97. Light *light = light_owner.get_or_null(p_light);
  98. ERR_FAIL_COND(!light);
  99. light->color = p_color;
  100. }
  101. void LightStorage::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
  102. Light *light = light_owner.get_or_null(p_light);
  103. ERR_FAIL_COND(!light);
  104. ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
  105. if (light->param[p_param] == p_value) {
  106. return;
  107. }
  108. switch (p_param) {
  109. case RS::LIGHT_PARAM_RANGE:
  110. case RS::LIGHT_PARAM_SPOT_ANGLE:
  111. case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
  112. case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
  113. case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
  114. case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
  115. case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
  116. case RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE:
  117. case RS::LIGHT_PARAM_SHADOW_BIAS: {
  118. light->version++;
  119. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  120. } break;
  121. case RS::LIGHT_PARAM_SIZE: {
  122. if ((light->param[p_param] > CMP_EPSILON) != (p_value > CMP_EPSILON)) {
  123. //changing from no size to size and the opposite
  124. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
  125. }
  126. } break;
  127. default: {
  128. }
  129. }
  130. light->param[p_param] = p_value;
  131. }
  132. void LightStorage::light_set_shadow(RID p_light, bool p_enabled) {
  133. Light *light = light_owner.get_or_null(p_light);
  134. ERR_FAIL_COND(!light);
  135. light->shadow = p_enabled;
  136. light->version++;
  137. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  138. }
  139. void LightStorage::light_set_projector(RID p_light, RID p_texture) {
  140. GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
  141. Light *light = light_owner.get_or_null(p_light);
  142. ERR_FAIL_COND(!light);
  143. if (light->projector == p_texture) {
  144. return;
  145. }
  146. if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) {
  147. texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
  148. }
  149. light->projector = p_texture;
  150. if (light->type != RS::LIGHT_DIRECTIONAL) {
  151. if (light->projector.is_valid()) {
  152. texture_storage->texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI);
  153. }
  154. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR);
  155. }
  156. }
  157. void LightStorage::light_set_negative(RID p_light, bool p_enable) {
  158. Light *light = light_owner.get_or_null(p_light);
  159. ERR_FAIL_COND(!light);
  160. light->negative = p_enable;
  161. }
  162. void LightStorage::light_set_cull_mask(RID p_light, uint32_t p_mask) {
  163. Light *light = light_owner.get_or_null(p_light);
  164. ERR_FAIL_COND(!light);
  165. light->cull_mask = p_mask;
  166. light->version++;
  167. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  168. }
  169. void LightStorage::light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) {
  170. Light *light = light_owner.get_or_null(p_light);
  171. ERR_FAIL_COND(!light);
  172. light->distance_fade = p_enabled;
  173. light->distance_fade_begin = p_begin;
  174. light->distance_fade_shadow = p_shadow;
  175. light->distance_fade_length = p_length;
  176. }
  177. void LightStorage::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
  178. Light *light = light_owner.get_or_null(p_light);
  179. ERR_FAIL_COND(!light);
  180. light->reverse_cull = p_enabled;
  181. light->version++;
  182. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  183. }
  184. void LightStorage::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
  185. Light *light = light_owner.get_or_null(p_light);
  186. ERR_FAIL_COND(!light);
  187. light->bake_mode = p_bake_mode;
  188. light->version++;
  189. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  190. }
  191. void LightStorage::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
  192. Light *light = light_owner.get_or_null(p_light);
  193. ERR_FAIL_COND(!light);
  194. light->omni_shadow_mode = p_mode;
  195. light->version++;
  196. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  197. }
  198. RS::LightOmniShadowMode LightStorage::light_omni_get_shadow_mode(RID p_light) {
  199. const Light *light = light_owner.get_or_null(p_light);
  200. ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
  201. return light->omni_shadow_mode;
  202. }
  203. void LightStorage::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
  204. Light *light = light_owner.get_or_null(p_light);
  205. ERR_FAIL_COND(!light);
  206. light->directional_shadow_mode = p_mode;
  207. light->version++;
  208. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  209. }
  210. void LightStorage::light_directional_set_blend_splits(RID p_light, bool p_enable) {
  211. Light *light = light_owner.get_or_null(p_light);
  212. ERR_FAIL_COND(!light);
  213. light->directional_blend_splits = p_enable;
  214. light->version++;
  215. light->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_LIGHT);
  216. }
  217. bool LightStorage::light_directional_get_blend_splits(RID p_light) const {
  218. const Light *light = light_owner.get_or_null(p_light);
  219. ERR_FAIL_COND_V(!light, false);
  220. return light->directional_blend_splits;
  221. }
  222. void LightStorage::light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) {
  223. Light *light = light_owner.get_or_null(p_light);
  224. ERR_FAIL_COND(!light);
  225. light->directional_sky_mode = p_mode;
  226. }
  227. RS::LightDirectionalSkyMode LightStorage::light_directional_get_sky_mode(RID p_light) const {
  228. const Light *light = light_owner.get_or_null(p_light);
  229. ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
  230. return light->directional_sky_mode;
  231. }
  232. RS::LightDirectionalShadowMode LightStorage::light_directional_get_shadow_mode(RID p_light) {
  233. const Light *light = light_owner.get_or_null(p_light);
  234. ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
  235. return light->directional_shadow_mode;
  236. }
  237. RS::LightBakeMode LightStorage::light_get_bake_mode(RID p_light) {
  238. const Light *light = light_owner.get_or_null(p_light);
  239. ERR_FAIL_COND_V(!light, RS::LIGHT_BAKE_DISABLED);
  240. return light->bake_mode;
  241. }
  242. uint64_t LightStorage::light_get_version(RID p_light) const {
  243. const Light *light = light_owner.get_or_null(p_light);
  244. ERR_FAIL_COND_V(!light, 0);
  245. return light->version;
  246. }
  247. uint32_t LightStorage::light_get_cull_mask(RID p_light) const {
  248. const Light *light = light_owner.get_or_null(p_light);
  249. ERR_FAIL_COND_V(!light, 0);
  250. return light->cull_mask;
  251. }
  252. AABB LightStorage::light_get_aabb(RID p_light) const {
  253. const Light *light = light_owner.get_or_null(p_light);
  254. ERR_FAIL_COND_V(!light, AABB());
  255. switch (light->type) {
  256. case RS::LIGHT_SPOT: {
  257. float len = light->param[RS::LIGHT_PARAM_RANGE];
  258. float size = Math::tan(Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
  259. return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
  260. };
  261. case RS::LIGHT_OMNI: {
  262. float r = light->param[RS::LIGHT_PARAM_RANGE];
  263. return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
  264. };
  265. case RS::LIGHT_DIRECTIONAL: {
  266. return AABB();
  267. };
  268. }
  269. ERR_FAIL_V(AABB());
  270. }
  271. /* LIGHT INSTANCE API */
  272. RID LightStorage::light_instance_create(RID p_light) {
  273. RID li = light_instance_owner.make_rid(LightInstance());
  274. LightInstance *light_instance = light_instance_owner.get_or_null(li);
  275. light_instance->self = li;
  276. light_instance->light = p_light;
  277. light_instance->light_type = light_get_type(p_light);
  278. return li;
  279. }
  280. void LightStorage::light_instance_free(RID p_light_instance) {
  281. LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
  282. ERR_FAIL_COND(!light_instance);
  283. light_instance_owner.free(p_light_instance);
  284. }
  285. void LightStorage::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
  286. LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
  287. ERR_FAIL_COND(!light_instance);
  288. light_instance->transform = p_transform;
  289. }
  290. void LightStorage::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
  291. LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
  292. ERR_FAIL_COND(!light_instance);
  293. light_instance->aabb = p_aabb;
  294. }
  295. 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) {
  296. }
  297. void LightStorage::light_instance_mark_visible(RID p_light_instance) {
  298. }
  299. /* PROBE API */
  300. RID LightStorage::reflection_probe_allocate() {
  301. return RID();
  302. }
  303. void LightStorage::reflection_probe_initialize(RID p_rid) {
  304. }
  305. void LightStorage::reflection_probe_free(RID p_rid) {
  306. }
  307. void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
  308. }
  309. void LightStorage::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
  310. }
  311. void LightStorage::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
  312. }
  313. void LightStorage::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) {
  314. }
  315. void LightStorage::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) {
  316. }
  317. void LightStorage::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
  318. }
  319. void LightStorage::reflection_probe_set_size(RID p_probe, const Vector3 &p_size) {
  320. }
  321. void LightStorage::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
  322. }
  323. void LightStorage::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
  324. }
  325. void LightStorage::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
  326. }
  327. void LightStorage::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
  328. }
  329. void LightStorage::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
  330. }
  331. void LightStorage::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
  332. }
  333. AABB LightStorage::reflection_probe_get_aabb(RID p_probe) const {
  334. return AABB();
  335. }
  336. RS::ReflectionProbeUpdateMode LightStorage::reflection_probe_get_update_mode(RID p_probe) const {
  337. return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE;
  338. }
  339. uint32_t LightStorage::reflection_probe_get_cull_mask(RID p_probe) const {
  340. return 0;
  341. }
  342. Vector3 LightStorage::reflection_probe_get_size(RID p_probe) const {
  343. return Vector3();
  344. }
  345. Vector3 LightStorage::reflection_probe_get_origin_offset(RID p_probe) const {
  346. return Vector3();
  347. }
  348. float LightStorage::reflection_probe_get_origin_max_distance(RID p_probe) const {
  349. return 0.0;
  350. }
  351. bool LightStorage::reflection_probe_renders_shadows(RID p_probe) const {
  352. return false;
  353. }
  354. void LightStorage::reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_ratio) {
  355. }
  356. float LightStorage::reflection_probe_get_mesh_lod_threshold(RID p_probe) const {
  357. return 0.0;
  358. }
  359. /* REFLECTION ATLAS */
  360. RID LightStorage::reflection_atlas_create() {
  361. return RID();
  362. }
  363. void LightStorage::reflection_atlas_free(RID p_ref_atlas) {
  364. }
  365. int LightStorage::reflection_atlas_get_size(RID p_ref_atlas) const {
  366. return 0;
  367. }
  368. void LightStorage::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
  369. }
  370. /* REFLECTION PROBE INSTANCE */
  371. RID LightStorage::reflection_probe_instance_create(RID p_probe) {
  372. return RID();
  373. }
  374. void LightStorage::reflection_probe_instance_free(RID p_instance) {
  375. }
  376. void LightStorage::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
  377. }
  378. void LightStorage::reflection_probe_release_atlas_index(RID p_instance) {
  379. }
  380. bool LightStorage::reflection_probe_instance_needs_redraw(RID p_instance) {
  381. return false;
  382. }
  383. bool LightStorage::reflection_probe_instance_has_reflection(RID p_instance) {
  384. return false;
  385. }
  386. bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
  387. return false;
  388. }
  389. Ref<RenderSceneBuffers> LightStorage::reflection_probe_atlas_get_render_buffers(RID p_reflection_atlas) {
  390. return Ref<RenderSceneBuffers>();
  391. }
  392. bool LightStorage::reflection_probe_instance_postprocess_step(RID p_instance) {
  393. return true;
  394. }
  395. /* LIGHTMAP CAPTURE */
  396. RID LightStorage::lightmap_allocate() {
  397. return lightmap_owner.allocate_rid();
  398. }
  399. void LightStorage::lightmap_initialize(RID p_rid) {
  400. lightmap_owner.initialize_rid(p_rid, Lightmap());
  401. }
  402. void LightStorage::lightmap_free(RID p_rid) {
  403. Lightmap *lightmap = lightmap_owner.get_or_null(p_rid);
  404. lightmap->dependency.deleted_notify(p_rid);
  405. lightmap_owner.free(p_rid);
  406. }
  407. void LightStorage::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
  408. }
  409. void LightStorage::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) {
  410. }
  411. void LightStorage::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
  412. }
  413. 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) {
  414. }
  415. void LightStorage::lightmap_set_baked_exposure_normalization(RID p_lightmap, float p_exposure) {
  416. }
  417. PackedVector3Array LightStorage::lightmap_get_probe_capture_points(RID p_lightmap) const {
  418. return PackedVector3Array();
  419. }
  420. PackedColorArray LightStorage::lightmap_get_probe_capture_sh(RID p_lightmap) const {
  421. return PackedColorArray();
  422. }
  423. PackedInt32Array LightStorage::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
  424. return PackedInt32Array();
  425. }
  426. PackedInt32Array LightStorage::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
  427. return PackedInt32Array();
  428. }
  429. AABB LightStorage::lightmap_get_aabb(RID p_lightmap) const {
  430. return AABB();
  431. }
  432. void LightStorage::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
  433. }
  434. bool LightStorage::lightmap_is_interior(RID p_lightmap) const {
  435. return false;
  436. }
  437. void LightStorage::lightmap_set_probe_capture_update_speed(float p_speed) {
  438. }
  439. float LightStorage::lightmap_get_probe_capture_update_speed() const {
  440. return 0;
  441. }
  442. /* LIGHTMAP INSTANCE */
  443. RID LightStorage::lightmap_instance_create(RID p_lightmap) {
  444. return RID();
  445. }
  446. void LightStorage::lightmap_instance_free(RID p_lightmap) {
  447. }
  448. void LightStorage::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
  449. }
  450. /* LIGHT SHADOW MAPPING */
  451. /*
  452. RID LightStorage::canvas_light_occluder_create() {
  453. CanvasOccluder *co = memnew(CanvasOccluder);
  454. co->index_id = 0;
  455. co->vertex_id = 0;
  456. co->len = 0;
  457. return canvas_occluder_owner.make_rid(co);
  458. }
  459. void LightStorage::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
  460. CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
  461. ERR_FAIL_COND(!co);
  462. co->lines = p_lines;
  463. if (p_lines.size() != co->len) {
  464. if (co->index_id) {
  465. glDeleteBuffers(1, &co->index_id);
  466. } if (co->vertex_id) {
  467. glDeleteBuffers(1, &co->vertex_id);
  468. }
  469. co->index_id = 0;
  470. co->vertex_id = 0;
  471. co->len = 0;
  472. }
  473. if (p_lines.size()) {
  474. PoolVector<float> geometry;
  475. PoolVector<uint16_t> indices;
  476. int lc = p_lines.size();
  477. geometry.resize(lc * 6);
  478. indices.resize(lc * 3);
  479. PoolVector<float>::Write vw = geometry.write();
  480. PoolVector<uint16_t>::Write iw = indices.write();
  481. PoolVector<Vector2>::Read lr = p_lines.read();
  482. const int POLY_HEIGHT = 16384;
  483. for (int i = 0; i < lc / 2; i++) {
  484. vw[i * 12 + 0] = lr[i * 2 + 0].x;
  485. vw[i * 12 + 1] = lr[i * 2 + 0].y;
  486. vw[i * 12 + 2] = POLY_HEIGHT;
  487. vw[i * 12 + 3] = lr[i * 2 + 1].x;
  488. vw[i * 12 + 4] = lr[i * 2 + 1].y;
  489. vw[i * 12 + 5] = POLY_HEIGHT;
  490. vw[i * 12 + 6] = lr[i * 2 + 1].x;
  491. vw[i * 12 + 7] = lr[i * 2 + 1].y;
  492. vw[i * 12 + 8] = -POLY_HEIGHT;
  493. vw[i * 12 + 9] = lr[i * 2 + 0].x;
  494. vw[i * 12 + 10] = lr[i * 2 + 0].y;
  495. vw[i * 12 + 11] = -POLY_HEIGHT;
  496. iw[i * 6 + 0] = i * 4 + 0;
  497. iw[i * 6 + 1] = i * 4 + 1;
  498. iw[i * 6 + 2] = i * 4 + 2;
  499. iw[i * 6 + 3] = i * 4 + 2;
  500. iw[i * 6 + 4] = i * 4 + 3;
  501. iw[i * 6 + 5] = i * 4 + 0;
  502. }
  503. //if same buffer len is being set, just use BufferSubData to avoid a pipeline flush
  504. if (!co->vertex_id) {
  505. glGenBuffers(1, &co->vertex_id);
  506. glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
  507. glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW);
  508. } else {
  509. glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
  510. glBufferSubData(GL_ARRAY_BUFFER, 0, lc * 6 * sizeof(real_t), vw.ptr());
  511. }
  512. glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
  513. if (!co->index_id) {
  514. glGenBuffers(1, &co->index_id);
  515. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
  516. glBufferData(GL_ELEMENT_ARRAY_BUFFER, lc * 3 * sizeof(uint16_t), iw.ptr(), GL_DYNAMIC_DRAW);
  517. } else {
  518. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
  519. glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, lc * 3 * sizeof(uint16_t), iw.ptr());
  520. }
  521. glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //unbind
  522. co->len = lc;
  523. }
  524. }
  525. */
  526. /* SHADOW ATLAS API */
  527. RID LightStorage::shadow_atlas_create() {
  528. return RID();
  529. }
  530. void LightStorage::shadow_atlas_free(RID p_atlas) {
  531. }
  532. void LightStorage::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
  533. }
  534. void LightStorage::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
  535. }
  536. bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
  537. return false;
  538. }
  539. void LightStorage::shadow_atlas_update(RID p_atlas) {
  540. }
  541. void LightStorage::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) {
  542. }
  543. int LightStorage::get_directional_light_shadow_size(RID p_light_intance) {
  544. return 0;
  545. }
  546. void LightStorage::set_directional_shadow_count(int p_count) {
  547. }
  548. #endif // !GLES3_ENABLED