light.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*************************************************************************/
  2. /* light.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  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. #include "light.h"
  31. #include "core/engine.h"
  32. #include "core/project_settings.h"
  33. #include "scene/resources/surface_tool.h"
  34. bool Light::_can_gizmo_scale() const {
  35. return false;
  36. }
  37. void Light::set_param(Param p_param, float p_value) {
  38. ERR_FAIL_INDEX(p_param, PARAM_MAX);
  39. param[p_param] = p_value;
  40. VS::get_singleton()->light_set_param(light, VS::LightParam(p_param), p_value);
  41. if (p_param == PARAM_SPOT_ANGLE || p_param == PARAM_RANGE) {
  42. update_gizmo();
  43. if (p_param == PARAM_SPOT_ANGLE) {
  44. _change_notify("spot_angle");
  45. } else if (p_param == PARAM_RANGE) {
  46. _change_notify("omni_range");
  47. _change_notify("spot_range");
  48. }
  49. }
  50. }
  51. float Light::get_param(Param p_param) const {
  52. ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
  53. return param[p_param];
  54. }
  55. void Light::set_shadow(bool p_enable) {
  56. shadow = p_enable;
  57. VS::get_singleton()->light_set_shadow(light, p_enable);
  58. }
  59. bool Light::has_shadow() const {
  60. return shadow;
  61. }
  62. void Light::set_negative(bool p_enable) {
  63. negative = p_enable;
  64. VS::get_singleton()->light_set_negative(light, p_enable);
  65. }
  66. bool Light::is_negative() const {
  67. return negative;
  68. }
  69. void Light::set_cull_mask(uint32_t p_cull_mask) {
  70. cull_mask = p_cull_mask;
  71. VS::get_singleton()->light_set_cull_mask(light, p_cull_mask);
  72. }
  73. uint32_t Light::get_cull_mask() const {
  74. return cull_mask;
  75. }
  76. void Light::set_color(const Color &p_color) {
  77. color = p_color;
  78. VS::get_singleton()->light_set_color(light, p_color);
  79. }
  80. Color Light::get_color() const {
  81. return color;
  82. }
  83. void Light::set_shadow_color(const Color &p_shadow_color) {
  84. shadow_color = p_shadow_color;
  85. VS::get_singleton()->light_set_shadow_color(light, p_shadow_color);
  86. }
  87. Color Light::get_shadow_color() const {
  88. return shadow_color;
  89. }
  90. void Light::set_shadow_reverse_cull_face(bool p_enable) {
  91. reverse_cull = p_enable;
  92. VS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull);
  93. }
  94. bool Light::get_shadow_reverse_cull_face() const {
  95. return reverse_cull;
  96. }
  97. AABB Light::get_aabb() const {
  98. if (type == VisualServer::LIGHT_DIRECTIONAL) {
  99. return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
  100. } else if (type == VisualServer::LIGHT_OMNI) {
  101. return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
  102. } else if (type == VisualServer::LIGHT_SPOT) {
  103. float len = param[PARAM_RANGE];
  104. float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len;
  105. return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
  106. }
  107. return AABB();
  108. }
  109. PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
  110. return PoolVector<Face3>();
  111. }
  112. void Light::set_bake_mode(BakeMode p_mode) {
  113. bake_mode = p_mode;
  114. }
  115. Light::BakeMode Light::get_bake_mode() const {
  116. return bake_mode;
  117. }
  118. void Light::_update_visibility() {
  119. if (!is_inside_tree())
  120. return;
  121. bool editor_ok = true;
  122. #ifdef TOOLS_ENABLED
  123. if (editor_only) {
  124. if (!Engine::get_singleton()->is_editor_hint()) {
  125. editor_ok = false;
  126. } else {
  127. editor_ok = (get_tree()->get_edited_scene_root() && (this == get_tree()->get_edited_scene_root() || get_owner() == get_tree()->get_edited_scene_root()));
  128. }
  129. }
  130. #else
  131. if (editor_only) {
  132. editor_ok = false;
  133. }
  134. #endif
  135. VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok);
  136. _change_notify("geometry/visible");
  137. }
  138. void Light::_notification(int p_what) {
  139. if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
  140. _update_visibility();
  141. }
  142. if (p_what == NOTIFICATION_ENTER_TREE) {
  143. _update_visibility();
  144. }
  145. if (p_what == NOTIFICATION_EXIT_TREE) {
  146. }
  147. }
  148. void Light::set_editor_only(bool p_editor_only) {
  149. editor_only = p_editor_only;
  150. _update_visibility();
  151. }
  152. bool Light::is_editor_only() const {
  153. return editor_only;
  154. }
  155. void Light::_bind_methods() {
  156. ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light::set_editor_only);
  157. ClassDB::bind_method(D_METHOD("is_editor_only"), &Light::is_editor_only);
  158. ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &Light::set_param);
  159. ClassDB::bind_method(D_METHOD("get_param", "param"), &Light::get_param);
  160. ClassDB::bind_method(D_METHOD("set_shadow", "enabled"), &Light::set_shadow);
  161. ClassDB::bind_method(D_METHOD("has_shadow"), &Light::has_shadow);
  162. ClassDB::bind_method(D_METHOD("set_negative", "enabled"), &Light::set_negative);
  163. ClassDB::bind_method(D_METHOD("is_negative"), &Light::is_negative);
  164. ClassDB::bind_method(D_METHOD("set_cull_mask", "cull_mask"), &Light::set_cull_mask);
  165. ClassDB::bind_method(D_METHOD("get_cull_mask"), &Light::get_cull_mask);
  166. ClassDB::bind_method(D_METHOD("set_color", "color"), &Light::set_color);
  167. ClassDB::bind_method(D_METHOD("get_color"), &Light::get_color);
  168. ClassDB::bind_method(D_METHOD("set_shadow_reverse_cull_face", "enable"), &Light::set_shadow_reverse_cull_face);
  169. ClassDB::bind_method(D_METHOD("get_shadow_reverse_cull_face"), &Light::get_shadow_reverse_cull_face);
  170. ClassDB::bind_method(D_METHOD("set_shadow_color", "shadow_color"), &Light::set_shadow_color);
  171. ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light::get_shadow_color);
  172. ClassDB::bind_method(D_METHOD("set_bake_mode", "bake_mode"), &Light::set_bake_mode);
  173. ClassDB::bind_method(D_METHOD("get_bake_mode"), &Light::get_bake_mode);
  174. ADD_GROUP("Light", "light_");
  175. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color");
  176. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_ENERGY);
  177. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_indirect_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_INDIRECT_ENERGY);
  178. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_negative"), "set_negative", "is_negative");
  179. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SPECULAR);
  180. ADD_PROPERTY(PropertyInfo(Variant::INT, "light_bake_mode", PROPERTY_HINT_ENUM, "Disable,Indirect,All"), "set_bake_mode", "get_bake_mode");
  181. ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
  182. ADD_GROUP("Shadow", "shadow_");
  183. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow", "has_shadow");
  184. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color");
  185. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS);
  186. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE);
  187. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
  188. ADD_GROUP("Editor", "");
  189. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
  190. ADD_GROUP("", "");
  191. BIND_ENUM_CONSTANT(PARAM_ENERGY);
  192. BIND_ENUM_CONSTANT(PARAM_INDIRECT_ENERGY);
  193. BIND_ENUM_CONSTANT(PARAM_SPECULAR);
  194. BIND_ENUM_CONSTANT(PARAM_RANGE);
  195. BIND_ENUM_CONSTANT(PARAM_ATTENUATION);
  196. BIND_ENUM_CONSTANT(PARAM_SPOT_ANGLE);
  197. BIND_ENUM_CONSTANT(PARAM_SPOT_ATTENUATION);
  198. BIND_ENUM_CONSTANT(PARAM_CONTACT_SHADOW_SIZE);
  199. BIND_ENUM_CONSTANT(PARAM_SHADOW_MAX_DISTANCE);
  200. BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_1_OFFSET);
  201. BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_2_OFFSET);
  202. BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_3_OFFSET);
  203. BIND_ENUM_CONSTANT(PARAM_SHADOW_NORMAL_BIAS);
  204. BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS);
  205. BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS_SPLIT_SCALE);
  206. BIND_ENUM_CONSTANT(PARAM_MAX);
  207. BIND_ENUM_CONSTANT(BAKE_DISABLED);
  208. BIND_ENUM_CONSTANT(BAKE_INDIRECT);
  209. BIND_ENUM_CONSTANT(BAKE_ALL);
  210. }
  211. Light::Light(VisualServer::LightType p_type) {
  212. type = p_type;
  213. switch (p_type) {
  214. case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break;
  215. case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break;
  216. case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break;
  217. default: {};
  218. }
  219. VS::get_singleton()->instance_set_base(get_instance(), light);
  220. reverse_cull = false;
  221. bake_mode = BAKE_INDIRECT;
  222. editor_only = false;
  223. set_color(Color(1, 1, 1, 1));
  224. set_shadow(false);
  225. set_negative(false);
  226. set_cull_mask(0xFFFFFFFF);
  227. set_param(PARAM_ENERGY, 1);
  228. set_param(PARAM_INDIRECT_ENERGY, 1);
  229. set_param(PARAM_SPECULAR, 0.5);
  230. set_param(PARAM_RANGE, 5);
  231. set_param(PARAM_ATTENUATION, 1);
  232. set_param(PARAM_SPOT_ANGLE, 45);
  233. set_param(PARAM_SPOT_ATTENUATION, 1);
  234. set_param(PARAM_CONTACT_SHADOW_SIZE, 0);
  235. set_param(PARAM_SHADOW_MAX_DISTANCE, 0);
  236. set_param(PARAM_SHADOW_SPLIT_1_OFFSET, 0.1);
  237. set_param(PARAM_SHADOW_SPLIT_2_OFFSET, 0.2);
  238. set_param(PARAM_SHADOW_SPLIT_3_OFFSET, 0.5);
  239. set_param(PARAM_SHADOW_NORMAL_BIAS, 0.0);
  240. set_param(PARAM_SHADOW_BIAS, 0.15);
  241. set_disable_scale(true);
  242. }
  243. Light::Light() {
  244. type = VisualServer::LIGHT_DIRECTIONAL;
  245. ERR_PRINT("Light should not be instanced directly; use the DirectionalLight, OmniLight or SpotLight subtypes instead.");
  246. }
  247. Light::~Light() {
  248. VS::get_singleton()->instance_set_base(get_instance(), RID());
  249. if (light.is_valid())
  250. VisualServer::get_singleton()->free(light);
  251. }
  252. /////////////////////////////////////////
  253. void DirectionalLight::set_shadow_mode(ShadowMode p_mode) {
  254. shadow_mode = p_mode;
  255. VS::get_singleton()->light_directional_set_shadow_mode(light, VS::LightDirectionalShadowMode(p_mode));
  256. }
  257. DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
  258. return shadow_mode;
  259. }
  260. void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) {
  261. shadow_depth_range = p_range;
  262. VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range));
  263. }
  264. DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const {
  265. return shadow_depth_range;
  266. }
  267. void DirectionalLight::set_blend_splits(bool p_enable) {
  268. blend_splits = p_enable;
  269. VS::get_singleton()->light_directional_set_blend_splits(light, p_enable);
  270. }
  271. bool DirectionalLight::is_blend_splits_enabled() const {
  272. return blend_splits;
  273. }
  274. void DirectionalLight::_bind_methods() {
  275. ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode);
  276. ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode);
  277. ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range);
  278. ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range);
  279. ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits);
  280. ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled);
  281. ADD_GROUP("Directional Shadow", "directional_shadow_");
  282. ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_mode", PROPERTY_HINT_ENUM, "Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), "set_shadow_mode", "get_shadow_mode");
  283. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_split_1", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_1_OFFSET);
  284. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_split_2", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_2_OFFSET);
  285. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
  286. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled");
  287. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS);
  288. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE);
  289. ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range");
  290. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_max_distance", PROPERTY_HINT_EXP_RANGE, "0,8192,0.1,or_greater"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
  291. BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL);
  292. BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
  293. BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
  294. BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_STABLE);
  295. BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_OPTIMIZED);
  296. }
  297. DirectionalLight::DirectionalLight() :
  298. Light(VisualServer::LIGHT_DIRECTIONAL) {
  299. set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8);
  300. set_param(PARAM_SHADOW_BIAS, 0.1);
  301. set_param(PARAM_SHADOW_MAX_DISTANCE, 200);
  302. set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25);
  303. set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
  304. set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE);
  305. blend_splits = false;
  306. }
  307. void OmniLight::set_shadow_mode(ShadowMode p_mode) {
  308. shadow_mode = p_mode;
  309. VS::get_singleton()->light_omni_set_shadow_mode(light, VS::LightOmniShadowMode(p_mode));
  310. }
  311. OmniLight::ShadowMode OmniLight::get_shadow_mode() const {
  312. return shadow_mode;
  313. }
  314. void OmniLight::set_shadow_detail(ShadowDetail p_detail) {
  315. shadow_detail = p_detail;
  316. VS::get_singleton()->light_omni_set_shadow_detail(light, VS::LightOmniShadowDetail(p_detail));
  317. }
  318. OmniLight::ShadowDetail OmniLight::get_shadow_detail() const {
  319. return shadow_detail;
  320. }
  321. void OmniLight::_bind_methods() {
  322. ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &OmniLight::set_shadow_mode);
  323. ClassDB::bind_method(D_METHOD("get_shadow_mode"), &OmniLight::get_shadow_mode);
  324. ClassDB::bind_method(D_METHOD("set_shadow_detail", "detail"), &OmniLight::set_shadow_detail);
  325. ClassDB::bind_method(D_METHOD("get_shadow_detail"), &OmniLight::get_shadow_detail);
  326. ADD_GROUP("Omni", "omni_");
  327. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "omni_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE);
  328. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "omni_attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_param", "get_param", PARAM_ATTENUATION);
  329. ADD_PROPERTY(PropertyInfo(Variant::INT, "omni_shadow_mode", PROPERTY_HINT_ENUM, "Dual Paraboloid,Cube"), "set_shadow_mode", "get_shadow_mode");
  330. ADD_PROPERTY(PropertyInfo(Variant::INT, "omni_shadow_detail", PROPERTY_HINT_ENUM, "Vertical,Horizontal"), "set_shadow_detail", "get_shadow_detail");
  331. BIND_ENUM_CONSTANT(SHADOW_DUAL_PARABOLOID);
  332. BIND_ENUM_CONSTANT(SHADOW_CUBE);
  333. BIND_ENUM_CONSTANT(SHADOW_DETAIL_VERTICAL);
  334. BIND_ENUM_CONSTANT(SHADOW_DETAIL_HORIZONTAL);
  335. }
  336. OmniLight::OmniLight() :
  337. Light(VisualServer::LIGHT_OMNI) {
  338. set_shadow_mode(SHADOW_CUBE);
  339. set_shadow_detail(SHADOW_DETAIL_HORIZONTAL);
  340. }
  341. void SpotLight::_bind_methods() {
  342. ADD_GROUP("Spot", "spot_");
  343. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "spot_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE);
  344. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "spot_attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_param", "get_param", PARAM_ATTENUATION);
  345. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "spot_angle", PROPERTY_HINT_RANGE, "0,180,0.1"), "set_param", "get_param", PARAM_SPOT_ANGLE);
  346. ADD_PROPERTYI(PropertyInfo(Variant::REAL, "spot_angle_attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_param", "get_param", PARAM_SPOT_ATTENUATION);
  347. }