rendering_server.cpp 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987
  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 "core/config/project_settings.h"
  32. #include "core/object/worker_thread_pool.h"
  33. #include "core/variant/typed_array.h"
  34. #include "servers/rendering/rendering_server_globals.h"
  35. #include "servers/rendering/shader_language.h"
  36. RenderingServer *RenderingServer::singleton = nullptr;
  37. RenderingServer *(*RenderingServer::create_func)() = nullptr;
  38. RenderingServer *RenderingServer::get_singleton() {
  39. return singleton;
  40. }
  41. RenderingServer *RenderingServer::create() {
  42. ERR_FAIL_COND_V(singleton, nullptr);
  43. if (create_func) {
  44. return create_func();
  45. }
  46. return nullptr;
  47. }
  48. Array RenderingServer::_texture_debug_usage_bind() {
  49. List<TextureInfo> list;
  50. texture_debug_usage(&list);
  51. Array arr;
  52. for (const TextureInfo &E : list) {
  53. Dictionary dict;
  54. dict["texture"] = E.texture;
  55. dict["width"] = E.width;
  56. dict["height"] = E.height;
  57. dict["depth"] = E.depth;
  58. dict["format"] = E.format;
  59. dict["bytes"] = E.bytes;
  60. dict["path"] = E.path;
  61. arr.push_back(dict);
  62. }
  63. return arr;
  64. }
  65. static PackedInt64Array to_int_array(const Vector<ObjectID> &ids) {
  66. PackedInt64Array a;
  67. a.resize(ids.size());
  68. for (int i = 0; i < ids.size(); ++i) {
  69. a.write[i] = ids[i];
  70. }
  71. return a;
  72. }
  73. PackedInt64Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
  74. if (RSG::threaded) {
  75. WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall.");
  76. }
  77. Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
  78. return to_int_array(ids);
  79. }
  80. PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
  81. if (RSG::threaded) {
  82. WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall.");
  83. }
  84. Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
  85. return to_int_array(ids);
  86. }
  87. PackedInt64Array RenderingServer::_instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario) const {
  88. if (RSG::threaded) {
  89. WARN_PRINT_ONCE("Using this function with a threaded renderer hurts performance, as it causes a server stall.");
  90. }
  91. Vector<Plane> planes;
  92. for (int i = 0; i < p_convex.size(); ++i) {
  93. Variant v = p_convex[i];
  94. ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, PackedInt64Array());
  95. planes.push_back(v);
  96. }
  97. Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);
  98. return to_int_array(ids);
  99. }
  100. RID RenderingServer::get_test_texture() {
  101. if (test_texture.is_valid()) {
  102. return test_texture;
  103. };
  104. #define TEST_TEXTURE_SIZE 256
  105. Vector<uint8_t> test_data;
  106. test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);
  107. {
  108. uint8_t *w = test_data.ptrw();
  109. for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {
  110. for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {
  111. Color c;
  112. int r = 255 - (x + y) / 2;
  113. if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {
  114. c.r = y;
  115. c.g = r;
  116. c.b = x;
  117. } else {
  118. c.r = r;
  119. c.g = x;
  120. c.b = y;
  121. }
  122. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r, 0, 255));
  123. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g, 0, 255));
  124. w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b, 0, 255));
  125. }
  126. }
  127. }
  128. Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));
  129. test_texture = texture_2d_create(data);
  130. return test_texture;
  131. }
  132. void RenderingServer::_free_internal_rids() {
  133. if (test_texture.is_valid()) {
  134. free(test_texture);
  135. }
  136. if (white_texture.is_valid()) {
  137. free(white_texture);
  138. }
  139. if (test_material.is_valid()) {
  140. free(test_material);
  141. }
  142. }
  143. RID RenderingServer::_make_test_cube() {
  144. Vector<Vector3> vertices;
  145. Vector<Vector3> normals;
  146. Vector<float> tangents;
  147. Vector<Vector3> uvs;
  148. #define ADD_VTX(m_idx) \
  149. vertices.push_back(face_points[m_idx]); \
  150. normals.push_back(normal_points[m_idx]); \
  151. tangents.push_back(normal_points[m_idx][1]); \
  152. tangents.push_back(normal_points[m_idx][2]); \
  153. tangents.push_back(normal_points[m_idx][0]); \
  154. tangents.push_back(1.0); \
  155. uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
  156. for (int i = 0; i < 6; i++) {
  157. Vector3 face_points[4];
  158. Vector3 normal_points[4];
  159. float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
  160. for (int j = 0; j < 4; j++) {
  161. float v[3];
  162. v[0] = 1.0;
  163. v[1] = 1 - 2 * ((j >> 1) & 1);
  164. v[2] = v[1] * (1 - 2 * (j & 1));
  165. for (int k = 0; k < 3; k++) {
  166. if (i < 3) {
  167. face_points[j][(i + k) % 3] = v[k];
  168. } else {
  169. face_points[3 - j][(i + k) % 3] = -v[k];
  170. }
  171. }
  172. normal_points[j] = Vector3();
  173. normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
  174. }
  175. // Tri 1
  176. ADD_VTX(0);
  177. ADD_VTX(1);
  178. ADD_VTX(2);
  179. // Tri 2
  180. ADD_VTX(2);
  181. ADD_VTX(3);
  182. ADD_VTX(0);
  183. }
  184. RID test_cube = mesh_create();
  185. Array d;
  186. d.resize(RS::ARRAY_MAX);
  187. d[RenderingServer::ARRAY_NORMAL] = normals;
  188. d[RenderingServer::ARRAY_TANGENT] = tangents;
  189. d[RenderingServer::ARRAY_TEX_UV] = uvs;
  190. d[RenderingServer::ARRAY_VERTEX] = vertices;
  191. Vector<int> indices;
  192. indices.resize(vertices.size());
  193. for (int i = 0; i < vertices.size(); i++) {
  194. indices.set(i, i);
  195. }
  196. d[RenderingServer::ARRAY_INDEX] = indices;
  197. mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
  198. /*
  199. test_material = fixed_material_create();
  200. //material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
  201. fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
  202. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
  203. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
  204. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
  205. fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
  206. */
  207. mesh_surface_set_material(test_cube, 0, test_material);
  208. return test_cube;
  209. }
  210. RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, real_t p_radius) {
  211. Vector<Vector3> vertices;
  212. Vector<Vector3> normals;
  213. const double lat_step = Math_TAU / p_lats;
  214. const double lon_step = Math_TAU / p_lons;
  215. for (int i = 1; i <= p_lats; i++) {
  216. double lat0 = lat_step * (i - 1) - Math_TAU / 4;
  217. double z0 = Math::sin(lat0);
  218. double zr0 = Math::cos(lat0);
  219. double lat1 = lat_step * i - Math_TAU / 4;
  220. double z1 = Math::sin(lat1);
  221. double zr1 = Math::cos(lat1);
  222. for (int j = p_lons; j >= 1; j--) {
  223. double lng0 = lon_step * (j - 1);
  224. double x0 = Math::cos(lng0);
  225. double y0 = Math::sin(lng0);
  226. double lng1 = lon_step * j;
  227. double x1 = Math::cos(lng1);
  228. double y1 = Math::sin(lng1);
  229. Vector3 v[4] = {
  230. Vector3(x1 * zr0, z0, y1 * zr0),
  231. Vector3(x1 * zr1, z1, y1 * zr1),
  232. Vector3(x0 * zr1, z1, y0 * zr1),
  233. Vector3(x0 * zr0, z0, y0 * zr0)
  234. };
  235. #define ADD_POINT(m_idx) \
  236. normals.push_back(v[m_idx]); \
  237. vertices.push_back(v[m_idx] * p_radius);
  238. ADD_POINT(0);
  239. ADD_POINT(1);
  240. ADD_POINT(2);
  241. ADD_POINT(2);
  242. ADD_POINT(3);
  243. ADD_POINT(0);
  244. }
  245. }
  246. RID mesh = mesh_create();
  247. Array d;
  248. d.resize(RS::ARRAY_MAX);
  249. d[ARRAY_VERTEX] = vertices;
  250. d[ARRAY_NORMAL] = normals;
  251. mesh_add_surface_from_arrays(mesh, PRIMITIVE_TRIANGLES, d);
  252. return mesh;
  253. }
  254. RID RenderingServer::get_white_texture() {
  255. if (white_texture.is_valid()) {
  256. return white_texture;
  257. }
  258. Vector<uint8_t> wt;
  259. wt.resize(16 * 3);
  260. {
  261. uint8_t *w = wt.ptrw();
  262. for (int i = 0; i < 16 * 3; i++) {
  263. w[i] = 255;
  264. }
  265. }
  266. Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt));
  267. white_texture = texture_2d_create(white);
  268. return white_texture;
  269. }
  270. Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_vertex_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) {
  271. uint8_t *vw = r_vertex_array.ptrw();
  272. uint8_t *aw = r_attrib_array.ptrw();
  273. uint8_t *sw = r_skin_array.ptrw();
  274. uint8_t *iw = nullptr;
  275. if (r_index_array.size()) {
  276. iw = r_index_array.ptrw();
  277. }
  278. int max_bone = 0;
  279. for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {
  280. if (!(p_format & (1 << ai))) { // No array
  281. continue;
  282. }
  283. switch (ai) {
  284. case RS::ARRAY_VERTEX: {
  285. if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
  286. Vector<Vector2> array = p_arrays[ai];
  287. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  288. const Vector2 *src = array.ptr();
  289. // Setting vertices means regenerating the AABB.
  290. Rect2 aabb;
  291. {
  292. for (int i = 0; i < p_vertex_array_len; i++) {
  293. float vector[2] = { (float)src[i].x, (float)src[i].y };
  294. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2);
  295. if (i == 0) {
  296. aabb = Rect2(src[i], SMALL_VEC2); // Must have a bit of size.
  297. } else {
  298. aabb.expand_to(src[i]);
  299. }
  300. }
  301. }
  302. r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
  303. } else {
  304. Vector<Vector3> array = p_arrays[ai];
  305. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  306. const Vector3 *src = array.ptr();
  307. // Setting vertices means regenerating the AABB.
  308. AABB aabb;
  309. {
  310. for (int i = 0; i < p_vertex_array_len; i++) {
  311. float vector[3] = { (float)src[i].x, (float)src[i].y, (float)src[i].z };
  312. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 3);
  313. if (i == 0) {
  314. aabb = AABB(src[i], SMALL_VEC3);
  315. } else {
  316. aabb.expand_to(src[i]);
  317. }
  318. }
  319. }
  320. r_aabb = aabb;
  321. }
  322. } break;
  323. case RS::ARRAY_NORMAL: {
  324. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
  325. Vector<Vector3> array = p_arrays[ai];
  326. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  327. const Vector3 *src = array.ptr();
  328. for (int i = 0; i < p_vertex_array_len; i++) {
  329. Vector2 res = src[i].octahedron_encode();
  330. int16_t vector[2] = {
  331. (int16_t)CLAMP(res.x * 65535, 0, 65535),
  332. (int16_t)CLAMP(res.y * 65535, 0, 65535),
  333. };
  334. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, 4);
  335. }
  336. } break;
  337. case RS::ARRAY_TANGENT: {
  338. Variant::Type type = p_arrays[ai].get_type();
  339. ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY, ERR_INVALID_PARAMETER);
  340. if (type == Variant::PACKED_FLOAT32_ARRAY) {
  341. Vector<float> array = p_arrays[ai];
  342. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  343. const float *src_ptr = array.ptr();
  344. for (int i = 0; i < p_vertex_array_len; i++) {
  345. const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);
  346. Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);
  347. int16_t vector[2] = {
  348. (int16_t)CLAMP(res.x * 65535, 0, 65535),
  349. (int16_t)CLAMP(res.y * 65535, 0, 65535),
  350. };
  351. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, 4);
  352. }
  353. } else { // PACKED_FLOAT64_ARRAY
  354. Vector<double> array = p_arrays[ai];
  355. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  356. const double *src_ptr = array.ptr();
  357. for (int i = 0; i < p_vertex_array_len; i++) {
  358. const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);
  359. Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);
  360. int16_t vector[2] = {
  361. (int16_t)CLAMP(res.x * 65535, 0, 65535),
  362. (int16_t)CLAMP(res.y * 65535, 0, 65535),
  363. };
  364. memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, 4);
  365. }
  366. }
  367. } break;
  368. case RS::ARRAY_COLOR: {
  369. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);
  370. Vector<Color> array = p_arrays[ai];
  371. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  372. const Color *src = array.ptr();
  373. for (int i = 0; i < p_vertex_array_len; i++) {
  374. uint8_t color8[4] = {
  375. uint8_t(CLAMP(src[i].r * 255.0, 0.0, 255.0)),
  376. uint8_t(CLAMP(src[i].g * 255.0, 0.0, 255.0)),
  377. uint8_t(CLAMP(src[i].b * 255.0, 0.0, 255.0)),
  378. uint8_t(CLAMP(src[i].a * 255.0, 0.0, 255.0))
  379. };
  380. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color8, 4);
  381. }
  382. } break;
  383. case RS::ARRAY_TEX_UV: {
  384. 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);
  385. Vector<Vector2> array = p_arrays[ai];
  386. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  387. const Vector2 *src = array.ptr();
  388. for (int i = 0; i < p_vertex_array_len; i++) {
  389. float uv[2] = { (float)src[i].x, (float)src[i].y };
  390. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);
  391. }
  392. } break;
  393. case RS::ARRAY_TEX_UV2: {
  394. 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);
  395. Vector<Vector2> array = p_arrays[ai];
  396. ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
  397. const Vector2 *src = array.ptr();
  398. for (int i = 0; i < p_vertex_array_len; i++) {
  399. float uv[2] = { (float)src[i].x, (float)src[i].y };
  400. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);
  401. }
  402. } break;
  403. case RS::ARRAY_CUSTOM0:
  404. case RS::ARRAY_CUSTOM1:
  405. case RS::ARRAY_CUSTOM2:
  406. case RS::ARRAY_CUSTOM3: {
  407. uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (ai - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;
  408. switch (type) {
  409. case ARRAY_CUSTOM_RGBA8_UNORM:
  410. case ARRAY_CUSTOM_RGBA8_SNORM:
  411. case ARRAY_CUSTOM_RG_HALF: {
  412. // Size 4
  413. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);
  414. Vector<uint8_t> array = p_arrays[ai];
  415. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);
  416. const uint8_t *src = array.ptr();
  417. for (int i = 0; i < p_vertex_array_len; i++) {
  418. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 4], 4);
  419. }
  420. } break;
  421. case ARRAY_CUSTOM_RGBA_HALF: {
  422. // Size 8
  423. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);
  424. Vector<uint8_t> array = p_arrays[ai];
  425. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 8, ERR_INVALID_PARAMETER);
  426. const uint8_t *src = array.ptr();
  427. for (int i = 0; i < p_vertex_array_len; i++) {
  428. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 8], 8);
  429. }
  430. } break;
  431. case ARRAY_CUSTOM_R_FLOAT:
  432. case ARRAY_CUSTOM_RG_FLOAT:
  433. case ARRAY_CUSTOM_RGB_FLOAT:
  434. case ARRAY_CUSTOM_RGBA_FLOAT: {
  435. // RF
  436. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
  437. Vector<float> array = p_arrays[ai];
  438. int32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;
  439. ERR_FAIL_COND_V(array.size() != p_vertex_array_len * s, ERR_INVALID_PARAMETER);
  440. const float *src = array.ptr();
  441. for (int i = 0; i < p_vertex_array_len; i++) {
  442. memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * s], sizeof(float) * s);
  443. }
  444. } break;
  445. default: {
  446. }
  447. }
  448. } break;
  449. case RS::ARRAY_WEIGHTS: {
  450. Variant::Type type = p_arrays[ai].get_type();
  451. ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY, ERR_INVALID_PARAMETER);
  452. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  453. if (type == Variant::PACKED_FLOAT32_ARRAY) {
  454. Vector<float> array = p_arrays[ai];
  455. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  456. const float *src = array.ptr();
  457. {
  458. uint16_t data[8];
  459. for (int i = 0; i < p_vertex_array_len; i++) {
  460. for (uint32_t j = 0; j < bone_count; j++) {
  461. data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);
  462. }
  463. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  464. }
  465. }
  466. } else { // PACKED_FLOAT64_ARRAY
  467. Vector<double> array = p_arrays[ai];
  468. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  469. const double *src = array.ptr();
  470. {
  471. uint16_t data[8];
  472. for (int i = 0; i < p_vertex_array_len; i++) {
  473. for (uint32_t j = 0; j < bone_count; j++) {
  474. data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);
  475. }
  476. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  477. }
  478. }
  479. }
  480. } break;
  481. case RS::ARRAY_BONES: {
  482. 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);
  483. Vector<int> array = p_arrays[ai];
  484. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  485. ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);
  486. const int *src = array.ptr();
  487. uint16_t data[8];
  488. for (int i = 0; i < p_vertex_array_len; i++) {
  489. for (uint32_t j = 0; j < bone_count; j++) {
  490. data[j] = src[i * bone_count + j];
  491. max_bone = MAX(data[j], max_bone);
  492. }
  493. memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);
  494. }
  495. } break;
  496. case RS::ARRAY_INDEX: {
  497. ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);
  498. ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
  499. ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);
  500. Vector<int> indices = p_arrays[ai];
  501. ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER);
  502. ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);
  503. /* determine whether using 16 or 32 bits indices */
  504. const int *src = indices.ptr();
  505. for (int i = 0; i < p_index_array_len; i++) {
  506. if (p_vertex_array_len <= (1 << 16) && p_vertex_array_len > 0) {
  507. uint16_t v = src[i];
  508. memcpy(&iw[i * 2], &v, 2);
  509. } else {
  510. uint32_t v = src[i];
  511. memcpy(&iw[i * 4], &v, 4);
  512. }
  513. }
  514. } break;
  515. default: {
  516. ERR_FAIL_V(ERR_INVALID_DATA);
  517. }
  518. }
  519. }
  520. if (p_format & RS::ARRAY_FORMAT_BONES) {
  521. // Create AABBs for each detected bone.
  522. int total_bones = max_bone + 1;
  523. bool first = r_bone_aabb.size() == 0;
  524. r_bone_aabb.resize(total_bones);
  525. int weight_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  526. if (first) {
  527. for (int i = 0; i < total_bones; i++) {
  528. r_bone_aabb.write[i].size = Vector3(-1, -1, -1); // Negative means unused.
  529. }
  530. }
  531. Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];
  532. Vector<int> bones = p_arrays[RS::ARRAY_BONES];
  533. Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS];
  534. bool any_valid = false;
  535. if (vertices.size() && bones.size() == vertices.size() * weight_count && weights.size() == bones.size()) {
  536. int vs = vertices.size();
  537. const Vector3 *rv = vertices.ptr();
  538. const int *rb = bones.ptr();
  539. const float *rw = weights.ptr();
  540. AABB *bptr = r_bone_aabb.ptrw();
  541. for (int i = 0; i < vs; i++) {
  542. Vector3 v = rv[i];
  543. for (int j = 0; j < weight_count; j++) {
  544. int idx = rb[i * weight_count + j];
  545. float w = rw[i * weight_count + j];
  546. if (w == 0) {
  547. continue; //break;
  548. }
  549. ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
  550. if (bptr[idx].size.x < 0) {
  551. // First
  552. bptr[idx] = AABB(v, SMALL_VEC3);
  553. any_valid = true;
  554. } else {
  555. bptr[idx].expand_to(v);
  556. }
  557. }
  558. }
  559. }
  560. if (!any_valid && first) {
  561. r_bone_aabb.clear();
  562. }
  563. }
  564. return OK;
  565. }
  566. uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const {
  567. ERR_FAIL_INDEX_V(p_array_index, ARRAY_MAX, 0);
  568. p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  569. uint32_t offsets[ARRAY_MAX];
  570. uint32_t vstr;
  571. uint32_t astr;
  572. uint32_t sstr;
  573. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, astr, sstr);
  574. return offsets[p_array_index];
  575. }
  576. uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  577. p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  578. uint32_t offsets[ARRAY_MAX];
  579. uint32_t vstr;
  580. uint32_t astr;
  581. uint32_t sstr;
  582. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, astr, sstr);
  583. return vstr;
  584. }
  585. uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  586. p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  587. uint32_t offsets[ARRAY_MAX];
  588. uint32_t vstr;
  589. uint32_t astr;
  590. uint32_t sstr;
  591. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, astr, sstr);
  592. return astr;
  593. }
  594. uint32_t RenderingServer::mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {
  595. p_format = int64_t(p_format) & ~ARRAY_FORMAT_INDEX;
  596. uint32_t offsets[ARRAY_MAX];
  597. uint32_t vstr;
  598. uint32_t astr;
  599. uint32_t sstr;
  600. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, astr, sstr);
  601. return sstr;
  602. }
  603. void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t &r_vertex_element_size, uint32_t &r_attrib_element_size, uint32_t &r_skin_element_size) const {
  604. r_vertex_element_size = 0;
  605. r_attrib_element_size = 0;
  606. r_skin_element_size = 0;
  607. uint32_t *size_accum = nullptr;
  608. for (int i = 0; i < RS::ARRAY_MAX; i++) {
  609. r_offsets[i] = 0; // Reset
  610. if (i == RS::ARRAY_VERTEX) {
  611. size_accum = &r_vertex_element_size;
  612. } else if (i == RS::ARRAY_COLOR) {
  613. size_accum = &r_attrib_element_size;
  614. } else if (i == RS::ARRAY_BONES) {
  615. size_accum = &r_skin_element_size;
  616. }
  617. if (!(p_format & (1 << i))) { // No array
  618. continue;
  619. }
  620. int elem_size = 0;
  621. switch (i) {
  622. case RS::ARRAY_VERTEX: {
  623. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  624. elem_size = 2;
  625. } else {
  626. elem_size = 3;
  627. }
  628. elem_size *= sizeof(float);
  629. } break;
  630. case RS::ARRAY_NORMAL: {
  631. elem_size = 4;
  632. } break;
  633. case RS::ARRAY_TANGENT: {
  634. elem_size = 4;
  635. } break;
  636. case RS::ARRAY_COLOR: {
  637. elem_size = 4;
  638. } break;
  639. case RS::ARRAY_TEX_UV: {
  640. elem_size = 8;
  641. } break;
  642. case RS::ARRAY_TEX_UV2: {
  643. elem_size = 8;
  644. } break;
  645. case RS::ARRAY_CUSTOM0:
  646. case RS::ARRAY_CUSTOM1:
  647. case RS::ARRAY_CUSTOM2:
  648. case RS::ARRAY_CUSTOM3: {
  649. uint32_t format = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + (ARRAY_FORMAT_CUSTOM_BITS * (i - ARRAY_CUSTOM0)))) & ARRAY_FORMAT_CUSTOM_MASK;
  650. switch (format) {
  651. case ARRAY_CUSTOM_RGBA8_UNORM: {
  652. elem_size = 4;
  653. } break;
  654. case ARRAY_CUSTOM_RGBA8_SNORM: {
  655. elem_size = 4;
  656. } break;
  657. case ARRAY_CUSTOM_RG_HALF: {
  658. elem_size = 4;
  659. } break;
  660. case ARRAY_CUSTOM_RGBA_HALF: {
  661. elem_size = 8;
  662. } break;
  663. case ARRAY_CUSTOM_R_FLOAT: {
  664. elem_size = 4;
  665. } break;
  666. case ARRAY_CUSTOM_RG_FLOAT: {
  667. elem_size = 8;
  668. } break;
  669. case ARRAY_CUSTOM_RGB_FLOAT: {
  670. elem_size = 12;
  671. } break;
  672. case ARRAY_CUSTOM_RGBA_FLOAT: {
  673. elem_size = 16;
  674. } break;
  675. }
  676. } break;
  677. case RS::ARRAY_WEIGHTS: {
  678. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  679. elem_size = sizeof(uint16_t) * bone_count;
  680. } break;
  681. case RS::ARRAY_BONES: {
  682. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  683. elem_size = sizeof(uint16_t) * bone_count;
  684. } break;
  685. case RS::ARRAY_INDEX: {
  686. if (p_index_len <= 0) {
  687. ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
  688. break;
  689. }
  690. /* determine whether using 16 or 32 bits indices */
  691. if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {
  692. elem_size = 2;
  693. } else {
  694. elem_size = 4;
  695. }
  696. r_offsets[i] = elem_size;
  697. continue;
  698. }
  699. default: {
  700. ERR_FAIL();
  701. }
  702. }
  703. if (size_accum != nullptr) {
  704. r_offsets[i] = (*size_accum);
  705. (*size_accum) += elem_size;
  706. } else {
  707. r_offsets[i] = 0;
  708. }
  709. }
  710. }
  711. 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, uint32_t p_compress_format) {
  712. ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);
  713. ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);
  714. uint32_t format = 0;
  715. // Validation
  716. int index_array_len = 0;
  717. int array_len = 0;
  718. for (int i = 0; i < p_arrays.size(); i++) {
  719. if (p_arrays[i].get_type() == Variant::NIL) {
  720. continue;
  721. }
  722. format |= (1 << i);
  723. if (i == RS::ARRAY_VERTEX) {
  724. switch (p_arrays[i].get_type()) {
  725. case Variant::PACKED_VECTOR2_ARRAY: {
  726. Vector<Vector2> v2 = p_arrays[i];
  727. array_len = v2.size();
  728. format |= ARRAY_FLAG_USE_2D_VERTICES;
  729. } break;
  730. case Variant::PACKED_VECTOR3_ARRAY: {
  731. ERR_FAIL_COND_V(p_compress_format & ARRAY_FLAG_USE_2D_VERTICES, ERR_INVALID_PARAMETER);
  732. Vector<Vector3> v3 = p_arrays[i];
  733. array_len = v3.size();
  734. } break;
  735. default: {
  736. ERR_FAIL_V(ERR_INVALID_DATA);
  737. } break;
  738. }
  739. ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);
  740. } else if (i == RS::ARRAY_BONES) {
  741. switch (p_arrays[i].get_type()) {
  742. case Variant::PACKED_INT32_ARRAY: {
  743. Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];
  744. Vector<int32_t> bones = p_arrays[i];
  745. int32_t bone_8_group_count = bones.size() / (ARRAY_WEIGHTS_SIZE * 2);
  746. int32_t vertex_count = vertices.size();
  747. if (vertex_count == bone_8_group_count) {
  748. format |= RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;
  749. }
  750. } break;
  751. default: {
  752. ERR_FAIL_V(ERR_INVALID_DATA);
  753. } break;
  754. }
  755. } else if (i == RS::ARRAY_INDEX) {
  756. index_array_len = PackedInt32Array(p_arrays[i]).size();
  757. }
  758. }
  759. if (p_blend_shapes.size()) {
  760. // Validate format for morphs.
  761. for (int i = 0; i < p_blend_shapes.size(); i++) {
  762. uint32_t bsformat = 0;
  763. Array arr = p_blend_shapes[i];
  764. for (int j = 0; j < arr.size(); j++) {
  765. if (arr[j].get_type() != Variant::NIL) {
  766. bsformat |= (1 << j);
  767. }
  768. }
  769. 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.");
  770. }
  771. }
  772. for (uint32_t i = 0; i < RS::ARRAY_CUSTOM_COUNT; ++i) {
  773. // Include custom array format type.
  774. if (format & (1 << (ARRAY_CUSTOM0 + i))) {
  775. format |= (RS::ARRAY_FORMAT_CUSTOM_MASK << (RS::ARRAY_FORMAT_CUSTOM_BASE + i * RS::ARRAY_FORMAT_CUSTOM_BITS)) & p_compress_format;
  776. }
  777. }
  778. uint32_t offsets[RS::ARRAY_MAX];
  779. uint32_t vertex_element_size;
  780. uint32_t attrib_element_size;
  781. uint32_t skin_element_size;
  782. mesh_surface_make_offsets_from_format(format, array_len, index_array_len, offsets, vertex_element_size, attrib_element_size, skin_element_size);
  783. uint32_t mask = (1 << ARRAY_MAX) - 1;
  784. format |= (~mask) & p_compress_format; // Make the full format.
  785. if ((format & RS::ARRAY_FORMAT_VERTEX) == 0 && !(format & RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY)) {
  786. 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.");
  787. // Set the flag here after warning to suppress errors down the pipeline.
  788. format |= RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY;
  789. }
  790. int vertex_array_size = vertex_element_size * array_len;
  791. int attrib_array_size = attrib_element_size * array_len;
  792. int skin_array_size = skin_element_size * array_len;
  793. int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len;
  794. Vector<uint8_t> vertex_array;
  795. vertex_array.resize(vertex_array_size);
  796. Vector<uint8_t> attrib_array;
  797. attrib_array.resize(attrib_array_size);
  798. Vector<uint8_t> skin_array;
  799. skin_array.resize(skin_array_size);
  800. Vector<uint8_t> index_array;
  801. index_array.resize(index_array_size);
  802. AABB aabb;
  803. Vector<AABB> bone_aabb;
  804. Error err = _surface_set_data(p_arrays, format, offsets, vertex_element_size, attrib_element_size, skin_element_size, vertex_array, attrib_array, skin_array, array_len, index_array, index_array_len, aabb, bone_aabb);
  805. ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Invalid array format for surface.");
  806. Vector<uint8_t> blend_shape_data;
  807. if (p_blend_shapes.size()) {
  808. uint32_t bs_format = format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK;
  809. for (int i = 0; i < p_blend_shapes.size(); i++) {
  810. Vector<uint8_t> vertex_array_shape;
  811. vertex_array_shape.resize(vertex_array_size);
  812. Vector<uint8_t> noindex;
  813. Vector<uint8_t> noattrib;
  814. Vector<uint8_t> noskin;
  815. AABB laabb;
  816. Error err2 = _surface_set_data(p_blend_shapes[i], bs_format, offsets, vertex_element_size, 0, 0, vertex_array_shape, noattrib, noskin, array_len, noindex, 0, laabb, bone_aabb);
  817. aabb.merge_with(laabb);
  818. ERR_FAIL_COND_V_MSG(err2 != OK, ERR_INVALID_DATA, "Invalid blend shape array format for surface.");
  819. blend_shape_data.append_array(vertex_array_shape);
  820. }
  821. }
  822. Vector<SurfaceData::LOD> lods;
  823. if (index_array_len) {
  824. List<Variant> keys;
  825. p_lods.get_key_list(&keys);
  826. keys.sort(); // otherwise lod levels may get skipped
  827. for (const Variant &E : keys) {
  828. float distance = E;
  829. ERR_CONTINUE(distance <= 0.0);
  830. Vector<int> indices = p_lods[E];
  831. ERR_CONTINUE(indices.size() == 0);
  832. uint32_t index_count = indices.size();
  833. ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller..
  834. const int *r = indices.ptr();
  835. Vector<uint8_t> data;
  836. if (array_len <= 65536) {
  837. // 16 bits indices
  838. data.resize(indices.size() * 2);
  839. uint8_t *w = data.ptrw();
  840. uint16_t *index_ptr = (uint16_t *)w;
  841. for (uint32_t i = 0; i < index_count; i++) {
  842. index_ptr[i] = r[i];
  843. }
  844. } else {
  845. // 32 bits indices
  846. data.resize(indices.size() * 4);
  847. uint8_t *w = data.ptrw();
  848. uint32_t *index_ptr = (uint32_t *)w;
  849. for (uint32_t i = 0; i < index_count; i++) {
  850. index_ptr[i] = r[i];
  851. }
  852. }
  853. SurfaceData::LOD lod;
  854. lod.edge_length = distance;
  855. lod.index_data = data;
  856. lods.push_back(lod);
  857. }
  858. }
  859. SurfaceData &surface_data = *r_surface_data;
  860. surface_data.format = format;
  861. surface_data.primitive = p_primitive;
  862. surface_data.aabb = aabb;
  863. surface_data.vertex_data = vertex_array;
  864. surface_data.attribute_data = attrib_array;
  865. surface_data.skin_data = skin_array;
  866. surface_data.vertex_count = array_len;
  867. surface_data.index_data = index_array;
  868. surface_data.index_count = index_array_len;
  869. surface_data.blend_shape_data = blend_shape_data;
  870. surface_data.bone_aabbs = bone_aabb;
  871. surface_data.lods = lods;
  872. return OK;
  873. }
  874. 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) {
  875. SurfaceData sd;
  876. Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);
  877. if (err != OK) {
  878. return;
  879. }
  880. mesh_add_surface(p_mesh, sd);
  881. }
  882. Array RenderingServer::_get_array_from_surface(uint32_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 {
  883. uint32_t offsets[RS::ARRAY_MAX];
  884. uint32_t vertex_elem_size;
  885. uint32_t attrib_elem_size;
  886. uint32_t skin_elem_size;
  887. mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets, vertex_elem_size, attrib_elem_size, skin_elem_size);
  888. Array ret;
  889. ret.resize(RS::ARRAY_MAX);
  890. const uint8_t *r = p_vertex_data.ptr();
  891. const uint8_t *ar = p_attrib_data.ptr();
  892. const uint8_t *sr = p_skin_data.ptr();
  893. for (int i = 0; i < RS::ARRAY_MAX; i++) {
  894. if (!(p_format & (1 << i))) {
  895. continue;
  896. }
  897. switch (i) {
  898. case RS::ARRAY_VERTEX: {
  899. if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
  900. Vector<Vector2> arr_2d;
  901. arr_2d.resize(p_vertex_len);
  902. {
  903. Vector2 *w = arr_2d.ptrw();
  904. for (int j = 0; j < p_vertex_len; j++) {
  905. const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
  906. w[j] = Vector2(v[0], v[1]);
  907. }
  908. }
  909. ret[i] = arr_2d;
  910. } else {
  911. Vector<Vector3> arr_3d;
  912. arr_3d.resize(p_vertex_len);
  913. {
  914. Vector3 *w = arr_3d.ptrw();
  915. for (int j = 0; j < p_vertex_len; j++) {
  916. const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);
  917. w[j] = Vector3(v[0], v[1], v[2]);
  918. }
  919. }
  920. ret[i] = arr_3d;
  921. }
  922. } break;
  923. case RS::ARRAY_NORMAL: {
  924. Vector<Vector3> arr;
  925. arr.resize(p_vertex_len);
  926. Vector3 *w = arr.ptrw();
  927. for (int j = 0; j < p_vertex_len; j++) {
  928. const uint32_t v = *(const uint32_t *)&r[j * vertex_elem_size + offsets[i]];
  929. w[j] = Vector3::octahedron_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0));
  930. }
  931. ret[i] = arr;
  932. } break;
  933. case RS::ARRAY_TANGENT: {
  934. Vector<float> arr;
  935. arr.resize(p_vertex_len * 4);
  936. float *w = arr.ptrw();
  937. for (int j = 0; j < p_vertex_len; j++) {
  938. const uint32_t v = *(const uint32_t *)&r[j * vertex_elem_size + offsets[i]];
  939. float tangent_sign;
  940. Vector3 res = Vector3::octahedron_tangent_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0), &tangent_sign);
  941. w[j * 4 + 0] = res.x;
  942. w[j * 4 + 1] = res.y;
  943. w[j * 4 + 2] = res.z;
  944. w[j * 4 + 3] = tangent_sign;
  945. }
  946. ret[i] = arr;
  947. } break;
  948. case RS::ARRAY_COLOR: {
  949. Vector<Color> arr;
  950. arr.resize(p_vertex_len);
  951. Color *w = arr.ptrw();
  952. for (int32_t j = 0; j < p_vertex_len; j++) {
  953. const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  954. w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
  955. }
  956. ret[i] = arr;
  957. } break;
  958. case RS::ARRAY_TEX_UV: {
  959. Vector<Vector2> arr;
  960. arr.resize(p_vertex_len);
  961. Vector2 *w = arr.ptrw();
  962. for (int j = 0; j < p_vertex_len; j++) {
  963. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  964. w[j] = Vector2(v[0], v[1]);
  965. }
  966. ret[i] = arr;
  967. } break;
  968. case RS::ARRAY_TEX_UV2: {
  969. Vector<Vector2> arr;
  970. arr.resize(p_vertex_len);
  971. Vector2 *w = arr.ptrw();
  972. for (int j = 0; j < p_vertex_len; j++) {
  973. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  974. w[j] = Vector2(v[0], v[1]);
  975. }
  976. ret[i] = arr;
  977. } break;
  978. case RS::ARRAY_CUSTOM0:
  979. case RS::ARRAY_CUSTOM1:
  980. case RS::ARRAY_CUSTOM2:
  981. case RS::ARRAY_CUSTOM3: {
  982. uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (i - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;
  983. switch (type) {
  984. case ARRAY_CUSTOM_RGBA8_UNORM:
  985. case ARRAY_CUSTOM_RGBA8_SNORM:
  986. case ARRAY_CUSTOM_RG_HALF:
  987. case ARRAY_CUSTOM_RGBA_HALF: {
  988. // Size 4
  989. int s = type == ARRAY_CUSTOM_RGBA_HALF ? 8 : 4;
  990. Vector<uint8_t> arr;
  991. arr.resize(p_vertex_len * s);
  992. uint8_t *w = arr.ptrw();
  993. for (int j = 0; j < p_vertex_len; j++) {
  994. const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);
  995. memcpy(&w[j * s], v, s);
  996. }
  997. ret[i] = arr;
  998. } break;
  999. case ARRAY_CUSTOM_R_FLOAT:
  1000. case ARRAY_CUSTOM_RG_FLOAT:
  1001. case ARRAY_CUSTOM_RGB_FLOAT:
  1002. case ARRAY_CUSTOM_RGBA_FLOAT: {
  1003. uint32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;
  1004. Vector<float> arr;
  1005. arr.resize(s * p_vertex_len);
  1006. float *w = arr.ptrw();
  1007. for (int j = 0; j < p_vertex_len; j++) {
  1008. const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);
  1009. memcpy(&w[j * s], v, s * sizeof(float));
  1010. }
  1011. ret[i] = arr;
  1012. } break;
  1013. default: {
  1014. }
  1015. }
  1016. } break;
  1017. case RS::ARRAY_WEIGHTS: {
  1018. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  1019. Vector<float> arr;
  1020. arr.resize(p_vertex_len * bone_count);
  1021. {
  1022. float *w = arr.ptrw();
  1023. for (int j = 0; j < p_vertex_len; j++) {
  1024. const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];
  1025. for (uint32_t k = 0; k < bone_count; k++) {
  1026. w[j * bone_count + k] = float(v[k] / 65535.0);
  1027. }
  1028. }
  1029. }
  1030. ret[i] = arr;
  1031. } break;
  1032. case RS::ARRAY_BONES: {
  1033. uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;
  1034. Vector<int> arr;
  1035. arr.resize(p_vertex_len * bone_count);
  1036. int *w = arr.ptrw();
  1037. for (int j = 0; j < p_vertex_len; j++) {
  1038. const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];
  1039. for (uint32_t k = 0; k < bone_count; k++) {
  1040. w[j * bone_count + k] = v[k];
  1041. }
  1042. }
  1043. ret[i] = arr;
  1044. } break;
  1045. case RS::ARRAY_INDEX: {
  1046. /* determine whether using 16 or 32 bits indices */
  1047. const uint8_t *ir = p_index_data.ptr();
  1048. Vector<int> arr;
  1049. arr.resize(p_index_len);
  1050. if (p_vertex_len <= (1 << 16)) {
  1051. int *w = arr.ptrw();
  1052. for (int j = 0; j < p_index_len; j++) {
  1053. const uint16_t *v = (const uint16_t *)&ir[j * 2];
  1054. w[j] = *v;
  1055. }
  1056. } else {
  1057. int *w = arr.ptrw();
  1058. for (int j = 0; j < p_index_len; j++) {
  1059. const int *v = (const int *)&ir[j * 4];
  1060. w[j] = *v;
  1061. }
  1062. }
  1063. ret[i] = arr;
  1064. } break;
  1065. default: {
  1066. ERR_FAIL_V(ret);
  1067. }
  1068. }
  1069. }
  1070. return ret;
  1071. }
  1072. Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
  1073. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1074. return mesh_create_arrays_from_surface_data(sd);
  1075. }
  1076. Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {
  1077. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1078. ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());
  1079. Dictionary ret;
  1080. for (int i = 0; i < sd.lods.size(); i++) {
  1081. Vector<int> lods;
  1082. if (sd.vertex_count <= 65536) {
  1083. uint32_t lc = sd.lods[i].index_data.size() / 2;
  1084. lods.resize(lc);
  1085. const uint8_t *r = sd.lods[i].index_data.ptr();
  1086. const uint16_t *rptr = (const uint16_t *)r;
  1087. int *w = lods.ptrw();
  1088. for (uint32_t j = 0; j < lc; j++) {
  1089. w[j] = rptr[i];
  1090. }
  1091. } else {
  1092. uint32_t lc = sd.lods[i].index_data.size() / 4;
  1093. lods.resize(lc);
  1094. const uint8_t *r = sd.lods[i].index_data.ptr();
  1095. const uint32_t *rptr = (const uint32_t *)r;
  1096. int *w = lods.ptrw();
  1097. for (uint32_t j = 0; j < lc; j++) {
  1098. w[j] = rptr[i];
  1099. }
  1100. }
  1101. ret[sd.lods[i].edge_length] = lods;
  1102. }
  1103. return ret;
  1104. }
  1105. TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
  1106. SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
  1107. ERR_FAIL_COND_V(sd.vertex_count == 0, Array());
  1108. Vector<uint8_t> blend_shape_data = sd.blend_shape_data;
  1109. if (blend_shape_data.size() > 0) {
  1110. uint32_t bs_offsets[RS::ARRAY_MAX];
  1111. uint32_t bs_format = (sd.format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK);
  1112. uint32_t vertex_elem_size;
  1113. uint32_t attrib_elem_size;
  1114. uint32_t skin_elem_size;
  1115. mesh_surface_make_offsets_from_format(bs_format, sd.vertex_count, 0, bs_offsets, vertex_elem_size, attrib_elem_size, skin_elem_size);
  1116. int divisor = vertex_elem_size * sd.vertex_count;
  1117. ERR_FAIL_COND_V((blend_shape_data.size() % divisor) != 0, Array());
  1118. uint32_t blend_shape_count = blend_shape_data.size() / divisor;
  1119. ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array());
  1120. TypedArray<Array> blend_shape_array;
  1121. blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh));
  1122. for (uint32_t i = 0; i < blend_shape_count; i++) {
  1123. Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor);
  1124. Vector<uint8_t> unused;
  1125. blend_shape_array.set(i, _get_array_from_surface(bs_format, bs_data, unused, unused, sd.vertex_count, unused, 0));
  1126. }
  1127. return blend_shape_array;
  1128. } else {
  1129. return TypedArray<Array>();
  1130. }
  1131. }
  1132. Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {
  1133. Vector<uint8_t> vertex_data = p_data.vertex_data;
  1134. Vector<uint8_t> attrib_data = p_data.attribute_data;
  1135. Vector<uint8_t> skin_data = p_data.skin_data;
  1136. ERR_FAIL_COND_V(vertex_data.size() == 0 && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array());
  1137. int vertex_len = p_data.vertex_count;
  1138. Vector<uint8_t> index_data = p_data.index_data;
  1139. int index_len = p_data.index_count;
  1140. uint32_t format = p_data.format;
  1141. return _get_array_from_surface(format, vertex_data, attrib_data, skin_data, vertex_len, index_data, index_len);
  1142. }
  1143. #if 0
  1144. Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
  1145. Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
  1146. Array arr;
  1147. for (int i = 0; i < vec.size(); i++) {
  1148. arr[i] = vec[i];
  1149. }
  1150. return arr;
  1151. }
  1152. #endif
  1153. int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) {
  1154. switch (p_type) {
  1155. case RS::GLOBAL_VAR_TYPE_BOOL:
  1156. return ShaderLanguage::TYPE_BOOL;
  1157. case RS::GLOBAL_VAR_TYPE_BVEC2:
  1158. return ShaderLanguage::TYPE_BVEC2;
  1159. case RS::GLOBAL_VAR_TYPE_BVEC3:
  1160. return ShaderLanguage::TYPE_BVEC3;
  1161. case RS::GLOBAL_VAR_TYPE_BVEC4:
  1162. return ShaderLanguage::TYPE_BVEC4;
  1163. case RS::GLOBAL_VAR_TYPE_INT:
  1164. return ShaderLanguage::TYPE_INT;
  1165. case RS::GLOBAL_VAR_TYPE_IVEC2:
  1166. return ShaderLanguage::TYPE_IVEC2;
  1167. case RS::GLOBAL_VAR_TYPE_IVEC3:
  1168. return ShaderLanguage::TYPE_IVEC3;
  1169. case RS::GLOBAL_VAR_TYPE_IVEC4:
  1170. return ShaderLanguage::TYPE_IVEC4;
  1171. case RS::GLOBAL_VAR_TYPE_RECT2I:
  1172. return ShaderLanguage::TYPE_IVEC4;
  1173. case RS::GLOBAL_VAR_TYPE_UINT:
  1174. return ShaderLanguage::TYPE_UINT;
  1175. case RS::GLOBAL_VAR_TYPE_UVEC2:
  1176. return ShaderLanguage::TYPE_UVEC2;
  1177. case RS::GLOBAL_VAR_TYPE_UVEC3:
  1178. return ShaderLanguage::TYPE_UVEC3;
  1179. case RS::GLOBAL_VAR_TYPE_UVEC4:
  1180. return ShaderLanguage::TYPE_UVEC4;
  1181. case RS::GLOBAL_VAR_TYPE_FLOAT:
  1182. return ShaderLanguage::TYPE_FLOAT;
  1183. case RS::GLOBAL_VAR_TYPE_VEC2:
  1184. return ShaderLanguage::TYPE_VEC2;
  1185. case RS::GLOBAL_VAR_TYPE_VEC3:
  1186. return ShaderLanguage::TYPE_VEC3;
  1187. case RS::GLOBAL_VAR_TYPE_VEC4:
  1188. return ShaderLanguage::TYPE_VEC4;
  1189. case RS::GLOBAL_VAR_TYPE_COLOR:
  1190. return ShaderLanguage::TYPE_VEC4;
  1191. case RS::GLOBAL_VAR_TYPE_RECT2:
  1192. return ShaderLanguage::TYPE_VEC4;
  1193. case RS::GLOBAL_VAR_TYPE_MAT2:
  1194. return ShaderLanguage::TYPE_MAT2;
  1195. case RS::GLOBAL_VAR_TYPE_MAT3:
  1196. return ShaderLanguage::TYPE_MAT3;
  1197. case RS::GLOBAL_VAR_TYPE_MAT4:
  1198. return ShaderLanguage::TYPE_MAT4;
  1199. case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D:
  1200. return ShaderLanguage::TYPE_MAT3;
  1201. case RS::GLOBAL_VAR_TYPE_TRANSFORM:
  1202. return ShaderLanguage::TYPE_MAT4;
  1203. case RS::GLOBAL_VAR_TYPE_SAMPLER2D:
  1204. return ShaderLanguage::TYPE_SAMPLER2D;
  1205. case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY:
  1206. return ShaderLanguage::TYPE_SAMPLER2DARRAY;
  1207. case RS::GLOBAL_VAR_TYPE_SAMPLER3D:
  1208. return ShaderLanguage::TYPE_SAMPLER3D;
  1209. case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE:
  1210. return ShaderLanguage::TYPE_SAMPLERCUBE;
  1211. default:
  1212. return ShaderLanguage::TYPE_MAX; // Invalid or not found.
  1213. }
  1214. }
  1215. RenderingDevice *RenderingServer::get_rendering_device() const {
  1216. // Return the rendering device we're using globally.
  1217. return RenderingDevice::get_singleton();
  1218. }
  1219. RenderingDevice *RenderingServer::create_local_rendering_device() const {
  1220. RenderingDevice *device = RenderingDevice::get_singleton();
  1221. if (!device) {
  1222. return nullptr;
  1223. }
  1224. return device->create_local_device();
  1225. }
  1226. static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {
  1227. Vector<Ref<Image>> images;
  1228. images.resize(p_layers.size());
  1229. for (int i = 0; i < p_layers.size(); i++) {
  1230. images.write[i] = p_layers[i];
  1231. }
  1232. return images;
  1233. }
  1234. RID RenderingServer::_texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type) {
  1235. return texture_2d_layered_create(_get_imgvec(p_layers), p_layered_type);
  1236. }
  1237. 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) {
  1238. return texture_3d_create(p_format, p_width, p_height, p_depth, p_mipmaps, _get_imgvec(p_data));
  1239. }
  1240. void RenderingServer::_texture_3d_update(RID p_texture, const TypedArray<Image> &p_data) {
  1241. texture_3d_update(p_texture, _get_imgvec(p_data));
  1242. }
  1243. TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const {
  1244. Vector<Ref<Image>> images = texture_3d_get(p_texture);
  1245. TypedArray<Image> ret;
  1246. ret.resize(images.size());
  1247. for (int i = 0; i < images.size(); i++) {
  1248. ret[i] = images[i];
  1249. }
  1250. return ret;
  1251. }
  1252. TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const {
  1253. List<PropertyInfo> l;
  1254. get_shader_parameter_list(p_shader, &l);
  1255. return convert_property_list(&l);
  1256. }
  1257. static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) {
  1258. ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RS::SurfaceData());
  1259. ERR_FAIL_COND_V(!p_dictionary.has("format"), RS::SurfaceData());
  1260. ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RS::SurfaceData());
  1261. ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RS::SurfaceData());
  1262. ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RS::SurfaceData());
  1263. RS::SurfaceData sd;
  1264. sd.primitive = RS::PrimitiveType(int(p_dictionary["primitive"]));
  1265. sd.format = p_dictionary["format"];
  1266. sd.vertex_data = p_dictionary["vertex_data"];
  1267. if (p_dictionary.has("attribute_data")) {
  1268. sd.attribute_data = p_dictionary["attribute_data"];
  1269. }
  1270. if (p_dictionary.has("skin_data")) {
  1271. sd.skin_data = p_dictionary["skin_data"];
  1272. }
  1273. sd.vertex_count = p_dictionary["vertex_count"];
  1274. if (p_dictionary.has("index_data")) {
  1275. sd.index_data = p_dictionary["index_data"];
  1276. ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RS::SurfaceData());
  1277. sd.index_count = p_dictionary["index_count"];
  1278. }
  1279. sd.aabb = p_dictionary["aabb"];
  1280. if (p_dictionary.has("lods")) {
  1281. Array lods = p_dictionary["lods"];
  1282. for (int i = 0; i < lods.size(); i++) {
  1283. Dictionary lod = lods[i];
  1284. ERR_CONTINUE(!lod.has("edge_length"));
  1285. ERR_CONTINUE(!lod.has("index_data"));
  1286. RS::SurfaceData::LOD l;
  1287. l.edge_length = lod["edge_length"];
  1288. l.index_data = lod["index_data"];
  1289. sd.lods.push_back(l);
  1290. }
  1291. }
  1292. if (p_dictionary.has("bone_aabbs")) {
  1293. Array aabbs = p_dictionary["bone_aabbs"];
  1294. for (int i = 0; i < aabbs.size(); i++) {
  1295. AABB aabb = aabbs[i];
  1296. sd.bone_aabbs.push_back(aabb);
  1297. }
  1298. }
  1299. if (p_dictionary.has("blend_shape_data")) {
  1300. sd.blend_shape_data = p_dictionary["blend_shape_data"];
  1301. }
  1302. if (p_dictionary.has("material")) {
  1303. sd.material = p_dictionary["material"];
  1304. }
  1305. return sd;
  1306. }
  1307. RID RenderingServer::_mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count) {
  1308. Vector<RS::SurfaceData> surfaces;
  1309. for (int i = 0; i < p_surfaces.size(); i++) {
  1310. surfaces.push_back(_dict_to_surf(p_surfaces[i]));
  1311. }
  1312. return mesh_create_from_surfaces(surfaces);
  1313. }
  1314. void RenderingServer::_mesh_add_surface(RID p_mesh, const Dictionary &p_surface) {
  1315. mesh_add_surface(p_mesh, _dict_to_surf(p_surface));
  1316. }
  1317. Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) {
  1318. RS::SurfaceData sd = mesh_get_surface(p_mesh, p_idx);
  1319. Dictionary d;
  1320. d["primitive"] = sd.primitive;
  1321. d["format"] = sd.format;
  1322. d["vertex_data"] = sd.vertex_data;
  1323. if (sd.attribute_data.size()) {
  1324. d["attribute_data"] = sd.attribute_data;
  1325. }
  1326. if (sd.skin_data.size()) {
  1327. d["skin_data"] = sd.skin_data;
  1328. }
  1329. d["vertex_count"] = sd.vertex_count;
  1330. if (sd.index_count) {
  1331. d["index_data"] = sd.index_data;
  1332. d["index_count"] = sd.index_count;
  1333. }
  1334. d["aabb"] = sd.aabb;
  1335. if (sd.lods.size()) {
  1336. Array lods;
  1337. for (int i = 0; i < sd.lods.size(); i++) {
  1338. Dictionary ld;
  1339. ld["edge_length"] = sd.lods[i].edge_length;
  1340. ld["index_data"] = sd.lods[i].index_data;
  1341. lods.push_back(lods);
  1342. }
  1343. d["lods"] = lods;
  1344. }
  1345. if (sd.bone_aabbs.size()) {
  1346. Array aabbs;
  1347. for (int i = 0; i < sd.bone_aabbs.size(); i++) {
  1348. aabbs.push_back(sd.bone_aabbs[i]);
  1349. }
  1350. d["bone_aabbs"] = aabbs;
  1351. }
  1352. if (sd.blend_shape_data.size()) {
  1353. d["blend_shape_data"] = sd.blend_shape_data;
  1354. }
  1355. if (sd.material.is_valid()) {
  1356. d["material"] = sd.material;
  1357. }
  1358. return d;
  1359. }
  1360. TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const {
  1361. List<PropertyInfo> params;
  1362. instance_geometry_get_shader_parameter_list(p_instance, &params);
  1363. return convert_property_list(&params);
  1364. }
  1365. TypedArray<Image> RenderingServer::_bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) {
  1366. TypedArray<RID> mat_overrides;
  1367. for (int i = 0; i < p_material_overrides.size(); i++) {
  1368. mat_overrides.push_back(p_material_overrides[i]);
  1369. }
  1370. return bake_render_uv2(p_base, mat_overrides, p_image_size);
  1371. }
  1372. void RenderingServer::_particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses) {
  1373. Vector<Transform3D> tbposes;
  1374. tbposes.resize(p_bind_poses.size());
  1375. for (int i = 0; i < p_bind_poses.size(); i++) {
  1376. tbposes.write[i] = p_bind_poses[i];
  1377. }
  1378. particles_set_trail_bind_poses(p_particles, tbposes);
  1379. }
  1380. void RenderingServer::_bind_methods() {
  1381. BIND_CONSTANT(NO_INDEX_ARRAY);
  1382. BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
  1383. BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
  1384. BIND_CONSTANT(CANVAS_ITEM_Z_MAX);
  1385. BIND_CONSTANT(MAX_GLOW_LEVELS);
  1386. BIND_CONSTANT(MAX_CURSORS);
  1387. BIND_CONSTANT(MAX_2D_DIRECTIONAL_LIGHTS);
  1388. /* TEXTURE */
  1389. ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create);
  1390. ClassDB::bind_method(D_METHOD("texture_2d_layered_create", "layers", "layered_type"), &RenderingServer::_texture_2d_layered_create);
  1391. ClassDB::bind_method(D_METHOD("texture_3d_create", "format", "width", "height", "depth", "mipmaps", "data"), &RenderingServer::_texture_3d_create);
  1392. ClassDB::bind_method(D_METHOD("texture_proxy_create", "base"), &RenderingServer::texture_proxy_create);
  1393. ClassDB::bind_method(D_METHOD("texture_2d_update", "texture", "image", "layer"), &RenderingServer::texture_2d_update);
  1394. ClassDB::bind_method(D_METHOD("texture_3d_update", "texture", "data"), &RenderingServer::_texture_3d_update);
  1395. ClassDB::bind_method(D_METHOD("texture_proxy_update", "texture", "proxy_to"), &RenderingServer::texture_proxy_update);
  1396. ClassDB::bind_method(D_METHOD("texture_2d_placeholder_create"), &RenderingServer::texture_2d_placeholder_create);
  1397. ClassDB::bind_method(D_METHOD("texture_2d_layered_placeholder_create", "layered_type"), &RenderingServer::texture_2d_layered_placeholder_create);
  1398. ClassDB::bind_method(D_METHOD("texture_3d_placeholder_create"), &RenderingServer::texture_3d_placeholder_create);
  1399. ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get);
  1400. ClassDB::bind_method(D_METHOD("texture_2d_layer_get", "texture", "layer"), &RenderingServer::texture_2d_layer_get);
  1401. ClassDB::bind_method(D_METHOD("texture_3d_get", "texture"), &RenderingServer::_texture_3d_get);
  1402. ClassDB::bind_method(D_METHOD("texture_replace", "texture", "by_texture"), &RenderingServer::texture_replace);
  1403. ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height"), &RenderingServer::texture_set_size_override);
  1404. ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &RenderingServer::texture_set_path);
  1405. ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &RenderingServer::texture_get_path);
  1406. ClassDB::bind_method(D_METHOD("texture_set_force_redraw_if_visible", "texture", "enable"), &RenderingServer::texture_set_force_redraw_if_visible);
  1407. ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture_rid, DEFVAL(false));
  1408. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY);
  1409. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP);
  1410. BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP_ARRAY);
  1411. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_LEFT);
  1412. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_RIGHT);
  1413. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BOTTOM);
  1414. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_TOP);
  1415. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_FRONT);
  1416. BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BACK);
  1417. /* SHADER */
  1418. ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create);
  1419. ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);
  1420. ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint);
  1421. ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);
  1422. ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list);
  1423. ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default);
  1424. ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0));
  1425. ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0));
  1426. BIND_ENUM_CONSTANT(SHADER_SPATIAL);
  1427. BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
  1428. BIND_ENUM_CONSTANT(SHADER_PARTICLES);
  1429. BIND_ENUM_CONSTANT(SHADER_SKY);
  1430. BIND_ENUM_CONSTANT(SHADER_FOG);
  1431. BIND_ENUM_CONSTANT(SHADER_MAX);
  1432. /* MATERIAL */
  1433. ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create);
  1434. ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader);
  1435. ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param);
  1436. ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param);
  1437. ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority);
  1438. ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass);
  1439. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);
  1440. BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);
  1441. /* MESH API */
  1442. ClassDB::bind_method(D_METHOD("mesh_create_from_surfaces", "surfaces", "blend_shape_count"), &RenderingServer::_mesh_create_from_surfaces, DEFVAL(0));
  1443. ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create);
  1444. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_count", "array_index"), &RenderingServer::mesh_surface_get_format_offset);
  1445. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_vertex_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_vertex_stride);
  1446. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_attribute_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_attribute_stride);
  1447. ClassDB::bind_method(D_METHOD("mesh_surface_get_format_skin_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_skin_stride);
  1448. ClassDB::bind_method(D_METHOD("mesh_add_surface", "mesh", "surface"), &RenderingServer::_mesh_add_surface);
  1449. 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));
  1450. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count);
  1451. ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode);
  1452. ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode);
  1453. ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material);
  1454. ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material);
  1455. ClassDB::bind_method(D_METHOD("mesh_get_surface", "mesh", "surface"), &RenderingServer::_mesh_get_surface);
  1456. ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays);
  1457. ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays);
  1458. ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count);
  1459. ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb);
  1460. ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb);
  1461. ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear);
  1462. ClassDB::bind_method(D_METHOD("mesh_surface_update_vertex_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_vertex_region);
  1463. ClassDB::bind_method(D_METHOD("mesh_surface_update_attribute_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_attribute_region);
  1464. ClassDB::bind_method(D_METHOD("mesh_surface_update_skin_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_skin_region);
  1465. ClassDB::bind_method(D_METHOD("mesh_set_shadow_mesh", "mesh", "shadow_mesh"), &RenderingServer::mesh_set_shadow_mesh);
  1466. BIND_ENUM_CONSTANT(ARRAY_VERTEX);
  1467. BIND_ENUM_CONSTANT(ARRAY_NORMAL);
  1468. BIND_ENUM_CONSTANT(ARRAY_TANGENT);
  1469. BIND_ENUM_CONSTANT(ARRAY_COLOR);
  1470. BIND_ENUM_CONSTANT(ARRAY_TEX_UV);
  1471. BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);
  1472. BIND_ENUM_CONSTANT(ARRAY_CUSTOM0);
  1473. BIND_ENUM_CONSTANT(ARRAY_CUSTOM1);
  1474. BIND_ENUM_CONSTANT(ARRAY_CUSTOM2);
  1475. BIND_ENUM_CONSTANT(ARRAY_CUSTOM3);
  1476. BIND_ENUM_CONSTANT(ARRAY_BONES);
  1477. BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);
  1478. BIND_ENUM_CONSTANT(ARRAY_INDEX);
  1479. BIND_ENUM_CONSTANT(ARRAY_MAX);
  1480. BIND_CONSTANT(ARRAY_CUSTOM_COUNT);
  1481. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_UNORM);
  1482. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_SNORM);
  1483. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_HALF);
  1484. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_HALF);
  1485. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_R_FLOAT);
  1486. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_FLOAT);
  1487. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGB_FLOAT);
  1488. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_FLOAT);
  1489. BIND_ENUM_CONSTANT(ARRAY_CUSTOM_MAX);
  1490. BIND_BITFIELD_FLAG(ARRAY_FORMAT_VERTEX);
  1491. BIND_BITFIELD_FLAG(ARRAY_FORMAT_NORMAL);
  1492. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TANGENT);
  1493. BIND_BITFIELD_FLAG(ARRAY_FORMAT_COLOR);
  1494. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV);
  1495. BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV2);
  1496. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0);
  1497. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1);
  1498. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2);
  1499. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3);
  1500. BIND_BITFIELD_FLAG(ARRAY_FORMAT_BONES);
  1501. BIND_BITFIELD_FLAG(ARRAY_FORMAT_WEIGHTS);
  1502. BIND_BITFIELD_FLAG(ARRAY_FORMAT_INDEX);
  1503. BIND_BITFIELD_FLAG(ARRAY_FORMAT_BLEND_SHAPE_MASK);
  1504. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BASE);
  1505. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BITS);
  1506. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0_SHIFT);
  1507. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1_SHIFT);
  1508. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2_SHIFT);
  1509. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3_SHIFT);
  1510. BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_MASK);
  1511. BIND_BITFIELD_FLAG(ARRAY_COMPRESS_FLAGS_BASE);
  1512. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_2D_VERTICES);
  1513. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_DYNAMIC_UPDATE);
  1514. BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_8_BONE_WEIGHTS);
  1515. BIND_BITFIELD_FLAG(ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY);
  1516. BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
  1517. BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
  1518. BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
  1519. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
  1520. BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
  1521. BIND_ENUM_CONSTANT(PRIMITIVE_MAX);
  1522. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
  1523. BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
  1524. /* MULTIMESH API */
  1525. ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create);
  1526. 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));
  1527. ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count);
  1528. ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh);
  1529. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform);
  1530. ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d);
  1531. ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color);
  1532. ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data);
  1533. ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh);
  1534. ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb);
  1535. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform);
  1536. ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d);
  1537. ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color);
  1538. ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data);
  1539. ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);
  1540. ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);
  1541. ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);
  1542. ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);
  1543. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);
  1544. BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);
  1545. /* SKELETON API */
  1546. ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create);
  1547. ClassDB::bind_method(D_METHOD("skeleton_allocate_data", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate_data, DEFVAL(false));
  1548. ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count);
  1549. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform);
  1550. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform);
  1551. ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d);
  1552. ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d);
  1553. ClassDB::bind_method(D_METHOD("skeleton_set_base_transform_2d", "skeleton", "base_transform"), &RenderingServer::skeleton_set_base_transform_2d);
  1554. /* Light API */
  1555. ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);
  1556. ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);
  1557. ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);
  1558. ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);
  1559. ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);
  1560. ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow);
  1561. ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector);
  1562. ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);
  1563. ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);
  1564. ClassDB::bind_method(D_METHOD("light_set_distance_fade", "decal", "enabled", "begin", "shadow", "length"), &RenderingServer::light_set_distance_fade);
  1565. ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);
  1566. ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &RenderingServer::light_set_bake_mode);
  1567. ClassDB::bind_method(D_METHOD("light_set_max_sdfgi_cascade", "light", "cascade"), &RenderingServer::light_set_max_sdfgi_cascade);
  1568. ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);
  1569. ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode);
  1570. ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);
  1571. ClassDB::bind_method(D_METHOD("light_directional_set_sky_mode", "light", "mode"), &RenderingServer::light_directional_set_sky_mode);
  1572. ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter);
  1573. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST);
  1574. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR);
  1575. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS);
  1576. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);
  1577. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);
  1578. BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);
  1579. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);
  1580. BIND_ENUM_CONSTANT(LIGHT_OMNI);
  1581. BIND_ENUM_CONSTANT(LIGHT_SPOT);
  1582. BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);
  1583. BIND_ENUM_CONSTANT(LIGHT_PARAM_INDIRECT_ENERGY);
  1584. BIND_ENUM_CONSTANT(LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY);
  1585. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);
  1586. BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);
  1587. BIND_ENUM_CONSTANT(LIGHT_PARAM_SIZE);
  1588. BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);
  1589. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);
  1590. BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);
  1591. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);
  1592. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);
  1593. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);
  1594. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);
  1595. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_FADE_START);
  1596. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);
  1597. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);
  1598. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_PANCAKE_SIZE);
  1599. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_OPACITY);
  1600. BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BLUR);
  1601. BIND_ENUM_CONSTANT(LIGHT_PARAM_TRANSMITTANCE_BIAS);
  1602. BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
  1603. BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);
  1604. BIND_ENUM_CONSTANT(LIGHT_BAKE_STATIC);
  1605. BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);
  1606. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
  1607. BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
  1608. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
  1609. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);
  1610. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);
  1611. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);
  1612. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_ONLY);
  1613. BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_SKY_ONLY);
  1614. ClassDB::bind_method(D_METHOD("positional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::positional_soft_shadow_filter_set_quality);
  1615. ClassDB::bind_method(D_METHOD("directional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::directional_soft_shadow_filter_set_quality);
  1616. ClassDB::bind_method(D_METHOD("directional_shadow_atlas_set_size", "size", "is_16bits"), &RenderingServer::directional_shadow_atlas_set_size);
  1617. BIND_ENUM_CONSTANT(SHADOW_QUALITY_HARD);
  1618. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_VERY_LOW);
  1619. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_LOW);
  1620. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_MEDIUM);
  1621. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_HIGH);
  1622. BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_ULTRA);
  1623. BIND_ENUM_CONSTANT(SHADOW_QUALITY_MAX);
  1624. /* REFLECTION PROBE */
  1625. ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);
  1626. ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);
  1627. ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);
  1628. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_ambient_mode);
  1629. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_color", "probe", "color"), &RenderingServer::reflection_probe_set_ambient_color);
  1630. ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_ambient_energy);
  1631. ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);
  1632. ClassDB::bind_method(D_METHOD("reflection_probe_set_size", "probe", "size"), &RenderingServer::reflection_probe_set_size);
  1633. ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);
  1634. ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);
  1635. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);
  1636. ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);
  1637. ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);
  1638. ClassDB::bind_method(D_METHOD("reflection_probe_set_resolution", "probe", "resolution"), &RenderingServer::reflection_probe_set_resolution);
  1639. ClassDB::bind_method(D_METHOD("reflection_probe_set_mesh_lod_threshold", "probe", "pixels"), &RenderingServer::reflection_probe_set_mesh_lod_threshold);
  1640. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);
  1641. BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);
  1642. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_DISABLED);
  1643. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_ENVIRONMENT);
  1644. BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_COLOR);
  1645. /* DECAL */
  1646. ClassDB::bind_method(D_METHOD("decal_create"), &RenderingServer::decal_create);
  1647. ClassDB::bind_method(D_METHOD("decal_set_size", "decal", "size"), &RenderingServer::decal_set_size);
  1648. ClassDB::bind_method(D_METHOD("decal_set_texture", "decal", "type", "texture"), &RenderingServer::decal_set_texture);
  1649. ClassDB::bind_method(D_METHOD("decal_set_emission_energy", "decal", "energy"), &RenderingServer::decal_set_emission_energy);
  1650. ClassDB::bind_method(D_METHOD("decal_set_albedo_mix", "decal", "albedo_mix"), &RenderingServer::decal_set_albedo_mix);
  1651. ClassDB::bind_method(D_METHOD("decal_set_modulate", "decal", "color"), &RenderingServer::decal_set_modulate);
  1652. ClassDB::bind_method(D_METHOD("decal_set_cull_mask", "decal", "mask"), &RenderingServer::decal_set_cull_mask);
  1653. ClassDB::bind_method(D_METHOD("decal_set_distance_fade", "decal", "enabled", "begin", "length"), &RenderingServer::decal_set_distance_fade);
  1654. ClassDB::bind_method(D_METHOD("decal_set_fade", "decal", "above", "below"), &RenderingServer::decal_set_fade);
  1655. ClassDB::bind_method(D_METHOD("decal_set_normal_fade", "decal", "fade"), &RenderingServer::decal_set_normal_fade);
  1656. ClassDB::bind_method(D_METHOD("decals_set_filter", "filter"), &RenderingServer::decals_set_filter);
  1657. BIND_ENUM_CONSTANT(DECAL_TEXTURE_ALBEDO);
  1658. BIND_ENUM_CONSTANT(DECAL_TEXTURE_NORMAL);
  1659. BIND_ENUM_CONSTANT(DECAL_TEXTURE_ORM);
  1660. BIND_ENUM_CONSTANT(DECAL_TEXTURE_EMISSION);
  1661. BIND_ENUM_CONSTANT(DECAL_TEXTURE_MAX);
  1662. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST);
  1663. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR);
  1664. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS);
  1665. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS);
  1666. BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);
  1667. BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);
  1668. /* GI API (affects VoxelGI and SDFGI) */
  1669. ClassDB::bind_method(D_METHOD("gi_set_use_half_resolution", "half_resolution"), &RenderingServer::gi_set_use_half_resolution);
  1670. /* VOXEL GI API */
  1671. ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create);
  1672. 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);
  1673. ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_size", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_size);
  1674. ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_cells);
  1675. ClassDB::bind_method(D_METHOD("voxel_gi_get_data_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_data_cells);
  1676. ClassDB::bind_method(D_METHOD("voxel_gi_get_distance_field", "voxel_gi"), &RenderingServer::voxel_gi_get_distance_field);
  1677. ClassDB::bind_method(D_METHOD("voxel_gi_get_level_counts", "voxel_gi"), &RenderingServer::voxel_gi_get_level_counts);
  1678. ClassDB::bind_method(D_METHOD("voxel_gi_get_to_cell_xform", "voxel_gi"), &RenderingServer::voxel_gi_get_to_cell_xform);
  1679. ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_range", "voxel_gi", "range"), &RenderingServer::voxel_gi_set_dynamic_range);
  1680. ClassDB::bind_method(D_METHOD("voxel_gi_set_propagation", "voxel_gi", "amount"), &RenderingServer::voxel_gi_set_propagation);
  1681. ClassDB::bind_method(D_METHOD("voxel_gi_set_energy", "voxel_gi", "energy"), &RenderingServer::voxel_gi_set_energy);
  1682. ClassDB::bind_method(D_METHOD("voxel_gi_set_baked_exposure_normalization", "voxel_gi", "baked_exposure"), &RenderingServer::voxel_gi_set_baked_exposure_normalization);
  1683. ClassDB::bind_method(D_METHOD("voxel_gi_set_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_bias);
  1684. ClassDB::bind_method(D_METHOD("voxel_gi_set_normal_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_normal_bias);
  1685. ClassDB::bind_method(D_METHOD("voxel_gi_set_interior", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_interior);
  1686. ClassDB::bind_method(D_METHOD("voxel_gi_set_use_two_bounces", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_use_two_bounces);
  1687. ClassDB::bind_method(D_METHOD("voxel_gi_set_quality", "quality"), &RenderingServer::voxel_gi_set_quality);
  1688. BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_LOW);
  1689. BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_HIGH);
  1690. /* LIGHTMAP */
  1691. ClassDB::bind_method(D_METHOD("lightmap_create"), &RenderingServer::lightmap_create);
  1692. ClassDB::bind_method(D_METHOD("lightmap_set_textures", "lightmap", "light", "uses_sh"), &RenderingServer::lightmap_set_textures);
  1693. ClassDB::bind_method(D_METHOD("lightmap_set_probe_bounds", "lightmap", "bounds"), &RenderingServer::lightmap_set_probe_bounds);
  1694. ClassDB::bind_method(D_METHOD("lightmap_set_probe_interior", "lightmap", "interior"), &RenderingServer::lightmap_set_probe_interior);
  1695. ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_data", "lightmap", "points", "point_sh", "tetrahedra", "bsp_tree"), &RenderingServer::lightmap_set_probe_capture_data);
  1696. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_points", "lightmap"), &RenderingServer::lightmap_get_probe_capture_points);
  1697. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_sh", "lightmap"), &RenderingServer::lightmap_get_probe_capture_sh);
  1698. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_tetrahedra", "lightmap"), &RenderingServer::lightmap_get_probe_capture_tetrahedra);
  1699. ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_bsp_tree", "lightmap"), &RenderingServer::lightmap_get_probe_capture_bsp_tree);
  1700. ClassDB::bind_method(D_METHOD("lightmap_set_baked_exposure_normalization", "lightmap", "baked_exposure"), &RenderingServer::lightmap_set_baked_exposure_normalization);
  1701. ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_update_speed", "speed"), &RenderingServer::lightmap_set_probe_capture_update_speed);
  1702. /* PARTICLES API */
  1703. ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create);
  1704. ClassDB::bind_method(D_METHOD("particles_set_mode", "particles", "mode"), &RenderingServer::particles_set_mode);
  1705. ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting);
  1706. ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting);
  1707. ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount);
  1708. ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime);
  1709. ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot);
  1710. ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time);
  1711. ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio);
  1712. ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio);
  1713. ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb);
  1714. ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale);
  1715. ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates);
  1716. ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material);
  1717. ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps);
  1718. ClassDB::bind_method(D_METHOD("particles_set_interpolate", "particles", "enable"), &RenderingServer::particles_set_interpolate);
  1719. ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta);
  1720. ClassDB::bind_method(D_METHOD("particles_set_collision_base_size", "particles", "size"), &RenderingServer::particles_set_collision_base_size);
  1721. ClassDB::bind_method(D_METHOD("particles_set_transform_align", "particles", "align"), &RenderingServer::particles_set_transform_align);
  1722. ClassDB::bind_method(D_METHOD("particles_set_trails", "particles", "enable", "length_sec"), &RenderingServer::particles_set_trails);
  1723. ClassDB::bind_method(D_METHOD("particles_set_trail_bind_poses", "particles", "bind_poses"), &RenderingServer::_particles_set_trail_bind_poses);
  1724. ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive);
  1725. ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process);
  1726. ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart);
  1727. ClassDB::bind_method(D_METHOD("particles_set_subemitter", "particles", "subemitter_particles"), &RenderingServer::particles_set_subemitter);
  1728. ClassDB::bind_method(D_METHOD("particles_emit", "particles", "transform", "velocity", "color", "custom", "emit_flags"), &RenderingServer::particles_emit);
  1729. ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order);
  1730. ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes);
  1731. ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh);
  1732. ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb);
  1733. ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform);
  1734. BIND_ENUM_CONSTANT(PARTICLES_MODE_2D);
  1735. BIND_ENUM_CONSTANT(PARTICLES_MODE_3D);
  1736. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_DISABLED);
  1737. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD);
  1738. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY);
  1739. BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY);
  1740. BIND_CONSTANT(PARTICLES_EMIT_FLAG_POSITION);
  1741. BIND_CONSTANT(PARTICLES_EMIT_FLAG_ROTATION_SCALE);
  1742. BIND_CONSTANT(PARTICLES_EMIT_FLAG_VELOCITY);
  1743. BIND_CONSTANT(PARTICLES_EMIT_FLAG_COLOR);
  1744. BIND_CONSTANT(PARTICLES_EMIT_FLAG_CUSTOM);
  1745. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);
  1746. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);
  1747. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);
  1748. BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);
  1749. /* PARTICLES COLLISION */
  1750. ClassDB::bind_method(D_METHOD("particles_collision_create"), &RenderingServer::particles_collision_create);
  1751. ClassDB::bind_method(D_METHOD("particles_collision_set_collision_type", "particles_collision", "type"), &RenderingServer::particles_collision_set_collision_type);
  1752. ClassDB::bind_method(D_METHOD("particles_collision_set_cull_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_cull_mask);
  1753. ClassDB::bind_method(D_METHOD("particles_collision_set_sphere_radius", "particles_collision", "radius"), &RenderingServer::particles_collision_set_sphere_radius);
  1754. ClassDB::bind_method(D_METHOD("particles_collision_set_box_extents", "particles_collision", "extents"), &RenderingServer::particles_collision_set_box_extents);
  1755. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_strength", "particles_collision", "setrngth"), &RenderingServer::particles_collision_set_attractor_strength);
  1756. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_directionality", "particles_collision", "amount"), &RenderingServer::particles_collision_set_attractor_directionality);
  1757. ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_attenuation", "particles_collision", "curve"), &RenderingServer::particles_collision_set_attractor_attenuation);
  1758. ClassDB::bind_method(D_METHOD("particles_collision_set_field_texture", "particles_collision", "texture"), &RenderingServer::particles_collision_set_field_texture);
  1759. ClassDB::bind_method(D_METHOD("particles_collision_height_field_update", "particles_collision"), &RenderingServer::particles_collision_height_field_update);
  1760. ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_resolution", "particles_collision", "resolution"), &RenderingServer::particles_collision_set_height_field_resolution);
  1761. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT);
  1762. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_ATTRACT);
  1763. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT);
  1764. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE);
  1765. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_COLLIDE);
  1766. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SDF_COLLIDE);
  1767. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE);
  1768. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256);
  1769. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512);
  1770. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024);
  1771. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_2048);
  1772. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_4096);
  1773. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192);
  1774. BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
  1775. /* FOG VOLUMES */
  1776. ClassDB::bind_method(D_METHOD("fog_volume_create"), &RenderingServer::fog_volume_create);
  1777. ClassDB::bind_method(D_METHOD("fog_volume_set_shape", "fog_volume", "shape"), &RenderingServer::fog_volume_set_shape);
  1778. ClassDB::bind_method(D_METHOD("fog_volume_set_size", "fog_volume", "size"), &RenderingServer::fog_volume_set_size);
  1779. ClassDB::bind_method(D_METHOD("fog_volume_set_material", "fog_volume", "material"), &RenderingServer::fog_volume_set_material);
  1780. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_ELLIPSOID);
  1781. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CONE);
  1782. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CYLINDER);
  1783. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_BOX);
  1784. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_WORLD);
  1785. BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_MAX);
  1786. /* VISIBILITY NOTIFIER */
  1787. ClassDB::bind_method(D_METHOD("visibility_notifier_create"), &RenderingServer::visibility_notifier_create);
  1788. ClassDB::bind_method(D_METHOD("visibility_notifier_set_aabb", "notifier", "aabb"), &RenderingServer::visibility_notifier_set_aabb);
  1789. ClassDB::bind_method(D_METHOD("visibility_notifier_set_callbacks", "notifier", "enter_callable", "exit_callable"), &RenderingServer::visibility_notifier_set_callbacks);
  1790. /* OCCLUDER */
  1791. ClassDB::bind_method(D_METHOD("occluder_create"), &RenderingServer::occluder_create);
  1792. ClassDB::bind_method(D_METHOD("occluder_set_mesh", "occluder", "vertices", "indices"), &RenderingServer::occluder_set_mesh);
  1793. /* CAMERA */
  1794. ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);
  1795. ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective);
  1796. ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal);
  1797. ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum);
  1798. ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform);
  1799. ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask);
  1800. ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment);
  1801. ClassDB::bind_method(D_METHOD("camera_set_camera_attributes", "camera", "effects"), &RenderingServer::camera_set_camera_attributes);
  1802. ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);
  1803. /* VIEWPORT */
  1804. ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);
  1805. ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr);
  1806. ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);
  1807. ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);
  1808. ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);
  1809. ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID));
  1810. ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen);
  1811. ClassDB::bind_method(D_METHOD("viewport_set_canvas_cull_mask", "viewport", "canvas_cull_mask"), &RenderingServer::viewport_set_canvas_cull_mask);
  1812. ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_mode", "viewport", "scaling_3d_mode"), &RenderingServer::viewport_set_scaling_3d_mode);
  1813. ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_scale", "viewport", "scale"), &RenderingServer::viewport_set_scaling_3d_scale);
  1814. ClassDB::bind_method(D_METHOD("viewport_set_fsr_sharpness", "viewport", "sharpness"), &RenderingServer::viewport_set_fsr_sharpness);
  1815. ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias);
  1816. ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);
  1817. ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);
  1818. ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target);
  1819. ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);
  1820. ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d);
  1821. ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d);
  1822. ClassDB::bind_method(D_METHOD("viewport_set_environment_mode", "viewport", "mode"), &RenderingServer::viewport_set_environment_mode);
  1823. ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera);
  1824. ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario);
  1825. ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);
  1826. ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);
  1827. ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_transforms_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_transforms_to_pixel);
  1828. ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_vertices_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_vertices_to_pixel);
  1829. ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_filter", "viewport", "filter"), &RenderingServer::viewport_set_default_canvas_item_texture_filter);
  1830. ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_repeat", "viewport", "repeat"), &RenderingServer::viewport_set_default_canvas_item_texture_repeat);
  1831. ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);
  1832. ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking);
  1833. ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background);
  1834. ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform);
  1835. ClassDB::bind_method(D_METHOD("viewport_set_sdf_oversize_and_scale", "viewport", "oversize", "scale"), &RenderingServer::viewport_set_sdf_oversize_and_scale);
  1836. 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));
  1837. ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_positional_shadow_atlas_quadrant_subdivision);
  1838. ClassDB::bind_method(D_METHOD("viewport_set_msaa_3d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_3d);
  1839. ClassDB::bind_method(D_METHOD("viewport_set_msaa_2d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_2d);
  1840. ClassDB::bind_method(D_METHOD("viewport_set_screen_space_aa", "viewport", "mode"), &RenderingServer::viewport_set_screen_space_aa);
  1841. ClassDB::bind_method(D_METHOD("viewport_set_use_taa", "viewport", "enable"), &RenderingServer::viewport_set_use_taa);
  1842. ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "enable"), &RenderingServer::viewport_set_use_debanding);
  1843. ClassDB::bind_method(D_METHOD("viewport_set_use_occlusion_culling", "viewport", "enable"), &RenderingServer::viewport_set_use_occlusion_culling);
  1844. ClassDB::bind_method(D_METHOD("viewport_set_occlusion_rays_per_thread", "rays_per_thread"), &RenderingServer::viewport_set_occlusion_rays_per_thread);
  1845. ClassDB::bind_method(D_METHOD("viewport_set_occlusion_culling_build_quality", "quality"), &RenderingServer::viewport_set_occlusion_culling_build_quality);
  1846. ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "type", "info"), &RenderingServer::viewport_get_render_info);
  1847. ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw);
  1848. ClassDB::bind_method(D_METHOD("viewport_set_measure_render_time", "viewport", "enable"), &RenderingServer::viewport_set_measure_render_time);
  1849. ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_cpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_cpu);
  1850. ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_gpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_gpu);
  1851. ClassDB::bind_method(D_METHOD("viewport_set_vrs_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_mode);
  1852. ClassDB::bind_method(D_METHOD("viewport_set_vrs_texture", "viewport", "texture"), &RenderingServer::viewport_set_vrs_texture);
  1853. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_BILINEAR);
  1854. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR);
  1855. BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_MAX);
  1856. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);
  1857. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); // Then goes to disabled); must be manually updated.
  1858. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // Default
  1859. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
  1860. BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);
  1861. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);
  1862. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);
  1863. BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);
  1864. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_DISABLED);
  1865. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_ENABLED);
  1866. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_INHERIT);
  1867. BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_MAX);
  1868. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_100_PERCENT);
  1869. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_120_PERCENT);
  1870. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_150_PERCENT);
  1871. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_200_PERCENT);
  1872. BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_MAX);
  1873. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_100_PERCENT);
  1874. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_50_PERCENT);
  1875. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_25_PERCENT);
  1876. BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_MAX);
  1877. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);
  1878. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);
  1879. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);
  1880. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);
  1881. BIND_ENUM_CONSTANT(VIEWPORT_MSAA_MAX);
  1882. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_DISABLED);
  1883. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_FXAA);
  1884. BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_MAX);
  1885. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW);
  1886. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM);
  1887. BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH);
  1888. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);
  1889. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME);
  1890. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);
  1891. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);
  1892. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_VISIBLE);
  1893. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_SHADOW);
  1894. BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_MAX);
  1895. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);
  1896. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);
  1897. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_LIGHTING);
  1898. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);
  1899. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);
  1900. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER);
  1901. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO);
  1902. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING);
  1903. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION);
  1904. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS);
  1905. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
  1906. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE);
  1907. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSAO);
  1908. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSIL);
  1909. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_PSSM_SPLITS);
  1910. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DECAL_ATLAS);
  1911. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI);
  1912. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI_PROBES);
  1913. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_BUFFER);
  1914. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLE_LOD);
  1915. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS);
  1916. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS);
  1917. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS);
  1918. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES);
  1919. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OCCLUDERS);
  1920. BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_MOTION_VECTORS);
  1921. BIND_ENUM_CONSTANT(VIEWPORT_VRS_DISABLED);
  1922. BIND_ENUM_CONSTANT(VIEWPORT_VRS_TEXTURE);
  1923. BIND_ENUM_CONSTANT(VIEWPORT_VRS_XR);
  1924. BIND_ENUM_CONSTANT(VIEWPORT_VRS_MAX);
  1925. /* SKY API */
  1926. ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create);
  1927. ClassDB::bind_method(D_METHOD("sky_set_radiance_size", "sky", "radiance_size"), &RenderingServer::sky_set_radiance_size);
  1928. ClassDB::bind_method(D_METHOD("sky_set_mode", "sky", "mode"), &RenderingServer::sky_set_mode);
  1929. ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material);
  1930. ClassDB::bind_method(D_METHOD("sky_bake_panorama", "sky", "energy", "bake_irradiance", "size"), &RenderingServer::sky_bake_panorama);
  1931. BIND_ENUM_CONSTANT(SKY_MODE_AUTOMATIC);
  1932. BIND_ENUM_CONSTANT(SKY_MODE_QUALITY);
  1933. BIND_ENUM_CONSTANT(SKY_MODE_INCREMENTAL);
  1934. BIND_ENUM_CONSTANT(SKY_MODE_REALTIME);
  1935. /* ENVIRONMENT */
  1936. ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create);
  1937. ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background);
  1938. ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky);
  1939. ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov);
  1940. ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation);
  1941. ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color);
  1942. ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "multiplier", "exposure_value"), &RenderingServer::environment_set_bg_energy);
  1943. ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer);
  1944. 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));
  1945. 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);
  1946. ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white"), &RenderingServer::environment_set_tonemap);
  1947. ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "use_1d_color_correction", "color_correction"), &RenderingServer::environment_set_adjustment);
  1948. ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance"), &RenderingServer::environment_set_ssr);
  1949. 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);
  1950. ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "light_color", "light_energy", "sun_scatter", "density", "height", "height_density", "aerial_perspective", "sky_affect"), &RenderingServer::environment_set_fog);
  1951. 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);
  1952. 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);
  1953. ClassDB::bind_method(D_METHOD("environment_glow_set_use_bicubic_upscale", "enable"), &RenderingServer::environment_glow_set_use_bicubic_upscale);
  1954. ClassDB::bind_method(D_METHOD("environment_set_ssr_roughness_quality", "quality"), &RenderingServer::environment_set_ssr_roughness_quality);
  1955. 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);
  1956. 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);
  1957. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_ray_count", "ray_count"), &RenderingServer::environment_set_sdfgi_ray_count);
  1958. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_converge", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_converge);
  1959. ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_update_light", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_update_light);
  1960. ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_volume_size", "size", "depth"), &RenderingServer::environment_set_volumetric_fog_volume_size);
  1961. ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_filter_active", "active"), &RenderingServer::environment_set_volumetric_fog_filter_active);
  1962. ClassDB::bind_method(D_METHOD("environment_bake_panorama", "environment", "bake_irradiance", "size"), &RenderingServer::environment_bake_panorama);
  1963. ClassDB::bind_method(D_METHOD("screen_space_roughness_limiter_set_active", "enable", "amount", "limit"), &RenderingServer::screen_space_roughness_limiter_set_active);
  1964. ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_quality", "quality"), &RenderingServer::sub_surface_scattering_set_quality);
  1965. ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_scale", "scale", "depth_scale"), &RenderingServer::sub_surface_scattering_set_scale);
  1966. BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);
  1967. BIND_ENUM_CONSTANT(ENV_BG_COLOR);
  1968. BIND_ENUM_CONSTANT(ENV_BG_SKY);
  1969. BIND_ENUM_CONSTANT(ENV_BG_CANVAS);
  1970. BIND_ENUM_CONSTANT(ENV_BG_KEEP);
  1971. BIND_ENUM_CONSTANT(ENV_BG_CAMERA_FEED);
  1972. BIND_ENUM_CONSTANT(ENV_BG_MAX);
  1973. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_BG);
  1974. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_DISABLED);
  1975. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_COLOR);
  1976. BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_SKY);
  1977. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_BG);
  1978. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_DISABLED);
  1979. BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_SKY);
  1980. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_ADDITIVE);
  1981. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SCREEN);
  1982. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SOFTLIGHT);
  1983. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_REPLACE);
  1984. BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_MIX);
  1985. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);
  1986. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);
  1987. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);
  1988. BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);
  1989. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_DISABLED);
  1990. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_LOW);
  1991. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_MEDIUM);
  1992. BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_HIGH);
  1993. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_VERY_LOW);
  1994. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);
  1995. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);
  1996. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);
  1997. BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_ULTRA);
  1998. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_VERY_LOW);
  1999. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_LOW);
  2000. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_MEDIUM);
  2001. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_HIGH);
  2002. BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_ULTRA);
  2003. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_50_PERCENT);
  2004. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_75_PERCENT);
  2005. BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_100_PERCENT);
  2006. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_4);
  2007. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_8);
  2008. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_16);
  2009. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_32);
  2010. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_64);
  2011. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_96);
  2012. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_128);
  2013. BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_MAX);
  2014. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_5_FRAMES);
  2015. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_10_FRAMES);
  2016. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_15_FRAMES);
  2017. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_20_FRAMES);
  2018. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_25_FRAMES);
  2019. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_30_FRAMES);
  2020. BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_MAX);
  2021. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME);
  2022. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES);
  2023. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES);
  2024. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES);
  2025. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES);
  2026. BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_MAX);
  2027. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_DISABLED);
  2028. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_LOW);
  2029. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_MEDIUM);
  2030. BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_HIGH);
  2031. /* CAMERA EFFECTS */
  2032. ClassDB::bind_method(D_METHOD("camera_attributes_create"), &RenderingServer::camera_attributes_create);
  2033. ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_quality", "quality", "use_jitter"), &RenderingServer::camera_attributes_set_dof_blur_quality);
  2034. ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_bokeh_shape", "shape"), &RenderingServer::camera_attributes_set_dof_blur_bokeh_shape);
  2035. 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);
  2036. ClassDB::bind_method(D_METHOD("camera_attributes_set_exposure", "camera_attributes", "multiplier", "normalization"), &RenderingServer::camera_attributes_set_exposure);
  2037. 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);
  2038. BIND_ENUM_CONSTANT(DOF_BOKEH_BOX);
  2039. BIND_ENUM_CONSTANT(DOF_BOKEH_HEXAGON);
  2040. BIND_ENUM_CONSTANT(DOF_BOKEH_CIRCLE);
  2041. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_VERY_LOW);
  2042. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);
  2043. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
  2044. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);
  2045. /* SCENARIO */
  2046. ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create);
  2047. ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment);
  2048. ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment);
  2049. ClassDB::bind_method(D_METHOD("scenario_set_camera_attributes", "scenario", "effects"), &RenderingServer::scenario_set_camera_attributes);
  2050. /* INSTANCE */
  2051. ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2);
  2052. ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create);
  2053. ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base);
  2054. ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario);
  2055. ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask);
  2056. ClassDB::bind_method(D_METHOD("instance_set_pivot_data", "instance", "sorting_offset", "use_aabb_center"), &RenderingServer::instance_set_pivot_data);
  2057. ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);
  2058. ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);
  2059. ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);
  2060. ClassDB::bind_method(D_METHOD("instance_set_surface_override_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_override_material);
  2061. ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);
  2062. ClassDB::bind_method(D_METHOD("instance_geometry_set_transparency", "instance", "transparency"), &RenderingServer::instance_geometry_set_transparency);
  2063. ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);
  2064. ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton);
  2065. ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin);
  2066. ClassDB::bind_method(D_METHOD("instance_set_visibility_parent", "instance", "parent"), &RenderingServer::instance_set_visibility_parent);
  2067. ClassDB::bind_method(D_METHOD("instance_set_ignore_culling", "instance", "enabled"), &RenderingServer::instance_set_ignore_culling);
  2068. ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag);
  2069. ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting);
  2070. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override);
  2071. ClassDB::bind_method(D_METHOD("instance_geometry_set_material_overlay", "instance", "material"), &RenderingServer::instance_geometry_set_material_overlay);
  2072. 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);
  2073. ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap);
  2074. ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias);
  2075. ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter);
  2076. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter);
  2077. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value);
  2078. ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list);
  2079. ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));
  2080. ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));
  2081. ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID()));
  2082. BIND_ENUM_CONSTANT(INSTANCE_NONE);
  2083. BIND_ENUM_CONSTANT(INSTANCE_MESH);
  2084. BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);
  2085. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);
  2086. BIND_ENUM_CONSTANT(INSTANCE_PARTICLES_COLLISION);
  2087. BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
  2088. BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
  2089. BIND_ENUM_CONSTANT(INSTANCE_DECAL);
  2090. BIND_ENUM_CONSTANT(INSTANCE_VOXEL_GI);
  2091. BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP);
  2092. BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER);
  2093. BIND_ENUM_CONSTANT(INSTANCE_VISIBLITY_NOTIFIER);
  2094. BIND_ENUM_CONSTANT(INSTANCE_FOG_VOLUME);
  2095. BIND_ENUM_CONSTANT(INSTANCE_MAX);
  2096. BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
  2097. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);
  2098. BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_DYNAMIC_GI);
  2099. BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);
  2100. BIND_ENUM_CONSTANT(INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING);
  2101. BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);
  2102. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);
  2103. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);
  2104. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
  2105. BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
  2106. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DISABLED);
  2107. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_SELF);
  2108. BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DEPENDENCIES);
  2109. /* Bake 3D Object */
  2110. ClassDB::bind_method(D_METHOD("bake_render_uv2", "base", "material_overrides", "image_size"), &RenderingServer::bake_render_uv2);
  2111. BIND_ENUM_CONSTANT(BAKE_CHANNEL_ALBEDO_ALPHA);
  2112. BIND_ENUM_CONSTANT(BAKE_CHANNEL_NORMAL);
  2113. BIND_ENUM_CONSTANT(BAKE_CHANNEL_ORM);
  2114. BIND_ENUM_CONSTANT(BAKE_CHANNEL_EMISSION);
  2115. /* CANVAS (2D) */
  2116. ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create);
  2117. ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring);
  2118. ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate);
  2119. ClassDB::bind_method(D_METHOD("canvas_set_disable_scale", "disable"), &RenderingServer::canvas_set_disable_scale);
  2120. /* CANVAS TEXTURE */
  2121. ClassDB::bind_method(D_METHOD("canvas_texture_create"), &RenderingServer::canvas_texture_create);
  2122. ClassDB::bind_method(D_METHOD("canvas_texture_set_channel", "canvas_texture", "channel", "texture"), &RenderingServer::canvas_texture_set_channel);
  2123. ClassDB::bind_method(D_METHOD("canvas_texture_set_shading_parameters", "canvas_texture", "base_color", "shininess"), &RenderingServer::canvas_texture_set_shading_parameters);
  2124. ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_filter", "canvas_texture", "filter"), &RenderingServer::canvas_texture_set_texture_filter);
  2125. ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_repeat", "canvas_texture", "repeat"), &RenderingServer::canvas_texture_set_texture_repeat);
  2126. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_DIFFUSE);
  2127. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_NORMAL);
  2128. BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_SPECULAR);
  2129. /* CANVAS ITEM */
  2130. ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create);
  2131. ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent);
  2132. ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_filter", "item", "filter"), &RenderingServer::canvas_item_set_default_texture_filter);
  2133. ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_repeat", "item", "repeat"), &RenderingServer::canvas_item_set_default_texture_repeat);
  2134. ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible);
  2135. ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask);
  2136. ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_layer", "item", "visibility_layer"), &RenderingServer::canvas_item_set_visibility_layer);
  2137. ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform);
  2138. ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip);
  2139. ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode);
  2140. ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
  2141. ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate);
  2142. ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate);
  2143. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent);
  2144. /* Primitives */
  2145. 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));
  2146. ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(-1.0), DEFVAL(false));
  2147. ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &RenderingServer::canvas_item_add_rect);
  2148. ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &RenderingServer::canvas_item_add_circle);
  2149. 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));
  2150. 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));
  2151. 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);
  2152. 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));
  2153. 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)));
  2154. ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_primitive);
  2155. ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()));
  2156. 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));
  2157. 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()));
  2158. ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));
  2159. ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture"), &RenderingServer::canvas_item_add_particles);
  2160. ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);
  2161. ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);
  2162. 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));
  2163. ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);
  2164. ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);
  2165. ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);
  2166. ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);
  2167. ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);
  2168. ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);
  2169. ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);
  2170. ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material);
  2171. ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_notifier", "item", "enable", "area", "enter_callable", "exit_callable"), &RenderingServer::canvas_item_set_visibility_notifier);
  2172. 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));
  2173. BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);
  2174. BIND_ENUM_CONSTANT(NINE_PATCH_TILE);
  2175. BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);
  2176. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);
  2177. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
  2178. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR);
  2179. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
  2180. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);
  2181. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC);
  2182. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC);
  2183. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_MAX);
  2184. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
  2185. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
  2186. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
  2187. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MIRROR);
  2188. BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MAX);
  2189. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_DISABLED);
  2190. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_ONLY);
  2191. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_AND_DRAW);
  2192. BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_TRANSPARENT);
  2193. /* CANVAS LIGHT */
  2194. ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create);
  2195. ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas);
  2196. ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled);
  2197. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_scale", "light", "scale"), &RenderingServer::canvas_light_set_texture_scale);
  2198. ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform);
  2199. ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture);
  2200. ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset);
  2201. ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color);
  2202. ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height);
  2203. ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy);
  2204. ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range);
  2205. ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range);
  2206. ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask);
  2207. ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask);
  2208. ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode);
  2209. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled);
  2210. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);
  2211. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);
  2212. ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);
  2213. ClassDB::bind_method(D_METHOD("canvas_light_set_blend_mode", "light", "mode"), &RenderingServer::canvas_light_set_blend_mode);
  2214. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_POINT);
  2215. BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_DIRECTIONAL);
  2216. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_ADD);
  2217. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_SUB);
  2218. BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_MIX);
  2219. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);
  2220. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);
  2221. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);
  2222. BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_MAX);
  2223. /* CANVAS OCCLUDER */
  2224. ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create);
  2225. ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas);
  2226. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled);
  2227. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon);
  2228. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_as_sdf_collision", "occluder", "enable"), &RenderingServer::canvas_light_occluder_set_as_sdf_collision);
  2229. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform);
  2230. ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask);
  2231. /* CANVAS LIGHT OCCLUDER POLYGON */
  2232. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create);
  2233. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape);
  2234. ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode);
  2235. ClassDB::bind_method(D_METHOD("canvas_set_shadow_texture_size", "size"), &RenderingServer::canvas_set_shadow_texture_size);
  2236. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);
  2237. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);
  2238. BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);
  2239. /* GLOBAL SHADER UNIFORMS */
  2240. ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add);
  2241. ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove);
  2242. ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::global_shader_parameter_get_list);
  2243. ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set);
  2244. ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override);
  2245. ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get);
  2246. ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type);
  2247. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL);
  2248. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2);
  2249. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC3);
  2250. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC4);
  2251. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_INT);
  2252. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC2);
  2253. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC3);
  2254. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC4);
  2255. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2I);
  2256. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UINT);
  2257. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC2);
  2258. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC3);
  2259. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC4);
  2260. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_FLOAT);
  2261. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC2);
  2262. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC3);
  2263. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC4);
  2264. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_COLOR);
  2265. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2);
  2266. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT2);
  2267. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT3);
  2268. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT4);
  2269. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM_2D);
  2270. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM);
  2271. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2D);
  2272. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2DARRAY);
  2273. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER3D);
  2274. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLERCUBE);
  2275. BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAX);
  2276. /* Free */
  2277. ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // Shouldn't conflict with Object::free().
  2278. /* Misc */
  2279. ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "callable"), &RenderingServer::request_frame_drawn_callback);
  2280. ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed);
  2281. ClassDB::bind_method(D_METHOD("get_rendering_info", "info"), &RenderingServer::get_rendering_info);
  2282. ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);
  2283. ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);
  2284. ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type);
  2285. ClassDB::bind_method(D_METHOD("get_video_adapter_api_version"), &RenderingServer::get_video_adapter_api_version);
  2286. ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);
  2287. ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);
  2288. ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);
  2289. ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);
  2290. ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));
  2291. ClassDB::bind_method(D_METHOD("get_default_clear_color"), &RenderingServer::get_default_clear_color);
  2292. ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);
  2293. ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);
  2294. ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);
  2295. ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);
  2296. ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);
  2297. ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);
  2298. ClassDB::bind_method(D_METHOD("get_frame_setup_time_cpu"), &RenderingServer::get_frame_setup_time_cpu);
  2299. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
  2300. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);
  2301. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);
  2302. BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);
  2303. BIND_ENUM_CONSTANT(RENDERING_INFO_TEXTURE_MEM_USED);
  2304. BIND_ENUM_CONSTANT(RENDERING_INFO_BUFFER_MEM_USED);
  2305. BIND_ENUM_CONSTANT(RENDERING_INFO_VIDEO_MEM_USED);
  2306. BIND_ENUM_CONSTANT(FEATURE_SHADERS);
  2307. BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);
  2308. ADD_SIGNAL(MethodInfo("frame_pre_draw"));
  2309. ADD_SIGNAL(MethodInfo("frame_post_draw"));
  2310. ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);
  2311. ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));
  2312. ClassDB::bind_method(D_METHOD("get_rendering_device"), &RenderingServer::get_rendering_device);
  2313. ClassDB::bind_method(D_METHOD("create_local_rendering_device"), &RenderingServer::create_local_rendering_device);
  2314. }
  2315. void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {
  2316. Vector<Vector3> vertices;
  2317. Vector<Vector3> normals;
  2318. for (const Geometry3D::MeshData::Face &f : p_mesh_data.faces) {
  2319. for (uint32_t j = 2; j < f.indices.size(); j++) {
  2320. vertices.push_back(p_mesh_data.vertices[f.indices[0]]);
  2321. normals.push_back(f.plane.normal);
  2322. vertices.push_back(p_mesh_data.vertices[f.indices[j - 1]]);
  2323. normals.push_back(f.plane.normal);
  2324. vertices.push_back(p_mesh_data.vertices[f.indices[j]]);
  2325. normals.push_back(f.plane.normal);
  2326. }
  2327. }
  2328. Array d;
  2329. d.resize(RS::ARRAY_MAX);
  2330. d[ARRAY_VERTEX] = vertices;
  2331. d[ARRAY_NORMAL] = normals;
  2332. mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);
  2333. }
  2334. void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {
  2335. Geometry3D::MeshData mdata = Geometry3D::build_convex_mesh(p_planes);
  2336. mesh_add_surface_from_mesh_data(p_mesh, mdata);
  2337. }
  2338. RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {
  2339. RID instance = instance_create();
  2340. instance_set_base(instance, p_base);
  2341. instance_set_scenario(instance, p_scenario);
  2342. return instance;
  2343. }
  2344. bool RenderingServer::is_render_loop_enabled() const {
  2345. return render_loop_enabled;
  2346. }
  2347. void RenderingServer::set_render_loop_enabled(bool p_enabled) {
  2348. render_loop_enabled = p_enabled;
  2349. }
  2350. RenderingServer::RenderingServer() {
  2351. //ERR_FAIL_COND(singleton);
  2352. singleton = this;
  2353. }
  2354. void RenderingServer::init() {
  2355. GLOBAL_DEF_RST_NOVAL_BASIC("rendering/textures/vram_compression/import_s3tc_bptc", OS::get_singleton()->get_preferred_texture_format() == OS::PREFERRED_TEXTURE_FORMAT_S3TC_BPTC);
  2356. GLOBAL_DEF_RST_NOVAL_BASIC("rendering/textures/vram_compression/import_etc2_astc", OS::get_singleton()->get_preferred_texture_format() == OS::PREFERRED_TEXTURE_FORMAT_ETC2_ASTC);
  2357. GLOBAL_DEF("rendering/textures/lossless_compression/force_png", false);
  2358. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/webp_compression/compression_method", PROPERTY_HINT_RANGE, "0,6,1"), 2);
  2359. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/webp_compression/lossless_compression_factor", PROPERTY_HINT_RANGE, "0,100,1"), 25);
  2360. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 3600);
  2361. GLOBAL_DEF_RST("rendering/lights_and_shadows/use_physical_light_units", false);
  2362. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"), 4096);
  2363. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/size.mobile", 2048);
  2364. 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);
  2365. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile", 0);
  2366. GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/16_bits", true);
  2367. 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);
  2368. GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);
  2369. GLOBAL_DEF("rendering/2d/shadow_atlas/size", 2048);
  2370. // Number of commands that can be drawn per frame.
  2371. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/gl_compatibility/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);
  2372. GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true);
  2373. GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true);
  2374. GLOBAL_DEF("rendering/shader_compiler/shader_cache/use_zstd_compression", true);
  2375. GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug", false);
  2376. GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug.release", true);
  2377. GLOBAL_DEF_RST("rendering/reflections/sky_reflections/roughness_layers", 8); // Assumes a 256x256 cubemap
  2378. GLOBAL_DEF_RST("rendering/reflections/sky_reflections/texture_array_reflections", true);
  2379. GLOBAL_DEF("rendering/reflections/sky_reflections/texture_array_reflections.mobile", false);
  2380. GLOBAL_DEF_RST("rendering/reflections/sky_reflections/ggx_samples", 32);
  2381. GLOBAL_DEF("rendering/reflections/sky_reflections/ggx_samples.mobile", 16);
  2382. GLOBAL_DEF("rendering/reflections/sky_reflections/fast_filter_high_quality", false);
  2383. GLOBAL_DEF("rendering/reflections/reflection_atlas/reflection_size", 256);
  2384. GLOBAL_DEF("rendering/reflections/reflection_atlas/reflection_size.mobile", 128);
  2385. GLOBAL_DEF("rendering/reflections/reflection_atlas/reflection_count", 64);
  2386. GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false);
  2387. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/voxel_gi/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)"), 0);
  2388. GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading", false);
  2389. GLOBAL_DEF("rendering/shading/overrides/force_vertex_shading.mobile", true);
  2390. GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley", false);
  2391. GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley.mobile", true);
  2392. GLOBAL_DEF("rendering/driver/depth_prepass/enable", true);
  2393. GLOBAL_DEF("rendering/driver/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
  2394. GLOBAL_DEF_RST("rendering/textures/default_filters/use_nearest_mipmap_filter", false);
  2395. 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);
  2396. 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);
  2397. 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);
  2398. GLOBAL_DEF("rendering/camera/depth_of_field/depth_of_field_use_jitter", false);
  2399. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);
  2400. GLOBAL_DEF("rendering/environment/ssao/half_size", true);
  2401. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);
  2402. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 2);
  2403. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);
  2404. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);
  2405. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);
  2406. GLOBAL_DEF("rendering/environment/ssil/half_size", true);
  2407. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);
  2408. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 4);
  2409. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);
  2410. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);
  2411. GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);
  2412. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);
  2413. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);
  2414. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast)"), 0);
  2415. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);
  2416. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);
  2417. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);
  2418. 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);
  2419. 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);
  2420. GLOBAL_DEF_RST("rendering/occlusion_culling/occlusion_rays_per_thread", 512);
  2421. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slow)"), 1);
  2422. GLOBAL_DEF("rendering/environment/glow/upscale_mode.mobile", 0);
  2423. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/screen_space_reflection/roughness_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);
  2424. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/subsurface_scattering/subsurface_scattering_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);
  2425. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.05);
  2426. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.01);
  2427. GLOBAL_DEF("rendering/limits/global_shader_variables/buffer_size", 65536);
  2428. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/probe_capture/update_speed", PROPERTY_HINT_RANGE, "0.001,256,0.001"), 15);
  2429. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/probe_ray_count", PROPERTY_HINT_ENUM, "8 (Fastest),16,32,64,96,128 (Slowest)"), 1);
  2430. 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);
  2431. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/frames_to_update_lights", PROPERTY_HINT_ENUM, "1 (Slower),2,4,8,16 (Faster)"), 2);
  2432. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_size", PROPERTY_HINT_RANGE, "16,512,1"), 64);
  2433. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_depth", PROPERTY_HINT_RANGE, "16,512,1"), 64);
  2434. GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/use_filter", PROPERTY_HINT_ENUM, "No (Faster),Yes (Higher Quality)"), 1);
  2435. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10);
  2436. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000);
  2437. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/forward_renderer/threaded_render_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 500);
  2438. GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"), 512);
  2439. // OpenGL limits
  2440. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_elements", PROPERTY_HINT_RANGE, "1024,65536,1"), 65536);
  2441. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_lights", PROPERTY_HINT_RANGE, "2,256,1"), 32);
  2442. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_lights_per_object", PROPERTY_HINT_RANGE, "2,1024,1"), 8);
  2443. GLOBAL_DEF_RST_BASIC("xr/shaders/enabled", false);
  2444. }
  2445. RenderingServer::~RenderingServer() {
  2446. singleton = nullptr;
  2447. }