rendering_server.cpp 181 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702
  1. /**************************************************************************/
  2. /* rendering_server.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "rendering_server.h"
  31. #include "rendering_server.compat.inc"
  32. #include "core/config/project_settings.h"
  33. #include "core/object/worker_thread_pool.h"
  34. #include "core/variant/typed_array.h"
  35. #include "servers/rendering/rendering_server_globals.h"
  36. #include "servers/rendering/shader_language.h"
  37. #include "servers/rendering/shader_warnings.h"
  38. RenderingServer *RenderingServer::singleton = nullptr;
  39. RenderingServer *(*RenderingServer::create_func)() = nullptr;
  40. RenderingServer *RenderingServer::get_singleton() {
  41. return singleton;
  42. }
  43. RenderingServer *RenderingServer::create() {
  44. ERR_FAIL_COND_V(singleton, nullptr);
  45. if (create_func) {
  46. return create_func();
  47. }
  48. return nullptr;
  49. }
  50. Array RenderingServer::_texture_debug_usage_bind() {
  51. List<TextureInfo> list;
  52. texture_debug_usage(&list);
  53. Array arr;
  54. for (const TextureInfo &E : list) {
  55. Dictionary dict;
  56. dict["texture"] = E.texture;
  57. dict["width"] = E.width;
  58. dict["height"] = E.height;
  59. dict["depth"] = E.depth;
  60. dict["format"] = E.format;
  61. dict["bytes"] = E.bytes;
  62. dict["path"] = E.path;
  63. arr.push_back(dict);
  64. }
  65. return arr;
  66. }
  67. static PackedInt64Array to_int_array(const Vector<ObjectID> &ids) {
  68. PackedInt64Array a;
  69. a.resize(ids.size());
  70. for (int i = 0; i < ids.size(); ++i) {
  71. a.write[i] = ids[i];
  72. }
  73. return a;
  74. }
  75. PackedInt64Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
  76. Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
  77. return to_int_array(ids);
  78. }
  79. PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
  80. Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
  81. return to_int_array(ids);
  82. }
  83. PackedInt64Array RenderingServer::_instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario) const {
  84. Vector<Plane> planes;
  85. for (int i = 0; i < p_convex.size(); ++i) {
  86. const Variant &v = p_convex[i];
  87. ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, PackedInt64Array());
  88. planes.push_back(v);
  89. }
  90. Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);
  91. return to_int_array(ids);
  92. }
  93. RID RenderingServer::get_test_texture() {
  94. if (test_texture.is_valid()) {
  95. return test_texture;
  96. };
  97. #define TEST_TEXTURE_SIZE 256
  98. Vector<uint8_t> test_data;
  99. test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);
  100. {
  101. uint8_t *w = test_data.ptrw();
  102. for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {
  103. for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {
  104. Color c;
  105. int r = 255 - (x + y) / 2;
  106. if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {
  107. c.r = y;
  108. c.g = r;
  109. c.b = x;
  110. } else {
  111. c.r = r;
  112. c.g = x;
  113. c.b = y;
  114. }
  115. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r, 0, 255));
  116. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g, 0, 255));
  117. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b, 0, 255));
  118. }
  119. }
  120. }
  121. Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));
  122. test_texture = texture_2d_create(data);
  123. return test_texture;
  124. }
  125. void RenderingServer::_free_internal_rids() {
  126. if (test_texture.is_valid()) {
  127. free(test_texture);
  128. }
  129. if (white_texture.is_valid()) {
  130. free(white_texture);
  131. }
  132. if (test_material.is_valid()) {
  133. free(test_material);
  134. }
  135. }
  136. RID RenderingServer::_make_test_cube() {
  137. Vector<Vector3> vertices;
  138. Vector<Vector3> normals;
  139. Vector<float> tangents;
  140. Vector<Vector3> uvs;
  141. #define ADD_VTX(m_idx) \
  142. vertices.push_back(face_points[m_idx]); \
  143. normals.push_back(normal_points[m_idx]); \
  144. tangents.push_back(normal_points[m_idx][1]); \
  145. tangents.push_back(normal_points[m_idx][2]); \
  146. tangents.push_back(normal_points[m_idx][0]); \
  147. tangents.push_back(1.0); \
  148. uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
  149. for (int i = 0; i < 6; i++) {
  150. Vector3 face_points[4];
  151. Vector3 normal_points[4];
  152. float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
  153. for (int j = 0; j < 4; j++) {
  154. float v[3];
  155. v[0] = 1.0;
  156. v[1] = 1 - 2 * ((j >> 1) & 1);
  157. v[2] = v[1] * (1 - 2 * (j & 1));
  158. for (int k = 0; k < 3; k++) {
  159. if (i < 3) {
  160. face_points[j][(i + k) % 3] = v[k];
  161. } else {
  162. face_points[3 - j][(i + k) % 3] = -v[k];
  163. }
  164. }
  165. normal_points[j] = Vector3();
  166. normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
  167. }
  168. // Tri 1
  169. ADD_VTX(0);
  170. ADD_VTX(1);
  171. ADD_VTX(2);
  172. // Tri 2
  173. ADD_VTX(2);
  174. ADD_VTX(3);
  175. ADD_VTX(0);
  176. }
  177. RID test_cube = mesh_create();
  178. Array d;
  179. d.resize(RS::ARRAY_MAX);
  180. d[RenderingServer::ARRAY_NORMAL] = normals;
  181. d[RenderingServer::ARRAY_TANGENT] = tangents;
  182. d[RenderingServer::ARRAY_TEX_UV] = uvs;
  183. d[RenderingServer::ARRAY_VERTEX] = vertices;
  184. Vector<int> indices;
  185. indices.resize(vertices.size());
  186. for (int i = 0; i < vertices.size(); i++) {
  187. indices.set(i, i);
  188. }
  189. d[RenderingServer::ARRAY_INDEX] = indices;
  190. mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
  191. /*
  192. test_material = fixed_material_create();
  193. //material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
  194. fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
  195. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
  196. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
  197. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
  198. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
  199. */
  200. mesh_surface_set_material(test_cube, 0, test_material);
  201. return test_cube;
  202. }
  203. RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, real_t p_radius) {
  204. Vector<Vector3> vertices;
  205. Vector<Vector3> normals;
  206. const double lat_step = Math_TAU / p_lats;
  207. const double lon_step = Math_TAU / p_lons;
  208. for (int i = 1; i <= p_lats; i++) {
  209. double lat0 = lat_step * (i - 1) - Math_TAU / 4;
  210. double z0 = Math::sin(lat0);
  211. double zr0 = Math::cos(lat0);
  212. double lat1 = lat_step * i - Math_TAU / 4;
  213. double z1 = Math::sin(lat1);
  214. double zr1 = Math::cos(lat1);
  215. for (int j = p_lons; j >= 1; j--) {
  216. double lng0 = lon_step * (j - 1);
  217. double x0 = Math::cos(lng0);
  218. double y0 = Math::sin(lng0);
  219. double lng1 = lon_step * j;
  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(RS::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 RenderingServer::get_white_texture() {
  248. if (white_texture.is_valid()) {
  249. return white_texture;
  250. }
  251. Vector<uint8_t> wt;
  252. wt.resize(16 * 3);
  253. {
  254. uint8_t *w = wt.ptrw();
  255. for (int i = 0; i < 16 * 3; i++) {
  256. w[i] = 255;
  257. }
  258. }
  259. Ref<Image> white = memnew(Image(4, 4, false, Image::FORMAT_RGB8, wt));
  260. white_texture = texture_2d_create(white);
  261. return white_texture;
  262. }
  263. void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r_angle, Vector3 &r_axis) {
  264. Vector3 normal = p_normal.normalized();
  265. Vector3 tangent = Vector3(p_tangent.x, p_tangent.y, p_tangent.z).normalized();
  266. float d = p_tangent.w;
  267. Vector3 binormal = normal.cross(tangent).normalized();
  268. real_t angle;
  269. Basis tbn = Basis();
  270. tbn.rows[0] = tangent;
  271. tbn.rows[1] = binormal;
  272. tbn.rows[2] = normal;
  273. tbn.get_axis_angle(r_axis, angle);
  274. r_angle = float(angle);
  275. if (d < 0.0) {
  276. r_angle = CLAMP((1.0 - r_angle / Math_PI) * 0.5, 0.0, 0.49999);
  277. } else {
  278. r_angle = CLAMP((r_angle / Math_PI) * 0.5 + 0.5, 0.500008, 1.0);
  279. }
  280. }
  281. // The inputs to this function should match the outputs of _get_axis_angle. I.e. p_axis is a normalized vector
  282. // and p_angle includes the binormal direction.
  283. void _get_tbn_from_axis_angle(const Vector3 &p_axis, float p_angle, Vector3 &r_normal, Vector4 &r_tangent) {
  284. float binormal_sign = p_angle > 0.5 ? 1.0 : -1.0;
  285. float angle = Math::abs(p_angle * 2.0 - 1.0) * Math_PI;
  286. Basis tbn = Basis(p_axis, angle);
  287. Vector3 tan = tbn.rows[0];
  288. r_tangent = Vector4(tan.x, tan.y, tan.z, binormal_sign);
  289. r_normal = tbn.rows[2];
  290. }
  291. AABB _compute_aabb_from_points(const Vector3 *p_data, int p_length) {
  292. if (p_length == 0) {
  293. return AABB();
  294. }
  295. Vector3 min = p_data[0];
  296. Vector3 max = p_data[0];
  297. for (int i = 1; i < p_length; ++i) {
  298. min = min.min(p_data[i]);
  299. max = max.max(p_data[i]);
  300. }
  301. return AABB(min, max - min);
  302. }
  303. Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint32_t *p_offsets, uint32_t p_vertex_stride, uint32_t p_normal_stride, uint32_t p_attrib_stride, uint32_t p_skin_stride, Vector<uint8_t> &r_vertex_array, Vector<uint8_t> &r_attrib_array, Vector<uint8_t> &r_skin_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb, Vector4 &r_uv_scale) {
  304. uint8_t *vw = r_vertex_array.ptrw();
  305. uint8_t *aw = r_attrib_array.ptrw();
  306. uint8_t *sw = r_skin_array.ptrw();
  307. uint8_t *iw = nullptr;
  308. if (r_index_array.size()) {
  309. iw = r_index_array.ptrw();
  310. }
  311. int max_bone = 0;
  312. // Preprocess UVs if compression is enabled
  313. if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && ((p_format & RS::ARRAY_FORMAT_TEX_UV) || (p_format & RS::ARRAY_FORMAT_TEX_UV2))) {
  314. const Vector2 *uv_src = nullptr;
  315. if (p_format & RS::ARRAY_FORMAT_TEX_UV) {
  316. Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV];
  317. uv_src = array.ptr();
  318. }
  319. const Vector2 *uv2_src = nullptr;
  320. if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {
  321. Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV2];
  322. uv2_src = array.ptr();
  323. }
  324. Vector2 max_val = Vector2(0.0, 0.0);
  325. Vector2 min_val = Vector2(0.0, 0.0);
  326. Vector2 max_val2 = Vector2(0.0, 0.0);
  327. Vector2 min_val2 = Vector2(0.0, 0.0);
  328. for (int i = 0; i < p_vertex_array_len; i++) {
  329. if (p_format & RS::ARRAY_FORMAT_TEX_UV) {
  330. max_val = max_val.max(uv_src[i]);
  331. min_val = min_val.min(uv_src[i]);
  332. }
  333. if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {
  334. max_val2 = max_val2.max(uv2_src[i]);
  335. min_val2 = min_val2.min(uv2_src[i]);
  336. }
  337. }
  338. max_val = max_val.abs().max(min_val.abs());
  339. max_val2 = max_val2.abs().max(min_val2.abs());
  340. if (min_val.x >= 0.0 && min_val2.x >= 0.0 && max_val.x <= 1.0 && max_val2.x <= 1.0 &&
  341. min_val.y >= 0.0 && min_val2.y >= 0.0 && max_val.y <= 1.0 && max_val2.y <= 1.0) {
  342. // When all channels are in the 0-1 range, we will compress to 16-bit without scaling to
  343. // preserve the bits as best as possible.
  344. r_uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);
  345. } else {
  346. r_uv_scale = Vector4(max_val.x, max_val.y, max_val2.x, max_val2.y) * Vector4(2.0, 2.0, 2.0, 2.0);
  347. }
  348. }
  349. for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {
  350. if (!(p_format & (1ULL << ai))) { // No array
  351. continue;
  352. }
  353. switch (ai) {
  354. case RS::ARRAY_VERTEX: {
  355. if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
  356. Vector<Vector2> array = p_arrays[ai];
  357. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  358. const Vector2 *src = array.ptr();
  359. // Setting vertices means regenerating the AABB.
  360. Rect2 aabb;
  361. {
  362. for (int i = 0; i < p_vertex_array_len; i++) {
  363. float vector[2] = { (float)src[i].x, (float)src[i].y };
  364. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2);
  365. if (i == 0) {
  366. aabb = Rect2(src[i], SMALL_VEC2); // Must have a bit of size.
  367. } else {
  368. aabb.expand_to(src[i]);
  369. }
  370. }
  371. }
  372. r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
  373. } else {
  374. Vector<Vector3> array = p_arrays[ai];
  375. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  376. const Vector3 *src = array.ptr();
  377. r_aabb = _compute_aabb_from_points(src, p_vertex_array_len);
  378. r_aabb.size = r_aabb.size.max(SMALL_VEC3);
  379. if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  380. if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {
  381. // Early out if we are only setting vertex positions.
  382. for (int i = 0; i < p_vertex_array_len; i++) {
  383. Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;
  384. uint16_t vector[4] = {
  385. (uint16_t)CLAMP(pos.x * 65535, 0, 65535),
  386. (uint16_t)CLAMP(pos.y * 65535, 0, 65535),
  387. (uint16_t)CLAMP(pos.z * 65535, 0, 65535),
  388. (uint16_t)0
  389. };
  390. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);
  391. }
  392. continue;
  393. }
  394. // Validate normal and tangent arrays.
  395. ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  396. Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];
  397. ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  398. const Vector3 *normal_src = normal_array.ptr();
  399. Variant::Type tangent_type = p_arrays[RS::ARRAY_TANGENT].get_type();
  400. ERR_FAIL_COND_V(tangent_type != Variant::PACKED_FLOAT32_ARRAY && tangent_type != Variant::PACKED_FLOAT64_ARRAY && tangent_type != Variant::NIL, ERR_INVALID_PARAMETER);
  401. // We need a different version if using double precision tangents.
  402. if (tangent_type == Variant::PACKED_FLOAT32_ARRAY) {
  403. Vector<float> tangent_array = p_arrays[RS::ARRAY_TANGENT];
  404. ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  405. const float *tangent_src = tangent_array.ptr();
  406. // Set data for vertex, normal, and tangent.
  407. for (int i = 0; i < p_vertex_array_len; i++) {
  408. float angle = 0.0;
  409. Vector3 axis;
  410. Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);
  411. _get_axis_angle(normal_src[i], tangent, angle, axis);
  412. // Store axis.
  413. {
  414. Vector2 res = axis.octahedron_encode();
  415. uint16_t vector[2] = {
  416. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  417. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  418. };
  419. memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);
  420. }
  421. // Store vertex position + angle.
  422. {
  423. Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;
  424. uint16_t vector[4] = {
  425. (uint16_t)CLAMP(pos.x * 65535, 0, 65535),
  426. (uint16_t)CLAMP(pos.y * 65535, 0, 65535),
  427. (uint16_t)CLAMP(pos.z * 65535, 0, 65535),
  428. (uint16_t)CLAMP(angle * 65535, 0, 65535)
  429. };
  430. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);
  431. }
  432. }
  433. } else if (tangent_type == Variant::PACKED_FLOAT64_ARRAY) {
  434. Vector<double> tangent_array = p_arrays[RS::ARRAY_TANGENT];
  435. ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  436. const double *tangent_src = tangent_array.ptr();
  437. // Set data for vertex, normal, and tangent.
  438. for (int i = 0; i < p_vertex_array_len; i++) {
  439. float angle;
  440. Vector3 axis;
  441. Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);
  442. _get_axis_angle(normal_src[i], tangent, angle, axis);
  443. // Store axis.
  444. {
  445. Vector2 res = axis.octahedron_encode();
  446. uint16_t vector[2] = {
  447. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  448. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  449. };
  450. memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);
  451. }
  452. // Store vertex position + angle.
  453. {
  454. Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;
  455. uint16_t vector[4] = {
  456. (uint16_t)CLAMP(pos.x * 65535, 0, 65535),
  457. (uint16_t)CLAMP(pos.y * 65535, 0, 65535),
  458. (uint16_t)CLAMP(pos.z * 65535, 0, 65535),
  459. (uint16_t)CLAMP(angle * 65535, 0, 65535)
  460. };
  461. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);
  462. }
  463. }
  464. } else { // No tangent array.
  465. // Set data for vertex, normal, and tangent.
  466. for (int i = 0; i < p_vertex_array_len; i++) {
  467. float angle;
  468. Vector3 axis;
  469. // Generate an arbitrary vector that is tangential to normal.
  470. // This assumes that the normal is never (0,0,0).
  471. Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();
  472. Vector4 tangent = Vector4(tan.x, tan.y, tan.z, 1.0);
  473. _get_axis_angle(normal_src[i], tangent, angle, axis);
  474. // Store axis.
  475. {
  476. Vector2 res = axis.octahedron_encode();
  477. uint16_t vector[2] = {
  478. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  479. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  480. };
  481. memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);
  482. }
  483. // Store vertex position + angle.
  484. {
  485. Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;
  486. uint16_t vector[4] = {
  487. (uint16_t)CLAMP(pos.x * 65535, 0, 65535),
  488. (uint16_t)CLAMP(pos.y * 65535, 0, 65535),
  489. (uint16_t)CLAMP(pos.z * 65535, 0, 65535),
  490. (uint16_t)CLAMP(angle * 65535, 0, 65535)
  491. };
  492. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);
  493. }
  494. }
  495. }
  496. } else {
  497. for (int i = 0; i < p_vertex_array_len; i++) {
  498. float vector[3] = { (float)src[i].x, (float)src[i].y, (float)src[i].z };
  499. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 3);
  500. }
  501. }
  502. }
  503. } break;
  504. case RS::ARRAY_NORMAL: {
  505. // If using compression we store normal while storing vertices.
  506. if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
  507. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  508. Vector<Vector3> array = p_arrays[ai];
  509. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  510. const Vector3 *src = array.ptr();
  511. for (int i = 0; i < p_vertex_array_len; i++) {
  512. Vector2 res = src[i].octahedron_encode();
  513. uint16_t vector[2] = {
  514. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  515. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  516. };
  517. memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
  518. }
  519. }
  520. } break;
  521. case RS::ARRAY_TANGENT: {
  522. // If using compression we store tangent while storing vertices.
  523. if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
  524. Variant::Type type = p_arrays[ai].get_type();
  525. ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY && type != Variant::NIL, ERR_INVALID_PARAMETER);
  526. if (type == Variant::PACKED_FLOAT32_ARRAY) {
  527. Vector<float> array = p_arrays[ai];
  528. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  529. const float *src_ptr = array.ptr();
  530. for (int i = 0; i < p_vertex_array_len; i++) {
  531. const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);
  532. Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);
  533. uint16_t vector[2] = {
  534. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  535. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  536. };
  537. if (vector[0] == 0 && vector[1] == 65535) {
  538. // (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
  539. // So we sanitize here.
  540. vector[0] = 65535;
  541. }
  542. memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
  543. }
  544. } else if (type == Variant::PACKED_FLOAT64_ARRAY) {
  545. Vector<double> array = p_arrays[ai];
  546. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  547. const double *src_ptr = array.ptr();
  548. for (int i = 0; i < p_vertex_array_len; i++) {
  549. const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);
  550. Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);
  551. uint16_t vector[2] = {
  552. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  553. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  554. };
  555. if (vector[0] == 0 && vector[1] == 65535) {
  556. // (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
  557. // So we sanitize here.
  558. vector[0] = 65535;
  559. }
  560. memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
  561. }
  562. } else { // No tangent array.
  563. ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  564. Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];
  565. ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  566. const Vector3 *normal_src = normal_array.ptr();
  567. // Set data for tangent.
  568. for (int i = 0; i < p_vertex_array_len; i++) {
  569. // Generate an arbitrary vector that is tangential to normal.
  570. // This assumes that the normal is never (0,0,0).
  571. Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();
  572. Vector2 res = tan.octahedron_tangent_encode(1.0);
  573. uint16_t vector[2] = {
  574. (uint16_t)CLAMP(res.x * 65535, 0, 65535),
  575. (uint16_t)CLAMP(res.y * 65535, 0, 65535),
  576. };
  577. if (vector[0] == 0 && vector[1] == 65535) {
  578. // (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.
  579. // So we sanitize here.
  580. vector[0] = 65535;
  581. }
  582. memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);
  583. }
  584. }
  585. }
  586. } break;
  587. case RS::ARRAY_COLOR: {
  588. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);
  589. Vector<Color> array = p_arrays[ai];
  590. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  591. const Color *src = array.ptr();
  592. for (int i = 0; i < p_vertex_array_len; i++) {
  593. uint8_t color8[4] = {
  594. uint8_t(CLAMP(src[i].r * 255.0, 0.0, 255.0)),
  595. uint8_t(CLAMP(src[i].g * 255.0, 0.0, 255.0)),
  596. uint8_t(CLAMP(src[i].b * 255.0, 0.0, 255.0)),
  597. uint8_t(CLAMP(src[i].a * 255.0, 0.0, 255.0))
  598. };
  599. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color8, 4);
  600. }
  601. } break;
  602. case RS::ARRAY_TEX_UV: {
  603. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  604. Vector<Vector2> array = p_arrays[ai];
  605. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  606. const Vector2 *src = array.ptr();
  607. if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  608. for (int i = 0; i < p_vertex_array_len; i++) {
  609. Vector2 vec = src[i];
  610. if (!r_uv_scale.is_zero_approx()) {
  611. // Normalize into 0-1 from possible range -uv_scale - uv_scale.
  612. vec = vec / (Vector2(r_uv_scale.x, r_uv_scale.y)) + Vector2(0.5, 0.5);
  613. }
  614. uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };
  615. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);
  616. }
  617. } else {
  618. for (int i = 0; i < p_vertex_array_len; i++) {
  619. float uv[2] = { (float)src[i].x, (float)src[i].y };
  620. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);
  621. }
  622. }
  623. } break;
  624. case RS::ARRAY_TEX_UV2: {
  625. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
  626. Vector<Vector2> array = p_arrays[ai];
  627. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  628. const Vector2 *src = array.ptr();
  629. if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  630. for (int i = 0; i < p_vertex_array_len; i++) {
  631. Vector2 vec = src[i];
  632. if (!r_uv_scale.is_zero_approx()) {
  633. // Normalize into 0-1 from possible range -uv_scale - uv_scale.
  634. vec = vec / (Vector2(r_uv_scale.z, r_uv_scale.w)) + Vector2(0.5, 0.5);
  635. }
  636. uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };
  637. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);
  638. }
  639. } else {
  640. for (int i = 0; i < p_vertex_array_len; i++) {
  641. float uv[2] = { (float)src[i].x, (float)src[i].y };
  642. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);
  643. }
  644. }
  645. } break;
  646. case RS::ARRAY_CUSTOM0:
  647. case RS::ARRAY_CUSTOM1:
  648. case RS::ARRAY_CUSTOM2:
  649. case RS::ARRAY_CUSTOM3: {
  650. uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (ai - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;
  651. switch (type) {
  652. case ARRAY_CUSTOM_RGBA8_UNORM:
  653. case ARRAY_CUSTOM_RGBA8_SNORM:
  654. case ARRAY_CUSTOM_RG_HALF: {
  655. // Size 4
  656. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);
  657. Vector<uint8_t> array = p_arrays[ai];
  658. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  659. const uint8_t *src = array.ptr();
  660. for (int i = 0; i < p_vertex_array_len; i++) {
  661. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 4], 4);
  662. }
  663. } break;
  664. case ARRAY_CUSTOM_RGBA_HALF: {
  665. // Size 8
  666. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);
  667. Vector<uint8_t> array = p_arrays[ai];
  668. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 8, ERR_INVALID_PARAMETER);
  669. const uint8_t *src = array.ptr();
  670. for (int i = 0; i < p_vertex_array_len; i++) {
  671. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 8], 8);
  672. }
  673. } break;
  674. case ARRAY_CUSTOM_R_FLOAT:
  675. case ARRAY_CUSTOM_RG_FLOAT:
  676. case ARRAY_CUSTOM_RGB_FLOAT:
  677. case ARRAY_CUSTOM_RGBA_FLOAT: {
  678. // RF
  679. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
  680. Vector<float> array = p_arrays[ai];
  681. int32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;
  682. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * s, ERR_INVALID_PARAMETER);
  683. const float *src = array.ptr();
  684. for (int i = 0; i < p_vertex_array_len; i++) {
  685. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * s], sizeof(float) * s);
  686. }
  687. } break;
  688. default: {
  689. }
  690. }
  691. } break;
  692. case RS::ARRAY_WEIGHTS: {
  693. Variant::Type type = p_arrays[ai].get_type();
  694. ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY, ERR_INVALID_PARAMETER);
  695. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  696. if (type == Variant::PACKED_FLOAT32_ARRAY) {
  697. Vector<float> array = p_arrays[ai];
  698. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  699. const float *src = array.ptr();
  700. {
  701. uint16_t data[8];
  702. for (int i = 0; i < p_vertex_array_len; i++) {
  703. for (uint32_t j = 0; j < bone_count; j++) {
  704. data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);
  705. }
  706. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  707. }
  708. }
  709. } else { // PACKED_FLOAT64_ARRAY
  710. Vector<double> array = p_arrays[ai];
  711. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  712. const double *src = array.ptr();
  713. {
  714. uint16_t data[8];
  715. for (int i = 0; i < p_vertex_array_len; i++) {
  716. for (uint32_t j = 0; j < bone_count; j++) {
  717. data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);
  718. }
  719. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  720. }
  721. }
  722. }
  723. } break;
  724. case RS::ARRAY_BONES: {
  725. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
  726. Vector<int> array = p_arrays[ai];
  727. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  728. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  729. const int *src = array.ptr();
  730. uint16_t data[8];
  731. for (int i = 0; i < p_vertex_array_len; i++) {
  732. for (uint32_t j = 0; j < bone_count; j++) {
  733. data[j] = src[i * bone_count + j];
  734. max_bone = MAX(data[j], max_bone);
  735. }
  736. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  737. }
  738. } break;
  739. case RS::ARRAY_INDEX: {
  740. ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);
  741. ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
  742. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);
  743. Vector<int> indices = p_arrays[ai];
  744. ERR_FAIL_COND_V(indices.is_empty(), ERR_INVALID_PARAMETER);
  745. ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);
  746. /* determine whether using 16 or 32 bits indices */
  747. const int *src = indices.ptr();
  748. for (int i = 0; i < p_index_array_len; i++) {
  749. if (p_vertex_array_len <= (1 << 16) && p_vertex_array_len > 0) {
  750. uint16_t v = src[i];
  751. memcpy(&iw[i * 2], &v, 2);
  752. } else {
  753. uint32_t v = src[i];
  754. memcpy(&iw[i * 4], &v, 4);
  755. }
  756. }
  757. } break;
  758. default: {
  759. ERR_FAIL_V(ERR_INVALID_DATA);
  760. }
  761. }
  762. }
  763. if (p_format & RS::ARRAY_FORMAT_BONES) {
  764. // Create AABBs for each detected bone.
  765. int total_bones = max_bone + 1;
  766. bool first = r_bone_aabb.size() == 0;
  767. r_bone_aabb.resize(total_bones);
  768. int weight_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  769. if (first) {
  770. for (int i = 0; i < total_bones; i++) {
  771. r_bone_aabb.write[i].size = Vector3(-1, -1, -1); // Negative means unused.
  772. }
  773. }
  774. Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];
  775. Vector<int> bones = p_arrays[RS::ARRAY_BONES];
  776. Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS];
  777. bool any_valid = false;
  778. if (vertices.size() && bones.size() == vertices.size() * weight_count && weights.size() == bones.size()) {
  779. int vs = vertices.size();
  780. const Vector3 *rv = vertices.ptr();
  781. const int *rb = bones.ptr();
  782. const float *rw = weights.ptr();
  783. AABB *bptr = r_bone_aabb.ptrw();
  784. for (int i = 0; i < vs; i++) {
  785. Vector3 v = rv[i];
  786. for (int j = 0; j < weight_count; j++) {
  787. int idx = rb[i * weight_count + j];
  788. float w = rw[i * weight_count + j];
  789. if (w == 0) {
  790. continue; //break;
  791. }
  792. ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
  793. if (bptr[idx].size.x < 0) {
  794. // First
  795. bptr[idx] = AABB(v, SMALL_VEC3);
  796. any_valid = true;
  797. } else {
  798. bptr[idx].expand_to(v);
  799. }
  800. }
  801. }
  802. }
  803. if (!any_valid && first) {
  804. r_bone_aabb.clear();
  805. }
  806. }
  807. return OK;
  808. }
  809. uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const {
  810. ERR_FAIL_INDEX_V(p_array_index, ARRAY_MAX, 0);
  811. p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  812. uint32_t offsets[ARRAY_MAX];
  813. uint32_t vstr;
  814. uint32_t ntstr;
  815. uint32_t astr;
  816. uint32_t sstr;
  817. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
  818. return offsets[p_array_index];
  819. }
  820. uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  821. p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  822. uint32_t offsets[ARRAY_MAX];
  823. uint32_t vstr;
  824. uint32_t ntstr;
  825. uint32_t astr;
  826. uint32_t sstr;
  827. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
  828. return vstr;
  829. }
  830. uint32_t RenderingServer::mesh_surface_get_format_normal_tangent_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  831. p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  832. uint32_t offsets[ARRAY_MAX];
  833. uint32_t vstr;
  834. uint32_t ntstr;
  835. uint32_t astr;
  836. uint32_t sstr;
  837. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
  838. return ntstr;
  839. }
  840. uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  841. p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  842. uint32_t offsets[ARRAY_MAX];
  843. uint32_t vstr;
  844. uint32_t ntstr;
  845. uint32_t astr;
  846. uint32_t sstr;
  847. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
  848. return astr;
  849. }
  850. uint32_t RenderingServer::mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  851. p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  852. uint32_t offsets[ARRAY_MAX];
  853. uint32_t vstr;
  854. uint32_t ntstr;
  855. uint32_t astr;
  856. uint32_t sstr;
  857. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);
  858. return sstr;
  859. }
  860. void RenderingServer::mesh_surface_make_offsets_from_format(uint64_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t &r_vertex_element_size, uint32_t &r_normal_element_size, uint32_t &r_attrib_element_size, uint32_t &r_skin_element_size) const {
  861. r_vertex_element_size = 0;
  862. r_normal_element_size = 0;
  863. r_attrib_element_size = 0;
  864. r_skin_element_size = 0;
  865. uint32_t *size_accum = nullptr;
  866. for (int i = 0; i < RS::ARRAY_MAX; i++) {
  867. r_offsets[i] = 0; // Reset
  868. if (i == RS::ARRAY_VERTEX) {
  869. size_accum = &r_vertex_element_size;
  870. } else if (i == RS::ARRAY_NORMAL) {
  871. size_accum = &r_normal_element_size;
  872. } else if (i == RS::ARRAY_COLOR) {
  873. size_accum = &r_attrib_element_size;
  874. } else if (i == RS::ARRAY_BONES) {
  875. size_accum = &r_skin_element_size;
  876. }
  877. if (!(p_format & (1ULL << i))) { // No array
  878. continue;
  879. }
  880. int elem_size = 0;
  881. switch (i) {
  882. case RS::ARRAY_VERTEX: {
  883. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  884. elem_size = 2;
  885. } else {
  886. elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 2 : 3;
  887. }
  888. elem_size *= sizeof(float);
  889. } break;
  890. case RS::ARRAY_NORMAL: {
  891. elem_size = 4;
  892. } break;
  893. case RS::ARRAY_TANGENT: {
  894. elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 0 : 4;
  895. } break;
  896. case RS::ARRAY_COLOR: {
  897. elem_size = 4;
  898. } break;
  899. case RS::ARRAY_TEX_UV: {
  900. elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;
  901. } break;
  902. case RS::ARRAY_TEX_UV2: {
  903. elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;
  904. } break;
  905. case RS::ARRAY_CUSTOM0:
  906. case RS::ARRAY_CUSTOM1:
  907. case RS::ARRAY_CUSTOM2:
  908. case RS::ARRAY_CUSTOM3: {
  909. uint64_t format = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + (ARRAY_FORMAT_CUSTOM_BITS * (i - ARRAY_CUSTOM0)))) & ARRAY_FORMAT_CUSTOM_MASK;
  910. switch (format) {
  911. case ARRAY_CUSTOM_RGBA8_UNORM: {
  912. elem_size = 4;
  913. } break;
  914. case ARRAY_CUSTOM_RGBA8_SNORM: {
  915. elem_size = 4;
  916. } break;
  917. case ARRAY_CUSTOM_RG_HALF: {
  918. elem_size = 4;
  919. } break;
  920. case ARRAY_CUSTOM_RGBA_HALF: {
  921. elem_size = 8;
  922. } break;
  923. case ARRAY_CUSTOM_R_FLOAT: {
  924. elem_size = 4;
  925. } break;
  926. case ARRAY_CUSTOM_RG_FLOAT: {
  927. elem_size = 8;
  928. } break;
  929. case ARRAY_CUSTOM_RGB_FLOAT: {
  930. elem_size = 12;
  931. } break;
  932. case ARRAY_CUSTOM_RGBA_FLOAT: {
  933. elem_size = 16;
  934. } break;
  935. }
  936. } break;
  937. case RS::ARRAY_WEIGHTS: {
  938. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  939. elem_size = sizeof(uint16_t) * bone_count;
  940. } break;
  941. case RS::ARRAY_BONES: {
  942. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  943. elem_size = sizeof(uint16_t) * bone_count;
  944. } break;
  945. case RS::ARRAY_INDEX: {
  946. if (p_index_len <= 0) {
  947. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  948. break;
  949. }
  950. /* determine whether using 16 or 32 bits indices */
  951. if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {
  952. elem_size = 2;
  953. } else {
  954. elem_size = 4;
  955. }
  956. r_offsets[i] = elem_size;
  957. continue;
  958. }
  959. default: {
  960. ERR_FAIL();
  961. }
  962. }
  963. if (size_accum != nullptr) {
  964. r_offsets[i] = (*size_accum);
  965. if (i == RS::ARRAY_NORMAL || i == RS::ARRAY_TANGENT) {
  966. r_offsets[i] += r_vertex_element_size * p_vertex_len;
  967. }
  968. (*size_accum) += elem_size;
  969. } else {
  970. r_offsets[i] = 0;
  971. }
  972. }
  973. }
  974. Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint64_t p_compress_format) {
  975. ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);
  976. ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);
  977. uint64_t format = 0;
  978. // Validation
  979. int index_array_len = 0;
  980. int array_len = 0;
  981. for (int i = 0; i < p_arrays.size(); i++) {
  982. if (p_arrays[i].get_type() == Variant::NIL) {
  983. continue;
  984. }
  985. format |= (1ULL << i);
  986. if (i == RS::ARRAY_VERTEX) {
  987. switch (p_arrays[i].get_type()) {
  988. case Variant::PACKED_VECTOR2_ARRAY: {
  989. Vector<Vector2> v2 = p_arrays[i];
  990. array_len = v2.size();
  991. format |= ARRAY_FLAG_USE_2D_VERTICES;
  992. } break;
  993. case Variant::PACKED_VECTOR3_ARRAY: {
  994. ERR_FAIL_COND_V(p_compress_format & ARRAY_FLAG_USE_2D_VERTICES, ERR_INVALID_PARAMETER);
  995. Vector<Vector3> v3 = p_arrays[i];
  996. array_len = v3.size();
  997. } break;
  998. default: {
  999. ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Vertex array must be a PackedVector2Array or PackedVector3Array.");
  1000. } break;
  1001. }
  1002. ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);
  1003. } else if (i == RS::ARRAY_NORMAL) {
  1004. if (p_arrays[RS::ARRAY_TANGENT].get_type() == Variant::NIL) {
  1005. // We must use tangents if using normals.
  1006. format |= (1ULL << RS::ARRAY_TANGENT);
  1007. }
  1008. } else if (i == RS::ARRAY_BONES) {
  1009. switch (p_arrays[i].get_type()) {
  1010. case Variant::PACKED_INT32_ARRAY: {
  1011. Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];
  1012. Vector<int32_t> bones = p_arrays[i];
  1013. int32_t bone_8_group_count = bones.size() / (ARRAY_WEIGHTS_SIZE * 2);
  1014. int32_t vertex_count = vertices.size();
  1015. if (vertex_count == bone_8_group_count) {
  1016. format |= RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
  1017. }
  1018. } break;
  1019. default: {
  1020. ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Bones array must be a PackedInt32Array.");
  1021. } break;
  1022. }
  1023. } else if (i == RS::ARRAY_INDEX) {
  1024. index_array_len = PackedInt32Array(p_arrays[i]).size();
  1025. }
  1026. }
  1027. if (p_blend_shapes.size()) {
  1028. // Validate format for morphs.
  1029. for (int i = 0; i < p_blend_shapes.size(); i++) {
  1030. uint32_t bsformat = 0;
  1031. Array arr = p_blend_shapes[i];
  1032. for (int j = 0; j < arr.size(); j++) {
  1033. if (arr[j].get_type() != Variant::NIL) {
  1034. bsformat |= (1 << j);
  1035. }
  1036. }
  1037. if (bsformat & RS::ARRAY_FORMAT_NORMAL) {
  1038. // We must use tangents if using normals.
  1039. bsformat |= RS::ARRAY_FORMAT_TANGENT;
  1040. }
  1041. ERR_FAIL_COND_V_MSG(bsformat != (format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK), ERR_INVALID_PARAMETER, "Blend shape format must match the main array format for Vertex, Normal and Tangent arrays.");
  1042. }
  1043. }
  1044. for (uint32_t i = 0; i < RS::ARRAY_CUSTOM_COUNT; ++i) {
  1045. // Include custom array format type.
  1046. if (format & (1ULL << (ARRAY_CUSTOM0 + i))) {
  1047. format |= (RS::ARRAY_FORMAT_CUSTOM_MASK << (RS::ARRAY_FORMAT_CUSTOM_BASE + i * RS::ARRAY_FORMAT_CUSTOM_BITS)) & p_compress_format;
  1048. }
  1049. }
  1050. uint32_t offsets[RS::ARRAY_MAX];
  1051. uint32_t vertex_element_size;
  1052. uint32_t normal_element_size;
  1053. uint32_t attrib_element_size;
  1054. uint32_t skin_element_size;
  1055. uint64_t mask = (1ULL << ARRAY_MAX) - 1ULL;
  1056. format |= (~mask) & p_compress_format; // Make the full format.
  1057. // Force version to the current version as this function will always return a surface with the current version.
  1058. format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  1059. format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  1060. mesh_surface_make_offsets_from_format(format, array_len, index_array_len, offsets, vertex_element_size, normal_element_size, attrib_element_size, skin_element_size);
  1061. if ((format & RS::ARRAY_FORMAT_VERTEX) == 0 && !(format & RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY)) {
  1062. ERR_PRINT("Mesh created without vertex array. This mesh will not be visible with the default shader. If using an empty vertex array is intentional, create the mesh with the ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY flag to silence this error.");
  1063. // Set the flag here after warning to suppress errors down the pipeline.
  1064. format |= RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY;
  1065. }
  1066. if ((format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && ((format & RS::ARRAY_FORMAT_NORMAL) || (format & RS::ARRAY_FORMAT_TANGENT))) {
  1067. // If using normals or tangents, then we need all three.
  1068. ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_VERTEX), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using normals or tangents without vertex array.");
  1069. ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_NORMAL), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using tangents without normal array.");
  1070. }
  1071. int vertex_array_size = (vertex_element_size + normal_element_size) * array_len;
  1072. int attrib_array_size = attrib_element_size * array_len;
  1073. int skin_array_size = skin_element_size * array_len;
  1074. int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len;
  1075. Vector<uint8_t> vertex_array;
  1076. vertex_array.resize(vertex_array_size);
  1077. Vector<uint8_t> attrib_array;
  1078. attrib_array.resize(attrib_array_size);
  1079. Vector<uint8_t> skin_array;
  1080. skin_array.resize(skin_array_size);
  1081. Vector<uint8_t> index_array;
  1082. index_array.resize(index_array_size);
  1083. AABB aabb;
  1084. Vector<AABB> bone_aabb;
  1085. Vector4 uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);
  1086. Error err = _surface_set_data(p_arrays, format, offsets, vertex_element_size, normal_element_size, attrib_element_size, skin_element_size, vertex_array, attrib_array, skin_array, array_len, index_array, index_array_len, aabb, bone_aabb, uv_scale);
  1087. ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Invalid array format for surface.");
  1088. Vector<uint8_t> blend_shape_data;
  1089. if (p_blend_shapes.size()) {
  1090. uint32_t bs_format = format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK;
  1091. for (int i = 0; i < p_blend_shapes.size(); i++) {
  1092. Vector<uint8_t> vertex_array_shape;
  1093. vertex_array_shape.resize(vertex_array_size);
  1094. Vector<uint8_t> noindex;
  1095. Vector<uint8_t> noattrib;
  1096. Vector<uint8_t> noskin;
  1097. AABB laabb;
  1098. Vector4 bone_uv_scale; // Not used.
  1099. Error err2 = _surface_set_data(p_blend_shapes[i], bs_format, offsets, vertex_element_size, normal_element_size, 0, 0, vertex_array_shape, noattrib, noskin, array_len, noindex, 0, laabb, bone_aabb, bone_uv_scale);
  1100. aabb.merge_with(laabb);
  1101. ERR_FAIL_COND_V_MSG(err2 != OK, ERR_INVALID_DATA, "Invalid blend shape array format for surface.");
  1102. blend_shape_data.append_array(vertex_array_shape);
  1103. }
  1104. }
  1105. Vector<SurfaceData::LOD> lods;
  1106. if (index_array_len) {
  1107. List<Variant> keys;
  1108. p_lods.get_key_list(&keys);
  1109. keys.sort(); // otherwise lod levels may get skipped
  1110. for (const Variant &E : keys) {
  1111. float distance = E;
  1112. ERR_CONTINUE(distance <= 0.0);
  1113. Vector<int> indices = p_lods[E];
  1114. ERR_CONTINUE(indices.is_empty());
  1115. uint32_t index_count = indices.size();
  1116. ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller..
  1117. const int *r = indices.ptr();
  1118. Vector<uint8_t> data;
  1119. if (array_len <= 65536) {
  1120. // 16 bits indices
  1121. data.resize(indices.size() * 2);
  1122. uint8_t *w = data.ptrw();
  1123. uint16_t *index_ptr = (uint16_t *)w;
  1124. for (uint32_t i = 0; i < index_count; i++) {
  1125. index_ptr[i] = r[i];
  1126. }
  1127. } else {
  1128. // 32 bits indices
  1129. data.resize(indices.size() * 4);
  1130. uint8_t *w = data.ptrw();
  1131. uint32_t *index_ptr = (uint32_t *)w;
  1132. for (uint32_t i = 0; i < index_count; i++) {
  1133. index_ptr[i] = r[i];
  1134. }
  1135. }
  1136. SurfaceData::LOD lod;
  1137. lod.edge_length = distance;
  1138. lod.index_data = data;
  1139. lods.push_back(lod);
  1140. }
  1141. }
  1142. SurfaceData &surface_data = *r_surface_data;
  1143. surface_data.format = format;
  1144. surface_data.primitive = p_primitive;
  1145. surface_data.aabb = aabb;
  1146. surface_data.vertex_data = vertex_array;
  1147. surface_data.attribute_data = attrib_array;
  1148. surface_data.skin_data = skin_array;
  1149. surface_data.vertex_count = array_len;
  1150. surface_data.index_data = index_array;
  1151. surface_data.index_count = index_array_len;
  1152. surface_data.blend_shape_data = blend_shape_data;
  1153. surface_data.bone_aabbs = bone_aabb;
  1154. surface_data.lods = lods;
  1155. surface_data.uv_scale = uv_scale;
  1156. return OK;
  1157. }
  1158. void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, BitField<ArrayFormat> p_compress_format) {
  1159. SurfaceData sd;
  1160. Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);
  1161. if (err != OK) {
  1162. return;
  1163. }
  1164. mesh_add_surface(p_mesh, sd);
  1165. }
  1166. Array RenderingServer::_get_array_from_surface(uint64_t p_format, Vector<uint8_t> p_vertex_data, Vector<uint8_t> p_attrib_data, Vector<uint8_t> p_skin_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len, const AABB &p_aabb, const Vector4 &p_uv_scale) const {
  1167. uint32_t offsets[RS::ARRAY_MAX];
  1168. uint32_t vertex_elem_size;
  1169. uint32_t normal_elem_size;
  1170. uint32_t attrib_elem_size;
  1171. uint32_t skin_elem_size;
  1172. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets, vertex_elem_size, normal_elem_size, attrib_elem_size, skin_elem_size);
  1173. Array ret;
  1174. ret.resize(RS::ARRAY_MAX);
  1175. const uint8_t *r = p_vertex_data.ptr();
  1176. const uint8_t *ar = p_attrib_data.ptr();
  1177. const uint8_t *sr = p_skin_data.ptr();
  1178. for (int i = 0; i < RS::ARRAY_MAX; i++) {
  1179. if (!(p_format & (1ULL << i))) {
  1180. continue;
  1181. }
  1182. switch (i) {
  1183. case RS::ARRAY_VERTEX: {
  1184. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  1185. Vector<Vector2> arr_2d;
  1186. arr_2d.resize(p_vertex_len);
  1187. {
  1188. Vector2 *w = arr_2d.ptrw();
  1189. for (int j = 0; j < p_vertex_len; j++) {
  1190. const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
  1191. w[j] = Vector2(v[0], v[1]);
  1192. }
  1193. }
  1194. ret[i] = arr_2d;
  1195. } else {
  1196. Vector<Vector3> arr_3d;
  1197. arr_3d.resize(p_vertex_len);
  1198. {
  1199. Vector3 *w = arr_3d.ptrw();
  1200. if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  1201. // We only have vertices to read, so just read them and skip everything else.
  1202. if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {
  1203. for (int j = 0; j < p_vertex_len; j++) {
  1204. const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);
  1205. Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);
  1206. w[j] = (vec * p_aabb.size) + p_aabb.position;
  1207. }
  1208. continue;
  1209. }
  1210. Vector<Vector3> normals;
  1211. normals.resize(p_vertex_len);
  1212. Vector3 *normalsw = normals.ptrw();
  1213. Vector<float> tangents;
  1214. tangents.resize(p_vertex_len * 4);
  1215. float *tangentsw = tangents.ptrw();
  1216. for (int j = 0; j < p_vertex_len; j++) {
  1217. const uint32_t n = *(const uint32_t *)&r[j * normal_elem_size + offsets[RS::ARRAY_NORMAL]];
  1218. Vector3 axis = Vector3::octahedron_decode(Vector2((n & 0xFFFF) / 65535.0, ((n >> 16) & 0xFFFF) / 65535.0));
  1219. const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);
  1220. Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);
  1221. float angle = float(v[3]) / 65535.0;
  1222. w[j] = (vec * p_aabb.size) + p_aabb.position;
  1223. Vector3 normal;
  1224. Vector4 tan;
  1225. _get_tbn_from_axis_angle(axis, angle, normal, tan);
  1226. normalsw[j] = normal;
  1227. tangentsw[j * 4 + 0] = tan.x;
  1228. tangentsw[j * 4 + 1] = tan.y;
  1229. tangentsw[j * 4 + 2] = tan.z;
  1230. tangentsw[j * 4 + 3] = tan.w;
  1231. }
  1232. ret[RS::ARRAY_NORMAL] = normals;
  1233. ret[RS::ARRAY_TANGENT] = tangents;
  1234. } else {
  1235. for (int j = 0; j < p_vertex_len; j++) {
  1236. const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
  1237. w[j] = Vector3(v[0], v[1], v[2]);
  1238. }
  1239. }
  1240. }
  1241. ret[i] = arr_3d;
  1242. }
  1243. } break;
  1244. case RS::ARRAY_NORMAL: {
  1245. if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
  1246. Vector<Vector3> arr;
  1247. arr.resize(p_vertex_len);
  1248. Vector3 *w = arr.ptrw();
  1249. for (int j = 0; j < p_vertex_len; j++) {
  1250. const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];
  1251. w[j] = Vector3::octahedron_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0));
  1252. }
  1253. ret[i] = arr;
  1254. }
  1255. } break;
  1256. case RS::ARRAY_TANGENT: {
  1257. if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {
  1258. Vector<float> arr;
  1259. arr.resize(p_vertex_len * 4);
  1260. float *w = arr.ptrw();
  1261. for (int j = 0; j < p_vertex_len; j++) {
  1262. const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];
  1263. float tangent_sign;
  1264. Vector3 res = Vector3::octahedron_tangent_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0), &tangent_sign);
  1265. w[j * 4 + 0] = res.x;
  1266. w[j * 4 + 1] = res.y;
  1267. w[j * 4 + 2] = res.z;
  1268. w[j * 4 + 3] = tangent_sign;
  1269. }
  1270. ret[i] = arr;
  1271. }
  1272. } break;
  1273. case RS::ARRAY_COLOR: {
  1274. Vector<Color> arr;
  1275. arr.resize(p_vertex_len);
  1276. Color *w = arr.ptrw();
  1277. for (int32_t j = 0; j < p_vertex_len; j++) {
  1278. const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  1279. w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
  1280. }
  1281. ret[i] = arr;
  1282. } break;
  1283. case RS::ARRAY_TEX_UV: {
  1284. Vector<Vector2> arr;
  1285. arr.resize(p_vertex_len);
  1286. Vector2 *w = arr.ptrw();
  1287. if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  1288. for (int j = 0; j < p_vertex_len; j++) {
  1289. const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  1290. Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);
  1291. if (!p_uv_scale.is_zero_approx()) {
  1292. vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.x, p_uv_scale.y);
  1293. }
  1294. w[j] = vec;
  1295. }
  1296. } else {
  1297. for (int j = 0; j < p_vertex_len; j++) {
  1298. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  1299. w[j] = Vector2(v[0], v[1]);
  1300. }
  1301. }
  1302. ret[i] = arr;
  1303. } break;
  1304. case RS::ARRAY_TEX_UV2: {
  1305. Vector<Vector2> arr;
  1306. arr.resize(p_vertex_len);
  1307. Vector2 *w = arr.ptrw();
  1308. if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {
  1309. for (int j = 0; j < p_vertex_len; j++) {
  1310. const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  1311. Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);
  1312. if (!p_uv_scale.is_zero_approx()) {
  1313. vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.z, p_uv_scale.w);
  1314. }
  1315. w[j] = vec;
  1316. }
  1317. } else {
  1318. for (int j = 0; j < p_vertex_len; j++) {
  1319. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  1320. w[j] = Vector2(v[0], v[1]);
  1321. }
  1322. }
  1323. ret[i] = arr;
  1324. } break;
  1325. case RS::ARRAY_CUSTOM0:
  1326. case RS::ARRAY_CUSTOM1:
  1327. case RS::ARRAY_CUSTOM2:
  1328. case RS::ARRAY_CUSTOM3: {
  1329. uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (i - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;
  1330. switch (type) {
  1331. case ARRAY_CUSTOM_RGBA8_UNORM:
  1332. case ARRAY_CUSTOM_RGBA8_SNORM:
  1333. case ARRAY_CUSTOM_RG_HALF:
  1334. case ARRAY_CUSTOM_RGBA_HALF: {
  1335. // Size 4
  1336. int s = type == ARRAY_CUSTOM_RGBA_HALF ? 8 : 4;
  1337. Vector<uint8_t> arr;
  1338. arr.resize(p_vertex_len * s);
  1339. uint8_t *w = arr.ptrw();
  1340. for (int j = 0; j < p_vertex_len; j++) {
  1341. const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  1342. memcpy(&w[j * s], v, s);
  1343. }
  1344. ret[i] = arr;
  1345. } break;
  1346. case ARRAY_CUSTOM_R_FLOAT:
  1347. case ARRAY_CUSTOM_RG_FLOAT:
  1348. case ARRAY_CUSTOM_RGB_FLOAT:
  1349. case ARRAY_CUSTOM_RGBA_FLOAT: {
  1350. uint32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;
  1351. Vector<float> arr;
  1352. arr.resize(s * p_vertex_len);
  1353. float *w = arr.ptrw();
  1354. for (int j = 0; j < p_vertex_len; j++) {
  1355. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  1356. memcpy(&w[j * s], v, s * sizeof(float));
  1357. }
  1358. ret[i] = arr;
  1359. } break;
  1360. default: {
  1361. }
  1362. }
  1363. } break;
  1364. case RS::ARRAY_WEIGHTS: {
  1365. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  1366. Vector<float> arr;
  1367. arr.resize(p_vertex_len * bone_count);
  1368. {
  1369. float *w = arr.ptrw();
  1370. for (int j = 0; j < p_vertex_len; j++) {
  1371. const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];
  1372. for (uint32_t k = 0; k < bone_count; k++) {
  1373. w[j * bone_count + k] = float(v[k] / 65535.0);
  1374. }
  1375. }
  1376. }
  1377. ret[i] = arr;
  1378. } break;
  1379. case RS::ARRAY_BONES: {
  1380. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  1381. Vector<int> arr;
  1382. arr.resize(p_vertex_len * bone_count);
  1383. int *w = arr.ptrw();
  1384. for (int j = 0; j < p_vertex_len; j++) {
  1385. const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];
  1386. for (uint32_t k = 0; k < bone_count; k++) {
  1387. w[j * bone_count + k] = v[k];
  1388. }
  1389. }
  1390. ret[i] = arr;
  1391. } break;
  1392. case RS::ARRAY_INDEX: {
  1393. /* determine whether using 16 or 32 bits indices */
  1394. const uint8_t *ir = p_index_data.ptr();
  1395. Vector<int> arr;
  1396. arr.resize(p_index_len);
  1397. if (p_vertex_len <= (1 << 16)) {
  1398. int *w = arr.ptrw();
  1399. for (int j = 0; j < p_index_len; j++) {
  1400. const uint16_t *v = (const uint16_t *)&ir[j * 2];
  1401. w[j] = *v;
  1402. }
  1403. } else {
  1404. int *w = arr.ptrw();
  1405. for (int j = 0; j < p_index_len; j++) {
  1406. const int *v = (const int *)&ir[j * 4];
  1407. w[j] = *v;
  1408. }
  1409. }
  1410. ret[i] = arr;
  1411. } break;
  1412. default: {
  1413. ERR_FAIL_V(ret);
  1414. }
  1415. }
  1416. }
  1417. return ret;
  1418. }
  1419. Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
  1420. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1421. return mesh_create_arrays_from_surface_data(sd);
  1422. }
  1423. Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {
  1424. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1425. ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());
  1426. Dictionary ret;
  1427. for (int i = 0; i < sd.lods.size(); i++) {
  1428. Vector<int> lods;
  1429. if (sd.vertex_count <= 65536) {
  1430. uint32_t lc = sd.lods[i].index_data.size() / 2;
  1431. lods.resize(lc);
  1432. const uint8_t *r = sd.lods[i].index_data.ptr();
  1433. const uint16_t *rptr = (const uint16_t *)r;
  1434. int *w = lods.ptrw();
  1435. for (uint32_t j = 0; j < lc; j++) {
  1436. w[j] = rptr[i];
  1437. }
  1438. } else {
  1439. uint32_t lc = sd.lods[i].index_data.size() / 4;
  1440. lods.resize(lc);
  1441. const uint8_t *r = sd.lods[i].index_data.ptr();
  1442. const uint32_t *rptr = (const uint32_t *)r;
  1443. int *w = lods.ptrw();
  1444. for (uint32_t j = 0; j < lc; j++) {
  1445. w[j] = rptr[i];
  1446. }
  1447. }
  1448. ret[sd.lods[i].edge_length] = lods;
  1449. }
  1450. return ret;
  1451. }
  1452. TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
  1453. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1454. ERR_FAIL_COND_V(sd.vertex_count == 0, Array());
  1455. Vector<uint8_t> blend_shape_data = sd.blend_shape_data;
  1456. if (blend_shape_data.size() > 0) {
  1457. uint32_t bs_offsets[RS::ARRAY_MAX];
  1458. uint32_t bs_format = (sd.format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK);
  1459. uint32_t vertex_elem_size;
  1460. uint32_t normal_elem_size;
  1461. uint32_t attrib_elem_size;
  1462. uint32_t skin_elem_size;
  1463. mesh_surface_make_offsets_from_format(bs_format, sd.vertex_count, 0, bs_offsets, vertex_elem_size, normal_elem_size, attrib_elem_size, skin_elem_size);
  1464. int divisor = (vertex_elem_size + normal_elem_size) * sd.vertex_count;
  1465. ERR_FAIL_COND_V((blend_shape_data.size() % divisor) != 0, Array());
  1466. uint32_t blend_shape_count = blend_shape_data.size() / divisor;
  1467. ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array());
  1468. TypedArray<Array> blend_shape_array;
  1469. blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh));
  1470. for (uint32_t i = 0; i < blend_shape_count; i++) {
  1471. Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor);
  1472. Vector<uint8_t> unused;
  1473. blend_shape_array.set(i, _get_array_from_surface(bs_format, bs_data, unused, unused, sd.vertex_count, unused, 0, sd.aabb, sd.uv_scale));
  1474. }
  1475. return blend_shape_array;
  1476. } else {
  1477. return TypedArray<Array>();
  1478. }
  1479. }
  1480. Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {
  1481. Vector<uint8_t> vertex_data = p_data.vertex_data;
  1482. Vector<uint8_t> attrib_data = p_data.attribute_data;
  1483. Vector<uint8_t> skin_data = p_data.skin_data;
  1484. ERR_FAIL_COND_V(vertex_data.is_empty() && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array());
  1485. int vertex_len = p_data.vertex_count;
  1486. Vector<uint8_t> index_data = p_data.index_data;
  1487. int index_len = p_data.index_count;
  1488. uint64_t format = p_data.format;
  1489. return _get_array_from_surface(format, vertex_data, attrib_data, skin_data, vertex_len, index_data, index_len, p_data.aabb, p_data.uv_scale);
  1490. }
  1491. #if 0
  1492. Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
  1493. Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
  1494. Array arr;
  1495. for (int i = 0; i < vec.size(); i++) {
  1496. arr[i] = vec[i];
  1497. }
  1498. return arr;
  1499. }
  1500. #endif
  1501. Rect2 RenderingServer::debug_canvas_item_get_rect(RID p_item) {
  1502. #ifdef TOOLS_ENABLED
  1503. return _debug_canvas_item_get_rect(p_item);
  1504. #else
  1505. return Rect2();
  1506. #endif
  1507. }
  1508. int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) {
  1509. switch (p_type) {
  1510. case RS::GLOBAL_VAR_TYPE_BOOL:
  1511. return ShaderLanguage::TYPE_BOOL;
  1512. case RS::GLOBAL_VAR_TYPE_BVEC2:
  1513. return ShaderLanguage::TYPE_BVEC2;
  1514. case RS::GLOBAL_VAR_TYPE_BVEC3:
  1515. return ShaderLanguage::TYPE_BVEC3;
  1516. case RS::GLOBAL_VAR_TYPE_BVEC4:
  1517. return ShaderLanguage::TYPE_BVEC4;
  1518. case RS::GLOBAL_VAR_TYPE_INT:
  1519. return ShaderLanguage::TYPE_INT;
  1520. case RS::GLOBAL_VAR_TYPE_IVEC2:
  1521. return ShaderLanguage::TYPE_IVEC2;
  1522. case RS::GLOBAL_VAR_TYPE_IVEC3:
  1523. return ShaderLanguage::TYPE_IVEC3;
  1524. case RS::GLOBAL_VAR_TYPE_IVEC4:
  1525. return ShaderLanguage::TYPE_IVEC4;
  1526. case RS::GLOBAL_VAR_TYPE_RECT2I:
  1527. return ShaderLanguage::TYPE_IVEC4;
  1528. case RS::GLOBAL_VAR_TYPE_UINT:
  1529. return ShaderLanguage::TYPE_UINT;
  1530. case RS::GLOBAL_VAR_TYPE_UVEC2:
  1531. return ShaderLanguage::TYPE_UVEC2;
  1532. case RS::GLOBAL_VAR_TYPE_UVEC3:
  1533. return ShaderLanguage::TYPE_UVEC3;
  1534. case RS::GLOBAL_VAR_TYPE_UVEC4:
  1535. return ShaderLanguage::TYPE_UVEC4;
  1536. case RS::GLOBAL_VAR_TYPE_FLOAT:
  1537. return ShaderLanguage::TYPE_FLOAT;
  1538. case RS::GLOBAL_VAR_TYPE_VEC2:
  1539. return ShaderLanguage::TYPE_VEC2;
  1540. case RS::GLOBAL_VAR_TYPE_VEC3:
  1541. return ShaderLanguage::TYPE_VEC3;
  1542. case RS::GLOBAL_VAR_TYPE_VEC4:
  1543. return ShaderLanguage::TYPE_VEC4;
  1544. case RS::GLOBAL_VAR_TYPE_COLOR:
  1545. return ShaderLanguage::TYPE_VEC4;
  1546. case RS::GLOBAL_VAR_TYPE_RECT2:
  1547. return ShaderLanguage::TYPE_VEC4;
  1548. case RS::GLOBAL_VAR_TYPE_MAT2:
  1549. return ShaderLanguage::TYPE_MAT2;
  1550. case RS::GLOBAL_VAR_TYPE_MAT3:
  1551. return ShaderLanguage::TYPE_MAT3;
  1552. case RS::GLOBAL_VAR_TYPE_MAT4:
  1553. return ShaderLanguage::TYPE_MAT4;
  1554. case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D:
  1555. return ShaderLanguage::TYPE_MAT3;
  1556. case RS::GLOBAL_VAR_TYPE_TRANSFORM:
  1557. return ShaderLanguage::TYPE_MAT4;
  1558. case RS::GLOBAL_VAR_TYPE_SAMPLER2D:
  1559. return ShaderLanguage::TYPE_SAMPLER2D;
  1560. case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY:
  1561. return ShaderLanguage::TYPE_SAMPLER2DARRAY;
  1562. case RS::GLOBAL_VAR_TYPE_SAMPLER3D:
  1563. return ShaderLanguage::TYPE_SAMPLER3D;
  1564. case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE:
  1565. return ShaderLanguage::TYPE_SAMPLERCUBE;
  1566. default:
  1567. return ShaderLanguage::TYPE_MAX; // Invalid or not found.
  1568. }
  1569. }
  1570. RenderingDevice *RenderingServer::get_rendering_device() const {
  1571. // Return the rendering device we're using globally.
  1572. return RenderingDevice::get_singleton();
  1573. }
  1574. RenderingDevice *RenderingServer::create_local_rendering_device() const {
  1575. RenderingDevice *device = RenderingDevice::get_singleton();
  1576. if (!device) {
  1577. return nullptr;
  1578. }
  1579. return device->create_local_device();
  1580. }
  1581. static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {
  1582. Vector<Ref<Image>> images;
  1583. images.resize(p_layers.size());
  1584. for (int i = 0; i < p_layers.size(); i++) {
  1585. images.write[i] = p_layers[i];
  1586. }
  1587. return images;
  1588. }
  1589. RID RenderingServer::_texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type) {
  1590. return texture_2d_layered_create(_get_imgvec(p_layers), p_layered_type);
  1591. }
  1592. RID RenderingServer::_texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const TypedArray<Image> &p_data) {
  1593. return texture_3d_create(p_format, p_width, p_height, p_depth, p_mipmaps, _get_imgvec(p_data));
  1594. }
  1595. void RenderingServer::_texture_3d_update(RID p_texture, const TypedArray<Image> &p_data) {
  1596. texture_3d_update(p_texture, _get_imgvec(p_data));
  1597. }
  1598. TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const {
  1599. Vector<Ref<Image>> images = texture_3d_get(p_texture);
  1600. TypedArray<Image> ret;
  1601. ret.resize(images.size());
  1602. for (int i = 0; i < images.size(); i++) {
  1603. ret[i] = images[i];
  1604. }
  1605. return ret;
  1606. }
  1607. TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const {
  1608. List<PropertyInfo> l;
  1609. get_shader_parameter_list(p_shader, &l);
  1610. return convert_property_list(&l);
  1611. }
  1612. static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) {
  1613. ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RS::SurfaceData());
  1614. ERR_FAIL_COND_V(!p_dictionary.has("format"), RS::SurfaceData());
  1615. ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RS::SurfaceData());
  1616. ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RS::SurfaceData());
  1617. ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RS::SurfaceData());
  1618. RS::SurfaceData sd;
  1619. sd.primitive = RS::PrimitiveType(int(p_dictionary["primitive"]));
  1620. sd.format = p_dictionary["format"];
  1621. sd.vertex_data = p_dictionary["vertex_data"];
  1622. if (p_dictionary.has("attribute_data")) {
  1623. sd.attribute_data = p_dictionary["attribute_data"];
  1624. }
  1625. if (p_dictionary.has("skin_data")) {
  1626. sd.skin_data = p_dictionary["skin_data"];
  1627. }
  1628. sd.vertex_count = p_dictionary["vertex_count"];
  1629. if (p_dictionary.has("index_data")) {
  1630. sd.index_data = p_dictionary["index_data"];
  1631. ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RS::SurfaceData());
  1632. sd.index_count = p_dictionary["index_count"];
  1633. }
  1634. sd.aabb = p_dictionary["aabb"];
  1635. if (p_dictionary.has("uv_scale")) {
  1636. sd.uv_scale = p_dictionary["uv_scale"];
  1637. }
  1638. if (p_dictionary.has("lods")) {
  1639. Array lods = p_dictionary["lods"];
  1640. for (int i = 0; i < lods.size(); i++) {
  1641. Dictionary lod = lods[i];
  1642. ERR_CONTINUE(!lod.has("edge_length"));
  1643. ERR_CONTINUE(!lod.has("index_data"));
  1644. RS::SurfaceData::LOD l;
  1645. l.edge_length = lod["edge_length"];
  1646. l.index_data = lod["index_data"];
  1647. sd.lods.push_back(l);
  1648. }
  1649. }
  1650. if (p_dictionary.has("bone_aabbs")) {
  1651. Array aabbs = p_dictionary["bone_aabbs"];
  1652. for (int i = 0; i < aabbs.size(); i++) {
  1653. AABB aabb = aabbs[i];
  1654. sd.bone_aabbs.push_back(aabb);
  1655. }
  1656. }
  1657. if (p_dictionary.has("blend_shape_data")) {
  1658. sd.blend_shape_data = p_dictionary["blend_shape_data"];
  1659. }
  1660. if (p_dictionary.has("material")) {
  1661. sd.material = p_dictionary["material"];
  1662. }
  1663. return sd;
  1664. }
  1665. RID RenderingServer::_mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count) {
  1666. Vector<RS::SurfaceData> surfaces;
  1667. for (int i = 0; i < p_surfaces.size(); i++) {
  1668. surfaces.push_back(_dict_to_surf(p_surfaces[i]));
  1669. }
  1670. return mesh_create_from_surfaces(surfaces);
  1671. }
  1672. void RenderingServer::_mesh_add_surface(RID p_mesh, const Dictionary &p_surface) {
  1673. mesh_add_surface(p_mesh, _dict_to_surf(p_surface));
  1674. }
  1675. Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) {
  1676. RS::SurfaceData sd = mesh_get_surface(p_mesh, p_idx);
  1677. Dictionary d;
  1678. d["primitive"] = sd.primitive;
  1679. d["format"] = sd.format;
  1680. d["vertex_data"] = sd.vertex_data;
  1681. if (sd.attribute_data.size()) {
  1682. d["attribute_data"] = sd.attribute_data;
  1683. }
  1684. if (sd.skin_data.size()) {
  1685. d["skin_data"] = sd.skin_data;
  1686. }
  1687. d["vertex_count"] = sd.vertex_count;
  1688. if (sd.index_count) {
  1689. d["index_data"] = sd.index_data;
  1690. d["index_count"] = sd.index_count;
  1691. }
  1692. d["aabb"] = sd.aabb;
  1693. d["uv_scale"] = sd.uv_scale;
  1694. if (sd.lods.size()) {
  1695. Array lods;
  1696. for (int i = 0; i < sd.lods.size(); i++) {
  1697. Dictionary ld;
  1698. ld["edge_length"] = sd.lods[i].edge_length;
  1699. ld["index_data"] = sd.lods[i].index_data;
  1700. lods.push_back(lods);
  1701. }
  1702. d["lods"] = lods;
  1703. }
  1704. if (sd.bone_aabbs.size()) {
  1705. Array aabbs;
  1706. for (int i = 0; i < sd.bone_aabbs.size(); i++) {
  1707. aabbs.push_back(sd.bone_aabbs[i]);
  1708. }
  1709. d["bone_aabbs"] = aabbs;
  1710. }
  1711. if (sd.blend_shape_data.size()) {
  1712. d["blend_shape_data"] = sd.blend_shape_data;
  1713. }
  1714. if (sd.material.is_valid()) {
  1715. d["material"] = sd.material;
  1716. }
  1717. return d;
  1718. }
  1719. TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const {
  1720. List<PropertyInfo> params;
  1721. instance_geometry_get_shader_parameter_list(p_instance, &params);
  1722. return convert_property_list(&params);
  1723. }
  1724. TypedArray<Image> RenderingServer::_bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) {
  1725. TypedArray<RID> mat_overrides;
  1726. for (int i = 0; i < p_material_overrides.size(); i++) {
  1727. mat_overrides.push_back(p_material_overrides[i]);
  1728. }
  1729. return bake_render_uv2(p_base, mat_overrides, p_image_size);
  1730. }
  1731. void RenderingServer::_particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses) {
  1732. Vector<Transform3D> tbposes;
  1733. tbposes.resize(p_bind_poses.size());
  1734. for (int i = 0; i < p_bind_poses.size(); i++) {
  1735. tbposes.write[i] = p_bind_poses[i];
  1736. }
  1737. particles_set_trail_bind_poses(p_particles, tbposes);
  1738. }
  1739. String RenderingServer::get_current_rendering_driver_name() const {
  1740. // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.
  1741. return ::OS::get_singleton()->get_current_rendering_driver_name();
  1742. }
  1743. String RenderingServer::get_current_rendering_method() const {
  1744. // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.
  1745. return ::OS::get_singleton()->get_current_rendering_method();
  1746. }
  1747. Vector<uint8_t> _convert_surface_version_1_to_surface_version_2(uint64_t p_format, Vector<uint8_t> p_vertex_data, uint32_t p_vertex_count, uint32_t p_old_stride, uint32_t p_vertex_size, uint32_t p_normal_size, uint32_t p_position_stride, uint32_t p_normal_tangent_stride) {
  1748. Vector<uint8_t> new_vertex_data;
  1749. new_vertex_data.resize(p_vertex_data.size());
  1750. uint8_t *dst_vertex_ptr = new_vertex_data.ptrw();
  1751. const uint8_t *src_vertex_ptr = p_vertex_data.ptr();
  1752. uint32_t position_size = p_position_stride * p_vertex_count;
  1753. for (uint32_t j = 0; j < RS::ARRAY_COLOR; j++) {
  1754. if (!(p_format & (1ULL << j))) {
  1755. continue;
  1756. }
  1757. switch (j) {
  1758. case RS::ARRAY_VERTEX: {
  1759. if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
  1760. for (uint32_t i = 0; i < p_vertex_count; i++) {
  1761. const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];
  1762. float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];
  1763. dst[0] = src[0];
  1764. dst[1] = src[1];
  1765. }
  1766. } else {
  1767. for (uint32_t i = 0; i < p_vertex_count; i++) {
  1768. const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];
  1769. float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];
  1770. dst[0] = src[0];
  1771. dst[1] = src[1];
  1772. dst[2] = src[2];
  1773. }
  1774. }
  1775. } break;
  1776. case RS::ARRAY_NORMAL: {
  1777. for (uint32_t i = 0; i < p_vertex_count; i++) {
  1778. const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size];
  1779. uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size];
  1780. dst[0] = src[0];
  1781. dst[1] = src[1];
  1782. }
  1783. } break;
  1784. case RS::ARRAY_TANGENT: {
  1785. for (uint32_t i = 0; i < p_vertex_count; i++) {
  1786. const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size + p_normal_size];
  1787. uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size + p_normal_size];
  1788. dst[0] = src[0];
  1789. dst[1] = src[1];
  1790. }
  1791. } break;
  1792. }
  1793. }
  1794. return new_vertex_data;
  1795. }
  1796. #ifdef TOOLS_ENABLED
  1797. void RenderingServer::set_surface_upgrade_callback(SurfaceUpgradeCallback p_callback) {
  1798. surface_upgrade_callback = p_callback;
  1799. }
  1800. void RenderingServer::set_warn_on_surface_upgrade(bool p_warn) {
  1801. warn_on_surface_upgrade = p_warn;
  1802. }
  1803. #endif
  1804. #ifndef DISABLE_DEPRECATED
  1805. void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const String &p_path) {
  1806. uint64_t surface_version = p_surface.format & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  1807. ERR_FAIL_COND_MSG(surface_version > ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Cannot convert surface with version provided (" + itos((surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + ") to current version (" + itos((RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + ")");
  1808. #ifdef TOOLS_ENABLED
  1809. // Editor callback to ask user about re-saving all meshes.
  1810. if (surface_upgrade_callback && warn_on_surface_upgrade) {
  1811. surface_upgrade_callback();
  1812. }
  1813. if (warn_on_surface_upgrade) {
  1814. WARN_PRINT_ONCE_ED("At least one surface uses an old surface format and needs to be upgraded. The upgrade happens automatically at load time every time until the mesh is saved again or re-imported. Once saved (or re-imported), this mesh will be incompatible with earlier versions of Godot.");
  1815. if (!p_path.is_empty()) {
  1816. WARN_PRINT("A surface of " + p_path + " uses an old surface format and needs to be upgraded.");
  1817. }
  1818. }
  1819. #endif
  1820. if (surface_version == ARRAY_FLAG_FORMAT_VERSION_1) {
  1821. // The only difference for now is that Version 1 uses interleaved vertex positions while version 2 does not.
  1822. // I.e. PNTPNTPNT -> PPPNTNTNT.
  1823. if (p_surface.vertex_data.size() > 0 && p_surface.vertex_count > 0) {
  1824. int vertex_size = 0;
  1825. int normal_size = 0;
  1826. int tangent_size = 0;
  1827. if (p_surface.format & ARRAY_FORMAT_VERTEX) {
  1828. if (p_surface.format & ARRAY_FLAG_USE_2D_VERTICES) {
  1829. vertex_size = sizeof(float) * 2;
  1830. } else {
  1831. vertex_size = sizeof(float) * 3;
  1832. }
  1833. }
  1834. if (p_surface.format & ARRAY_FORMAT_NORMAL) {
  1835. normal_size += sizeof(uint16_t) * 2;
  1836. }
  1837. if (p_surface.format & ARRAY_FORMAT_TANGENT) {
  1838. tangent_size = sizeof(uint16_t) * 2;
  1839. }
  1840. int stride = p_surface.vertex_data.size() / p_surface.vertex_count;
  1841. int position_stride = vertex_size;
  1842. int normal_tangent_stride = normal_size + tangent_size;
  1843. p_surface.vertex_data = _convert_surface_version_1_to_surface_version_2(p_surface.format, p_surface.vertex_data, p_surface.vertex_count, stride, vertex_size, normal_size, position_stride, normal_tangent_stride);
  1844. if (p_surface.blend_shape_data.size() > 0) {
  1845. // The size of one blend shape.
  1846. int divisor = (vertex_size + normal_size + tangent_size) * p_surface.vertex_count;
  1847. ERR_FAIL_COND((p_surface.blend_shape_data.size() % divisor) != 0);
  1848. uint32_t blend_shape_count = p_surface.blend_shape_data.size() / divisor;
  1849. Vector<uint8_t> new_blend_shape_data;
  1850. for (uint32_t i = 0; i < blend_shape_count; i++) {
  1851. Vector<uint8_t> bs_data = p_surface.blend_shape_data.slice(i * divisor, (i + 1) * divisor);
  1852. Vector<uint8_t> blend_shape = _convert_surface_version_1_to_surface_version_2(p_surface.format, bs_data, p_surface.vertex_count, stride, vertex_size, normal_size, position_stride, normal_tangent_stride);
  1853. new_blend_shape_data.append_array(blend_shape);
  1854. }
  1855. ERR_FAIL_COND(p_surface.blend_shape_data.size() != new_blend_shape_data.size());
  1856. p_surface.blend_shape_data = new_blend_shape_data;
  1857. }
  1858. }
  1859. }
  1860. p_surface.format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  1861. p_surface.format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  1862. }
  1863. #endif
  1864. #ifdef TOOLS_ENABLED
  1865. void RenderingServer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
  1866. const String pf = p_function;
  1867. if (p_idx == 0) {
  1868. if (pf == "global_shader_parameter_set" || pf == "global_shader_parameter_set_override" ||
  1869. pf == "global_shader_parameter_get" || pf == "global_shader_parameter_get_type" || pf == "global_shader_parameter_remove") {
  1870. for (const StringName &E : global_shader_parameter_get_list()) {
  1871. r_options->push_back(E.operator String().quote());
  1872. }
  1873. } else if (pf == "has_os_feature") {
  1874. for (const String E : { "\"rgtc\"", "\"s3tc\"", "\"bptc\"", "\"etc\"", "\"etc2\"", "\"astc\"" }) {
  1875. r_options->push_back(E);
  1876. }
  1877. }
  1878. }
  1879. Object::get_argument_options(p_function, p_idx, r_options);
  1880. }
  1881. #endif
  1882. void RenderingServer::_bind_methods() {
  1883. BIND_CONSTANT(NO_INDEX_ARRAY);
  1884. BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
  1885. BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
  1886. BIND_CONSTANT(CANVAS_ITEM_Z_MAX);
  1887. BIND_CONSTANT(MAX_GLOW_LEVELS);
  1888. BIND_CONSTANT(MAX_CURSORS);
  1889. BIND_CONSTANT(MAX_2D_DIRECTIONAL_LIGHTS);
  1890. BIND_CONSTANT(MAX_MESH_SURFACES);
  1891. /* TEXTURE */
  1892. ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create);
  1893. ClassDB::bind_method(D_METHOD("texture_2d_layered_create", "layers", "layered_type"), &RenderingServer::_texture_2d_layered_create);
  1894. ClassDB::bind_method(D_METHOD("texture_3d_create", "format", "width", "height", "depth", "mipmaps", "data"), &RenderingServer::_texture_3d_create);
  1895. ClassDB::bind_method(D_METHOD("texture_proxy_create", "base"), &RenderingServer::texture_proxy_create);
  1896. ClassDB::bind_method(D_METHOD("texture_create_from_native_handle", "type", "format", "native_handle", "width", "height", "depth", "layers", "layered_type"), &RenderingServer::texture_create_from_native_handle, DEFVAL(1), DEFVAL(TEXTURE_LAYERED_2D_ARRAY));
  1897. ClassDB::bind_method(D_METHOD("texture_2d_update", "texture", "image", "layer"), &RenderingServer::texture_2d_update);
  1898. ClassDB::bind_method(D_METHOD("texture_3d_update", "texture", "data"), &RenderingServer::_texture_3d_update);
  1899. ClassDB::bind_method(D_METHOD("texture_proxy_update", "texture", "proxy_to"), &RenderingServer::texture_proxy_update);
  1900. ClassDB::bind_method(D_METHOD("texture_2d_placeholder_create"), &RenderingServer::texture_2d_placeholder_create);
  1901. ClassDB::bind_method(D_METHOD("texture_2d_layered_placeholder_create", "layered_type"), &RenderingServer::texture_2d_layered_placeholder_create);
  1902. ClassDB::bind_method(D_METHOD("texture_3d_placeholder_create"), &RenderingServer::texture_3d_placeholder_create);
  1903. ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get);
  1904. ClassDB::bind_method(D_METHOD("texture_2d_layer_get", "texture", "layer"), &RenderingServer::texture_2d_layer_get);
  1905. ClassDB::bind_method(D_METHOD("texture_3d_get", "texture"), &RenderingServer::_texture_3d_get);
  1906. ClassDB::bind_method(D_METHOD("texture_replace", "texture", "by_texture"), &RenderingServer::texture_replace);
  1907. ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height"), &RenderingServer::texture_set_size_override);
  1908. ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &RenderingServer::texture_set_path);
  1909. ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &RenderingServer::texture_get_path);
  1910. ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &RenderingServer::texture_get_format);
  1911. ClassDB::bind_method(D_METHOD("texture_set_force_redraw_if_visible", "texture", "enable"), &RenderingServer::texture_set_force_redraw_if_visible);
  1912. ClassDB::bind_method(D_METHOD("texture_rd_create", "rd_texture", "layer_type"), &RenderingServer::texture_rd_create, DEFVAL(RenderingServer::TEXTURE_LAYERED_2D_ARRAY));
  1913. ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture, DEFVAL(false));
  1914. ClassDB::bind_method(D_METHOD("texture_get_native_handle", "texture", "srgb"), &RenderingServer::texture_get_native_handle, DEFVAL(false));
  1915. BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);
  1916. BIND_ENUM_CONSTANT(TEXTURE_TYPE_LAYERED);
  1917. BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);
  1918. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY);
  1919. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP);
  1920. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP_ARRAY);
  1921. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_LEFT);
  1922. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_RIGHT);
  1923. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BOTTOM);
  1924. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_TOP);
  1925. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_FRONT);
  1926. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BACK);
  1927. /* SHADER */
  1928. ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create);
  1929. ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);
  1930. ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint);
  1931. ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);
  1932. ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list);
  1933. ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default);
  1934. ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0));
  1935. ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0));
  1936. BIND_ENUM_CONSTANT(SHADER_SPATIAL);
  1937. BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
  1938. BIND_ENUM_CONSTANT(SHADER_PARTICLES);
  1939. BIND_ENUM_CONSTANT(SHADER_SKY);
  1940. BIND_ENUM_CONSTANT(SHADER_FOG);
  1941. BIND_ENUM_CONSTANT(SHADER_MAX);
  1942. /* MATERIAL */
  1943. ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create);
  1944. ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader);
  1945. ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param);
  1946. ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param);
  1947. ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority);
  1948. ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass);
  1949. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);
  1950. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);
  1951. /* MESH API */
  1952. ClassDB::bind_method(D_METHOD("mesh_create_from_surfaces", "surfaces", "blend_shape_count"), &RenderingServer::_mesh_create_from_surfaces, DEFVAL(0));
  1953. ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create);
  1954. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_count", "array_index"), &RenderingServer::mesh_surface_get_format_offset);
  1955. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_vertex_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_vertex_stride);
  1956. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_normal_tangent_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_normal_tangent_stride);
  1957. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_attribute_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_attribute_stride);
  1958. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_skin_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_skin_stride);
  1959. ClassDB::bind_method(D_METHOD("mesh_add_surface", "mesh", "surface"), &RenderingServer::_mesh_add_surface);
  1960. ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "lods", "compress_format"), &RenderingServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(0));
  1961. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count);
  1962. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode);
  1963. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode);
  1964. ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material);
  1965. ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material);
  1966. ClassDB::bind_method(D_METHOD("mesh_get_surface", "mesh", "surface"), &RenderingServer::_mesh_get_surface);
  1967. ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays);
  1968. ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays);
  1969. ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count);
  1970. ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb);
  1971. ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb);
  1972. ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear);
  1973. ClassDB::bind_method(D_METHOD("mesh_surface_update_vertex_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_vertex_region);
  1974. ClassDB::bind_method(D_METHOD("mesh_surface_update_attribute_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_attribute_region);
  1975. ClassDB::bind_method(D_METHOD("mesh_surface_update_skin_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_skin_region);
  1976. ClassDB::bind_method(D_METHOD("mesh_set_shadow_mesh", "mesh", "shadow_mesh"), &RenderingServer::mesh_set_shadow_mesh);
  1977. BIND_ENUM_CONSTANT(ARRAY_VERTEX);
  1978. BIND_ENUM_CONSTANT(ARRAY_NORMAL);
  1979. BIND_ENUM_CONSTANT(ARRAY_TANGENT);
  1980. BIND_ENUM_CONSTANT(ARRAY_COLOR);
  1981. BIND_ENUM_CONSTANT(ARRAY_TEX_UV);
  1982. BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);
  1983. BIND_ENUM_CONSTANT(ARRAY_CUSTOM0);
  1984. BIND_ENUM_CONSTANT(ARRAY_CUSTOM1);
  1985. BIND_ENUM_CONSTANT(ARRAY_CUSTOM2);
  1986. BIND_ENUM_CONSTANT(ARRAY_CUSTOM3);
  1987. BIND_ENUM_CONSTANT(ARRAY_BONES);
  1988. BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);
  1989. BIND_ENUM_CONSTANT(ARRAY_INDEX);
  1990. BIND_ENUM_CONSTANT(ARRAY_MAX);
  1991. BIND_CONSTANT(ARRAY_CUSTOM_COUNT);
  1992. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_UNORM);
  1993. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_SNORM);
  1994. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_HALF);
  1995. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_HALF);
  1996. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_R_FLOAT);
  1997. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_FLOAT);
  1998. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGB_FLOAT);
  1999. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_FLOAT);
  2000. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_MAX);
  2001. BIND_BITFIELD_FLAG(ARRAY_FORMAT_VERTEX);
  2002. BIND_BITFIELD_FLAG(ARRAY_FORMAT_NORMAL);
  2003. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TANGENT);
  2004. BIND_BITFIELD_FLAG(ARRAY_FORMAT_COLOR);
  2005. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV);
  2006. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV2);
  2007. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0);
  2008. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1);
  2009. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2);
  2010. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3);
  2011. BIND_BITFIELD_FLAG(ARRAY_FORMAT_BONES);
  2012. BIND_BITFIELD_FLAG(ARRAY_FORMAT_WEIGHTS);
  2013. BIND_BITFIELD_FLAG(ARRAY_FORMAT_INDEX);
  2014. BIND_BITFIELD_FLAG(ARRAY_FORMAT_BLEND_SHAPE_MASK);
  2015. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BASE);
  2016. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BITS);
  2017. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0_SHIFT);
  2018. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1_SHIFT);
  2019. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2_SHIFT);
  2020. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3_SHIFT);
  2021. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_MASK);
  2022. BIND_BITFIELD_FLAG(ARRAY_COMPRESS_FLAGS_BASE);
  2023. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_2D_VERTICES);
  2024. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_DYNAMIC_UPDATE);
  2025. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_8_BONE_WEIGHTS);
  2026. BIND_BITFIELD_FLAG(ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY);
  2027. BIND_BITFIELD_FLAG(ARRAY_FLAG_COMPRESS_ATTRIBUTES);
  2028. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_BASE);
  2029. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_SHIFT);
  2030. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_1);
  2031. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_2);
  2032. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_CURRENT_VERSION);
  2033. BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_MASK);
  2034. BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
  2035. BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
  2036. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
  2037. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
  2038. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
  2039. BIND_ENUM_CONSTANT(PRIMITIVE_MAX);
  2040. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
  2041. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
  2042. /* MULTIMESH API */
  2043. ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create);
  2044. ClassDB::bind_method(D_METHOD("multimesh_allocate_data", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &RenderingServer::multimesh_allocate_data, DEFVAL(false), DEFVAL(false));
  2045. ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count);
  2046. ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh);
  2047. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform);
  2048. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d);
  2049. ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color);
  2050. ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data);
  2051. ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh);
  2052. ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb);
  2053. ClassDB::bind_method(D_METHOD("multimesh_set_custom_aabb", "multimesh", "aabb"), &RenderingServer::multimesh_set_custom_aabb);
  2054. ClassDB::bind_method(D_METHOD("multimesh_get_custom_aabb", "multimesh"), &RenderingServer::multimesh_get_custom_aabb);
  2055. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform);
  2056. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d);
  2057. ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color);
  2058. ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data);
  2059. ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);
  2060. ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);
  2061. ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);
  2062. ClassDB::bind_method(D_METHOD("multimesh_get_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_buffer_rd_rid);
  2063. ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);
  2064. ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated);
  2065. ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolated", "multimesh", "interpolated"), &RenderingServer::multimesh_set_physics_interpolated);
  2066. ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolation_quality", "multimesh", "quality"), &RenderingServer::multimesh_set_physics_interpolation_quality);
  2067. ClassDB::bind_method(D_METHOD("multimesh_instance_reset_physics_interpolation", "multimesh", "index"), &RenderingServer::multimesh_instance_reset_physics_interpolation);
  2068. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);
  2069. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);
  2070. BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_FAST);
  2071. BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_HIGH);
  2072. /* SKELETON API */
  2073. ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create);
  2074. ClassDB::bind_method(D_METHOD("skeleton_allocate_data", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate_data, DEFVAL(false));
  2075. ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count);
  2076. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform);
  2077. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform);
  2078. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d);
  2079. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d);
  2080. ClassDB::bind_method(D_METHOD("skeleton_set_base_transform_2d", "skeleton", "base_transform"), &RenderingServer::skeleton_set_base_transform_2d);
  2081. /* Light API */
  2082. ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);
  2083. ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);
  2084. ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);
  2085. ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);
  2086. ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);
  2087. ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow);
  2088. ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector);
  2089. ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);
  2090. ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);
  2091. ClassDB::bind_method(D_METHOD("light_set_distance_fade", "decal", "enabled", "begin", "shadow", "length"), &RenderingServer::light_set_distance_fade);
  2092. ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);
  2093. ClassDB::bind_method(D_METHOD("light_set_shadow_caster_mask", "light", "mask"), &RenderingServer::light_set_shadow_caster_mask);
  2094. ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &RenderingServer::light_set_bake_mode);
  2095. ClassDB::bind_method(D_METHOD("light_set_max_sdfgi_cascade", "light", "cascade"), &RenderingServer::light_set_max_sdfgi_cascade);
  2096. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);
  2097. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode);
  2098. ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);
  2099. ClassDB::bind_method(D_METHOD("light_directional_set_sky_mode", "light", "mode"), &RenderingServer::light_directional_set_sky_mode);
  2100. ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter);
  2101. ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "enable"), &RenderingServer::lightmaps_set_bicubic_filter);
  2102. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST);
  2103. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR);
  2104. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS);
  2105. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);
  2106. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);
  2107. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);
  2108. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);
  2109. BIND_ENUM_CONSTANT(LIGHT_OMNI);
  2110. BIND_ENUM_CONSTANT(LIGHT_SPOT);
  2111. BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);
  2112. BIND_ENUM_CONSTANT(LIGHT_PARAM_INDIRECT_ENERGY);
  2113. BIND_ENUM_CONSTANT(LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY);
  2114. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);
  2115. BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);
  2116. BIND_ENUM_CONSTANT(LIGHT_PARAM_SIZE);
  2117. BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);
  2118. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);
  2119. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);
  2120. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);
  2121. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);
  2122. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);
  2123. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);
  2124. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_FADE_START);
  2125. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);
  2126. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);
  2127. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_PANCAKE_SIZE);
  2128. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_OPACITY);
  2129. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BLUR);
  2130. BIND_ENUM_CONSTANT(LIGHT_PARAM_TRANSMITTANCE_BIAS);
  2131. BIND_ENUM_CONSTANT(LIGHT_PARAM_INTENSITY);
  2132. BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
  2133. BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);
  2134. BIND_ENUM_CONSTANT(LIGHT_BAKE_STATIC);
  2135. BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);
  2136. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
  2137. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
  2138. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
  2139. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);
  2140. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);
  2141. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
  2142. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_ONLY);
  2143. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_SKY_ONLY);
  2144. ClassDB::bind_method(D_METHOD("positional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::positional_soft_shadow_filter_set_quality);
  2145. ClassDB::bind_method(D_METHOD("directional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::directional_soft_shadow_filter_set_quality);
  2146. ClassDB::bind_method(D_METHOD("directional_shadow_atlas_set_size", "size", "is_16bits"), &RenderingServer::directional_shadow_atlas_set_size);
  2147. BIND_ENUM_CONSTANT(SHADOW_QUALITY_HARD);
  2148. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_VERY_LOW);
  2149. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_LOW);
  2150. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_MEDIUM);
  2151. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_HIGH);
  2152. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_ULTRA);
  2153. BIND_ENUM_CONSTANT(SHADOW_QUALITY_MAX);
  2154. /* REFLECTION PROBE */
  2155. ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);
  2156. ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);
  2157. ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);
  2158. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_ambient_mode);
  2159. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_color", "probe", "color"), &RenderingServer::reflection_probe_set_ambient_color);
  2160. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_ambient_energy);
  2161. ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);
  2162. ClassDB::bind_method(D_METHOD("reflection_probe_set_size", "probe", "size"), &RenderingServer::reflection_probe_set_size);
  2163. ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);
  2164. ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);
  2165. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);
  2166. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);
  2167. ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);
  2168. ClassDB::bind_method(D_METHOD("reflection_probe_set_reflection_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_reflection_mask);
  2169. ClassDB::bind_method(D_METHOD("reflection_probe_set_resolution", "probe", "resolution"), &RenderingServer::reflection_probe_set_resolution);
  2170. ClassDB::bind_method(D_METHOD("reflection_probe_set_mesh_lod_threshold", "probe", "pixels"), &RenderingServer::reflection_probe_set_mesh_lod_threshold);
  2171. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);
  2172. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);
  2173. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_DISABLED);
  2174. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_ENVIRONMENT);
  2175. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_COLOR);
  2176. /* DECAL */
  2177. ClassDB::bind_method(D_METHOD("decal_create"), &RenderingServer::decal_create);
  2178. ClassDB::bind_method(D_METHOD("decal_set_size", "decal", "size"), &RenderingServer::decal_set_size);
  2179. ClassDB::bind_method(D_METHOD("decal_set_texture", "decal", "type", "texture"), &RenderingServer::decal_set_texture);
  2180. ClassDB::bind_method(D_METHOD("decal_set_emission_energy", "decal", "energy"), &RenderingServer::decal_set_emission_energy);
  2181. ClassDB::bind_method(D_METHOD("decal_set_albedo_mix", "decal", "albedo_mix"), &RenderingServer::decal_set_albedo_mix);
  2182. ClassDB::bind_method(D_METHOD("decal_set_modulate", "decal", "color"), &RenderingServer::decal_set_modulate);
  2183. ClassDB::bind_method(D_METHOD("decal_set_cull_mask", "decal", "mask"), &RenderingServer::decal_set_cull_mask);
  2184. ClassDB::bind_method(D_METHOD("decal_set_distance_fade", "decal", "enabled", "begin", "length"), &RenderingServer::decal_set_distance_fade);
  2185. ClassDB::bind_method(D_METHOD("decal_set_fade", "decal", "above", "below"), &RenderingServer::decal_set_fade);
  2186. ClassDB::bind_method(D_METHOD("decal_set_normal_fade", "decal", "fade"), &RenderingServer::decal_set_normal_fade);
  2187. ClassDB::bind_method(D_METHOD("decals_set_filter", "filter"), &RenderingServer::decals_set_filter);
  2188. BIND_ENUM_CONSTANT(DECAL_TEXTURE_ALBEDO);
  2189. BIND_ENUM_CONSTANT(DECAL_TEXTURE_NORMAL);
  2190. BIND_ENUM_CONSTANT(DECAL_TEXTURE_ORM);
  2191. BIND_ENUM_CONSTANT(DECAL_TEXTURE_EMISSION);
  2192. BIND_ENUM_CONSTANT(DECAL_TEXTURE_MAX);
  2193. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST);
  2194. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR);
  2195. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS);
  2196. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS);
  2197. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);
  2198. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);
  2199. /* GI API (affects VoxelGI and SDFGI) */
  2200. ClassDB::bind_method(D_METHOD("gi_set_use_half_resolution", "half_resolution"), &RenderingServer::gi_set_use_half_resolution);
  2201. /* VOXEL GI API */
  2202. ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create);
  2203. ClassDB::bind_method(D_METHOD("voxel_gi_allocate_data", "voxel_gi", "to_cell_xform", "aabb", "octree_size", "octree_cells", "data_cells", "distance_field", "level_counts"), &RenderingServer::voxel_gi_allocate_data);
  2204. ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_size", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_size);
  2205. ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_cells);
  2206. ClassDB::bind_method(D_METHOD("voxel_gi_get_data_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_data_cells);
  2207. ClassDB::bind_method(D_METHOD("voxel_gi_get_distance_field", "voxel_gi"), &RenderingServer::voxel_gi_get_distance_field);
  2208. ClassDB::bind_method(D_METHOD("voxel_gi_get_level_counts", "voxel_gi"), &RenderingServer::voxel_gi_get_level_counts);
  2209. ClassDB::bind_method(D_METHOD("voxel_gi_get_to_cell_xform", "voxel_gi"), &RenderingServer::voxel_gi_get_to_cell_xform);
  2210. ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_range", "voxel_gi", "range"), &RenderingServer::voxel_gi_set_dynamic_range);
  2211. ClassDB::bind_method(D_METHOD("voxel_gi_set_propagation", "voxel_gi", "amount"), &RenderingServer::voxel_gi_set_propagation);
  2212. ClassDB::bind_method(D_METHOD("voxel_gi_set_energy", "voxel_gi", "energy"), &RenderingServer::voxel_gi_set_energy);
  2213. ClassDB::bind_method(D_METHOD("voxel_gi_set_baked_exposure_normalization", "voxel_gi", "baked_exposure"), &RenderingServer::voxel_gi_set_baked_exposure_normalization);
  2214. ClassDB::bind_method(D_METHOD("voxel_gi_set_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_bias);
  2215. ClassDB::bind_method(D_METHOD("voxel_gi_set_normal_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_normal_bias);
  2216. ClassDB::bind_method(D_METHOD("voxel_gi_set_interior", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_interior);
  2217. ClassDB::bind_method(D_METHOD("voxel_gi_set_use_two_bounces", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_use_two_bounces);
  2218. ClassDB::bind_method(D_METHOD("voxel_gi_set_quality", "quality"), &RenderingServer::voxel_gi_set_quality);
  2219. BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_LOW);
  2220. BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_HIGH);
  2221. /* LIGHTMAP */
  2222. ClassDB::bind_method(D_METHOD("lightmap_create"), &RenderingServer::lightmap_create);
  2223. ClassDB::bind_method(D_METHOD("lightmap_set_textures", "lightmap", "light", "uses_sh"), &RenderingServer::lightmap_set_textures);
  2224. ClassDB::bind_method(D_METHOD("lightmap_set_probe_bounds", "lightmap", "bounds"), &RenderingServer::lightmap_set_probe_bounds);
  2225. ClassDB::bind_method(D_METHOD("lightmap_set_probe_interior", "lightmap", "interior"), &RenderingServer::lightmap_set_probe_interior);
  2226. ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_data", "lightmap", "points", "point_sh", "tetrahedra", "bsp_tree"), &RenderingServer::lightmap_set_probe_capture_data);
  2227. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_points", "lightmap"), &RenderingServer::lightmap_get_probe_capture_points);
  2228. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_sh", "lightmap"), &RenderingServer::lightmap_get_probe_capture_sh);
  2229. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_tetrahedra", "lightmap"), &RenderingServer::lightmap_get_probe_capture_tetrahedra);
  2230. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_bsp_tree", "lightmap"), &RenderingServer::lightmap_get_probe_capture_bsp_tree);
  2231. ClassDB::bind_method(D_METHOD("lightmap_set_baked_exposure_normalization", "lightmap", "baked_exposure"), &RenderingServer::lightmap_set_baked_exposure_normalization);
  2232. ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_update_speed", "speed"), &RenderingServer::lightmap_set_probe_capture_update_speed);
  2233. /* PARTICLES API */
  2234. ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create);
  2235. ClassDB::bind_method(D_METHOD("particles_set_mode", "particles", "mode"), &RenderingServer::particles_set_mode);
  2236. ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting);
  2237. ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting);
  2238. ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount);
  2239. ClassDB::bind_method(D_METHOD("particles_set_amount_ratio", "particles", "ratio"), &RenderingServer::particles_set_amount_ratio);
  2240. ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime);
  2241. ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot);
  2242. ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time);
  2243. ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio);
  2244. ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio);
  2245. ClassDB::bind_method(D_METHOD("particles_set_interp_to_end", "particles", "factor"), &RenderingServer::particles_set_interp_to_end);
  2246. ClassDB::bind_method(D_METHOD("particles_set_emitter_velocity", "particles", "velocity"), &RenderingServer::particles_set_emitter_velocity);
  2247. ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb);
  2248. ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale);
  2249. ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates);
  2250. ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material);
  2251. ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps);
  2252. ClassDB::bind_method(D_METHOD("particles_set_interpolate", "particles", "enable"), &RenderingServer::particles_set_interpolate);
  2253. ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta);
  2254. ClassDB::bind_method(D_METHOD("particles_set_collision_base_size", "particles", "size"), &RenderingServer::particles_set_collision_base_size);
  2255. ClassDB::bind_method(D_METHOD("particles_set_transform_align", "particles", "align"), &RenderingServer::particles_set_transform_align);
  2256. ClassDB::bind_method(D_METHOD("particles_set_trails", "particles", "enable", "length_sec"), &RenderingServer::particles_set_trails);
  2257. ClassDB::bind_method(D_METHOD("particles_set_trail_bind_poses", "particles", "bind_poses"), &RenderingServer::_particles_set_trail_bind_poses);
  2258. ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive);
  2259. ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process);
  2260. ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart);
  2261. ClassDB::bind_method(D_METHOD("particles_set_subemitter", "particles", "subemitter_particles"), &RenderingServer::particles_set_subemitter);
  2262. ClassDB::bind_method(D_METHOD("particles_emit", "particles", "transform", "velocity", "color", "custom", "emit_flags"), &RenderingServer::particles_emit);
  2263. ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order);
  2264. ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes);
  2265. ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh);
  2266. ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb);
  2267. ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform);
  2268. BIND_ENUM_CONSTANT(PARTICLES_MODE_2D);
  2269. BIND_ENUM_CONSTANT(PARTICLES_MODE_3D);
  2270. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_DISABLED);
  2271. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD);
  2272. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY);
  2273. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY);
  2274. BIND_CONSTANT(PARTICLES_EMIT_FLAG_POSITION);
  2275. BIND_CONSTANT(PARTICLES_EMIT_FLAG_ROTATION_SCALE);
  2276. BIND_CONSTANT(PARTICLES_EMIT_FLAG_VELOCITY);
  2277. BIND_CONSTANT(PARTICLES_EMIT_FLAG_COLOR);
  2278. BIND_CONSTANT(PARTICLES_EMIT_FLAG_CUSTOM);
  2279. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);
  2280. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);
  2281. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);
  2282. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);
  2283. /* PARTICLES COLLISION */
  2284. ClassDB::bind_method(D_METHOD("particles_collision_create"), &RenderingServer::particles_collision_create);
  2285. ClassDB::bind_method(D_METHOD("particles_collision_set_collision_type", "particles_collision", "type"), &RenderingServer::particles_collision_set_collision_type);
  2286. ClassDB::bind_method(D_METHOD("particles_collision_set_cull_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_cull_mask);
  2287. ClassDB::bind_method(D_METHOD("particles_collision_set_sphere_radius", "particles_collision", "radius"), &RenderingServer::particles_collision_set_sphere_radius);
  2288. ClassDB::bind_method(D_METHOD("particles_collision_set_box_extents", "particles_collision", "extents"), &RenderingServer::particles_collision_set_box_extents);
  2289. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_strength", "particles_collision", "strength"), &RenderingServer::particles_collision_set_attractor_strength);
  2290. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_directionality", "particles_collision", "amount"), &RenderingServer::particles_collision_set_attractor_directionality);
  2291. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_attenuation", "particles_collision", "curve"), &RenderingServer::particles_collision_set_attractor_attenuation);
  2292. ClassDB::bind_method(D_METHOD("particles_collision_set_field_texture", "particles_collision", "texture"), &RenderingServer::particles_collision_set_field_texture);
  2293. ClassDB::bind_method(D_METHOD("particles_collision_height_field_update", "particles_collision"), &RenderingServer::particles_collision_height_field_update);
  2294. ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_resolution", "particles_collision", "resolution"), &RenderingServer::particles_collision_set_height_field_resolution);
  2295. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT);
  2296. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_ATTRACT);
  2297. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT);
  2298. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE);
  2299. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_COLLIDE);
  2300. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SDF_COLLIDE);
  2301. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE);
  2302. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256);
  2303. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512);
  2304. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024);
  2305. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_2048);
  2306. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_4096);
  2307. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192);
  2308. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
  2309. /* FOG VOLUMES */
  2310. ClassDB::bind_method(D_METHOD("fog_volume_create"), &RenderingServer::fog_volume_create);
  2311. ClassDB::bind_method(D_METHOD("fog_volume_set_shape", "fog_volume", "shape"), &RenderingServer::fog_volume_set_shape);
  2312. ClassDB::bind_method(D_METHOD("fog_volume_set_size", "fog_volume", "size"), &RenderingServer::fog_volume_set_size);
  2313. ClassDB::bind_method(D_METHOD("fog_volume_set_material", "fog_volume", "material"), &RenderingServer::fog_volume_set_material);
  2314. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_ELLIPSOID);
  2315. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CONE);
  2316. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CYLINDER);
  2317. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_BOX);
  2318. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_WORLD);
  2319. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_MAX);
  2320. /* VISIBILITY NOTIFIER */
  2321. ClassDB::bind_method(D_METHOD("visibility_notifier_create"), &RenderingServer::visibility_notifier_create);
  2322. ClassDB::bind_method(D_METHOD("visibility_notifier_set_aabb", "notifier", "aabb"), &RenderingServer::visibility_notifier_set_aabb);
  2323. ClassDB::bind_method(D_METHOD("visibility_notifier_set_callbacks", "notifier", "enter_callable", "exit_callable"), &RenderingServer::visibility_notifier_set_callbacks);
  2324. /* OCCLUDER */
  2325. ClassDB::bind_method(D_METHOD("occluder_create"), &RenderingServer::occluder_create);
  2326. ClassDB::bind_method(D_METHOD("occluder_set_mesh", "occluder", "vertices", "indices"), &RenderingServer::occluder_set_mesh);
  2327. /* CAMERA */
  2328. ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);
  2329. ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective);
  2330. ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal);
  2331. ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum);
  2332. ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform);
  2333. ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask);
  2334. ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment);
  2335. ClassDB::bind_method(D_METHOD("camera_set_camera_attributes", "camera", "effects"), &RenderingServer::camera_set_camera_attributes);
  2336. ClassDB::bind_method(D_METHOD("camera_set_compositor", "camera", "compositor"), &RenderingServer::camera_set_compositor);
  2337. ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);
  2338. /* VIEWPORT */
  2339. ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);
  2340. ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr);
  2341. ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);
  2342. ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);
  2343. ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);
  2344. ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID));
  2345. ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen);
  2346. ClassDB::bind_method(D_METHOD("viewport_set_canvas_cull_mask", "viewport", "canvas_cull_mask"), &RenderingServer::viewport_set_canvas_cull_mask);
  2347. ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_mode", "viewport", "scaling_3d_mode"), &RenderingServer::viewport_set_scaling_3d_mode);
  2348. ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_scale", "viewport", "scale"), &RenderingServer::viewport_set_scaling_3d_scale);
  2349. ClassDB::bind_method(D_METHOD("viewport_set_fsr_sharpness", "viewport", "sharpness"), &RenderingServer::viewport_set_fsr_sharpness);
  2350. ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias);
  2351. ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);
  2352. ClassDB::bind_method(D_METHOD("viewport_get_update_mode", "viewport"), &RenderingServer::viewport_get_update_mode);
  2353. ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);
  2354. ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target);
  2355. ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);
  2356. ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d);
  2357. ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d);
  2358. ClassDB::bind_method(D_METHOD("viewport_set_environment_mode", "viewport", "mode"), &RenderingServer::viewport_set_environment_mode);
  2359. ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera);
  2360. ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario);
  2361. ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);
  2362. ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);
  2363. ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_transforms_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_transforms_to_pixel);
  2364. ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_vertices_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_vertices_to_pixel);
  2365. ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_filter", "viewport", "filter"), &RenderingServer::viewport_set_default_canvas_item_texture_filter);
  2366. ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_repeat", "viewport", "repeat"), &RenderingServer::viewport_set_default_canvas_item_texture_repeat);
  2367. ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);
  2368. ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking);
  2369. ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background);
  2370. ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform);
  2371. ClassDB::bind_method(D_METHOD("viewport_set_sdf_oversize_and_scale", "viewport", "oversize", "scale"), &RenderingServer::viewport_set_sdf_oversize_and_scale);
  2372. ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_size", "viewport", "size", "use_16_bits"), &RenderingServer::viewport_set_positional_shadow_atlas_size, DEFVAL(false));
  2373. ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_positional_shadow_atlas_quadrant_subdivision);
  2374. ClassDB::bind_method(D_METHOD("viewport_set_msaa_3d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_3d);
  2375. ClassDB::bind_method(D_METHOD("viewport_set_msaa_2d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_2d);
  2376. ClassDB::bind_method(D_METHOD("viewport_set_use_hdr_2d", "viewport", "enabled"), &RenderingServer::viewport_set_use_hdr_2d);
  2377. ClassDB::bind_method(D_METHOD("viewport_set_screen_space_aa", "viewport", "mode"), &RenderingServer::viewport_set_screen_space_aa);
  2378. ClassDB::bind_method(D_METHOD("viewport_set_use_taa", "viewport", "enable"), &RenderingServer::viewport_set_use_taa);
  2379. ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "enable"), &RenderingServer::viewport_set_use_debanding);
  2380. ClassDB::bind_method(D_METHOD("viewport_set_use_occlusion_culling", "viewport", "enable"), &RenderingServer::viewport_set_use_occlusion_culling);
  2381. ClassDB::bind_method(D_METHOD("viewport_set_occlusion_rays_per_thread", "rays_per_thread"), &RenderingServer::viewport_set_occlusion_rays_per_thread);
  2382. ClassDB::bind_method(D_METHOD("viewport_set_occlusion_culling_build_quality", "quality"), &RenderingServer::viewport_set_occlusion_culling_build_quality);
  2383. ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "type", "info"), &RenderingServer::viewport_get_render_info);
  2384. ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw);
  2385. ClassDB::bind_method(D_METHOD("viewport_set_measure_render_time", "viewport", "enable"), &RenderingServer::viewport_set_measure_render_time);
  2386. ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_cpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_cpu);
  2387. ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_gpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_gpu);
  2388. ClassDB::bind_method(D_METHOD("viewport_set_vrs_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_mode);
  2389. ClassDB::bind_method(D_METHOD("viewport_set_vrs_update_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_update_mode);
  2390. ClassDB::bind_method(D_METHOD("viewport_set_vrs_texture", "viewport", "texture"), &RenderingServer::viewport_set_vrs_texture);
  2391. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_BILINEAR);
  2392. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR);
  2393. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR2);
  2394. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_MAX);
  2395. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);
  2396. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); // Then goes to disabled, must be manually updated.
  2397. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // Default
  2398. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
  2399. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);
  2400. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);
  2401. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);
  2402. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);
  2403. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_DISABLED);
  2404. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_ENABLED);
  2405. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_INHERIT);
  2406. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_MAX);
  2407. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_100_PERCENT);
  2408. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_120_PERCENT);
  2409. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_150_PERCENT);
  2410. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_200_PERCENT);
  2411. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_MAX);
  2412. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_100_PERCENT);
  2413. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_50_PERCENT);
  2414. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_25_PERCENT);
  2415. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_MAX);
  2416. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);
  2417. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);
  2418. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);
  2419. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);
  2420. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_MAX);
  2421. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_DISABLED);
  2422. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_FXAA);
  2423. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_MAX);
  2424. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW);
  2425. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM);
  2426. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH);
  2427. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);
  2428. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME);
  2429. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);
  2430. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);
  2431. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_VISIBLE);
  2432. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_SHADOW);
  2433. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_CANVAS);
  2434. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_MAX);
  2435. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);
  2436. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);
  2437. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_LIGHTING);
  2438. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);
  2439. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);
  2440. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER);
  2441. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO);
  2442. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING);
  2443. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION);
  2444. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS);
  2445. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
  2446. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE);
  2447. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSAO);
  2448. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSIL);
  2449. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_PSSM_SPLITS);
  2450. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DECAL_ATLAS);
  2451. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI);
  2452. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI_PROBES);
  2453. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_BUFFER);
  2454. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLE_LOD);
  2455. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS);
  2456. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS);
  2457. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS);
  2458. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES);
  2459. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OCCLUDERS);
  2460. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_MOTION_VECTORS);
  2461. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_INTERNAL_BUFFER);
  2462. BIND_ENUM_CONSTANT(VIEWPORT_VRS_DISABLED);
  2463. BIND_ENUM_CONSTANT(VIEWPORT_VRS_TEXTURE);
  2464. BIND_ENUM_CONSTANT(VIEWPORT_VRS_XR);
  2465. BIND_ENUM_CONSTANT(VIEWPORT_VRS_MAX);
  2466. BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_DISABLED);
  2467. BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ONCE); // Then goes to disabled, must be manually updated.
  2468. BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ALWAYS);
  2469. BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_MAX);
  2470. /* SKY API */
  2471. ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create);
  2472. ClassDB::bind_method(D_METHOD("sky_set_radiance_size", "sky", "radiance_size"), &RenderingServer::sky_set_radiance_size);
  2473. ClassDB::bind_method(D_METHOD("sky_set_mode", "sky", "mode"), &RenderingServer::sky_set_mode);
  2474. ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material);
  2475. ClassDB::bind_method(D_METHOD("sky_bake_panorama", "sky", "energy", "bake_irradiance", "size"), &RenderingServer::sky_bake_panorama);
  2476. BIND_ENUM_CONSTANT(SKY_MODE_AUTOMATIC);
  2477. BIND_ENUM_CONSTANT(SKY_MODE_QUALITY);
  2478. BIND_ENUM_CONSTANT(SKY_MODE_INCREMENTAL);
  2479. BIND_ENUM_CONSTANT(SKY_MODE_REALTIME);
  2480. /* COMPOSITOR EFFECT API */
  2481. ClassDB::bind_method(D_METHOD("compositor_effect_create"), &RenderingServer::compositor_effect_create);
  2482. ClassDB::bind_method(D_METHOD("compositor_effect_set_enabled", "effect", "enabled"), &RenderingServer::compositor_effect_set_enabled);
  2483. ClassDB::bind_method(D_METHOD("compositor_effect_set_callback", "effect", "callback_type", "callback"), &RenderingServer::compositor_effect_set_callback);
  2484. ClassDB::bind_method(D_METHOD("compositor_effect_set_flag", "effect", "flag", "set"), &RenderingServer::compositor_effect_set_flag);
  2485. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_COLOR);
  2486. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_DEPTH);
  2487. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS);
  2488. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_ROUGHNESS);
  2489. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_SEPARATE_SPECULAR);
  2490. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_OPAQUE);
  2491. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_OPAQUE);
  2492. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_SKY);
  2493. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT);
  2494. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_TRANSPARENT);
  2495. BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_ANY);
  2496. /* COMPOSITOR */
  2497. ClassDB::bind_method(D_METHOD("compositor_create"), &RenderingServer::compositor_create);
  2498. ClassDB::bind_method(D_METHOD("compositor_set_compositor_effects", "compositor", "effects"), &RenderingServer::compositor_set_compositor_effects);
  2499. /* ENVIRONMENT */
  2500. ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create);
  2501. ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background);
  2502. ClassDB::bind_method(D_METHOD("environment_set_camera_id", "env", "id"), &RenderingServer::environment_set_camera_feed_id);
  2503. ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky);
  2504. ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov);
  2505. ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation);
  2506. ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color);
  2507. ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "multiplier", "exposure_value"), &RenderingServer::environment_set_bg_energy);
  2508. ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer);
  2509. ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source"), &RenderingServer::environment_set_ambient_light, DEFVAL(RS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(RS::ENV_REFLECTION_SOURCE_BG));
  2510. ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "levels", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "glow_map_strength", "glow_map"), &RenderingServer::environment_set_glow);
  2511. ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white"), &RenderingServer::environment_set_tonemap);
  2512. ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "use_1d_color_correction", "color_correction"), &RenderingServer::environment_set_adjustment);
  2513. ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance"), &RenderingServer::environment_set_ssr);
  2514. ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "power", "detail", "horizon", "sharpness", "light_affect", "ao_channel_affect"), &RenderingServer::environment_set_ssao);
  2515. ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "light_color", "light_energy", "sun_scatter", "density", "height", "height_density", "aerial_perspective", "sky_affect", "fog_mode"), &RenderingServer::environment_set_fog, DEFVAL(RS::ENV_FOG_MODE_EXPONENTIAL));
  2516. ClassDB::bind_method(D_METHOD("environment_set_sdfgi", "env", "enable", "cascades", "min_cell_size", "y_scale", "use_occlusion", "bounce_feedback", "read_sky", "energy", "normal_bias", "probe_bias"), &RenderingServer::environment_set_sdfgi);
  2517. ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog", "env", "enable", "density", "albedo", "emission", "emission_energy", "anisotropy", "length", "p_detail_spread", "gi_inject", "temporal_reprojection", "temporal_reprojection_amount", "ambient_inject", "sky_affect"), &RenderingServer::environment_set_volumetric_fog);
  2518. ClassDB::bind_method(D_METHOD("environment_glow_set_use_bicubic_upscale", "enable"), &RenderingServer::environment_glow_set_use_bicubic_upscale);
  2519. ClassDB::bind_method(D_METHOD("environment_set_ssr_roughness_quality", "quality"), &RenderingServer::environment_set_ssr_roughness_quality);
  2520. ClassDB::bind_method(D_METHOD("environment_set_ssao_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssao_quality);
  2521. ClassDB::bind_method(D_METHOD("environment_set_ssil_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssil_quality);
  2522. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_ray_count", "ray_count"), &RenderingServer::environment_set_sdfgi_ray_count);
  2523. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_converge", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_converge);
  2524. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_update_light", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_update_light);
  2525. ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_volume_size", "size", "depth"), &RenderingServer::environment_set_volumetric_fog_volume_size);
  2526. ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_filter_active", "active"), &RenderingServer::environment_set_volumetric_fog_filter_active);
  2527. ClassDB::bind_method(D_METHOD("environment_bake_panorama", "environment", "bake_irradiance", "size"), &RenderingServer::environment_bake_panorama);
  2528. ClassDB::bind_method(D_METHOD("screen_space_roughness_limiter_set_active", "enable", "amount", "limit"), &RenderingServer::screen_space_roughness_limiter_set_active);
  2529. ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_quality", "quality"), &RenderingServer::sub_surface_scattering_set_quality);
  2530. ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_scale", "scale", "depth_scale"), &RenderingServer::sub_surface_scattering_set_scale);
  2531. BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);
  2532. BIND_ENUM_CONSTANT(ENV_BG_COLOR);
  2533. BIND_ENUM_CONSTANT(ENV_BG_SKY);
  2534. BIND_ENUM_CONSTANT(ENV_BG_CANVAS);
  2535. BIND_ENUM_CONSTANT(ENV_BG_KEEP);
  2536. BIND_ENUM_CONSTANT(ENV_BG_CAMERA_FEED);
  2537. BIND_ENUM_CONSTANT(ENV_BG_MAX);
  2538. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_BG);
  2539. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_DISABLED);
  2540. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_COLOR);
  2541. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_SKY);
  2542. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_BG);
  2543. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_DISABLED);
  2544. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_SKY);
  2545. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_ADDITIVE);
  2546. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SCREEN);
  2547. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SOFTLIGHT);
  2548. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_REPLACE);
  2549. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_MIX);
  2550. BIND_ENUM_CONSTANT(ENV_FOG_MODE_EXPONENTIAL);
  2551. BIND_ENUM_CONSTANT(ENV_FOG_MODE_DEPTH);
  2552. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);
  2553. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);
  2554. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);
  2555. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);
  2556. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_DISABLED);
  2557. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_LOW);
  2558. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_MEDIUM);
  2559. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_HIGH);
  2560. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_VERY_LOW);
  2561. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);
  2562. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);
  2563. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);
  2564. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_ULTRA);
  2565. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_VERY_LOW);
  2566. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_LOW);
  2567. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_MEDIUM);
  2568. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_HIGH);
  2569. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_ULTRA);
  2570. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_50_PERCENT);
  2571. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_75_PERCENT);
  2572. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_100_PERCENT);
  2573. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_4);
  2574. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_8);
  2575. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_16);
  2576. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_32);
  2577. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_64);
  2578. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_96);
  2579. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_128);
  2580. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_MAX);
  2581. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_5_FRAMES);
  2582. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_10_FRAMES);
  2583. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_15_FRAMES);
  2584. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_20_FRAMES);
  2585. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_25_FRAMES);
  2586. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_30_FRAMES);
  2587. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_MAX);
  2588. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME);
  2589. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES);
  2590. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES);
  2591. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES);
  2592. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES);
  2593. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_MAX);
  2594. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_DISABLED);
  2595. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_LOW);
  2596. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_MEDIUM);
  2597. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_HIGH);
  2598. /* CAMERA EFFECTS */
  2599. ClassDB::bind_method(D_METHOD("camera_attributes_create"), &RenderingServer::camera_attributes_create);
  2600. ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_quality", "quality", "use_jitter"), &RenderingServer::camera_attributes_set_dof_blur_quality);
  2601. ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_bokeh_shape", "shape"), &RenderingServer::camera_attributes_set_dof_blur_bokeh_shape);
  2602. ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur", "camera_attributes", "far_enable", "far_distance", "far_transition", "near_enable", "near_distance", "near_transition", "amount"), &RenderingServer::camera_attributes_set_dof_blur);
  2603. ClassDB::bind_method(D_METHOD("camera_attributes_set_exposure", "camera_attributes", "multiplier", "normalization"), &RenderingServer::camera_attributes_set_exposure);
  2604. ClassDB::bind_method(D_METHOD("camera_attributes_set_auto_exposure", "camera_attributes", "enable", "min_sensitivity", "max_sensitivity", "speed", "scale"), &RenderingServer::camera_attributes_set_auto_exposure);
  2605. BIND_ENUM_CONSTANT(DOF_BOKEH_BOX);
  2606. BIND_ENUM_CONSTANT(DOF_BOKEH_HEXAGON);
  2607. BIND_ENUM_CONSTANT(DOF_BOKEH_CIRCLE);
  2608. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_VERY_LOW);
  2609. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);
  2610. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
  2611. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);
  2612. /* SCENARIO */
  2613. ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create);
  2614. ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment);
  2615. ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment);
  2616. ClassDB::bind_method(D_METHOD("scenario_set_camera_attributes", "scenario", "effects"), &RenderingServer::scenario_set_camera_attributes);
  2617. ClassDB::bind_method(D_METHOD("scenario_set_compositor", "scenario", "compositor"), &RenderingServer::scenario_set_compositor);
  2618. /* INSTANCE */
  2619. ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2);
  2620. ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create);
  2621. ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base);
  2622. ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario);
  2623. ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask);
  2624. ClassDB::bind_method(D_METHOD("instance_set_pivot_data", "instance", "sorting_offset", "use_aabb_center"), &RenderingServer::instance_set_pivot_data);
  2625. ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);
  2626. ClassDB::bind_method(D_METHOD("instance_set_interpolated", "instance", "interpolated"), &RenderingServer::instance_set_interpolated);
  2627. ClassDB::bind_method(D_METHOD("instance_reset_physics_interpolation", "instance"), &RenderingServer::instance_reset_physics_interpolation);
  2628. ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);
  2629. ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);
  2630. ClassDB::bind_method(D_METHOD("instance_set_surface_override_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_override_material);
  2631. ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);
  2632. ClassDB::bind_method(D_METHOD("instance_geometry_set_transparency", "instance", "transparency"), &RenderingServer::instance_geometry_set_transparency);
  2633. ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);
  2634. ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton);
  2635. ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin);
  2636. ClassDB::bind_method(D_METHOD("instance_set_visibility_parent", "instance", "parent"), &RenderingServer::instance_set_visibility_parent);
  2637. ClassDB::bind_method(D_METHOD("instance_set_ignore_culling", "instance", "enabled"), &RenderingServer::instance_set_ignore_culling);
  2638. ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag);
  2639. ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting);
  2640. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override);
  2641. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_overlay", "instance", "material"), &RenderingServer::instance_geometry_set_material_overlay);
  2642. ClassDB::bind_method(D_METHOD("instance_geometry_set_visibility_range", "instance", "min", "max", "min_margin", "max_margin", "fade_mode"), &RenderingServer::instance_geometry_set_visibility_range);
  2643. ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap);
  2644. ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias);
  2645. ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter);
  2646. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter);
  2647. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value);
  2648. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list);
  2649. ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));
  2650. ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));
  2651. ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID()));
  2652. BIND_ENUM_CONSTANT(INSTANCE_NONE);
  2653. BIND_ENUM_CONSTANT(INSTANCE_MESH);
  2654. BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);
  2655. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);
  2656. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES_COLLISION);
  2657. BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
  2658. BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
  2659. BIND_ENUM_CONSTANT(INSTANCE_DECAL);
  2660. BIND_ENUM_CONSTANT(INSTANCE_VOXEL_GI);
  2661. BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP);
  2662. BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER);
  2663. BIND_ENUM_CONSTANT(INSTANCE_VISIBLITY_NOTIFIER);
  2664. BIND_ENUM_CONSTANT(INSTANCE_FOG_VOLUME);
  2665. BIND_ENUM_CONSTANT(INSTANCE_MAX);
  2666. BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
  2667. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);
  2668. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_DYNAMIC_GI);
  2669. BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
  2670. BIND_ENUM_CONSTANT(INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING);
  2671. BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);
  2672. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
  2673. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);
  2674. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
  2675. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
  2676. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DISABLED);
  2677. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_SELF);
  2678. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DEPENDENCIES);
  2679. /* Bake 3D Object */
  2680. ClassDB::bind_method(D_METHOD("bake_render_uv2", "base", "material_overrides", "image_size"), &RenderingServer::bake_render_uv2);
  2681. BIND_ENUM_CONSTANT(BAKE_CHANNEL_ALBEDO_ALPHA);
  2682. BIND_ENUM_CONSTANT(BAKE_CHANNEL_NORMAL);
  2683. BIND_ENUM_CONSTANT(BAKE_CHANNEL_ORM);
  2684. BIND_ENUM_CONSTANT(BAKE_CHANNEL_EMISSION);
  2685. /* CANVAS (2D) */
  2686. ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create);
  2687. ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring);
  2688. ClassDB::bind_method(D_METHOD("canvas_set_item_repeat", "item", "repeat_size", "repeat_times"), &RenderingServer::canvas_set_item_repeat);
  2689. ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate);
  2690. ClassDB::bind_method(D_METHOD("canvas_set_disable_scale", "disable"), &RenderingServer::canvas_set_disable_scale);
  2691. /* CANVAS TEXTURE */
  2692. ClassDB::bind_method(D_METHOD("canvas_texture_create"), &RenderingServer::canvas_texture_create);
  2693. ClassDB::bind_method(D_METHOD("canvas_texture_set_channel", "canvas_texture", "channel", "texture"), &RenderingServer::canvas_texture_set_channel);
  2694. ClassDB::bind_method(D_METHOD("canvas_texture_set_shading_parameters", "canvas_texture", "base_color", "shininess"), &RenderingServer::canvas_texture_set_shading_parameters);
  2695. ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_filter", "canvas_texture", "filter"), &RenderingServer::canvas_texture_set_texture_filter);
  2696. ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_repeat", "canvas_texture", "repeat"), &RenderingServer::canvas_texture_set_texture_repeat);
  2697. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_DIFFUSE);
  2698. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_NORMAL);
  2699. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_SPECULAR);
  2700. /* CANVAS ITEM */
  2701. ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create);
  2702. ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent);
  2703. ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_filter", "item", "filter"), &RenderingServer::canvas_item_set_default_texture_filter);
  2704. ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_repeat", "item", "repeat"), &RenderingServer::canvas_item_set_default_texture_repeat);
  2705. ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible);
  2706. ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask);
  2707. ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_layer", "item", "visibility_layer"), &RenderingServer::canvas_item_set_visibility_layer);
  2708. ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform);
  2709. ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip);
  2710. ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode);
  2711. ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
  2712. ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate);
  2713. ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate);
  2714. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent);
  2715. ClassDB::bind_method(D_METHOD("canvas_item_set_interpolated", "item", "interpolated"), &RenderingServer::canvas_item_set_interpolated);
  2716. ClassDB::bind_method(D_METHOD("canvas_item_reset_physics_interpolation", "item"), &RenderingServer::canvas_item_reset_physics_interpolation);
  2717. ClassDB::bind_method(D_METHOD("canvas_item_transform_physics_interpolation", "item", "transform"), &RenderingServer::canvas_item_transform_physics_interpolation);
  2718. /* Primitives */
  2719. ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(-1.0), DEFVAL(false));
  2720. ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(-1.0), DEFVAL(false));
  2721. ClassDB::bind_method(D_METHOD("canvas_item_add_multiline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_multiline, DEFVAL(-1.0), DEFVAL(false));
  2722. ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color", "antialiased"), &RenderingServer::canvas_item_add_rect, DEFVAL(false));
  2723. ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color", "antialiased"), &RenderingServer::canvas_item_add_circle, DEFVAL(false));
  2724. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose"), &RenderingServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false));
  2725. ClassDB::bind_method(D_METHOD("canvas_item_add_msdf_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "outline_size", "px_range", "scale"), &RenderingServer::canvas_item_add_msdf_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(1.0), DEFVAL(1.0));
  2726. ClassDB::bind_method(D_METHOD("canvas_item_add_lcd_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate"), &RenderingServer::canvas_item_add_lcd_texture_rect_region);
  2727. ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "clip_uv"), &RenderingServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(true));
  2728. 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"), &RenderingServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)));
  2729. ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_primitive);
  2730. ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()));
  2731. ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count"), &RenderingServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1));
  2732. ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture"), &RenderingServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
  2733. ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));
  2734. ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture"), &RenderingServer::canvas_item_add_particles);
  2735. ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);
  2736. ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);
  2737. ClassDB::bind_method(D_METHOD("canvas_item_add_animation_slice", "item", "animation_length", "slice_begin", "slice_end", "offset"), &RenderingServer::canvas_item_add_animation_slice, DEFVAL(0.0));
  2738. ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);
  2739. ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);
  2740. ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);
  2741. ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);
  2742. ClassDB::bind_method(D_METHOD("canvas_item_attach_skeleton", "item", "skeleton"), &RenderingServer::canvas_item_attach_skeleton);
  2743. ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);
  2744. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);
  2745. ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);
  2746. ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material);
  2747. ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_notifier", "item", "enable", "area", "enter_callable", "exit_callable"), &RenderingServer::canvas_item_set_visibility_notifier);
  2748. ClassDB::bind_method(D_METHOD("canvas_item_set_canvas_group_mode", "item", "mode", "clear_margin", "fit_empty", "fit_margin", "blur_mipmaps"), &RenderingServer::canvas_item_set_canvas_group_mode, DEFVAL(5.0), DEFVAL(false), DEFVAL(0.0), DEFVAL(false));
  2749. ClassDB::bind_method(D_METHOD("debug_canvas_item_get_rect", "item"), &RenderingServer::debug_canvas_item_get_rect);
  2750. BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);
  2751. BIND_ENUM_CONSTANT(NINE_PATCH_TILE);
  2752. BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);
  2753. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);
  2754. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
  2755. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR);
  2756. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
  2757. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);
  2758. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC);
  2759. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC);
  2760. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_MAX);
  2761. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
  2762. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
  2763. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
  2764. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MIRROR);
  2765. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MAX);
  2766. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_DISABLED);
  2767. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_ONLY);
  2768. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_AND_DRAW);
  2769. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_TRANSPARENT);
  2770. /* CANVAS LIGHT */
  2771. ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create);
  2772. ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas);
  2773. ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled);
  2774. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_scale", "light", "scale"), &RenderingServer::canvas_light_set_texture_scale);
  2775. ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform);
  2776. ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture);
  2777. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset);
  2778. ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color);
  2779. ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height);
  2780. ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy);
  2781. ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range);
  2782. ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range);
  2783. ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask);
  2784. ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask);
  2785. ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode);
  2786. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled);
  2787. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);
  2788. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);
  2789. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);
  2790. ClassDB::bind_method(D_METHOD("canvas_light_set_blend_mode", "light", "mode"), &RenderingServer::canvas_light_set_blend_mode);
  2791. ClassDB::bind_method(D_METHOD("canvas_light_set_interpolated", "light", "interpolated"), &RenderingServer::canvas_light_set_interpolated);
  2792. ClassDB::bind_method(D_METHOD("canvas_light_reset_physics_interpolation", "light"), &RenderingServer::canvas_light_reset_physics_interpolation);
  2793. ClassDB::bind_method(D_METHOD("canvas_light_transform_physics_interpolation", "light", "transform"), &RenderingServer::canvas_light_transform_physics_interpolation);
  2794. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_POINT);
  2795. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_DIRECTIONAL);
  2796. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_ADD);
  2797. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_SUB);
  2798. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_MIX);
  2799. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);
  2800. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);
  2801. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);
  2802. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_MAX);
  2803. /* CANVAS OCCLUDER */
  2804. ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create);
  2805. ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas);
  2806. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled);
  2807. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon);
  2808. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_as_sdf_collision", "occluder", "enable"), &RenderingServer::canvas_light_occluder_set_as_sdf_collision);
  2809. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform);
  2810. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask);
  2811. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_interpolated", "occluder", "interpolated"), &RenderingServer::canvas_light_occluder_set_interpolated);
  2812. ClassDB::bind_method(D_METHOD("canvas_light_occluder_reset_physics_interpolation", "occluder"), &RenderingServer::canvas_light_occluder_reset_physics_interpolation);
  2813. ClassDB::bind_method(D_METHOD("canvas_light_occluder_transform_physics_interpolation", "occluder", "transform"), &RenderingServer::canvas_light_occluder_transform_physics_interpolation);
  2814. /* CANVAS LIGHT OCCLUDER POLYGON */
  2815. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create);
  2816. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape);
  2817. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode);
  2818. ClassDB::bind_method(D_METHOD("canvas_set_shadow_texture_size", "size"), &RenderingServer::canvas_set_shadow_texture_size);
  2819. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);
  2820. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);
  2821. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);
  2822. /* GLOBAL SHADER UNIFORMS */
  2823. ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add);
  2824. ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove);
  2825. ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::_global_shader_parameter_get_list);
  2826. ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set);
  2827. ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override);
  2828. ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get);
  2829. ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type);
  2830. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL);
  2831. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2);
  2832. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC3);
  2833. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC4);
  2834. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_INT);
  2835. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC2);
  2836. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC3);
  2837. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC4);
  2838. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2I);
  2839. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UINT);
  2840. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC2);
  2841. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC3);
  2842. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC4);
  2843. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_FLOAT);
  2844. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC2);
  2845. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC3);
  2846. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC4);
  2847. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_COLOR);
  2848. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2);
  2849. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT2);
  2850. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT3);
  2851. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT4);
  2852. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM_2D);
  2853. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM);
  2854. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2D);
  2855. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2DARRAY);
  2856. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER3D);
  2857. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLERCUBE);
  2858. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLEREXT);
  2859. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAX);
  2860. /* Free */
  2861. ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // Shouldn't conflict with Object::free().
  2862. /* Misc */
  2863. ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "callable"), &RenderingServer::request_frame_drawn_callback);
  2864. ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed);
  2865. ClassDB::bind_method(D_METHOD("get_rendering_info", "info"), &RenderingServer::get_rendering_info);
  2866. ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);
  2867. ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);
  2868. ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type);
  2869. ClassDB::bind_method(D_METHOD("get_video_adapter_api_version"), &RenderingServer::get_video_adapter_api_version);
  2870. ClassDB::bind_method(D_METHOD("get_current_rendering_driver_name"), &RenderingServer::get_current_rendering_driver_name);
  2871. ClassDB::bind_method(D_METHOD("get_current_rendering_method"), &RenderingServer::get_current_rendering_method);
  2872. ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);
  2873. ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);
  2874. ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);
  2875. ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);
  2876. ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));
  2877. ClassDB::bind_method(D_METHOD("get_default_clear_color"), &RenderingServer::get_default_clear_color);
  2878. ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);
  2879. ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);
  2880. ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);
  2881. ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);
  2882. ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);
  2883. ClassDB::bind_method(D_METHOD("get_frame_setup_time_cpu"), &RenderingServer::get_frame_setup_time_cpu);
  2884. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
  2885. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);
  2886. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);
  2887. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);
  2888. BIND_ENUM_CONSTANT(RENDERING_INFO_TEXTURE_MEM_USED);
  2889. BIND_ENUM_CONSTANT(RENDERING_INFO_BUFFER_MEM_USED);
  2890. BIND_ENUM_CONSTANT(RENDERING_INFO_VIDEO_MEM_USED);
  2891. BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_CANVAS);
  2892. BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_MESH);
  2893. BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SURFACE);
  2894. BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_DRAW);
  2895. BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);
  2896. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_CANVAS);
  2897. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MESH);
  2898. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SURFACE);
  2899. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_DRAW);
  2900. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SPECIALIZATION);
  2901. BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MAX);
  2902. ADD_SIGNAL(MethodInfo("frame_pre_draw"));
  2903. ADD_SIGNAL(MethodInfo("frame_post_draw"));
  2904. ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);
  2905. ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));
  2906. ClassDB::bind_method(D_METHOD("get_rendering_device"), &RenderingServer::get_rendering_device);
  2907. ClassDB::bind_method(D_METHOD("create_local_rendering_device"), &RenderingServer::create_local_rendering_device);
  2908. ClassDB::bind_method(D_METHOD("is_on_render_thread"), &RenderingServer::is_on_render_thread);
  2909. ClassDB::bind_method(D_METHOD("call_on_render_thread", "callable"), &RenderingServer::call_on_render_thread);
  2910. #ifndef DISABLE_DEPRECATED
  2911. ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);
  2912. BIND_ENUM_CONSTANT(FEATURE_SHADERS);
  2913. BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);
  2914. #endif
  2915. }
  2916. void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {
  2917. Vector<Vector3> vertices;
  2918. Vector<Vector3> normals;
  2919. for (const Geometry3D::MeshData::Face &f : p_mesh_data.faces) {
  2920. for (uint32_t j = 2; j < f.indices.size(); j++) {
  2921. vertices.push_back(p_mesh_data.vertices[f.indices[0]]);
  2922. normals.push_back(f.plane.normal);
  2923. vertices.push_back(p_mesh_data.vertices[f.indices[j - 1]]);
  2924. normals.push_back(f.plane.normal);
  2925. vertices.push_back(p_mesh_data.vertices[f.indices[j]]);
  2926. normals.push_back(f.plane.normal);
  2927. }
  2928. }
  2929. Array d;
  2930. d.resize(RS::ARRAY_MAX);
  2931. d[ARRAY_VERTEX] = vertices;
  2932. d[ARRAY_NORMAL] = normals;
  2933. mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);
  2934. }
  2935. void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {
  2936. Geometry3D::MeshData mdata = Geometry3D::build_convex_mesh(p_planes);
  2937. mesh_add_surface_from_mesh_data(p_mesh, mdata);
  2938. }
  2939. RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {
  2940. RID instance = instance_create();
  2941. instance_set_base(instance, p_base);
  2942. instance_set_scenario(instance, p_scenario);
  2943. return instance;
  2944. }
  2945. bool RenderingServer::is_render_loop_enabled() const {
  2946. return render_loop_enabled;
  2947. }
  2948. void RenderingServer::set_render_loop_enabled(bool p_enabled) {
  2949. render_loop_enabled = p_enabled;
  2950. }
  2951. RenderingServer::RenderingServer() {
  2952. //ERR_FAIL_COND(singleton);
  2953. singleton = this;
  2954. }
  2955. TypedArray<StringName> RenderingServer::_global_shader_parameter_get_list() const {
  2956. TypedArray<StringName> gsp;
  2957. Vector<StringName> gsp_sn = global_shader_parameter_get_list();
  2958. gsp.resize(gsp_sn.size());
  2959. for (int i = 0; i < gsp_sn.size(); i++) {
  2960. gsp[i] = gsp_sn[i];
  2961. }
  2962. return gsp;
  2963. }
  2964. void RenderingServer::init() {
  2965. // These are overrides, even if they are false Godot will still
  2966. // import the texture formats that the host platform needs.
  2967. // See `const bool can_s3tc_bptc` in the resource importer.
  2968. GLOBAL_DEF_RST("rendering/textures/vram_compression/import_s3tc_bptc", false);
  2969. GLOBAL_DEF_RST("rendering/textures/vram_compression/import_etc2_astc", false);
  2970. GLOBAL_DEF("rendering/textures/vram_compression/compress_with_gpu", true);
  2971. GLOBAL_DEF("rendering/textures/vram_compression/cache_gpu_compressor", true);
  2972. GLOBAL_DEF("rendering/textures/lossless_compression/force_png", false);
  2973. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/webp_compression/compression_method", PROPERTY_HINT_RANGE, "0,6,1"), 2);
  2974. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/webp_compression/lossless_compression_factor", PROPERTY_HINT_RANGE, "0,100,1"), 25);
  2975. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 3600);
  2976. GLOBAL_DEF_RST("rendering/lights_and_shadows/use_physical_light_units", false);
  2977. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"), 4096);
  2978. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/size.mobile", 2048);
  2979. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality", PROPERTY_HINT_ENUM, "Hard (Fastest),Soft Very Low (Faster),Soft Low (Fast),Soft Medium (Average),Soft High (Slow),Soft Ultra (Slowest)"), 2);
  2980. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile", 0);
  2981. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/16_bits", true);
  2982. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality", PROPERTY_HINT_ENUM, "Hard (Fastest),Soft Very Low (Faster),Soft Low (Fast),Soft Medium (Average),Soft High (Slow),Soft Ultra (Slowest)"), 2);
  2983. GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);
  2984. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/2d/shadow_atlas/size", PROPERTY_HINT_RANGE, "128,16384"), 2048);
  2985. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);
  2986. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/uniform_set_cache_size", PROPERTY_HINT_RANGE, "256,1048576,1"), 256);
  2987. // Number of commands that can be drawn per frame.
  2988. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/gl_compatibility/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);
  2989. GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true);
  2990. GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true);
  2991. GLOBAL_DEF("rendering/shader_compiler/shader_cache/use_zstd_compression", true);
  2992. GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug", false);
  2993. GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug.release", true);
  2994. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/roughness_layers", PROPERTY_HINT_RANGE, "1,32,1"), 8); // Assumes a 256x256 cubemap
  2995. GLOBAL_DEF_RST("rendering/reflections/sky_reflections/texture_array_reflections", true);
  2996. GLOBAL_DEF("rendering/reflections/sky_reflections/texture_array_reflections.mobile", false);
  2997. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples", PROPERTY_HINT_RANGE, "0,256,1"), 32);
  2998. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples.mobile", PROPERTY_HINT_RANGE, "0,128,1"), 16);
  2999. GLOBAL_DEF("rendering/reflections/sky_reflections/fast_filter_high_quality", false);
  3000. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size", PROPERTY_HINT_RANGE, "0,4096,1"), 256);
  3001. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size.mobile", PROPERTY_HINT_RANGE, "0,2048,1"), 128);
  3002. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_count", PROPERTY_HINT_RANGE, "0,256,1"), 64);
  3003. GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false);
  3004. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/voxel_gi/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)"), 0);
  3005. GLOBAL_DEF_RST("rendering/shading/overrides/force_vertex_shading", false);
  3006. GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley", false);
  3007. GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley.mobile", true);
  3008. GLOBAL_DEF_RST("rendering/driver/depth_prepass/enable", true);
  3009. GLOBAL_DEF_RST("rendering/driver/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
  3010. GLOBAL_DEF_RST("rendering/textures/default_filters/use_nearest_mipmap_filter", false);
  3011. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/textures/default_filters/anisotropic_filtering_level", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Faster),4× (Fast),8× (Average),16× (Slow)")), 2);
  3012. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/camera/depth_of_field/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slowest)"), 1);
  3013. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/camera/depth_of_field/depth_of_field_bokeh_quality", PROPERTY_HINT_ENUM, "Very Low (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);
  3014. GLOBAL_DEF("rendering/camera/depth_of_field/depth_of_field_use_jitter", false);
  3015. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);
  3016. GLOBAL_DEF("rendering/environment/ssao/half_size", true);
  3017. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);
  3018. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 2);
  3019. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);
  3020. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);
  3021. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);
  3022. GLOBAL_DEF("rendering/environment/ssil/half_size", true);
  3023. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);
  3024. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 4);
  3025. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);
  3026. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);
  3027. GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);
  3028. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);
  3029. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);
  3030. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast),FSR 2.2 (Slow)"), 0);
  3031. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);
  3032. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);
  3033. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);
  3034. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/decals/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Linear (Fast),Nearest Mipmap (Fast),Linear Mipmap (Fast),Nearest Mipmap Anisotropic (Average),Linear Mipmap Anisotropic (Average)"), DECAL_FILTER_LINEAR_MIPMAPS);
  3035. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/light_projectors/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Linear (Fast),Nearest Mipmap (Fast),Linear Mipmap (Fast),Nearest Mipmap Anisotropic (Average),Linear Mipmap Anisotropic (Average)"), LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);
  3036. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/occlusion_culling/occlusion_rays_per_thread", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), 512);
  3037. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slow)"), 1);
  3038. GLOBAL_DEF("rendering/environment/glow/upscale_mode.mobile", 0);
  3039. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/screen_space_reflection/roughness_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);
  3040. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/subsurface_scattering/subsurface_scattering_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);
  3041. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.05);
  3042. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.01);
  3043. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/global_shader_variables/buffer_size", PROPERTY_HINT_RANGE, "16,1048576,1"), 65536);
  3044. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/probe_capture/update_speed", PROPERTY_HINT_RANGE, "0.001,256,0.001"), 15);
  3045. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/primitive_meshes/texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.2);
  3046. GLOBAL_DEF("rendering/lightmapping/lightmap_gi/use_bicubic_filter", true);
  3047. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/probe_ray_count", PROPERTY_HINT_ENUM, "8 (Fastest),16,32,64,96,128 (Slowest)"), 1);
  3048. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/frames_to_converge", PROPERTY_HINT_ENUM, "5 (Less Latency but Lower Quality),10,15,20,25,30 (More Latency but Higher Quality)"), 5);
  3049. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/frames_to_update_lights", PROPERTY_HINT_ENUM, "1 (Slower),2,4,8,16 (Faster)"), 2);
  3050. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_size", PROPERTY_HINT_RANGE, "16,512,1"), 64);
  3051. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_depth", PROPERTY_HINT_RANGE, "16,512,1"), 64);
  3052. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/use_filter", PROPERTY_HINT_ENUM, "No (Faster),Yes (Higher Quality)"), 1);
  3053. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10);
  3054. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000);
  3055. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"), 512);
  3056. // OpenGL limits
  3057. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_elements", PROPERTY_HINT_RANGE, "1024,65536,1"), 65536);
  3058. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_lights", PROPERTY_HINT_RANGE, "2,256,1"), 32);
  3059. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_lights_per_object", PROPERTY_HINT_RANGE, "2,1024,1"), 8);
  3060. GLOBAL_DEF_RST_BASIC("xr/shaders/enabled", false);
  3061. GLOBAL_DEF("debug/shader_language/warnings/enable", true);
  3062. GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false);
  3063. #ifdef DEBUG_ENABLED
  3064. for (int i = 0; i < (int)ShaderWarning::WARNING_MAX; i++) {
  3065. GLOBAL_DEF("debug/shader_language/warnings/" + ShaderWarning::get_name_from_code((ShaderWarning::Code)i).to_lower(), true);
  3066. }
  3067. #endif
  3068. }
  3069. RenderingServer::~RenderingServer() {
  3070. singleton = nullptr;
  3071. }