visual_server.cpp 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418
  1. /*************************************************************************/
  2. /* visual_server.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 "visual_server.h"
  31. #include "core/method_bind_ext.gen.inc"
  32. #include "core/project_settings.h"
  33. VisualServer *VisualServer::singleton = NULL;
  34. VisualServer *(*VisualServer::create_func)() = NULL;
  35. VisualServer *VisualServer::get_singleton() {
  36. return singleton;
  37. }
  38. VisualServer *VisualServer::create() {
  39. ERR_FAIL_COND_V(singleton, NULL);
  40. if (create_func)
  41. return create_func();
  42. return NULL;
  43. }
  44. RID VisualServer::texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
  45. ERR_FAIL_COND_V(!p_image.is_valid(), RID());
  46. RID texture = texture_create();
  47. texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags); //if it has mipmaps, use, else generate
  48. ERR_FAIL_COND_V(!texture.is_valid(), texture);
  49. texture_set_data(texture, p_image);
  50. return texture;
  51. }
  52. Array VisualServer::_texture_debug_usage_bind() {
  53. List<TextureInfo> list;
  54. texture_debug_usage(&list);
  55. Array arr;
  56. for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) {
  57. Dictionary dict;
  58. dict["texture"] = E->get().texture;
  59. dict["width"] = E->get().width;
  60. dict["height"] = E->get().height;
  61. dict["depth"] = E->get().depth;
  62. dict["format"] = E->get().format;
  63. dict["bytes"] = E->get().bytes;
  64. dict["path"] = E->get().path;
  65. arr.push_back(dict);
  66. }
  67. return arr;
  68. }
  69. Array VisualServer::_shader_get_param_list_bind(RID p_shader) const {
  70. List<PropertyInfo> l;
  71. shader_get_param_list(p_shader, &l);
  72. return convert_property_list(&l);
  73. }
  74. static Array to_array(const Vector<ObjectID> &ids) {
  75. Array a;
  76. a.resize(ids.size());
  77. for (int i = 0; i < ids.size(); ++i) {
  78. a[i] = ids[i];
  79. }
  80. return a;
  81. }
  82. Array VisualServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
  83. Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
  84. return to_array(ids);
  85. }
  86. Array VisualServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
  87. Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
  88. return to_array(ids);
  89. }
  90. Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const {
  91. Vector<Plane> planes;
  92. for (int i = 0; i < p_convex.size(); ++i) {
  93. Variant v = p_convex[i];
  94. ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, Array());
  95. planes.push_back(v);
  96. }
  97. Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);
  98. return to_array(ids);
  99. }
  100. RID VisualServer::get_test_texture() {
  101. if (test_texture.is_valid()) {
  102. return test_texture;
  103. };
  104. #define TEST_TEXTURE_SIZE 256
  105. PoolVector<uint8_t> test_data;
  106. test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);
  107. {
  108. PoolVector<uint8_t>::Write w = test_data.write();
  109. for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {
  110. for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {
  111. Color c;
  112. int r = 255 - (x + y) / 2;
  113. if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {
  114. c.r = y;
  115. c.g = r;
  116. c.b = x;
  117. } else {
  118. c.r = r;
  119. c.g = x;
  120. c.b = y;
  121. }
  122. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r * 255, 0, 255));
  123. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g * 255, 0, 255));
  124. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b * 255, 0, 255));
  125. }
  126. }
  127. }
  128. Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));
  129. test_texture = texture_create_from_image(data);
  130. return test_texture;
  131. }
  132. void VisualServer::_free_internal_rids() {
  133. if (test_texture.is_valid())
  134. free(test_texture);
  135. if (white_texture.is_valid())
  136. free(white_texture);
  137. if (test_material.is_valid())
  138. free(test_material);
  139. }
  140. RID VisualServer::_make_test_cube() {
  141. PoolVector<Vector3> vertices;
  142. PoolVector<Vector3> normals;
  143. PoolVector<float> tangents;
  144. PoolVector<Vector3> uvs;
  145. #define ADD_VTX(m_idx) \
  146. vertices.push_back(face_points[m_idx]); \
  147. normals.push_back(normal_points[m_idx]); \
  148. tangents.push_back(normal_points[m_idx][1]); \
  149. tangents.push_back(normal_points[m_idx][2]); \
  150. tangents.push_back(normal_points[m_idx][0]); \
  151. tangents.push_back(1.0); \
  152. uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
  153. for (int i = 0; i < 6; i++) {
  154. Vector3 face_points[4];
  155. Vector3 normal_points[4];
  156. float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
  157. for (int j = 0; j < 4; j++) {
  158. float v[3];
  159. v[0] = 1.0;
  160. v[1] = 1 - 2 * ((j >> 1) & 1);
  161. v[2] = v[1] * (1 - 2 * (j & 1));
  162. for (int k = 0; k < 3; k++) {
  163. if (i < 3)
  164. face_points[j][(i + k) % 3] = v[k];
  165. else
  166. face_points[3 - j][(i + k) % 3] = -v[k];
  167. }
  168. normal_points[j] = Vector3();
  169. normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
  170. }
  171. //tri 1
  172. ADD_VTX(0);
  173. ADD_VTX(1);
  174. ADD_VTX(2);
  175. //tri 2
  176. ADD_VTX(2);
  177. ADD_VTX(3);
  178. ADD_VTX(0);
  179. }
  180. RID test_cube = mesh_create();
  181. Array d;
  182. d.resize(VS::ARRAY_MAX);
  183. d[VisualServer::ARRAY_NORMAL] = normals;
  184. d[VisualServer::ARRAY_TANGENT] = tangents;
  185. d[VisualServer::ARRAY_TEX_UV] = uvs;
  186. d[VisualServer::ARRAY_VERTEX] = vertices;
  187. PoolVector<int> indices;
  188. indices.resize(vertices.size());
  189. for (int i = 0; i < vertices.size(); i++)
  190. indices.set(i, i);
  191. d[VisualServer::ARRAY_INDEX] = indices;
  192. mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
  193. /*
  194. test_material = fixed_material_create();
  195. //material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
  196. fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
  197. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
  198. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
  199. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
  200. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
  201. */
  202. mesh_surface_set_material(test_cube, 0, test_material);
  203. return test_cube;
  204. }
  205. RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
  206. PoolVector<Vector3> vertices;
  207. PoolVector<Vector3> normals;
  208. for (int i = 1; i <= p_lats; i++) {
  209. double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
  210. double z0 = Math::sin(lat0);
  211. double zr0 = Math::cos(lat0);
  212. double lat1 = Math_PI * (-0.5 + (double)i / p_lats);
  213. double z1 = Math::sin(lat1);
  214. double zr1 = Math::cos(lat1);
  215. for (int j = p_lons; j >= 1; j--) {
  216. double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
  217. double x0 = Math::cos(lng0);
  218. double y0 = Math::sin(lng0);
  219. double lng1 = 2 * Math_PI * (double)(j) / p_lons;
  220. double x1 = Math::cos(lng1);
  221. double y1 = Math::sin(lng1);
  222. Vector3 v[4] = {
  223. Vector3(x1 * zr0, z0, y1 * zr0),
  224. Vector3(x1 * zr1, z1, y1 * zr1),
  225. Vector3(x0 * zr1, z1, y0 * zr1),
  226. Vector3(x0 * zr0, z0, y0 * zr0)
  227. };
  228. #define ADD_POINT(m_idx) \
  229. normals.push_back(v[m_idx]); \
  230. vertices.push_back(v[m_idx] * p_radius);
  231. ADD_POINT(0);
  232. ADD_POINT(1);
  233. ADD_POINT(2);
  234. ADD_POINT(2);
  235. ADD_POINT(3);
  236. ADD_POINT(0);
  237. }
  238. }
  239. RID mesh = mesh_create();
  240. Array d;
  241. d.resize(VS::ARRAY_MAX);
  242. d[ARRAY_VERTEX] = vertices;
  243. d[ARRAY_NORMAL] = normals;
  244. mesh_add_surface_from_arrays(mesh, PRIMITIVE_TRIANGLES, d);
  245. return mesh;
  246. }
  247. RID VisualServer::get_white_texture() {
  248. if (white_texture.is_valid())
  249. return white_texture;
  250. PoolVector<uint8_t> wt;
  251. wt.resize(16 * 3);
  252. {
  253. PoolVector<uint8_t>::Write w = wt.write();
  254. for (int i = 0; i < 16 * 3; i++)
  255. w[i] = 255;
  256. }
  257. Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt));
  258. white_texture = texture_create();
  259. texture_allocate(white_texture, 4, 4, 0, Image::FORMAT_RGB8, TEXTURE_TYPE_2D);
  260. texture_set_data(white_texture, white);
  261. return white_texture;
  262. }
  263. #define SMALL_VEC2 Vector2(0.00001, 0.00001)
  264. #define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
  265. Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
  266. PoolVector<uint8_t>::Write vw = r_vertex_array.write();
  267. PoolVector<uint8_t>::Write iw;
  268. if (r_index_array.size()) {
  269. iw = r_index_array.write();
  270. }
  271. int max_bone = 0;
  272. for (int ai = 0; ai < VS::ARRAY_MAX; ai++) {
  273. if (!(p_format & (1 << ai))) // no array
  274. continue;
  275. switch (ai) {
  276. case VS::ARRAY_VERTEX: {
  277. if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
  278. PoolVector<Vector2> array = p_arrays[ai];
  279. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  280. PoolVector<Vector2>::Read read = array.read();
  281. const Vector2 *src = read.ptr();
  282. // setting vertices means regenerating the AABB
  283. Rect2 aabb;
  284. if (p_format & ARRAY_COMPRESS_VERTEX) {
  285. for (int i = 0; i < p_vertex_array_len; i++) {
  286. uint16_t vector[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  287. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(uint16_t) * 2);
  288. if (i == 0) {
  289. aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
  290. } else {
  291. aabb.expand_to(src[i]);
  292. }
  293. }
  294. } else {
  295. for (int i = 0; i < p_vertex_array_len; i++) {
  296. float vector[2] = { src[i].x, src[i].y };
  297. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 2);
  298. if (i == 0) {
  299. aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
  300. } else {
  301. aabb.expand_to(src[i]);
  302. }
  303. }
  304. }
  305. r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
  306. } else {
  307. PoolVector<Vector3> array = p_arrays[ai];
  308. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  309. PoolVector<Vector3>::Read read = array.read();
  310. const Vector3 *src = read.ptr();
  311. // setting vertices means regenerating the AABB
  312. AABB aabb;
  313. if (p_format & ARRAY_COMPRESS_VERTEX) {
  314. for (int i = 0; i < p_vertex_array_len; i++) {
  315. uint16_t vector[4] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y), Math::make_half_float(src[i].z), Math::make_half_float(1.0) };
  316. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(uint16_t) * 4);
  317. if (i == 0) {
  318. aabb = AABB(src[i], SMALL_VEC3);
  319. } else {
  320. aabb.expand_to(src[i]);
  321. }
  322. }
  323. } else {
  324. for (int i = 0; i < p_vertex_array_len; i++) {
  325. float vector[3] = { src[i].x, src[i].y, src[i].z };
  326. copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 3);
  327. if (i == 0) {
  328. aabb = AABB(src[i], SMALL_VEC3);
  329. } else {
  330. aabb.expand_to(src[i]);
  331. }
  332. }
  333. }
  334. r_aabb = aabb;
  335. }
  336. } break;
  337. case VS::ARRAY_NORMAL: {
  338. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  339. PoolVector<Vector3> array = p_arrays[ai];
  340. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  341. PoolVector<Vector3>::Read read = array.read();
  342. const Vector3 *src = read.ptr();
  343. // setting vertices means regenerating the AABB
  344. if (p_format & ARRAY_COMPRESS_NORMAL) {
  345. for (int i = 0; i < p_vertex_array_len; i++) {
  346. int8_t vector[4] = {
  347. (int8_t)CLAMP(src[i].x * 127, -128, 127),
  348. (int8_t)CLAMP(src[i].y * 127, -128, 127),
  349. (int8_t)CLAMP(src[i].z * 127, -128, 127),
  350. 0,
  351. };
  352. copymem(&vw[p_offsets[ai] + i * p_stride], vector, 4);
  353. }
  354. } else {
  355. for (int i = 0; i < p_vertex_array_len; i++) {
  356. float vector[3] = { src[i].x, src[i].y, src[i].z };
  357. copymem(&vw[p_offsets[ai] + i * p_stride], vector, 3 * 4);
  358. }
  359. }
  360. } break;
  361. case VS::ARRAY_TANGENT: {
  362. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  363. PoolVector<real_t> array = p_arrays[ai];
  364. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  365. PoolVector<real_t>::Read read = array.read();
  366. const real_t *src = read.ptr();
  367. if (p_format & ARRAY_COMPRESS_TANGENT) {
  368. for (int i = 0; i < p_vertex_array_len; i++) {
  369. uint8_t xyzw[4] = {
  370. (uint8_t)CLAMP(src[i * 4 + 0] * 127, -128, 127),
  371. (uint8_t)CLAMP(src[i * 4 + 1] * 127, -128, 127),
  372. (uint8_t)CLAMP(src[i * 4 + 2] * 127, -128, 127),
  373. (uint8_t)CLAMP(src[i * 4 + 3] * 127, -128, 127)
  374. };
  375. copymem(&vw[p_offsets[ai] + i * p_stride], xyzw, 4);
  376. }
  377. } else {
  378. for (int i = 0; i < p_vertex_array_len; i++) {
  379. float xyzw[4] = {
  380. src[i * 4 + 0],
  381. src[i * 4 + 1],
  382. src[i * 4 + 2],
  383. src[i * 4 + 3]
  384. };
  385. copymem(&vw[p_offsets[ai] + i * p_stride], xyzw, 4 * 4);
  386. }
  387. }
  388. } break;
  389. case VS::ARRAY_COLOR: {
  390. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_COLOR_ARRAY, ERR_INVALID_PARAMETER);
  391. PoolVector<Color> array = p_arrays[ai];
  392. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  393. PoolVector<Color>::Read read = array.read();
  394. const Color *src = read.ptr();
  395. if (p_format & ARRAY_COMPRESS_COLOR) {
  396. for (int i = 0; i < p_vertex_array_len; i++) {
  397. uint8_t colors[4];
  398. for (int j = 0; j < 4; j++) {
  399. colors[j] = CLAMP(int((src[i][j]) * 255.0), 0, 255);
  400. }
  401. copymem(&vw[p_offsets[ai] + i * p_stride], colors, 4);
  402. }
  403. } else {
  404. for (int i = 0; i < p_vertex_array_len; i++) {
  405. copymem(&vw[p_offsets[ai] + i * p_stride], &src[i], 4 * 4);
  406. }
  407. }
  408. } break;
  409. case VS::ARRAY_TEX_UV: {
  410. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  411. PoolVector<Vector2> array = p_arrays[ai];
  412. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  413. PoolVector<Vector2>::Read read = array.read();
  414. const Vector2 *src = read.ptr();
  415. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  416. for (int i = 0; i < p_vertex_array_len; i++) {
  417. uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  418. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
  419. }
  420. } else {
  421. for (int i = 0; i < p_vertex_array_len; i++) {
  422. float uv[2] = { src[i].x, src[i].y };
  423. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
  424. }
  425. }
  426. } break;
  427. case VS::ARRAY_TEX_UV2: {
  428. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  429. PoolVector<Vector2> array = p_arrays[ai];
  430. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  431. PoolVector<Vector2>::Read read = array.read();
  432. const Vector2 *src = read.ptr();
  433. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  434. for (int i = 0; i < p_vertex_array_len; i++) {
  435. uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
  436. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
  437. }
  438. } else {
  439. for (int i = 0; i < p_vertex_array_len; i++) {
  440. float uv[2] = { src[i].x, src[i].y };
  441. copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
  442. }
  443. }
  444. } break;
  445. case VS::ARRAY_WEIGHTS: {
  446. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  447. PoolVector<real_t> array = p_arrays[ai];
  448. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
  449. PoolVector<real_t>::Read read = array.read();
  450. const real_t *src = read.ptr();
  451. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  452. for (int i = 0; i < p_vertex_array_len; i++) {
  453. uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
  454. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  455. data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535);
  456. }
  457. copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4);
  458. }
  459. } else {
  460. for (int i = 0; i < p_vertex_array_len; i++) {
  461. float data[VS::ARRAY_WEIGHTS_SIZE];
  462. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  463. data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
  464. }
  465. copymem(&vw[p_offsets[ai] + i * p_stride], data, 4 * 4);
  466. }
  467. }
  468. } break;
  469. case VS::ARRAY_BONES: {
  470. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY && p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER);
  471. PoolVector<int> array = p_arrays[ai];
  472. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
  473. PoolVector<int>::Read read = array.read();
  474. const int *src = read.ptr();
  475. if (!(p_format & ARRAY_FLAG_USE_16_BIT_BONES)) {
  476. for (int i = 0; i < p_vertex_array_len; i++) {
  477. uint8_t data[VS::ARRAY_WEIGHTS_SIZE];
  478. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  479. data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j], 0, 255);
  480. max_bone = MAX(data[j], max_bone);
  481. }
  482. copymem(&vw[p_offsets[ai] + i * p_stride], data, 4);
  483. }
  484. } else {
  485. for (int i = 0; i < p_vertex_array_len; i++) {
  486. uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
  487. for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
  488. data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
  489. max_bone = MAX(data[j], max_bone);
  490. }
  491. copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4);
  492. }
  493. }
  494. } break;
  495. case VS::ARRAY_INDEX: {
  496. ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
  497. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER);
  498. PoolVector<int> indices = p_arrays[ai];
  499. ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER);
  500. ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);
  501. /* determine whether using 16 or 32 bits indices */
  502. PoolVector<int>::Read read = indices.read();
  503. const int *src = read.ptr();
  504. for (int i = 0; i < p_index_array_len; i++) {
  505. if (p_vertex_array_len < (1 << 16)) {
  506. uint16_t v = src[i];
  507. copymem(&iw[i * 2], &v, 2);
  508. } else {
  509. uint32_t v = src[i];
  510. copymem(&iw[i * 4], &v, 4);
  511. }
  512. }
  513. } break;
  514. default: {
  515. ERR_FAIL_V(ERR_INVALID_DATA);
  516. }
  517. }
  518. }
  519. if (p_format & VS::ARRAY_FORMAT_BONES) {
  520. //create AABBs for each detected bone
  521. int total_bones = max_bone + 1;
  522. bool first = r_bone_aabb.size() == 0;
  523. r_bone_aabb.resize(total_bones);
  524. if (first) {
  525. for (int i = 0; i < total_bones; i++) {
  526. r_bone_aabb.write[i].size = Vector3(-1, -1, -1); //negative means unused
  527. }
  528. }
  529. PoolVector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX];
  530. PoolVector<int> bones = p_arrays[VS::ARRAY_BONES];
  531. PoolVector<float> weights = p_arrays[VS::ARRAY_WEIGHTS];
  532. bool any_valid = false;
  533. if (vertices.size() && bones.size() == vertices.size() * 4 && weights.size() == bones.size()) {
  534. int vs = vertices.size();
  535. PoolVector<Vector3>::Read rv = vertices.read();
  536. PoolVector<int>::Read rb = bones.read();
  537. PoolVector<float>::Read rw = weights.read();
  538. AABB *bptr = r_bone_aabb.ptrw();
  539. for (int i = 0; i < vs; i++) {
  540. Vector3 v = rv[i];
  541. for (int j = 0; j < 4; j++) {
  542. int idx = rb[i * 4 + j];
  543. float w = rw[i * 4 + j];
  544. if (w == 0)
  545. continue; //break;
  546. ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
  547. if (bptr[idx].size.x < 0) {
  548. //first
  549. bptr[idx] = AABB(v, SMALL_VEC3);
  550. any_valid = true;
  551. } else {
  552. bptr[idx].expand_to(v);
  553. }
  554. }
  555. }
  556. }
  557. if (!any_valid && first) {
  558. r_bone_aabb.clear();
  559. }
  560. }
  561. return OK;
  562. }
  563. uint32_t VisualServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const {
  564. uint32_t offsets[ARRAY_MAX];
  565. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
  566. return offsets[p_array_index];
  567. }
  568. uint32_t VisualServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const {
  569. uint32_t offsets[ARRAY_MAX];
  570. return mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
  571. }
  572. uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
  573. int total_elem_size = 0;
  574. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  575. r_offsets[i] = 0; //reset
  576. if (!(p_format & (1 << i))) // no array
  577. continue;
  578. int elem_size = 0;
  579. switch (i) {
  580. case VS::ARRAY_VERTEX: {
  581. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  582. elem_size = 2;
  583. } else {
  584. elem_size = 3;
  585. }
  586. if (p_format & ARRAY_COMPRESS_VERTEX) {
  587. elem_size *= sizeof(int16_t);
  588. } else {
  589. elem_size *= sizeof(float);
  590. }
  591. if (elem_size == 6) {
  592. elem_size = 8;
  593. }
  594. } break;
  595. case VS::ARRAY_NORMAL: {
  596. if (p_format & ARRAY_COMPRESS_NORMAL) {
  597. elem_size = sizeof(uint32_t);
  598. } else {
  599. elem_size = sizeof(float) * 3;
  600. }
  601. } break;
  602. case VS::ARRAY_TANGENT: {
  603. if (p_format & ARRAY_COMPRESS_TANGENT) {
  604. elem_size = sizeof(uint32_t);
  605. } else {
  606. elem_size = sizeof(float) * 4;
  607. }
  608. } break;
  609. case VS::ARRAY_COLOR: {
  610. if (p_format & ARRAY_COMPRESS_COLOR) {
  611. elem_size = sizeof(uint32_t);
  612. } else {
  613. elem_size = sizeof(float) * 4;
  614. }
  615. } break;
  616. case VS::ARRAY_TEX_UV: {
  617. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  618. elem_size = sizeof(uint32_t);
  619. } else {
  620. elem_size = sizeof(float) * 2;
  621. }
  622. } break;
  623. case VS::ARRAY_TEX_UV2: {
  624. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  625. elem_size = sizeof(uint32_t);
  626. } else {
  627. elem_size = sizeof(float) * 2;
  628. }
  629. } break;
  630. case VS::ARRAY_WEIGHTS: {
  631. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  632. elem_size = sizeof(uint16_t) * 4;
  633. } else {
  634. elem_size = sizeof(float) * 4;
  635. }
  636. } break;
  637. case VS::ARRAY_BONES: {
  638. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  639. elem_size = sizeof(uint16_t) * 4;
  640. } else {
  641. elem_size = sizeof(uint32_t);
  642. }
  643. } break;
  644. case VS::ARRAY_INDEX: {
  645. if (p_index_len <= 0) {
  646. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  647. break;
  648. }
  649. /* determine whether using 16 or 32 bits indices */
  650. if (p_vertex_len >= (1 << 16)) {
  651. elem_size = 4;
  652. } else {
  653. elem_size = 2;
  654. }
  655. r_offsets[i] = elem_size;
  656. continue;
  657. } break;
  658. default: {
  659. ERR_FAIL_V(0);
  660. }
  661. }
  662. r_offsets[i] = total_elem_size;
  663. total_elem_size += elem_size;
  664. }
  665. return total_elem_size;
  666. }
  667. void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format) {
  668. ERR_FAIL_INDEX(p_primitive, VS::PRIMITIVE_MAX);
  669. ERR_FAIL_COND(p_arrays.size() != VS::ARRAY_MAX);
  670. uint32_t format = 0;
  671. // validation
  672. int index_array_len = 0;
  673. int array_len = 0;
  674. for (int i = 0; i < p_arrays.size(); i++) {
  675. if (p_arrays[i].get_type() == Variant::NIL)
  676. continue;
  677. format |= (1 << i);
  678. if (i == VS::ARRAY_VERTEX) {
  679. Variant var = p_arrays[i];
  680. switch (var.get_type()) {
  681. case Variant::POOL_VECTOR2_ARRAY: {
  682. PoolVector<Vector2> v2 = var;
  683. array_len = v2.size();
  684. } break;
  685. case Variant::POOL_VECTOR3_ARRAY: {
  686. PoolVector<Vector3> v3 = var;
  687. array_len = v3.size();
  688. } break;
  689. default: {
  690. Array v = var;
  691. array_len = v.size();
  692. } break;
  693. }
  694. array_len = PoolVector3Array(p_arrays[i]).size();
  695. ERR_FAIL_COND(array_len == 0);
  696. } else if (i == VS::ARRAY_INDEX) {
  697. index_array_len = PoolIntArray(p_arrays[i]).size();
  698. }
  699. }
  700. ERR_FAIL_COND((format & VS::ARRAY_FORMAT_VERTEX) == 0); // mandatory
  701. if (p_blend_shapes.size()) {
  702. //validate format for morphs
  703. for (int i = 0; i < p_blend_shapes.size(); i++) {
  704. uint32_t bsformat = 0;
  705. Array arr = p_blend_shapes[i];
  706. for (int j = 0; j < arr.size(); j++) {
  707. if (arr[j].get_type() != Variant::NIL)
  708. bsformat |= (1 << j);
  709. }
  710. ERR_FAIL_COND((bsformat) != (format & (VS::ARRAY_FORMAT_INDEX - 1)));
  711. }
  712. }
  713. uint32_t offsets[VS::ARRAY_MAX];
  714. int total_elem_size = 0;
  715. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  716. offsets[i] = 0; //reset
  717. if (!(format & (1 << i))) // no array
  718. continue;
  719. int elem_size = 0;
  720. switch (i) {
  721. case VS::ARRAY_VERTEX: {
  722. Variant arr = p_arrays[0];
  723. if (arr.get_type() == Variant::POOL_VECTOR2_ARRAY) {
  724. elem_size = 2;
  725. p_compress_format |= ARRAY_FLAG_USE_2D_VERTICES;
  726. } else if (arr.get_type() == Variant::POOL_VECTOR3_ARRAY) {
  727. p_compress_format &= ~ARRAY_FLAG_USE_2D_VERTICES;
  728. elem_size = 3;
  729. } else {
  730. elem_size = (p_compress_format & ARRAY_FLAG_USE_2D_VERTICES) ? 2 : 3;
  731. }
  732. if (p_compress_format & ARRAY_COMPRESS_VERTEX) {
  733. elem_size *= sizeof(int16_t);
  734. } else {
  735. elem_size *= sizeof(float);
  736. }
  737. if (elem_size == 6) {
  738. //had to pad
  739. elem_size = 8;
  740. }
  741. } break;
  742. case VS::ARRAY_NORMAL: {
  743. if (p_compress_format & ARRAY_COMPRESS_NORMAL) {
  744. elem_size = sizeof(uint32_t);
  745. } else {
  746. elem_size = sizeof(float) * 3;
  747. }
  748. } break;
  749. case VS::ARRAY_TANGENT: {
  750. if (p_compress_format & ARRAY_COMPRESS_TANGENT) {
  751. elem_size = sizeof(uint32_t);
  752. } else {
  753. elem_size = sizeof(float) * 4;
  754. }
  755. } break;
  756. case VS::ARRAY_COLOR: {
  757. if (p_compress_format & ARRAY_COMPRESS_COLOR) {
  758. elem_size = sizeof(uint32_t);
  759. } else {
  760. elem_size = sizeof(float) * 4;
  761. }
  762. } break;
  763. case VS::ARRAY_TEX_UV: {
  764. if (p_compress_format & ARRAY_COMPRESS_TEX_UV) {
  765. elem_size = sizeof(uint32_t);
  766. } else {
  767. elem_size = sizeof(float) * 2;
  768. }
  769. } break;
  770. case VS::ARRAY_TEX_UV2: {
  771. if (p_compress_format & ARRAY_COMPRESS_TEX_UV2) {
  772. elem_size = sizeof(uint32_t);
  773. } else {
  774. elem_size = sizeof(float) * 2;
  775. }
  776. } break;
  777. case VS::ARRAY_WEIGHTS: {
  778. if (p_compress_format & ARRAY_COMPRESS_WEIGHTS) {
  779. elem_size = sizeof(uint16_t) * 4;
  780. } else {
  781. elem_size = sizeof(float) * 4;
  782. }
  783. } break;
  784. case VS::ARRAY_BONES: {
  785. PoolVector<int> bones = p_arrays[VS::ARRAY_BONES];
  786. int max_bone = 0;
  787. {
  788. int bc = bones.size();
  789. PoolVector<int>::Read r = bones.read();
  790. for (int j = 0; j < bc; j++) {
  791. max_bone = MAX(r[j], max_bone);
  792. }
  793. }
  794. if (max_bone > 255) {
  795. p_compress_format |= ARRAY_FLAG_USE_16_BIT_BONES;
  796. elem_size = sizeof(uint16_t) * 4;
  797. } else {
  798. p_compress_format &= ~ARRAY_FLAG_USE_16_BIT_BONES;
  799. elem_size = sizeof(uint32_t);
  800. }
  801. } break;
  802. case VS::ARRAY_INDEX: {
  803. if (index_array_len <= 0) {
  804. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  805. break;
  806. }
  807. /* determine whether using 16 or 32 bits indices */
  808. if (array_len >= (1 << 16)) {
  809. elem_size = 4;
  810. } else {
  811. elem_size = 2;
  812. }
  813. offsets[i] = elem_size;
  814. continue;
  815. } break;
  816. default: {
  817. ERR_FAIL();
  818. }
  819. }
  820. offsets[i] = total_elem_size;
  821. total_elem_size += elem_size;
  822. }
  823. uint32_t mask = (1 << ARRAY_MAX) - 1;
  824. format |= (~mask) & p_compress_format; //make the full format
  825. int array_size = total_elem_size * array_len;
  826. PoolVector<uint8_t> vertex_array;
  827. vertex_array.resize(array_size);
  828. int index_array_size = offsets[VS::ARRAY_INDEX] * index_array_len;
  829. PoolVector<uint8_t> index_array;
  830. index_array.resize(index_array_size);
  831. AABB aabb;
  832. Vector<AABB> bone_aabb;
  833. Error err = _surface_set_data(p_arrays, format, offsets, total_elem_size, vertex_array, array_len, index_array, index_array_len, aabb, bone_aabb);
  834. if (err) {
  835. ERR_EXPLAIN("Invalid array format for surface");
  836. ERR_FAIL_COND(err != OK);
  837. }
  838. Vector<PoolVector<uint8_t> > blend_shape_data;
  839. for (int i = 0; i < p_blend_shapes.size(); i++) {
  840. PoolVector<uint8_t> vertex_array_shape;
  841. vertex_array_shape.resize(array_size);
  842. PoolVector<uint8_t> noindex;
  843. AABB laabb;
  844. Error err2 = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb);
  845. aabb.merge_with(laabb);
  846. if (err2) {
  847. ERR_EXPLAIN("Invalid blend shape array format for surface");
  848. ERR_FAIL_COND(err2 != OK);
  849. }
  850. blend_shape_data.push_back(vertex_array_shape);
  851. }
  852. mesh_add_surface(p_mesh, format, p_primitive, vertex_array, array_len, index_array, index_array_len, aabb, blend_shape_data, bone_aabb);
  853. }
  854. Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector<uint8_t> p_vertex_data, int p_vertex_len, PoolVector<uint8_t> p_index_data, int p_index_len) const {
  855. uint32_t offsets[ARRAY_MAX];
  856. int total_elem_size = 0;
  857. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  858. offsets[i] = 0; //reset
  859. if (!(p_format & (1 << i))) // no array
  860. continue;
  861. int elem_size = 0;
  862. switch (i) {
  863. case VS::ARRAY_VERTEX: {
  864. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  865. elem_size = 2;
  866. } else {
  867. elem_size = 3;
  868. }
  869. if (p_format & ARRAY_COMPRESS_VERTEX) {
  870. elem_size *= sizeof(int16_t);
  871. } else {
  872. elem_size *= sizeof(float);
  873. }
  874. if (elem_size == 6) {
  875. elem_size = 8;
  876. }
  877. } break;
  878. case VS::ARRAY_NORMAL: {
  879. if (p_format & ARRAY_COMPRESS_NORMAL) {
  880. elem_size = sizeof(uint32_t);
  881. } else {
  882. elem_size = sizeof(float) * 3;
  883. }
  884. } break;
  885. case VS::ARRAY_TANGENT: {
  886. if (p_format & ARRAY_COMPRESS_TANGENT) {
  887. elem_size = sizeof(uint32_t);
  888. } else {
  889. elem_size = sizeof(float) * 4;
  890. }
  891. } break;
  892. case VS::ARRAY_COLOR: {
  893. if (p_format & ARRAY_COMPRESS_COLOR) {
  894. elem_size = sizeof(uint32_t);
  895. } else {
  896. elem_size = sizeof(float) * 4;
  897. }
  898. } break;
  899. case VS::ARRAY_TEX_UV: {
  900. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  901. elem_size = sizeof(uint32_t);
  902. } else {
  903. elem_size = sizeof(float) * 2;
  904. }
  905. } break;
  906. case VS::ARRAY_TEX_UV2: {
  907. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  908. elem_size = sizeof(uint32_t);
  909. } else {
  910. elem_size = sizeof(float) * 2;
  911. }
  912. } break;
  913. case VS::ARRAY_WEIGHTS: {
  914. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  915. elem_size = sizeof(uint16_t) * 4;
  916. } else {
  917. elem_size = sizeof(float) * 4;
  918. }
  919. } break;
  920. case VS::ARRAY_BONES: {
  921. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  922. elem_size = sizeof(uint16_t) * 4;
  923. } else {
  924. elem_size = sizeof(uint32_t);
  925. }
  926. } break;
  927. case VS::ARRAY_INDEX: {
  928. if (p_index_len <= 0) {
  929. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  930. break;
  931. }
  932. /* determine whether using 16 or 32 bits indices */
  933. if (p_vertex_len >= (1 << 16)) {
  934. elem_size = 4;
  935. } else {
  936. elem_size = 2;
  937. }
  938. offsets[i] = elem_size;
  939. continue;
  940. } break;
  941. default: {
  942. ERR_FAIL_V(Array());
  943. }
  944. }
  945. offsets[i] = total_elem_size;
  946. total_elem_size += elem_size;
  947. }
  948. Array ret;
  949. ret.resize(VS::ARRAY_MAX);
  950. PoolVector<uint8_t>::Read r = p_vertex_data.read();
  951. for (int i = 0; i < VS::ARRAY_MAX; i++) {
  952. if (!(p_format & (1 << i)))
  953. continue;
  954. switch (i) {
  955. case VS::ARRAY_VERTEX: {
  956. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  957. PoolVector<Vector2> arr_2d;
  958. arr_2d.resize(p_vertex_len);
  959. if (p_format & ARRAY_COMPRESS_VERTEX) {
  960. PoolVector<Vector2>::Write w = arr_2d.write();
  961. for (int j = 0; j < p_vertex_len; j++) {
  962. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  963. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  964. }
  965. } else {
  966. PoolVector<Vector2>::Write w = arr_2d.write();
  967. for (int j = 0; j < p_vertex_len; j++) {
  968. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  969. w[j] = Vector2(v[0], v[1]);
  970. }
  971. }
  972. ret[i] = arr_2d;
  973. } else {
  974. PoolVector<Vector3> arr_3d;
  975. arr_3d.resize(p_vertex_len);
  976. if (p_format & ARRAY_COMPRESS_VERTEX) {
  977. PoolVector<Vector3>::Write w = arr_3d.write();
  978. for (int j = 0; j < p_vertex_len; j++) {
  979. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  980. w[j] = Vector3(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]), Math::halfptr_to_float(&v[2]));
  981. }
  982. } else {
  983. PoolVector<Vector3>::Write w = arr_3d.write();
  984. for (int j = 0; j < p_vertex_len; j++) {
  985. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  986. w[j] = Vector3(v[0], v[1], v[2]);
  987. }
  988. }
  989. ret[i] = arr_3d;
  990. }
  991. } break;
  992. case VS::ARRAY_NORMAL: {
  993. PoolVector<Vector3> arr;
  994. arr.resize(p_vertex_len);
  995. if (p_format & ARRAY_COMPRESS_NORMAL) {
  996. PoolVector<Vector3>::Write w = arr.write();
  997. const float multiplier = 1.f / 127.f;
  998. for (int j = 0; j < p_vertex_len; j++) {
  999. const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
  1000. w[j] = Vector3(float(v[0]) * multiplier, float(v[1]) * multiplier, float(v[2]) * multiplier);
  1001. }
  1002. } else {
  1003. PoolVector<Vector3>::Write w = arr.write();
  1004. for (int j = 0; j < p_vertex_len; j++) {
  1005. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1006. w[j] = Vector3(v[0], v[1], v[2]);
  1007. }
  1008. }
  1009. ret[i] = arr;
  1010. } break;
  1011. case VS::ARRAY_TANGENT: {
  1012. PoolVector<float> arr;
  1013. arr.resize(p_vertex_len * 4);
  1014. if (p_format & ARRAY_COMPRESS_TANGENT) {
  1015. PoolVector<float>::Write w = arr.write();
  1016. for (int j = 0; j < p_vertex_len; j++) {
  1017. const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
  1018. for (int k = 0; k < 4; k++) {
  1019. w[j * 4 + k] = float(v[k] / 127.0);
  1020. }
  1021. }
  1022. } else {
  1023. PoolVector<float>::Write w = arr.write();
  1024. for (int j = 0; j < p_vertex_len; j++) {
  1025. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1026. for (int k = 0; k < 4; k++) {
  1027. w[j * 4 + k] = v[k];
  1028. }
  1029. }
  1030. }
  1031. ret[i] = arr;
  1032. } break;
  1033. case VS::ARRAY_COLOR: {
  1034. PoolVector<Color> arr;
  1035. arr.resize(p_vertex_len);
  1036. if (p_format & ARRAY_COMPRESS_COLOR) {
  1037. PoolVector<Color>::Write w = arr.write();
  1038. for (int j = 0; j < p_vertex_len; j++) {
  1039. const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
  1040. w[j] = Color(float(v[0] / 255.0), float(v[1] / 255.0), float(v[2] / 255.0), float(v[3] / 255.0));
  1041. }
  1042. } else {
  1043. PoolVector<Color>::Write w = arr.write();
  1044. for (int j = 0; j < p_vertex_len; j++) {
  1045. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1046. w[j] = Color(v[0], v[1], v[2], v[3]);
  1047. }
  1048. }
  1049. ret[i] = arr;
  1050. } break;
  1051. case VS::ARRAY_TEX_UV: {
  1052. PoolVector<Vector2> arr;
  1053. arr.resize(p_vertex_len);
  1054. if (p_format & ARRAY_COMPRESS_TEX_UV) {
  1055. PoolVector<Vector2>::Write w = arr.write();
  1056. for (int j = 0; j < p_vertex_len; j++) {
  1057. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1058. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  1059. }
  1060. } else {
  1061. PoolVector<Vector2>::Write w = arr.write();
  1062. for (int j = 0; j < p_vertex_len; j++) {
  1063. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1064. w[j] = Vector2(v[0], v[1]);
  1065. }
  1066. }
  1067. ret[i] = arr;
  1068. } break;
  1069. case VS::ARRAY_TEX_UV2: {
  1070. PoolVector<Vector2> arr;
  1071. arr.resize(p_vertex_len);
  1072. if (p_format & ARRAY_COMPRESS_TEX_UV2) {
  1073. PoolVector<Vector2>::Write w = arr.write();
  1074. for (int j = 0; j < p_vertex_len; j++) {
  1075. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1076. w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
  1077. }
  1078. } else {
  1079. PoolVector<Vector2>::Write w = arr.write();
  1080. for (int j = 0; j < p_vertex_len; j++) {
  1081. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1082. w[j] = Vector2(v[0], v[1]);
  1083. }
  1084. }
  1085. ret[i] = arr;
  1086. } break;
  1087. case VS::ARRAY_WEIGHTS: {
  1088. PoolVector<float> arr;
  1089. arr.resize(p_vertex_len * 4);
  1090. if (p_format & ARRAY_COMPRESS_WEIGHTS) {
  1091. PoolVector<float>::Write w = arr.write();
  1092. for (int j = 0; j < p_vertex_len; j++) {
  1093. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1094. for (int k = 0; k < 4; k++) {
  1095. w[j * 4 + k] = float(v[k] / 65535.0);
  1096. }
  1097. }
  1098. } else {
  1099. PoolVector<float>::Write w = arr.write();
  1100. for (int j = 0; j < p_vertex_len; j++) {
  1101. const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
  1102. for (int k = 0; k < 4; k++) {
  1103. w[j * 4 + k] = v[k];
  1104. }
  1105. }
  1106. }
  1107. ret[i] = arr;
  1108. } break;
  1109. case VS::ARRAY_BONES: {
  1110. PoolVector<int> arr;
  1111. arr.resize(p_vertex_len * 4);
  1112. if (p_format & ARRAY_FLAG_USE_16_BIT_BONES) {
  1113. PoolVector<int>::Write w = arr.write();
  1114. for (int j = 0; j < p_vertex_len; j++) {
  1115. const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
  1116. for (int k = 0; k < 4; k++) {
  1117. w[j * 4 + k] = v[k];
  1118. }
  1119. }
  1120. } else {
  1121. PoolVector<int>::Write w = arr.write();
  1122. for (int j = 0; j < p_vertex_len; j++) {
  1123. const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
  1124. for (int k = 0; k < 4; k++) {
  1125. w[j * 4 + k] = v[k];
  1126. }
  1127. }
  1128. }
  1129. ret[i] = arr;
  1130. } break;
  1131. case VS::ARRAY_INDEX: {
  1132. /* determine whether using 16 or 32 bits indices */
  1133. PoolVector<uint8_t>::Read ir = p_index_data.read();
  1134. PoolVector<int> arr;
  1135. arr.resize(p_index_len);
  1136. if (p_vertex_len < (1 << 16)) {
  1137. PoolVector<int>::Write w = arr.write();
  1138. for (int j = 0; j < p_index_len; j++) {
  1139. const uint16_t *v = (const uint16_t *)&ir[j * 2];
  1140. w[j] = *v;
  1141. }
  1142. } else {
  1143. PoolVector<int>::Write w = arr.write();
  1144. for (int j = 0; j < p_index_len; j++) {
  1145. const int *v = (const int *)&ir[j * 4];
  1146. w[j] = *v;
  1147. }
  1148. }
  1149. ret[i] = arr;
  1150. } break;
  1151. default: {
  1152. ERR_FAIL_V(ret);
  1153. }
  1154. }
  1155. }
  1156. return ret;
  1157. }
  1158. Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
  1159. PoolVector<uint8_t> vertex_data = mesh_surface_get_array(p_mesh, p_surface);
  1160. ERR_FAIL_COND_V(vertex_data.size() == 0, Array());
  1161. int vertex_len = mesh_surface_get_array_len(p_mesh, p_surface);
  1162. PoolVector<uint8_t> index_data = mesh_surface_get_index_array(p_mesh, p_surface);
  1163. int index_len = mesh_surface_get_array_index_len(p_mesh, p_surface);
  1164. uint32_t format = mesh_surface_get_format(p_mesh, p_surface);
  1165. return _get_array_from_surface(format, vertex_data, vertex_len, index_data, index_len);
  1166. }
  1167. Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
  1168. Vector<PoolVector<uint8_t> > blend_shape_data = mesh_surface_get_blend_shapes(p_mesh, p_surface);
  1169. if (blend_shape_data.size() > 0) {
  1170. int vertex_len = mesh_surface_get_array_len(p_mesh, p_surface);
  1171. PoolVector<uint8_t> index_data = mesh_surface_get_index_array(p_mesh, p_surface);
  1172. int index_len = mesh_surface_get_array_index_len(p_mesh, p_surface);
  1173. uint32_t format = mesh_surface_get_format(p_mesh, p_surface);
  1174. Array blend_shape_array;
  1175. blend_shape_array.resize(blend_shape_data.size());
  1176. for (int i = 0; i < blend_shape_data.size(); i++) {
  1177. blend_shape_array.set(i, _get_array_from_surface(format, blend_shape_data[i], vertex_len, index_data, index_len));
  1178. }
  1179. return blend_shape_array;
  1180. } else {
  1181. return Array();
  1182. }
  1183. }
  1184. Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
  1185. Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
  1186. Array arr;
  1187. for (int i = 0; i < vec.size(); i++) {
  1188. arr[i] = vec[i];
  1189. }
  1190. return arr;
  1191. }
  1192. void VisualServer::_bind_methods() {
  1193. ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync);
  1194. ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0));
  1195. // "draw" and "sync" are deprecated duplicates of "force_draw" and "force_sync"
  1196. // FIXME: Add deprecation messages using GH-4397 once available, and retire
  1197. // once the warnings have been enabled for a full release cycle
  1198. ClassDB::bind_method(D_METHOD("sync"), &VisualServer::sync);
  1199. ClassDB::bind_method(D_METHOD("draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0));
  1200. ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create);
  1201. ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT));
  1202. ClassDB::bind_method(D_METHOD("texture_allocate", "texture", "width", "height", "depth_3d", "format", "type", "flags"), &VisualServer::texture_allocate, DEFVAL(TEXTURE_FLAGS_DEFAULT));
  1203. ClassDB::bind_method(D_METHOD("texture_set_data", "texture", "image", "layer"), &VisualServer::texture_set_data, DEFVAL(0));
  1204. ClassDB::bind_method(D_METHOD("texture_set_data_partial", "texture", "image", "src_x", "src_y", "src_w", "src_h", "dst_x", "dst_y", "dst_mip", "layer"), &VisualServer::texture_set_data_partial, DEFVAL(0));
  1205. ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "cube_side"), &VisualServer::texture_get_data, DEFVAL(CUBEMAP_LEFT));
  1206. ClassDB::bind_method(D_METHOD("texture_set_flags", "texture", "flags"), &VisualServer::texture_set_flags);
  1207. ClassDB::bind_method(D_METHOD("texture_get_flags", "texture"), &VisualServer::texture_get_flags);
  1208. ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &VisualServer::texture_get_format);
  1209. ClassDB::bind_method(D_METHOD("texture_get_type", "texture"), &VisualServer::texture_get_type);
  1210. ClassDB::bind_method(D_METHOD("texture_get_texid", "texture"), &VisualServer::texture_get_texid);
  1211. ClassDB::bind_method(D_METHOD("texture_get_width", "texture"), &VisualServer::texture_get_width);
  1212. ClassDB::bind_method(D_METHOD("texture_get_height", "texture"), &VisualServer::texture_get_height);
  1213. ClassDB::bind_method(D_METHOD("texture_get_depth", "texture"), &VisualServer::texture_get_depth);
  1214. ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height", "depth"), &VisualServer::texture_set_size_override);
  1215. ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &VisualServer::texture_set_path);
  1216. ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &VisualServer::texture_get_path);
  1217. ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data);
  1218. ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind);
  1219. ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original);
  1220. #ifndef _3D_DISABLED
  1221. ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create);
  1222. ClassDB::bind_method(D_METHOD("sky_set_texture", "sky", "cube_map", "radiance_size"), &VisualServer::sky_set_texture);
  1223. #endif
  1224. ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create);
  1225. ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code);
  1226. ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code);
  1227. ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind);
  1228. ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param);
  1229. ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param);
  1230. ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create);
  1231. ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader);
  1232. ClassDB::bind_method(D_METHOD("material_get_shader", "shader_material"), &VisualServer::material_get_shader);
  1233. ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param);
  1234. ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param);
  1235. ClassDB::bind_method(D_METHOD("material_get_param_default", "material", "parameter"), &VisualServer::material_get_param_default);
  1236. ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority);
  1237. ClassDB::bind_method(D_METHOD("material_set_line_width", "material", "width"), &VisualServer::material_set_line_width);
  1238. ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass);
  1239. ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create);
  1240. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &VisualServer::mesh_surface_get_format_offset);
  1241. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &VisualServer::mesh_surface_get_format_stride);
  1242. ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primtive", "arrays", "blend_shapes", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(ARRAY_COMPRESS_DEFAULT));
  1243. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_count", "mesh", "amount"), &VisualServer::mesh_set_blend_shape_count);
  1244. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
  1245. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
  1246. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
  1247. ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region);
  1248. ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
  1249. ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
  1250. ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len);
  1251. ClassDB::bind_method(D_METHOD("mesh_surface_get_array_index_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_index_len);
  1252. ClassDB::bind_method(D_METHOD("mesh_surface_get_array", "mesh", "surface"), &VisualServer::mesh_surface_get_array);
  1253. ClassDB::bind_method(D_METHOD("mesh_surface_get_index_array", "mesh", "surface"), &VisualServer::mesh_surface_get_index_array);
  1254. ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_arrays);
  1255. ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_blend_shape_arrays);
  1256. ClassDB::bind_method(D_METHOD("mesh_surface_get_format", "mesh", "surface"), &VisualServer::mesh_surface_get_format);
  1257. ClassDB::bind_method(D_METHOD("mesh_surface_get_primitive_type", "mesh", "surface"), &VisualServer::mesh_surface_get_primitive_type);
  1258. ClassDB::bind_method(D_METHOD("mesh_surface_get_aabb", "mesh", "surface"), &VisualServer::mesh_surface_get_aabb);
  1259. ClassDB::bind_method(D_METHOD("mesh_surface_get_skeleton_aabb", "mesh", "surface"), &VisualServer::_mesh_surface_get_skeleton_aabb_bind);
  1260. ClassDB::bind_method(D_METHOD("mesh_remove_surface", "mesh", "index"), &VisualServer::mesh_remove_surface);
  1261. ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &VisualServer::mesh_get_surface_count);
  1262. ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &VisualServer::mesh_set_custom_aabb);
  1263. ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &VisualServer::mesh_get_custom_aabb);
  1264. ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &VisualServer::mesh_clear);
  1265. ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &VisualServer::multimesh_allocate, DEFVAL(MULTIMESH_CUSTOM_DATA_NONE));
  1266. ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &VisualServer::multimesh_get_instance_count);
  1267. ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &VisualServer::multimesh_set_mesh);
  1268. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform);
  1269. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform_2d);
  1270. ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &VisualServer::multimesh_instance_set_color);
  1271. ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &VisualServer::multimesh_instance_set_custom_data);
  1272. ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &VisualServer::multimesh_get_mesh);
  1273. ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &VisualServer::multimesh_get_aabb);
  1274. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform);
  1275. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform_2d);
  1276. ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &VisualServer::multimesh_instance_get_color);
  1277. ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &VisualServer::multimesh_instance_get_custom_data);
  1278. ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &VisualServer::multimesh_set_visible_instances);
  1279. ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &VisualServer::multimesh_get_visible_instances);
  1280. ClassDB::bind_method(D_METHOD("multimesh_set_as_bulk_array", "multimesh", "array"), &VisualServer::multimesh_set_as_bulk_array);
  1281. #ifndef _3D_DISABLED
  1282. ClassDB::bind_method(D_METHOD("immediate_create"), &VisualServer::immediate_create);
  1283. ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &VisualServer::immediate_begin, DEFVAL(RID()));
  1284. ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &VisualServer::immediate_vertex);
  1285. ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &VisualServer::immediate_vertex_2d);
  1286. ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &VisualServer::immediate_normal);
  1287. ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &VisualServer::immediate_tangent);
  1288. ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &VisualServer::immediate_color);
  1289. ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &VisualServer::immediate_uv);
  1290. ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &VisualServer::immediate_uv2);
  1291. ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &VisualServer::immediate_end);
  1292. ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &VisualServer::immediate_clear);
  1293. ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &VisualServer::immediate_set_material);
  1294. ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &VisualServer::immediate_get_material);
  1295. #endif
  1296. ClassDB::bind_method(D_METHOD("skeleton_create"), &VisualServer::skeleton_create);
  1297. ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &VisualServer::skeleton_allocate, DEFVAL(false));
  1298. ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &VisualServer::skeleton_get_bone_count);
  1299. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform);
  1300. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform);
  1301. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform_2d);
  1302. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform_2d);
  1303. #ifndef _3D_DISABLED
  1304. ClassDB::bind_method(D_METHOD("directional_light_create"), &VisualServer::directional_light_create);
  1305. ClassDB::bind_method(D_METHOD("omni_light_create"), &VisualServer::omni_light_create);
  1306. ClassDB::bind_method(D_METHOD("spot_light_create"), &VisualServer::spot_light_create);
  1307. ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &VisualServer::light_set_color);
  1308. ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &VisualServer::light_set_param);
  1309. ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &VisualServer::light_set_shadow);
  1310. ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &VisualServer::light_set_shadow_color);
  1311. ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &VisualServer::light_set_projector);
  1312. ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &VisualServer::light_set_negative);
  1313. ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &VisualServer::light_set_cull_mask);
  1314. ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &VisualServer::light_set_reverse_cull_face_mode);
  1315. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &VisualServer::light_omni_set_shadow_mode);
  1316. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_detail", "light", "detail"), &VisualServer::light_omni_set_shadow_detail);
  1317. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &VisualServer::light_directional_set_shadow_mode);
  1318. ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &VisualServer::light_directional_set_blend_splits);
  1319. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &VisualServer::light_directional_set_shadow_depth_range_mode);
  1320. ClassDB::bind_method(D_METHOD("reflection_probe_create"), &VisualServer::reflection_probe_create);
  1321. ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &VisualServer::reflection_probe_set_update_mode);
  1322. ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &VisualServer::reflection_probe_set_intensity);
  1323. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &VisualServer::reflection_probe_set_interior_ambient);
  1324. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &VisualServer::reflection_probe_set_interior_ambient_energy);
  1325. ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &VisualServer::reflection_probe_set_interior_ambient_probe_contribution);
  1326. ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &VisualServer::reflection_probe_set_max_distance);
  1327. ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &VisualServer::reflection_probe_set_extents);
  1328. ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &VisualServer::reflection_probe_set_origin_offset);
  1329. ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &VisualServer::reflection_probe_set_as_interior);
  1330. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &VisualServer::reflection_probe_set_enable_box_projection);
  1331. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &VisualServer::reflection_probe_set_enable_shadows);
  1332. ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &VisualServer::reflection_probe_set_cull_mask);
  1333. ClassDB::bind_method(D_METHOD("gi_probe_create"), &VisualServer::gi_probe_create);
  1334. ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &VisualServer::gi_probe_set_bounds);
  1335. ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &VisualServer::gi_probe_get_bounds);
  1336. ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &VisualServer::gi_probe_set_cell_size);
  1337. ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &VisualServer::gi_probe_get_cell_size);
  1338. ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &VisualServer::gi_probe_set_to_cell_xform);
  1339. ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &VisualServer::gi_probe_get_to_cell_xform);
  1340. ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &VisualServer::gi_probe_set_dynamic_data);
  1341. ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &VisualServer::gi_probe_get_dynamic_data);
  1342. ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &VisualServer::gi_probe_set_dynamic_range);
  1343. ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &VisualServer::gi_probe_get_dynamic_range);
  1344. ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &VisualServer::gi_probe_set_energy);
  1345. ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &VisualServer::gi_probe_get_energy);
  1346. ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &VisualServer::gi_probe_set_bias);
  1347. ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &VisualServer::gi_probe_get_bias);
  1348. ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &VisualServer::gi_probe_set_normal_bias);
  1349. ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &VisualServer::gi_probe_get_normal_bias);
  1350. ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &VisualServer::gi_probe_set_propagation);
  1351. ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &VisualServer::gi_probe_get_propagation);
  1352. ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &VisualServer::gi_probe_set_interior);
  1353. ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &VisualServer::gi_probe_is_interior);
  1354. ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &VisualServer::gi_probe_set_compress);
  1355. ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &VisualServer::gi_probe_is_compressed);
  1356. ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &VisualServer::lightmap_capture_create);
  1357. ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &VisualServer::lightmap_capture_set_bounds);
  1358. ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &VisualServer::lightmap_capture_get_bounds);
  1359. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &VisualServer::lightmap_capture_set_octree);
  1360. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &VisualServer::lightmap_capture_set_octree_cell_transform);
  1361. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &VisualServer::lightmap_capture_get_octree_cell_transform);
  1362. ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &VisualServer::lightmap_capture_set_octree_cell_subdiv);
  1363. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &VisualServer::lightmap_capture_get_octree_cell_subdiv);
  1364. ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &VisualServer::lightmap_capture_get_octree);
  1365. ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &VisualServer::lightmap_capture_set_energy);
  1366. ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &VisualServer::lightmap_capture_get_energy);
  1367. #endif
  1368. ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create);
  1369. ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting);
  1370. ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting);
  1371. ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &VisualServer::particles_set_amount);
  1372. ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &VisualServer::particles_set_lifetime);
  1373. ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &VisualServer::particles_set_one_shot);
  1374. ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &VisualServer::particles_set_pre_process_time);
  1375. ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &VisualServer::particles_set_explosiveness_ratio);
  1376. ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &VisualServer::particles_set_randomness_ratio);
  1377. ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &VisualServer::particles_set_custom_aabb);
  1378. ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &VisualServer::particles_set_speed_scale);
  1379. ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &VisualServer::particles_set_use_local_coordinates);
  1380. ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &VisualServer::particles_set_process_material);
  1381. ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &VisualServer::particles_set_fixed_fps);
  1382. ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &VisualServer::particles_set_fractional_delta);
  1383. ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &VisualServer::particles_restart);
  1384. ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &VisualServer::particles_set_draw_order);
  1385. ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &VisualServer::particles_set_draw_passes);
  1386. ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &VisualServer::particles_set_draw_pass_mesh);
  1387. ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &VisualServer::particles_get_current_aabb);
  1388. ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &VisualServer::particles_set_emission_transform);
  1389. ClassDB::bind_method(D_METHOD("camera_create"), &VisualServer::camera_create);
  1390. ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &VisualServer::camera_set_perspective);
  1391. ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &VisualServer::camera_set_orthogonal);
  1392. ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &VisualServer::camera_set_transform);
  1393. ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &VisualServer::camera_set_cull_mask);
  1394. ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &VisualServer::camera_set_environment);
  1395. ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &VisualServer::camera_set_use_vertical_aspect);
  1396. ClassDB::bind_method(D_METHOD("viewport_create"), &VisualServer::viewport_create);
  1397. ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &VisualServer::viewport_set_use_arvr);
  1398. ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &VisualServer::viewport_set_size);
  1399. ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &VisualServer::viewport_set_active);
  1400. ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &VisualServer::viewport_set_parent_viewport);
  1401. ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &VisualServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(0));
  1402. ClassDB::bind_method(D_METHOD("viewport_detach", "viewport"), &VisualServer::viewport_detach);
  1403. ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &VisualServer::viewport_set_update_mode);
  1404. ClassDB::bind_method(D_METHOD("viewport_set_vflip", "viewport", "enabled"), &VisualServer::viewport_set_vflip);
  1405. ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &VisualServer::viewport_set_clear_mode);
  1406. ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &VisualServer::viewport_get_texture);
  1407. ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &VisualServer::viewport_set_hide_scenario);
  1408. ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &VisualServer::viewport_set_hide_canvas);
  1409. ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &VisualServer::viewport_set_disable_environment);
  1410. ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disabled"), &VisualServer::viewport_set_disable_3d);
  1411. ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &VisualServer::viewport_attach_camera);
  1412. ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &VisualServer::viewport_set_scenario);
  1413. ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &VisualServer::viewport_attach_canvas);
  1414. ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &VisualServer::viewport_remove_canvas);
  1415. ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &VisualServer::viewport_set_canvas_transform);
  1416. ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &VisualServer::viewport_set_transparent_background);
  1417. ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &VisualServer::viewport_set_global_canvas_transform);
  1418. ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &VisualServer::viewport_set_canvas_stacking);
  1419. ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &VisualServer::viewport_set_shadow_atlas_size);
  1420. ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &VisualServer::viewport_set_shadow_atlas_quadrant_subdivision);
  1421. ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &VisualServer::viewport_set_msaa);
  1422. ClassDB::bind_method(D_METHOD("viewport_set_hdr", "viewport", "enabled"), &VisualServer::viewport_set_hdr);
  1423. ClassDB::bind_method(D_METHOD("viewport_set_usage", "viewport", "usage"), &VisualServer::viewport_set_usage);
  1424. ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &VisualServer::viewport_get_render_info);
  1425. ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &VisualServer::viewport_set_debug_draw);
  1426. ClassDB::bind_method(D_METHOD("environment_create"), &VisualServer::environment_create);
  1427. ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &VisualServer::environment_set_background);
  1428. ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &VisualServer::environment_set_sky);
  1429. ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &VisualServer::environment_set_sky_custom_fov);
  1430. ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &VisualServer::environment_set_sky_orientation);
  1431. ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &VisualServer::environment_set_bg_color);
  1432. ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &VisualServer::environment_set_bg_energy);
  1433. ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &VisualServer::environment_set_canvas_max_layer);
  1434. ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "energy", "sky_contibution"), &VisualServer::environment_set_ambient_light, DEFVAL(1.0), DEFVAL(0.0));
  1435. ClassDB::bind_method(D_METHOD("environment_set_dof_blur_near", "env", "enable", "distance", "transition", "far_amount", "quality"), &VisualServer::environment_set_dof_blur_near);
  1436. ClassDB::bind_method(D_METHOD("environment_set_dof_blur_far", "env", "enable", "distance", "transition", "far_amount", "quality"), &VisualServer::environment_set_dof_blur_far);
  1437. ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &VisualServer::environment_set_glow);
  1438. ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &VisualServer::environment_set_tonemap);
  1439. ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &VisualServer::environment_set_adjustment);
  1440. ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &VisualServer::environment_set_ssr);
  1441. ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "radius2", "intensity2", "bias", "light_affect", "ao_channel_affect", "color", "quality", "blur", "bilateral_sharpness"), &VisualServer::environment_set_ssao);
  1442. ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &VisualServer::environment_set_fog);
  1443. ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &VisualServer::environment_set_fog_depth);
  1444. ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &VisualServer::environment_set_fog_height);
  1445. ClassDB::bind_method(D_METHOD("scenario_create"), &VisualServer::scenario_create);
  1446. ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &VisualServer::scenario_set_debug);
  1447. ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &VisualServer::scenario_set_environment);
  1448. ClassDB::bind_method(D_METHOD("scenario_set_reflection_atlas_size", "scenario", "size", "subdiv"), &VisualServer::scenario_set_reflection_atlas_size);
  1449. ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &VisualServer::scenario_set_fallback_environment);
  1450. #ifndef _3D_DISABLED
  1451. ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &VisualServer::instance_create2);
  1452. ClassDB::bind_method(D_METHOD("instance_create"), &VisualServer::instance_create);
  1453. ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &VisualServer::instance_set_base);
  1454. ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &VisualServer::instance_set_scenario);
  1455. ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &VisualServer::instance_set_layer_mask);
  1456. ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &VisualServer::instance_set_transform);
  1457. ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &VisualServer::instance_attach_object_instance_id);
  1458. ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &VisualServer::instance_set_blend_shape_weight);
  1459. ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &VisualServer::instance_set_surface_material);
  1460. ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &VisualServer::instance_set_visible);
  1461. ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &VisualServer::instance_set_use_lightmap);
  1462. ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &VisualServer::instance_set_custom_aabb);
  1463. ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &VisualServer::instance_attach_skeleton);
  1464. ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &VisualServer::instance_set_exterior);
  1465. ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &VisualServer::instance_set_extra_visibility_margin);
  1466. ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &VisualServer::instance_geometry_set_flag);
  1467. ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &VisualServer::instance_geometry_set_cast_shadows_setting);
  1468. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &VisualServer::instance_geometry_set_material_override);
  1469. ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &VisualServer::instance_geometry_set_draw_range);
  1470. ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &VisualServer::instance_geometry_set_as_instance_lod);
  1471. ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &VisualServer::_instances_cull_aabb_bind, DEFVAL(RID()));
  1472. ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &VisualServer::_instances_cull_ray_bind, DEFVAL(RID()));
  1473. ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &VisualServer::_instances_cull_convex_bind, DEFVAL(RID()));
  1474. #endif
  1475. ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create);
  1476. ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring);
  1477. ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate);
  1478. ClassDB::bind_method(D_METHOD("canvas_item_create"), &VisualServer::canvas_item_create);
  1479. ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &VisualServer::canvas_item_set_parent);
  1480. ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &VisualServer::canvas_item_set_visible);
  1481. ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &VisualServer::canvas_item_set_light_mask);
  1482. ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &VisualServer::canvas_item_set_transform);
  1483. ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &VisualServer::canvas_item_set_clip);
  1484. ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &VisualServer::canvas_item_set_distance_field_mode);
  1485. ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &VisualServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
  1486. ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &VisualServer::canvas_item_set_modulate);
  1487. ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &VisualServer::canvas_item_set_self_modulate);
  1488. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &VisualServer::canvas_item_set_draw_behind_parent);
  1489. ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &VisualServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false));
  1490. ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &VisualServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false));
  1491. ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &VisualServer::canvas_item_add_rect);
  1492. ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &VisualServer::canvas_item_add_circle);
  1493. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &VisualServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()));
  1494. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true));
  1495. ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
  1496. ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
  1497. ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
  1498. ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()));
  1499. ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(RID()));
  1500. ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
  1501. ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
  1502. ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform);
  1503. ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &VisualServer::canvas_item_add_clip_ignore);
  1504. ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &VisualServer::canvas_item_set_sort_children_by_y);
  1505. ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &VisualServer::canvas_item_set_z_index);
  1506. ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &VisualServer::canvas_item_set_z_as_relative_to_parent);
  1507. ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &VisualServer::canvas_item_set_copy_to_backbuffer);
  1508. ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &VisualServer::canvas_item_clear);
  1509. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &VisualServer::canvas_item_set_draw_index);
  1510. ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &VisualServer::canvas_item_set_material);
  1511. ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &VisualServer::canvas_item_set_use_parent_material);
  1512. ClassDB::bind_method(D_METHOD("canvas_light_create"), &VisualServer::canvas_light_create);
  1513. ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &VisualServer::canvas_light_attach_to_canvas);
  1514. ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &VisualServer::canvas_light_set_enabled);
  1515. ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &VisualServer::canvas_light_set_scale);
  1516. ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &VisualServer::canvas_light_set_transform);
  1517. ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &VisualServer::canvas_light_set_texture);
  1518. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &VisualServer::canvas_light_set_texture_offset);
  1519. ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &VisualServer::canvas_light_set_color);
  1520. ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &VisualServer::canvas_light_set_height);
  1521. ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &VisualServer::canvas_light_set_energy);
  1522. ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &VisualServer::canvas_light_set_z_range);
  1523. ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &VisualServer::canvas_light_set_layer_range);
  1524. ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_cull_mask);
  1525. ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_shadow_cull_mask);
  1526. ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &VisualServer::canvas_light_set_mode);
  1527. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &VisualServer::canvas_light_set_shadow_enabled);
  1528. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &VisualServer::canvas_light_set_shadow_buffer_size);
  1529. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_gradient_length", "light", "length"), &VisualServer::canvas_light_set_shadow_gradient_length);
  1530. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &VisualServer::canvas_light_set_shadow_filter);
  1531. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &VisualServer::canvas_light_set_shadow_color);
  1532. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &VisualServer::canvas_light_set_shadow_smooth);
  1533. ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &VisualServer::canvas_light_occluder_create);
  1534. ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &VisualServer::canvas_light_occluder_attach_to_canvas);
  1535. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &VisualServer::canvas_light_occluder_set_enabled);
  1536. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &VisualServer::canvas_light_occluder_set_polygon);
  1537. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &VisualServer::canvas_light_occluder_set_transform);
  1538. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &VisualServer::canvas_light_occluder_set_light_mask);
  1539. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &VisualServer::canvas_occluder_polygon_create);
  1540. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &VisualServer::canvas_occluder_polygon_set_shape);
  1541. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &VisualServer::canvas_occluder_polygon_set_shape_as_lines);
  1542. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &VisualServer::canvas_occluder_polygon_set_cull_mode);
  1543. ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_margins);
  1544. ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_images);
  1545. ClassDB::bind_method(D_METHOD("free_rid", "rid"), &VisualServer::free); // shouldn't conflict with Object::free()
  1546. ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback);
  1547. ClassDB::bind_method(D_METHOD("has_changed"), &VisualServer::has_changed);
  1548. ClassDB::bind_method(D_METHOD("init"), &VisualServer::init);
  1549. ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish);
  1550. ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info);
  1551. #ifndef _3D_DISABLED
  1552. ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);
  1553. ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube);
  1554. #endif
  1555. ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture);
  1556. ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture);
  1557. ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale"), &VisualServer::set_boot_image);
  1558. ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color);
  1559. ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature);
  1560. ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature);
  1561. ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes);
  1562. BIND_CONSTANT(NO_INDEX_ARRAY);
  1563. BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
  1564. BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
  1565. BIND_CONSTANT(CANVAS_ITEM_Z_MAX);
  1566. BIND_CONSTANT(MAX_GLOW_LEVELS);
  1567. BIND_CONSTANT(MAX_CURSORS);
  1568. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);
  1569. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);
  1570. BIND_ENUM_CONSTANT(CUBEMAP_LEFT);
  1571. BIND_ENUM_CONSTANT(CUBEMAP_RIGHT);
  1572. BIND_ENUM_CONSTANT(CUBEMAP_BOTTOM);
  1573. BIND_ENUM_CONSTANT(CUBEMAP_TOP);
  1574. BIND_ENUM_CONSTANT(CUBEMAP_FRONT);
  1575. BIND_ENUM_CONSTANT(CUBEMAP_BACK);
  1576. BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);
  1577. BIND_ENUM_CONSTANT(TEXTURE_TYPE_CUBEMAP);
  1578. BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D_ARRAY);
  1579. BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);
  1580. BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIPMAPS);
  1581. BIND_ENUM_CONSTANT(TEXTURE_FLAG_REPEAT);
  1582. BIND_ENUM_CONSTANT(TEXTURE_FLAG_FILTER);
  1583. BIND_ENUM_CONSTANT(TEXTURE_FLAG_ANISOTROPIC_FILTER);
  1584. BIND_ENUM_CONSTANT(TEXTURE_FLAG_CONVERT_TO_LINEAR);
  1585. BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIRRORED_REPEAT);
  1586. BIND_ENUM_CONSTANT(TEXTURE_FLAG_USED_FOR_STREAMING);
  1587. BIND_ENUM_CONSTANT(TEXTURE_FLAGS_DEFAULT);
  1588. BIND_ENUM_CONSTANT(SHADER_SPATIAL);
  1589. BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
  1590. BIND_ENUM_CONSTANT(SHADER_PARTICLES);
  1591. BIND_ENUM_CONSTANT(SHADER_MAX);
  1592. BIND_ENUM_CONSTANT(ARRAY_VERTEX);
  1593. BIND_ENUM_CONSTANT(ARRAY_NORMAL);
  1594. BIND_ENUM_CONSTANT(ARRAY_TANGENT);
  1595. BIND_ENUM_CONSTANT(ARRAY_COLOR);
  1596. BIND_ENUM_CONSTANT(ARRAY_TEX_UV);
  1597. BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);
  1598. BIND_ENUM_CONSTANT(ARRAY_BONES);
  1599. BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);
  1600. BIND_ENUM_CONSTANT(ARRAY_INDEX);
  1601. BIND_ENUM_CONSTANT(ARRAY_MAX);
  1602. BIND_ENUM_CONSTANT(ARRAY_FORMAT_VERTEX);
  1603. BIND_ENUM_CONSTANT(ARRAY_FORMAT_NORMAL);
  1604. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TANGENT);
  1605. BIND_ENUM_CONSTANT(ARRAY_FORMAT_COLOR);
  1606. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV);
  1607. BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV2);
  1608. BIND_ENUM_CONSTANT(ARRAY_FORMAT_BONES);
  1609. BIND_ENUM_CONSTANT(ARRAY_FORMAT_WEIGHTS);
  1610. BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX);
  1611. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_VERTEX);
  1612. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_NORMAL);
  1613. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TANGENT);
  1614. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_COLOR);
  1615. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV);
  1616. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_TEX_UV2);
  1617. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_BONES);
  1618. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_WEIGHTS);
  1619. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_INDEX);
  1620. BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_2D_VERTICES);
  1621. BIND_ENUM_CONSTANT(ARRAY_FLAG_USE_16_BIT_BONES);
  1622. BIND_ENUM_CONSTANT(ARRAY_COMPRESS_DEFAULT);
  1623. BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
  1624. BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
  1625. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
  1626. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP);
  1627. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
  1628. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
  1629. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
  1630. BIND_ENUM_CONSTANT(PRIMITIVE_MAX);
  1631. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
  1632. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
  1633. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);
  1634. BIND_ENUM_CONSTANT(LIGHT_OMNI);
  1635. BIND_ENUM_CONSTANT(LIGHT_SPOT);
  1636. BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);
  1637. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);
  1638. BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);
  1639. BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);
  1640. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);
  1641. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);
  1642. BIND_ENUM_CONSTANT(LIGHT_PARAM_CONTACT_SHADOW_SIZE);
  1643. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);
  1644. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);
  1645. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);
  1646. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);
  1647. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);
  1648. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);
  1649. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE);
  1650. BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
  1651. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
  1652. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
  1653. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DETAIL_VERTICAL);
  1654. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL);
  1655. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
  1656. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);
  1657. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);
  1658. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
  1659. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED);
  1660. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);
  1661. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE);
  1662. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE);
  1663. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);
  1664. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);
  1665. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);
  1666. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);
  1667. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);
  1668. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);
  1669. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);
  1670. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);
  1671. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_16X);
  1672. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D);
  1673. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_2D_NO_SAMPLING);
  1674. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D);
  1675. BIND_ENUM_CONSTANT(VIEWPORT_USAGE_3D_NO_EFFECTS);
  1676. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);
  1677. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME);
  1678. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME);
  1679. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME);
  1680. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
  1681. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);
  1682. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);
  1683. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);
  1684. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);
  1685. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);
  1686. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);
  1687. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_DISABLED);
  1688. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_WIREFRAME);
  1689. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_OVERDRAW);
  1690. BIND_ENUM_CONSTANT(SCENARIO_DEBUG_SHADELESS);
  1691. BIND_ENUM_CONSTANT(INSTANCE_NONE);
  1692. BIND_ENUM_CONSTANT(INSTANCE_MESH);
  1693. BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);
  1694. BIND_ENUM_CONSTANT(INSTANCE_IMMEDIATE);
  1695. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);
  1696. BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
  1697. BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
  1698. BIND_ENUM_CONSTANT(INSTANCE_GI_PROBE);
  1699. BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP_CAPTURE);
  1700. BIND_ENUM_CONSTANT(INSTANCE_MAX);
  1701. BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
  1702. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);
  1703. BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
  1704. BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);
  1705. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
  1706. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);
  1707. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
  1708. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
  1709. BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);
  1710. BIND_ENUM_CONSTANT(NINE_PATCH_TILE);
  1711. BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);
  1712. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_ADD);
  1713. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_SUB);
  1714. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MIX);
  1715. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_MASK);
  1716. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);
  1717. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF3);
  1718. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);
  1719. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF7);
  1720. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF9);
  1721. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);
  1722. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);
  1723. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);
  1724. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);
  1725. BIND_ENUM_CONSTANT(INFO_OBJECTS_IN_FRAME);
  1726. BIND_ENUM_CONSTANT(INFO_VERTICES_IN_FRAME);
  1727. BIND_ENUM_CONSTANT(INFO_MATERIAL_CHANGES_IN_FRAME);
  1728. BIND_ENUM_CONSTANT(INFO_SHADER_CHANGES_IN_FRAME);
  1729. BIND_ENUM_CONSTANT(INFO_SURFACE_CHANGES_IN_FRAME);
  1730. BIND_ENUM_CONSTANT(INFO_DRAW_CALLS_IN_FRAME);
  1731. BIND_ENUM_CONSTANT(INFO_USAGE_VIDEO_MEM_TOTAL);
  1732. BIND_ENUM_CONSTANT(INFO_VIDEO_MEM_USED);
  1733. BIND_ENUM_CONSTANT(INFO_TEXTURE_MEM_USED);
  1734. BIND_ENUM_CONSTANT(INFO_VERTEX_MEM_USED);
  1735. BIND_ENUM_CONSTANT(FEATURE_SHADERS);
  1736. BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);
  1737. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);
  1738. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);
  1739. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_NONE);
  1740. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_8BIT);
  1741. BIND_ENUM_CONSTANT(MULTIMESH_COLOR_FLOAT);
  1742. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_NONE);
  1743. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_8BIT);
  1744. BIND_ENUM_CONSTANT(MULTIMESH_CUSTOM_DATA_FLOAT);
  1745. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);
  1746. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);
  1747. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);
  1748. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);
  1749. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);
  1750. BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);
  1751. BIND_ENUM_CONSTANT(ENV_BG_COLOR);
  1752. BIND_ENUM_CONSTANT(ENV_BG_SKY);
  1753. BIND_ENUM_CONSTANT(ENV_BG_COLOR_SKY);
  1754. BIND_ENUM_CONSTANT(ENV_BG_CANVAS);
  1755. BIND_ENUM_CONSTANT(ENV_BG_KEEP);
  1756. BIND_ENUM_CONSTANT(ENV_BG_MAX);
  1757. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_LOW);
  1758. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_MEDIUM);
  1759. BIND_ENUM_CONSTANT(ENV_DOF_BLUR_QUALITY_HIGH);
  1760. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
  1761. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SCREEN);
  1762. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
  1763. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
  1764. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);
  1765. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);
  1766. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);
  1767. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);
  1768. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);
  1769. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);
  1770. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);
  1771. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_DISABLED);
  1772. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_1x1);
  1773. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_2x2);
  1774. BIND_ENUM_CONSTANT(ENV_SSAO_BLUR_3x3);
  1775. ADD_SIGNAL(MethodInfo("frame_pre_draw"));
  1776. ADD_SIGNAL(MethodInfo("frame_post_draw"));
  1777. }
  1778. void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) {
  1779. ERR_FAIL_COND(p_margins.size() != 4);
  1780. //canvas_item_add_style_box(p_item,p_rect,p_source,p_texture,Vector2(p_margins[0],p_margins[1]),Vector2(p_margins[2],p_margins[3]),true,p_modulate);
  1781. }
  1782. void VisualServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
  1783. camera_set_orthogonal(p_camera, p_size, p_z_near, p_z_far);
  1784. }
  1785. void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {
  1786. PoolVector<Vector3> vertices;
  1787. PoolVector<Vector3> normals;
  1788. for (int i = 0; i < p_mesh_data.faces.size(); i++) {
  1789. const Geometry::MeshData::Face &f = p_mesh_data.faces[i];
  1790. for (int j = 2; j < f.indices.size(); j++) {
  1791. #define _ADD_VERTEX(m_idx) \
  1792. vertices.push_back(p_mesh_data.vertices[f.indices[m_idx]]); \
  1793. normals.push_back(f.plane.normal);
  1794. _ADD_VERTEX(0);
  1795. _ADD_VERTEX(j - 1);
  1796. _ADD_VERTEX(j);
  1797. }
  1798. }
  1799. Array d;
  1800. d.resize(VS::ARRAY_MAX);
  1801. d[ARRAY_VERTEX] = vertices;
  1802. d[ARRAY_NORMAL] = normals;
  1803. mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);
  1804. }
  1805. void VisualServer::mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes) {
  1806. Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes);
  1807. mesh_add_surface_from_mesh_data(p_mesh, mdata);
  1808. }
  1809. void VisualServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) {
  1810. immediate_vertex(p_immediate, Vector3(p_vertex.x, p_vertex.y, 0));
  1811. }
  1812. RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
  1813. RID instance = instance_create();
  1814. instance_set_base(instance, p_base);
  1815. instance_set_scenario(instance, p_scenario);
  1816. return instance;
  1817. }
  1818. VisualServer::VisualServer() {
  1819. //ERR_FAIL_COND(singleton);
  1820. singleton = this;
  1821. GLOBAL_DEF_RST("rendering/vram_compression/import_bptc", false);
  1822. GLOBAL_DEF_RST("rendering/vram_compression/import_s3tc", true);
  1823. GLOBAL_DEF_RST("rendering/vram_compression/import_etc", false);
  1824. GLOBAL_DEF_RST("rendering/vram_compression/import_etc2", true);
  1825. GLOBAL_DEF_RST("rendering/vram_compression/import_pvrtc", false);
  1826. GLOBAL_DEF("rendering/quality/directional_shadow/size", 4096);
  1827. GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048);
  1828. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/directional_shadow/size", PropertyInfo(Variant::INT, "rendering/quality/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"));
  1829. GLOBAL_DEF("rendering/quality/shadow_atlas/size", 4096);
  1830. GLOBAL_DEF("rendering/quality/shadow_atlas/size.mobile", 2048);
  1831. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384"));
  1832. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_0_subdiv", 1);
  1833. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_1_subdiv", 2);
  1834. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_2_subdiv", 3);
  1835. GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_3_subdiv", 4);
  1836. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_0_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_0_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1837. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_1_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_1_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1838. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_2_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_2_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1839. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/quadrant_3_subdiv", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/quadrant_3_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"));
  1840. GLOBAL_DEF("rendering/quality/shadows/filter_mode", 1);
  1841. GLOBAL_DEF("rendering/quality/shadows/filter_mode.mobile", 0);
  1842. ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadows/filter_mode", PropertyInfo(Variant::INT, "rendering/quality/shadows/filter_mode", PROPERTY_HINT_ENUM, "Disabled,PCF5,PCF13"));
  1843. GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections", true);
  1844. GLOBAL_DEF("rendering/quality/reflections/texture_array_reflections.mobile", false);
  1845. GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx", true);
  1846. GLOBAL_DEF("rendering/quality/reflections/high_quality_ggx.mobile", false);
  1847. GLOBAL_DEF("rendering/quality/shading/force_vertex_shading", false);
  1848. GLOBAL_DEF("rendering/quality/shading/force_vertex_shading.mobile", true);
  1849. GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley", false);
  1850. GLOBAL_DEF("rendering/quality/shading/force_lambert_over_burley.mobile", true);
  1851. GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx", false);
  1852. GLOBAL_DEF("rendering/quality/shading/force_blinn_over_ggx.mobile", true);
  1853. GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
  1854. GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
  1855. GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
  1856. }
  1857. VisualServer::~VisualServer() {
  1858. singleton = NULL;
  1859. }