Path: blob/master/servers/rendering/rendering_server.cpp
11322 views
/**************************************************************************/1/* rendering_server.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "rendering_server.h"31#include "rendering_server.compat.inc"3233#include "core/config/project_settings.h"34#include "core/variant/typed_array.h"35#include "servers/rendering/shader_language.h"36#include "servers/rendering/shader_warnings.h"3738RenderingServer *RenderingServer::singleton = nullptr;39RenderingServer *(*RenderingServer::create_func)() = nullptr;4041RenderingServer *RenderingServer::get_singleton() {42return singleton;43}4445RenderingServer *RenderingServer::create() {46ERR_FAIL_COND_V(singleton, nullptr);4748if (create_func) {49return create_func();50}5152return nullptr;53}5455Array RenderingServer::_texture_debug_usage_bind() {56List<TextureInfo> list;57texture_debug_usage(&list);58Array arr;59for (const TextureInfo &E : list) {60Dictionary dict;61dict["texture"] = E.texture;62dict["width"] = E.width;63dict["height"] = E.height;64dict["depth"] = E.depth;65dict["format"] = E.format;66dict["bytes"] = E.bytes;67dict["path"] = E.path;68arr.push_back(dict);69}70return arr;71}7273static PackedInt64Array to_int_array(const Vector<ObjectID> &ids) {74PackedInt64Array a;75a.resize(ids.size());76for (int i = 0; i < ids.size(); ++i) {77a.write[i] = ids[i];78}79return a;80}8182PackedInt64Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {83Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);84return to_int_array(ids);85}8687PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {88Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);89return to_int_array(ids);90}9192PackedInt64Array RenderingServer::_instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario) const {93Vector<Plane> planes;94for (int i = 0; i < p_convex.size(); ++i) {95const Variant &v = p_convex[i];96ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, PackedInt64Array());97planes.push_back(v);98}99100Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);101return to_int_array(ids);102}103104RID RenderingServer::get_test_texture() {105if (test_texture.is_valid()) {106return test_texture;107};108109#define TEST_TEXTURE_SIZE 256110111Vector<uint8_t> test_data;112test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);113114{115uint8_t *w = test_data.ptrw();116117for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {118for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {119Color c;120int r = 255 - (x + y) / 2;121122if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {123c.r = y;124c.g = r;125c.b = x;126127} else {128c.r = r;129c.g = x;130c.b = y;131}132133w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r, 0, 255));134w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g, 0, 255));135w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b, 0, 255));136}137}138}139140Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));141142test_texture = texture_2d_create(data);143144return test_texture;145}146147void RenderingServer::_free_internal_rids() {148if (test_texture.is_valid()) {149free_rid(test_texture);150}151if (white_texture.is_valid()) {152free_rid(white_texture);153}154if (test_material.is_valid()) {155free_rid(test_material);156}157}158159RID RenderingServer::_make_test_cube() {160Vector<Vector3> vertices;161Vector<Vector3> normals;162Vector<float> tangents;163Vector<Vector3> uvs;164165#define ADD_VTX(m_idx) \166vertices.push_back(face_points[m_idx]); \167normals.push_back(normal_points[m_idx]); \168tangents.push_back(normal_points[m_idx][1]); \169tangents.push_back(normal_points[m_idx][2]); \170tangents.push_back(normal_points[m_idx][0]); \171tangents.push_back(1.0); \172uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));173174for (int i = 0; i < 6; i++) {175Vector3 face_points[4];176Vector3 normal_points[4];177float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };178179for (int j = 0; j < 4; j++) {180float v[3];181v[0] = 1.0;182v[1] = 1 - 2 * ((j >> 1) & 1);183v[2] = v[1] * (1 - 2 * (j & 1));184185for (int k = 0; k < 3; k++) {186if (i < 3) {187face_points[j][(i + k) % 3] = v[k];188} else {189face_points[3 - j][(i + k) % 3] = -v[k];190}191}192normal_points[j] = Vector3();193normal_points[j][i % 3] = (i >= 3 ? -1 : 1);194}195196// Tri 1197ADD_VTX(0);198ADD_VTX(1);199ADD_VTX(2);200// Tri 2201ADD_VTX(2);202ADD_VTX(3);203ADD_VTX(0);204}205206RID test_cube = mesh_create();207208Array d;209d.resize(RS::ARRAY_MAX);210d[RenderingServer::ARRAY_NORMAL] = normals;211d[RenderingServer::ARRAY_TANGENT] = tangents;212d[RenderingServer::ARRAY_TEX_UV] = uvs;213d[RenderingServer::ARRAY_VERTEX] = vertices;214215Vector<int> indices;216indices.resize(vertices.size());217for (int i = 0; i < vertices.size(); i++) {218indices.set(i, i);219}220d[RenderingServer::ARRAY_INDEX] = indices;221222mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);223224/*225test_material = fixed_material_create();226//material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);227fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );228fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );229fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );230231fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );232fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );233*/234mesh_surface_set_material(test_cube, 0, test_material);235236return test_cube;237}238239RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, real_t p_radius) {240Vector<Vector3> vertices;241Vector<Vector3> normals;242const double lat_step = Math::TAU / p_lats;243const double lon_step = Math::TAU / p_lons;244245for (int i = 1; i <= p_lats; i++) {246double lat0 = lat_step * (i - 1) - Math::TAU / 4;247double z0 = Math::sin(lat0);248double zr0 = Math::cos(lat0);249250double lat1 = lat_step * i - Math::TAU / 4;251double z1 = Math::sin(lat1);252double zr1 = Math::cos(lat1);253254for (int j = p_lons; j >= 1; j--) {255double lng0 = lon_step * (j - 1);256double x0 = Math::cos(lng0);257double y0 = Math::sin(lng0);258259double lng1 = lon_step * j;260double x1 = Math::cos(lng1);261double y1 = Math::sin(lng1);262263Vector3 v[4] = {264Vector3(x1 * zr0, z0, y1 * zr0),265Vector3(x1 * zr1, z1, y1 * zr1),266Vector3(x0 * zr1, z1, y0 * zr1),267Vector3(x0 * zr0, z0, y0 * zr0)268};269270#define ADD_POINT(m_idx) \271normals.push_back(v[m_idx]); \272vertices.push_back(v[m_idx] * p_radius);273274ADD_POINT(0);275ADD_POINT(1);276ADD_POINT(2);277278ADD_POINT(2);279ADD_POINT(3);280ADD_POINT(0);281}282}283284RID mesh = mesh_create();285Array d;286d.resize(RS::ARRAY_MAX);287288d[ARRAY_VERTEX] = vertices;289d[ARRAY_NORMAL] = normals;290291mesh_add_surface_from_arrays(mesh, PRIMITIVE_TRIANGLES, d);292293return mesh;294}295296RID RenderingServer::get_white_texture() {297if (white_texture.is_valid()) {298return white_texture;299}300301Vector<uint8_t> wt;302wt.resize(16 * 3);303{304uint8_t *w = wt.ptrw();305for (int i = 0; i < 16 * 3; i++) {306w[i] = 255;307}308}309Ref<Image> white = memnew(Image(4, 4, false, Image::FORMAT_RGB8, wt));310white_texture = texture_2d_create(white);311return white_texture;312}313314void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r_angle, Vector3 &r_axis) {315Vector3 normal = p_normal.normalized();316Vector3 tangent = Vector3(p_tangent.x, p_tangent.y, p_tangent.z).normalized();317float d = p_tangent.w;318Vector3 binormal = normal.cross(tangent).normalized();319real_t angle;320321Basis tbn = Basis();322tbn.rows[0] = tangent;323tbn.rows[1] = binormal;324tbn.rows[2] = normal;325tbn.get_axis_angle(r_axis, angle);326r_angle = float(angle);327328if (d < 0.0) {329r_angle = CLAMP((1.0 - r_angle / Math::PI) * 0.5, 0.0, 0.49999);330} else {331r_angle = CLAMP((r_angle / Math::PI) * 0.5 + 0.5, 0.500008, 1.0);332}333}334335// The inputs to this function should match the outputs of _get_axis_angle. I.e. p_axis is a normalized vector336// and p_angle includes the binormal direction.337void _get_tbn_from_axis_angle(const Vector3 &p_axis, float p_angle, Vector3 &r_normal, Vector4 &r_tangent) {338float binormal_sign = p_angle > 0.5 ? 1.0 : -1.0;339float angle = Math::abs(p_angle * 2.0 - 1.0) * Math::PI;340341Basis tbn = Basis(p_axis, angle);342Vector3 tan = tbn.rows[0];343r_tangent = Vector4(tan.x, tan.y, tan.z, binormal_sign);344r_normal = tbn.rows[2];345}346347AABB _compute_aabb_from_points(const Vector3 *p_data, int p_length) {348if (p_length == 0) {349return AABB();350}351352Vector3 min = p_data[0];353Vector3 max = p_data[0];354355for (int i = 1; i < p_length; ++i) {356min = min.min(p_data[i]);357max = max.max(p_data[i]);358}359360return AABB(min, max - min);361}362363Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint32_t *p_offsets, uint32_t p_vertex_stride, uint32_t p_normal_stride, uint32_t p_attrib_stride, uint32_t p_skin_stride, Vector<uint8_t> &r_vertex_array, Vector<uint8_t> &r_attrib_array, Vector<uint8_t> &r_skin_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb, Vector4 &r_uv_scale) {364uint8_t *vw = r_vertex_array.ptrw();365uint8_t *aw = r_attrib_array.ptrw();366uint8_t *sw = r_skin_array.ptrw();367368uint8_t *iw = nullptr;369if (r_index_array.size()) {370iw = r_index_array.ptrw();371}372373int max_bone = 0;374375// Preprocess UVs if compression is enabled376if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && ((p_format & RS::ARRAY_FORMAT_TEX_UV) || (p_format & RS::ARRAY_FORMAT_TEX_UV2))) {377const Vector2 *uv_src = nullptr;378if (p_format & RS::ARRAY_FORMAT_TEX_UV) {379Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV];380uv_src = array.ptr();381}382383const Vector2 *uv2_src = nullptr;384if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {385Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV2];386uv2_src = array.ptr();387}388389Vector2 max_val = Vector2(0.0, 0.0);390Vector2 min_val = Vector2(0.0, 0.0);391Vector2 max_val2 = Vector2(0.0, 0.0);392Vector2 min_val2 = Vector2(0.0, 0.0);393394for (int i = 0; i < p_vertex_array_len; i++) {395if (p_format & RS::ARRAY_FORMAT_TEX_UV) {396max_val = max_val.max(uv_src[i]);397min_val = min_val.min(uv_src[i]);398}399if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {400max_val2 = max_val2.max(uv2_src[i]);401min_val2 = min_val2.min(uv2_src[i]);402}403}404405max_val = max_val.abs().max(min_val.abs());406max_val2 = max_val2.abs().max(min_val2.abs());407408if (min_val.x >= 0.0 && min_val2.x >= 0.0 && max_val.x <= 1.0 && max_val2.x <= 1.0 &&409min_val.y >= 0.0 && min_val2.y >= 0.0 && max_val.y <= 1.0 && max_val2.y <= 1.0) {410// When all channels are in the 0-1 range, we will compress to 16-bit without scaling to411// preserve the bits as best as possible.412r_uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);413} else {414r_uv_scale = Vector4(max_val.x, max_val.y, max_val2.x, max_val2.y) * Vector4(2.0, 2.0, 2.0, 2.0);415}416}417418for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {419if (!(p_format & (1ULL << ai))) { // No array420continue;421}422423switch (ai) {424case RS::ARRAY_VERTEX: {425if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {426Vector<Vector2> array = p_arrays[ai];427ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);428429const Vector2 *src = array.ptr();430431// Setting vertices means regenerating the AABB.432Rect2 aabb;433434{435for (int i = 0; i < p_vertex_array_len; i++) {436float vector[2] = { (float)src[i].x, (float)src[i].y };437438memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2);439440if (i == 0) {441aabb = Rect2(src[i], SMALL_VEC2); // Must have a bit of size.442} else {443aabb.expand_to(src[i]);444}445}446}447448r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));449450} else {451Vector<Vector3> array = p_arrays[ai];452ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);453454const Vector3 *src = array.ptr();455456r_aabb = _compute_aabb_from_points(src, p_vertex_array_len);457r_aabb.size = r_aabb.size.max(SMALL_VEC3);458459if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {460if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {461// Early out if we are only setting vertex positions.462for (int i = 0; i < p_vertex_array_len; i++) {463Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;464uint16_t vector[4] = {465(uint16_t)CLAMP(pos.x * 65535, 0, 65535),466(uint16_t)CLAMP(pos.y * 65535, 0, 65535),467(uint16_t)CLAMP(pos.z * 65535, 0, 65535),468(uint16_t)0469};470471memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);472}473continue;474}475476// Validate normal and tangent arrays.477ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);478479Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];480ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);481const Vector3 *normal_src = normal_array.ptr();482483Variant::Type tangent_type = p_arrays[RS::ARRAY_TANGENT].get_type();484ERR_FAIL_COND_V(tangent_type != Variant::PACKED_FLOAT32_ARRAY && tangent_type != Variant::PACKED_FLOAT64_ARRAY && tangent_type != Variant::NIL, ERR_INVALID_PARAMETER);485486// We need a different version if using double precision tangents.487if (tangent_type == Variant::PACKED_FLOAT32_ARRAY) {488Vector<float> tangent_array = p_arrays[RS::ARRAY_TANGENT];489ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);490const float *tangent_src = tangent_array.ptr();491492// Set data for vertex, normal, and tangent.493for (int i = 0; i < p_vertex_array_len; i++) {494float angle = 0.0;495Vector3 axis;496Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);497_get_axis_angle(normal_src[i], tangent, angle, axis);498499// Store axis.500{501Vector2 res = axis.octahedron_encode();502uint16_t vector[2] = {503(uint16_t)CLAMP(res.x * 65535, 0, 65535),504(uint16_t)CLAMP(res.y * 65535, 0, 65535),505};506507memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);508}509510// Store vertex position + angle.511{512Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;513uint16_t vector[4] = {514(uint16_t)CLAMP(pos.x * 65535, 0, 65535),515(uint16_t)CLAMP(pos.y * 65535, 0, 65535),516(uint16_t)CLAMP(pos.z * 65535, 0, 65535),517(uint16_t)CLAMP(angle * 65535, 0, 65535)518};519520memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);521}522}523} else if (tangent_type == Variant::PACKED_FLOAT64_ARRAY) {524Vector<double> tangent_array = p_arrays[RS::ARRAY_TANGENT];525ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);526const double *tangent_src = tangent_array.ptr();527528// Set data for vertex, normal, and tangent.529for (int i = 0; i < p_vertex_array_len; i++) {530float angle;531Vector3 axis;532Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);533_get_axis_angle(normal_src[i], tangent, angle, axis);534535// Store axis.536{537Vector2 res = axis.octahedron_encode();538uint16_t vector[2] = {539(uint16_t)CLAMP(res.x * 65535, 0, 65535),540(uint16_t)CLAMP(res.y * 65535, 0, 65535),541};542543memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);544}545546// Store vertex position + angle.547{548Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;549uint16_t vector[4] = {550(uint16_t)CLAMP(pos.x * 65535, 0, 65535),551(uint16_t)CLAMP(pos.y * 65535, 0, 65535),552(uint16_t)CLAMP(pos.z * 65535, 0, 65535),553(uint16_t)CLAMP(angle * 65535, 0, 65535)554};555556memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);557}558}559} else { // No tangent array.560// Set data for vertex, normal, and tangent.561for (int i = 0; i < p_vertex_array_len; i++) {562float angle;563Vector3 axis;564// Generate an arbitrary vector that is tangential to normal.565// This assumes that the normal is never (0,0,0).566Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();567Vector4 tangent = Vector4(tan.x, tan.y, tan.z, 1.0);568_get_axis_angle(normal_src[i], tangent, angle, axis);569570// Store axis.571{572Vector2 res = axis.octahedron_encode();573uint16_t vector[2] = {574(uint16_t)CLAMP(res.x * 65535, 0, 65535),575(uint16_t)CLAMP(res.y * 65535, 0, 65535),576};577578memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);579}580581// Store vertex position + angle.582{583Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;584uint16_t vector[4] = {585(uint16_t)CLAMP(pos.x * 65535, 0, 65535),586(uint16_t)CLAMP(pos.y * 65535, 0, 65535),587(uint16_t)CLAMP(pos.z * 65535, 0, 65535),588(uint16_t)CLAMP(angle * 65535, 0, 65535)589};590591memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);592}593}594}595} else {596for (int i = 0; i < p_vertex_array_len; i++) {597float vector[3] = { (float)src[i].x, (float)src[i].y, (float)src[i].z };598599memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 3);600}601}602}603604} break;605case RS::ARRAY_NORMAL: {606// If using compression we store normal while storing vertices.607if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {608ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);609610Vector<Vector3> array = p_arrays[ai];611ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);612613const Vector3 *src = array.ptr();614for (int i = 0; i < p_vertex_array_len; i++) {615Vector2 res = src[i].octahedron_encode();616uint16_t vector[2] = {617(uint16_t)CLAMP(res.x * 65535, 0, 65535),618(uint16_t)CLAMP(res.y * 65535, 0, 65535),619};620621memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);622}623}624} break;625626case RS::ARRAY_TANGENT: {627// If using compression we store tangent while storing vertices.628if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {629Variant::Type type = p_arrays[ai].get_type();630ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY && type != Variant::NIL, ERR_INVALID_PARAMETER);631632if (type == Variant::PACKED_FLOAT32_ARRAY) {633Vector<float> array = p_arrays[ai];634ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);635const float *src_ptr = array.ptr();636637for (int i = 0; i < p_vertex_array_len; i++) {638const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);639Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);640uint16_t vector[2] = {641(uint16_t)CLAMP(res.x * 65535, 0, 65535),642(uint16_t)CLAMP(res.y * 65535, 0, 65535),643};644645if (vector[0] == 0 && vector[1] == 65535) {646// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.647// So we sanitize here.648vector[0] = 65535;649}650651memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);652}653} else if (type == Variant::PACKED_FLOAT64_ARRAY) {654Vector<double> array = p_arrays[ai];655ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);656const double *src_ptr = array.ptr();657658for (int i = 0; i < p_vertex_array_len; i++) {659const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);660Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);661uint16_t vector[2] = {662(uint16_t)CLAMP(res.x * 65535, 0, 65535),663(uint16_t)CLAMP(res.y * 65535, 0, 65535),664};665666if (vector[0] == 0 && vector[1] == 65535) {667// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.668// So we sanitize here.669vector[0] = 65535;670}671672memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);673}674} else { // No tangent array.675ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);676677Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];678ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);679const Vector3 *normal_src = normal_array.ptr();680// Set data for tangent.681for (int i = 0; i < p_vertex_array_len; i++) {682// Generate an arbitrary vector that is tangential to normal.683// This assumes that the normal is never (0,0,0).684Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();685Vector2 res = tan.octahedron_tangent_encode(1.0);686uint16_t vector[2] = {687(uint16_t)CLAMP(res.x * 65535, 0, 65535),688(uint16_t)CLAMP(res.y * 65535, 0, 65535),689};690691if (vector[0] == 0 && vector[1] == 65535) {692// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.693// So we sanitize here.694vector[0] = 65535;695}696697memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);698}699}700}701} break;702case RS::ARRAY_COLOR: {703ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);704705Vector<Color> array = p_arrays[ai];706707ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);708709const Color *src = array.ptr();710for (int i = 0; i < p_vertex_array_len; i++) {711uint8_t color8[4] = {712uint8_t(CLAMP(src[i].r * 255.0, 0.0, 255.0)),713uint8_t(CLAMP(src[i].g * 255.0, 0.0, 255.0)),714uint8_t(CLAMP(src[i].b * 255.0, 0.0, 255.0)),715uint8_t(CLAMP(src[i].a * 255.0, 0.0, 255.0))716};717memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color8, 4);718}719} break;720case RS::ARRAY_TEX_UV: {721ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);722723Vector<Vector2> array = p_arrays[ai];724725ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);726727const Vector2 *src = array.ptr();728if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {729for (int i = 0; i < p_vertex_array_len; i++) {730Vector2 vec = src[i];731if (!r_uv_scale.is_zero_approx()) {732// Normalize into 0-1 from possible range -uv_scale - uv_scale.733vec = vec / (Vector2(r_uv_scale.x, r_uv_scale.y)) + Vector2(0.5, 0.5);734}735736uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };737memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);738}739} else {740for (int i = 0; i < p_vertex_array_len; i++) {741float uv[2] = { (float)src[i].x, (float)src[i].y };742memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);743}744}745} break;746747case RS::ARRAY_TEX_UV2: {748ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);749750Vector<Vector2> array = p_arrays[ai];751752ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);753754const Vector2 *src = array.ptr();755756if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {757for (int i = 0; i < p_vertex_array_len; i++) {758Vector2 vec = src[i];759if (!r_uv_scale.is_zero_approx()) {760// Normalize into 0-1 from possible range -uv_scale - uv_scale.761vec = vec / (Vector2(r_uv_scale.z, r_uv_scale.w)) + Vector2(0.5, 0.5);762}763uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };764memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);765}766} else {767for (int i = 0; i < p_vertex_array_len; i++) {768float uv[2] = { (float)src[i].x, (float)src[i].y };769memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);770}771}772} break;773case RS::ARRAY_CUSTOM0:774case RS::ARRAY_CUSTOM1:775case RS::ARRAY_CUSTOM2:776case RS::ARRAY_CUSTOM3: {777uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (ai - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;778switch (type) {779case ARRAY_CUSTOM_RGBA8_UNORM:780case ARRAY_CUSTOM_RGBA8_SNORM:781case ARRAY_CUSTOM_RG_HALF: {782// Size 4783ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);784785Vector<uint8_t> array = p_arrays[ai];786787ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);788789const uint8_t *src = array.ptr();790791for (int i = 0; i < p_vertex_array_len; i++) {792memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 4], 4);793}794795} break;796case ARRAY_CUSTOM_RGBA_HALF: {797// Size 8798ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);799800Vector<uint8_t> array = p_arrays[ai];801802ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 8, ERR_INVALID_PARAMETER);803804const uint8_t *src = array.ptr();805806for (int i = 0; i < p_vertex_array_len; i++) {807memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 8], 8);808}809} break;810case ARRAY_CUSTOM_R_FLOAT:811case ARRAY_CUSTOM_RG_FLOAT:812case ARRAY_CUSTOM_RGB_FLOAT:813case ARRAY_CUSTOM_RGBA_FLOAT: {814// RF815ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);816817Vector<float> array = p_arrays[ai];818int32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;819820ERR_FAIL_COND_V(array.size() != p_vertex_array_len * s, ERR_INVALID_PARAMETER);821822const float *src = array.ptr();823824for (int i = 0; i < p_vertex_array_len; i++) {825memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * s], sizeof(float) * s);826}827} break;828default: {829}830}831832} break;833case RS::ARRAY_WEIGHTS: {834Variant::Type type = p_arrays[ai].get_type();835ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY, ERR_INVALID_PARAMETER);836uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;837if (type == Variant::PACKED_FLOAT32_ARRAY) {838Vector<float> array = p_arrays[ai];839ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);840const float *src = array.ptr();841{842uint16_t data[8];843for (int i = 0; i < p_vertex_array_len; i++) {844for (uint32_t j = 0; j < bone_count; j++) {845data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);846}847848memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);849}850}851} else { // PACKED_FLOAT64_ARRAY852Vector<double> array = p_arrays[ai];853ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);854const double *src = array.ptr();855{856uint16_t data[8];857for (int i = 0; i < p_vertex_array_len; i++) {858for (uint32_t j = 0; j < bone_count; j++) {859data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);860}861862memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);863}864}865}866} break;867case RS::ARRAY_BONES: {868ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);869870Vector<int> array = p_arrays[ai];871872uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;873874ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);875876const int *src = array.ptr();877878uint16_t data[8];879880for (int i = 0; i < p_vertex_array_len; i++) {881for (uint32_t j = 0; j < bone_count; j++) {882data[j] = src[i * bone_count + j];883max_bone = MAX(data[j], max_bone);884}885886memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);887}888889} break;890891case RS::ARRAY_INDEX: {892ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);893ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);894ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);895896Vector<int> indices = p_arrays[ai];897ERR_FAIL_COND_V(indices.is_empty(), ERR_INVALID_PARAMETER);898ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);899900/* determine whether using 16 or 32 bits indices */901902const int *src = indices.ptr();903904for (int i = 0; i < p_index_array_len; i++) {905if (p_vertex_array_len <= (1 << 16) && p_vertex_array_len > 0) {906uint16_t v = src[i];907908memcpy(&iw[i * 2], &v, 2);909} else {910uint32_t v = src[i];911912memcpy(&iw[i * 4], &v, 4);913}914}915} break;916default: {917ERR_FAIL_V(ERR_INVALID_DATA);918}919}920}921922if (p_format & RS::ARRAY_FORMAT_BONES) {923// Create AABBs for each detected bone.924int total_bones = max_bone + 1;925926bool first = r_bone_aabb.is_empty();927928r_bone_aabb.resize(total_bones);929930int weight_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;931932if (first) {933for (int i = 0; i < total_bones; i++) {934r_bone_aabb.write[i].size = Vector3(-1, -1, -1); // Negative means unused.935}936}937938Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];939Vector<int> bones = p_arrays[RS::ARRAY_BONES];940Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS];941942bool any_valid = false;943944if (vertices.size() && bones.size() == vertices.size() * weight_count && weights.size() == bones.size()) {945int vs = vertices.size();946const Vector3 *rv = vertices.ptr();947const int *rb = bones.ptr();948const float *rw = weights.ptr();949950AABB *bptr = r_bone_aabb.ptrw();951952for (int i = 0; i < vs; i++) {953Vector3 v = rv[i];954for (int j = 0; j < weight_count; j++) {955int idx = rb[i * weight_count + j];956float w = rw[i * weight_count + j];957if (w == 0) {958continue; //break;959}960ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);961962if (bptr[idx].size.x < 0) {963// First964bptr[idx] = AABB(v, SMALL_VEC3);965any_valid = true;966} else {967bptr[idx].expand_to(v);968}969}970}971}972973if (!any_valid && first) {974r_bone_aabb.clear();975}976}977return OK;978}979980uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const {981ERR_FAIL_INDEX_V(p_array_index, ARRAY_MAX, 0);982p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;983uint32_t offsets[ARRAY_MAX];984uint32_t vstr;985uint32_t ntstr;986uint32_t astr;987uint32_t sstr;988mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);989return offsets[p_array_index];990}991992uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {993p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;994uint32_t offsets[ARRAY_MAX];995uint32_t vstr;996uint32_t ntstr;997uint32_t astr;998uint32_t sstr;999mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1000return vstr;1001}10021003uint32_t RenderingServer::mesh_surface_get_format_normal_tangent_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1004p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1005uint32_t offsets[ARRAY_MAX];1006uint32_t vstr;1007uint32_t ntstr;1008uint32_t astr;1009uint32_t sstr;1010mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1011return ntstr;1012}10131014uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1015p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1016uint32_t offsets[ARRAY_MAX];1017uint32_t vstr;1018uint32_t ntstr;1019uint32_t astr;1020uint32_t sstr;1021mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1022return astr;1023}10241025uint32_t RenderingServer::mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1026p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1027uint32_t offsets[ARRAY_MAX];1028uint32_t vstr;1029uint32_t ntstr;1030uint32_t astr;1031uint32_t sstr;1032mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1033return sstr;1034}10351036uint32_t RenderingServer::mesh_surface_get_format_index_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1037if (!(p_format & ARRAY_FORMAT_INDEX)) {1038return 0;1039}10401041// Determine whether using 16 or 32 bits indices.1042if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1043return 2;1044} else {1045return 4;1046}1047}10481049void RenderingServer::mesh_surface_make_offsets_from_format(uint64_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t &r_vertex_element_size, uint32_t &r_normal_element_size, uint32_t &r_attrib_element_size, uint32_t &r_skin_element_size) const {1050r_vertex_element_size = 0;1051r_normal_element_size = 0;1052r_attrib_element_size = 0;1053r_skin_element_size = 0;10541055uint32_t *size_accum = nullptr;10561057for (int i = 0; i < RS::ARRAY_MAX; i++) {1058r_offsets[i] = 0; // Reset10591060if (i == RS::ARRAY_VERTEX) {1061size_accum = &r_vertex_element_size;1062} else if (i == RS::ARRAY_NORMAL) {1063size_accum = &r_normal_element_size;1064} else if (i == RS::ARRAY_COLOR) {1065size_accum = &r_attrib_element_size;1066} else if (i == RS::ARRAY_BONES) {1067size_accum = &r_skin_element_size;1068}10691070if (!(p_format & (1ULL << i))) { // No array1071continue;1072}10731074int elem_size = 0;10751076switch (i) {1077case RS::ARRAY_VERTEX: {1078if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {1079elem_size = 2;1080} else {1081elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 2 : 3;1082}10831084elem_size *= sizeof(float);1085} break;1086case RS::ARRAY_NORMAL: {1087elem_size = 4;1088} break;1089case RS::ARRAY_TANGENT: {1090elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 0 : 4;1091} break;1092case RS::ARRAY_COLOR: {1093elem_size = 4;1094} break;1095case RS::ARRAY_TEX_UV: {1096elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;1097} break;1098case RS::ARRAY_TEX_UV2: {1099elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;1100} break;1101case RS::ARRAY_CUSTOM0:1102case RS::ARRAY_CUSTOM1:1103case RS::ARRAY_CUSTOM2:1104case RS::ARRAY_CUSTOM3: {1105uint64_t format = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + (ARRAY_FORMAT_CUSTOM_BITS * (i - ARRAY_CUSTOM0)))) & ARRAY_FORMAT_CUSTOM_MASK;1106switch (format) {1107case ARRAY_CUSTOM_RGBA8_UNORM: {1108elem_size = 4;1109} break;1110case ARRAY_CUSTOM_RGBA8_SNORM: {1111elem_size = 4;1112} break;1113case ARRAY_CUSTOM_RG_HALF: {1114elem_size = 4;1115} break;1116case ARRAY_CUSTOM_RGBA_HALF: {1117elem_size = 8;1118} break;1119case ARRAY_CUSTOM_R_FLOAT: {1120elem_size = 4;1121} break;1122case ARRAY_CUSTOM_RG_FLOAT: {1123elem_size = 8;1124} break;1125case ARRAY_CUSTOM_RGB_FLOAT: {1126elem_size = 12;1127} break;1128case ARRAY_CUSTOM_RGBA_FLOAT: {1129elem_size = 16;1130} break;1131}1132} break;1133case RS::ARRAY_WEIGHTS: {1134uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;1135elem_size = sizeof(uint16_t) * bone_count;11361137} break;1138case RS::ARRAY_BONES: {1139uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;1140elem_size = sizeof(uint16_t) * bone_count;1141} break;1142case RS::ARRAY_INDEX: {1143if (p_index_len <= 0) {1144ERR_PRINT("index_array_len==NO_INDEX_ARRAY");1145break;1146}1147/* determine whether using 16 or 32 bits indices */1148if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1149elem_size = 2;1150} else {1151elem_size = 4;1152}1153r_offsets[i] = elem_size;1154continue;1155}1156default: {1157ERR_FAIL();1158}1159}11601161if (size_accum != nullptr) {1162r_offsets[i] = (*size_accum);1163if (i == RS::ARRAY_NORMAL || i == RS::ARRAY_TANGENT) {1164r_offsets[i] += r_vertex_element_size * p_vertex_len;1165}1166(*size_accum) += elem_size;1167} else {1168r_offsets[i] = 0;1169}1170}1171}11721173Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint64_t p_compress_format) {1174ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);1175ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);11761177uint64_t format = 0;11781179// Validation1180int index_array_len = 0;1181int array_len = 0;11821183for (int i = 0; i < p_arrays.size(); i++) {1184if (p_arrays[i].get_type() == Variant::NIL) {1185continue;1186}11871188format |= (1ULL << i);11891190if (i == RS::ARRAY_VERTEX) {1191switch (p_arrays[i].get_type()) {1192case Variant::PACKED_VECTOR2_ARRAY: {1193Vector<Vector2> v2 = p_arrays[i];1194array_len = v2.size();1195format |= ARRAY_FLAG_USE_2D_VERTICES;1196} break;1197case Variant::PACKED_VECTOR3_ARRAY: {1198ERR_FAIL_COND_V(p_compress_format & ARRAY_FLAG_USE_2D_VERTICES, ERR_INVALID_PARAMETER);1199Vector<Vector3> v3 = p_arrays[i];1200array_len = v3.size();1201} break;1202default: {1203ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Vertex array must be a PackedVector2Array or PackedVector3Array.");1204} break;1205}1206ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);1207} else if (i == RS::ARRAY_NORMAL) {1208if (p_arrays[RS::ARRAY_TANGENT].get_type() == Variant::NIL) {1209// We must use tangents if using normals.1210format |= (1ULL << RS::ARRAY_TANGENT);1211}1212} else if (i == RS::ARRAY_BONES) {1213switch (p_arrays[i].get_type()) {1214case Variant::PACKED_INT32_ARRAY: {1215Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];1216Vector<int32_t> bones = p_arrays[i];1217int32_t bone_8_group_count = bones.size() / (ARRAY_WEIGHTS_SIZE * 2);1218int32_t vertex_count = vertices.size();1219if (vertex_count == bone_8_group_count) {1220format |= RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;1221}1222} break;1223default: {1224ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Bones array must be a PackedInt32Array.");1225} break;1226}1227} else if (i == RS::ARRAY_INDEX) {1228index_array_len = PackedInt32Array(p_arrays[i]).size();1229}1230}12311232if (p_blend_shapes.size()) {1233// Validate format for morphs.1234for (int i = 0; i < p_blend_shapes.size(); i++) {1235uint32_t bsformat = 0;1236Array arr = p_blend_shapes[i];1237for (int j = 0; j < arr.size(); j++) {1238if (arr[j].get_type() != Variant::NIL) {1239bsformat |= (1 << j);1240}1241}1242if (bsformat & RS::ARRAY_FORMAT_NORMAL) {1243// We must use tangents if using normals.1244bsformat |= RS::ARRAY_FORMAT_TANGENT;1245}12461247ERR_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.");1248}1249}12501251for (uint32_t i = 0; i < RS::ARRAY_CUSTOM_COUNT; ++i) {1252// Include custom array format type.1253if (format & (1ULL << (ARRAY_CUSTOM0 + i))) {1254format |= (RS::ARRAY_FORMAT_CUSTOM_MASK << (RS::ARRAY_FORMAT_CUSTOM_BASE + i * RS::ARRAY_FORMAT_CUSTOM_BITS)) & p_compress_format;1255}1256}12571258uint32_t offsets[RS::ARRAY_MAX];12591260uint32_t vertex_element_size;1261uint32_t normal_element_size;1262uint32_t attrib_element_size;1263uint32_t skin_element_size;12641265uint64_t mask = (1ULL << ARRAY_MAX) - 1ULL;1266format |= (~mask) & p_compress_format; // Make the full format.12671268// Force version to the current version as this function will always return a surface with the current version.1269format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);1270format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);12711272mesh_surface_make_offsets_from_format(format, array_len, index_array_len, offsets, vertex_element_size, normal_element_size, attrib_element_size, skin_element_size);12731274if ((format & RS::ARRAY_FORMAT_VERTEX) == 0 && !(format & RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY)) {1275ERR_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.");1276// Set the flag here after warning to suppress errors down the pipeline.1277format |= RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY;1278}12791280if ((format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && ((format & RS::ARRAY_FORMAT_NORMAL) || (format & RS::ARRAY_FORMAT_TANGENT))) {1281// If using normals or tangents, then we need all three.1282ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_VERTEX), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using normals or tangents without vertex array.");1283ERR_FAIL_COND_V_MSG(!(format & RS::ARRAY_FORMAT_NORMAL), ERR_INVALID_PARAMETER, "Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using tangents without normal array.");1284}12851286int vertex_array_size = (vertex_element_size + normal_element_size) * array_len;1287int attrib_array_size = attrib_element_size * array_len;1288int skin_array_size = skin_element_size * array_len;1289int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len;12901291Vector<uint8_t> vertex_array;1292vertex_array.resize(vertex_array_size);12931294Vector<uint8_t> attrib_array;1295attrib_array.resize(attrib_array_size);12961297Vector<uint8_t> skin_array;1298skin_array.resize(skin_array_size);12991300Vector<uint8_t> index_array;1301index_array.resize(index_array_size);13021303AABB aabb;1304Vector<AABB> bone_aabb;13051306Vector4 uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);13071308Error err = _surface_set_data(p_arrays, format, offsets, vertex_element_size, normal_element_size, attrib_element_size, skin_element_size, vertex_array, attrib_array, skin_array, array_len, index_array, index_array_len, aabb, bone_aabb, uv_scale);1309ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Invalid array format for surface.");13101311Vector<uint8_t> blend_shape_data;13121313if (p_blend_shapes.size()) {1314uint32_t bs_format = format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK;1315for (int i = 0; i < p_blend_shapes.size(); i++) {1316Vector<uint8_t> vertex_array_shape;1317vertex_array_shape.resize(vertex_array_size);1318Vector<uint8_t> noindex;1319Vector<uint8_t> noattrib;1320Vector<uint8_t> noskin;13211322AABB laabb;1323Vector4 bone_uv_scale; // Not used.1324Error err2 = _surface_set_data(p_blend_shapes[i], bs_format, offsets, vertex_element_size, normal_element_size, 0, 0, vertex_array_shape, noattrib, noskin, array_len, noindex, 0, laabb, bone_aabb, bone_uv_scale);1325aabb.merge_with(laabb);1326ERR_FAIL_COND_V_MSG(err2 != OK, ERR_INVALID_DATA, "Invalid blend shape array format for surface.");13271328blend_shape_data.append_array(vertex_array_shape);1329}1330}1331Vector<SurfaceData::LOD> lods;1332if (index_array_len) {1333LocalVector<Variant> keys = p_lods.get_key_list();1334keys.sort(); // otherwise lod levels may get skipped1335for (const Variant &E : keys) {1336float distance = E;1337ERR_CONTINUE(distance <= 0.0);1338Vector<int> indices = p_lods[E];1339ERR_CONTINUE(indices.is_empty());1340uint32_t index_count = indices.size();1341ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller..13421343const int *r = indices.ptr();13441345Vector<uint8_t> data;1346if (array_len <= 65536) {1347// 16 bits indices1348data.resize(indices.size() * 2);1349uint8_t *w = data.ptrw();1350uint16_t *index_ptr = (uint16_t *)w;1351for (uint32_t i = 0; i < index_count; i++) {1352index_ptr[i] = r[i];1353}1354} else {1355// 32 bits indices1356data.resize(indices.size() * 4);1357uint8_t *w = data.ptrw();1358uint32_t *index_ptr = (uint32_t *)w;1359for (uint32_t i = 0; i < index_count; i++) {1360index_ptr[i] = r[i];1361}1362}13631364SurfaceData::LOD lod;1365lod.edge_length = distance;1366lod.index_data = data;1367lods.push_back(lod);1368}1369}13701371SurfaceData &surface_data = *r_surface_data;1372surface_data.format = format;1373surface_data.primitive = p_primitive;1374surface_data.aabb = aabb;1375surface_data.vertex_data = vertex_array;1376surface_data.attribute_data = attrib_array;1377surface_data.skin_data = skin_array;1378surface_data.vertex_count = array_len;1379surface_data.index_data = index_array;1380surface_data.index_count = index_array_len;1381surface_data.blend_shape_data = blend_shape_data;1382surface_data.bone_aabbs = bone_aabb;1383surface_data.lods = lods;1384surface_data.uv_scale = uv_scale;13851386return OK;1387}13881389void 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) {1390SurfaceData sd;1391Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);1392if (err != OK) {1393return;1394}1395mesh_add_surface(p_mesh, sd);1396}13971398Array RenderingServer::_get_array_from_surface(uint64_t p_format, Vector<uint8_t> p_vertex_data, Vector<uint8_t> p_attrib_data, Vector<uint8_t> p_skin_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len, const AABB &p_aabb, const Vector4 &p_uv_scale) const {1399uint32_t offsets[RS::ARRAY_MAX];14001401uint32_t vertex_elem_size;1402uint32_t normal_elem_size;1403uint32_t attrib_elem_size;1404uint32_t skin_elem_size;1405mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets, vertex_elem_size, normal_elem_size, attrib_elem_size, skin_elem_size);14061407Array ret;1408ret.resize(RS::ARRAY_MAX);14091410const uint8_t *r = p_vertex_data.ptr();1411const uint8_t *ar = p_attrib_data.ptr();1412const uint8_t *sr = p_skin_data.ptr();14131414for (int i = 0; i < RS::ARRAY_MAX; i++) {1415if (!(p_format & (1ULL << i))) {1416continue;1417}14181419switch (i) {1420case RS::ARRAY_VERTEX: {1421if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {1422Vector<Vector2> arr_2d;1423arr_2d.resize(p_vertex_len);14241425{1426Vector2 *w = arr_2d.ptrw();14271428for (int j = 0; j < p_vertex_len; j++) {1429const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);1430w[j] = Vector2(v[0], v[1]);1431}1432}14331434ret[i] = arr_2d;1435} else {1436Vector<Vector3> arr_3d;1437arr_3d.resize(p_vertex_len);14381439{1440Vector3 *w = arr_3d.ptrw();14411442if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1443// We only have vertices to read, so just read them and skip everything else.1444if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {1445for (int j = 0; j < p_vertex_len; j++) {1446const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);1447Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);1448w[j] = (vec * p_aabb.size) + p_aabb.position;1449}1450continue;1451}14521453Vector<Vector3> normals;1454normals.resize(p_vertex_len);1455Vector3 *normalsw = normals.ptrw();14561457Vector<float> tangents;1458tangents.resize(p_vertex_len * 4);1459float *tangentsw = tangents.ptrw();14601461for (int j = 0; j < p_vertex_len; j++) {1462const uint32_t n = *(const uint32_t *)&r[j * normal_elem_size + offsets[RS::ARRAY_NORMAL]];1463Vector3 axis = Vector3::octahedron_decode(Vector2((n & 0xFFFF) / 65535.0, ((n >> 16) & 0xFFFF) / 65535.0));14641465const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);1466Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);1467float angle = float(v[3]) / 65535.0;1468w[j] = (vec * p_aabb.size) + p_aabb.position;14691470Vector3 normal;1471Vector4 tan;1472_get_tbn_from_axis_angle(axis, angle, normal, tan);14731474normalsw[j] = normal;1475tangentsw[j * 4 + 0] = tan.x;1476tangentsw[j * 4 + 1] = tan.y;1477tangentsw[j * 4 + 2] = tan.z;1478tangentsw[j * 4 + 3] = tan.w;1479}1480ret[RS::ARRAY_NORMAL] = normals;1481ret[RS::ARRAY_TANGENT] = tangents;14821483} else {1484for (int j = 0; j < p_vertex_len; j++) {1485const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);1486w[j] = Vector3(v[0], v[1], v[2]);1487}1488}1489}14901491ret[i] = arr_3d;1492}14931494} break;1495case RS::ARRAY_NORMAL: {1496if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {1497Vector<Vector3> arr;1498arr.resize(p_vertex_len);14991500Vector3 *w = arr.ptrw();15011502for (int j = 0; j < p_vertex_len; j++) {1503const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];15041505w[j] = Vector3::octahedron_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0));1506}15071508ret[i] = arr;1509}1510} break;15111512case RS::ARRAY_TANGENT: {1513if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {1514Vector<float> arr;1515arr.resize(p_vertex_len * 4);15161517float *w = arr.ptrw();15181519for (int j = 0; j < p_vertex_len; j++) {1520const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];1521float tangent_sign;1522Vector3 res = Vector3::octahedron_tangent_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0), &tangent_sign);1523w[j * 4 + 0] = res.x;1524w[j * 4 + 1] = res.y;1525w[j * 4 + 2] = res.z;1526w[j * 4 + 3] = tangent_sign;1527}15281529ret[i] = arr;1530}1531} break;1532case RS::ARRAY_COLOR: {1533Vector<Color> arr;1534arr.resize(p_vertex_len);15351536Color *w = arr.ptrw();15371538for (int32_t j = 0; j < p_vertex_len; j++) {1539const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);15401541w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);1542}15431544ret[i] = arr;1545} break;1546case RS::ARRAY_TEX_UV: {1547Vector<Vector2> arr;1548arr.resize(p_vertex_len);15491550Vector2 *w = arr.ptrw();1551if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1552for (int j = 0; j < p_vertex_len; j++) {1553const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);1554Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);1555if (!p_uv_scale.is_zero_approx()) {1556vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.x, p_uv_scale.y);1557}15581559w[j] = vec;1560}1561} else {1562for (int j = 0; j < p_vertex_len; j++) {1563const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1564w[j] = Vector2(v[0], v[1]);1565}1566}1567ret[i] = arr;1568} break;15691570case RS::ARRAY_TEX_UV2: {1571Vector<Vector2> arr;1572arr.resize(p_vertex_len);15731574Vector2 *w = arr.ptrw();15751576if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1577for (int j = 0; j < p_vertex_len; j++) {1578const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);1579Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);1580if (!p_uv_scale.is_zero_approx()) {1581vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.z, p_uv_scale.w);1582}1583w[j] = vec;1584}1585} else {1586for (int j = 0; j < p_vertex_len; j++) {1587const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1588w[j] = Vector2(v[0], v[1]);1589}1590}15911592ret[i] = arr;15931594} break;1595case RS::ARRAY_CUSTOM0:1596case RS::ARRAY_CUSTOM1:1597case RS::ARRAY_CUSTOM2:1598case RS::ARRAY_CUSTOM3: {1599uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (i - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;1600switch (type) {1601case ARRAY_CUSTOM_RGBA8_UNORM:1602case ARRAY_CUSTOM_RGBA8_SNORM:1603case ARRAY_CUSTOM_RG_HALF:1604case ARRAY_CUSTOM_RGBA_HALF: {1605// Size 41606int s = type == ARRAY_CUSTOM_RGBA_HALF ? 8 : 4;1607Vector<uint8_t> arr;1608arr.resize(p_vertex_len * s);16091610uint8_t *w = arr.ptrw();16111612for (int j = 0; j < p_vertex_len; j++) {1613const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);1614memcpy(&w[j * s], v, s);1615}16161617ret[i] = arr;16181619} break;1620case ARRAY_CUSTOM_R_FLOAT:1621case ARRAY_CUSTOM_RG_FLOAT:1622case ARRAY_CUSTOM_RGB_FLOAT:1623case ARRAY_CUSTOM_RGBA_FLOAT: {1624uint32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;16251626Vector<float> arr;1627arr.resize(s * p_vertex_len);16281629float *w = arr.ptrw();16301631for (int j = 0; j < p_vertex_len; j++) {1632const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1633memcpy(&w[j * s], v, s * sizeof(float));1634}1635ret[i] = arr;16361637} break;1638default: {1639}1640}16411642} break;1643case RS::ARRAY_WEIGHTS: {1644uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;16451646Vector<float> arr;1647arr.resize(p_vertex_len * bone_count);1648{1649float *w = arr.ptrw();16501651for (int j = 0; j < p_vertex_len; j++) {1652const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];1653for (uint32_t k = 0; k < bone_count; k++) {1654w[j * bone_count + k] = float(v[k] / 65535.0);1655}1656}1657}16581659ret[i] = arr;16601661} break;1662case RS::ARRAY_BONES: {1663uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;16641665Vector<int> arr;1666arr.resize(p_vertex_len * bone_count);16671668int *w = arr.ptrw();16691670for (int j = 0; j < p_vertex_len; j++) {1671const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];1672for (uint32_t k = 0; k < bone_count; k++) {1673w[j * bone_count + k] = v[k];1674}1675}16761677ret[i] = arr;16781679} break;1680case RS::ARRAY_INDEX: {1681/* determine whether using 16 or 32 bits indices */16821683const uint8_t *ir = p_index_data.ptr();16841685Vector<int> arr;1686arr.resize(p_index_len);1687if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1688int *w = arr.ptrw();16891690for (int j = 0; j < p_index_len; j++) {1691const uint16_t *v = (const uint16_t *)&ir[j * 2];1692w[j] = *v;1693}1694} else {1695int *w = arr.ptrw();16961697for (int j = 0; j < p_index_len; j++) {1698const int *v = (const int *)&ir[j * 4];1699w[j] = *v;1700}1701}1702ret[i] = arr;1703} break;1704default: {1705ERR_FAIL_V(ret);1706}1707}1708}17091710return ret;1711}17121713Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {1714SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1715return mesh_create_arrays_from_surface_data(sd);1716}17171718Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {1719SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1720ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());17211722Dictionary ret;17231724for (int i = 0; i < sd.lods.size(); i++) {1725Vector<int> lods;1726if (sd.vertex_count <= 65536) {1727uint32_t lc = sd.lods[i].index_data.size() / 2;1728lods.resize(lc);1729const uint8_t *r = sd.lods[i].index_data.ptr();1730const uint16_t *rptr = (const uint16_t *)r;1731int *w = lods.ptrw();1732for (uint32_t j = 0; j < lc; j++) {1733w[j] = rptr[j];1734}1735} else {1736uint32_t lc = sd.lods[i].index_data.size() / 4;1737lods.resize(lc);1738const uint8_t *r = sd.lods[i].index_data.ptr();1739const uint32_t *rptr = (const uint32_t *)r;1740int *w = lods.ptrw();1741for (uint32_t j = 0; j < lc; j++) {1742w[j] = rptr[j];1743}1744}17451746ret[sd.lods[i].edge_length] = lods;1747}17481749return ret;1750}17511752TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {1753SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1754ERR_FAIL_COND_V(sd.vertex_count == 0, Array());17551756Vector<uint8_t> blend_shape_data = sd.blend_shape_data;17571758if (blend_shape_data.size() > 0) {1759uint32_t bs_offsets[RS::ARRAY_MAX];1760uint32_t bs_format = (sd.format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK);1761uint32_t vertex_elem_size;1762uint32_t normal_elem_size;1763uint32_t attrib_elem_size;1764uint32_t skin_elem_size;17651766mesh_surface_make_offsets_from_format(bs_format, sd.vertex_count, 0, bs_offsets, vertex_elem_size, normal_elem_size, attrib_elem_size, skin_elem_size);17671768int divisor = (vertex_elem_size + normal_elem_size) * sd.vertex_count;1769ERR_FAIL_COND_V((blend_shape_data.size() % divisor) != 0, Array());17701771uint32_t blend_shape_count = blend_shape_data.size() / divisor;17721773ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array());17741775TypedArray<Array> blend_shape_array;1776blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh));1777for (uint32_t i = 0; i < blend_shape_count; i++) {1778Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor);1779Vector<uint8_t> unused;1780blend_shape_array.set(i, _get_array_from_surface(bs_format, bs_data, unused, unused, sd.vertex_count, unused, 0, sd.aabb, sd.uv_scale));1781}17821783return blend_shape_array;1784} else {1785return TypedArray<Array>();1786}1787}17881789Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {1790Vector<uint8_t> vertex_data = p_data.vertex_data;1791Vector<uint8_t> attrib_data = p_data.attribute_data;1792Vector<uint8_t> skin_data = p_data.skin_data;17931794ERR_FAIL_COND_V(vertex_data.is_empty() && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array());1795int vertex_len = p_data.vertex_count;17961797Vector<uint8_t> index_data = p_data.index_data;1798int index_len = p_data.index_count;17991800uint64_t format = p_data.format;18011802return _get_array_from_surface(format, vertex_data, attrib_data, skin_data, vertex_len, index_data, index_len, p_data.aabb, p_data.uv_scale);1803}1804#if 01805Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {1806Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);1807Array arr;1808for (int i = 0; i < vec.size(); i++) {1809arr[i] = vec[i];1810}1811return arr;1812}1813#endif18141815Rect2 RenderingServer::debug_canvas_item_get_rect(RID p_item) {1816#ifdef TOOLS_ENABLED1817return _debug_canvas_item_get_rect(p_item);1818#else1819return Rect2();1820#endif1821}18221823int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) {1824switch (p_type) {1825case RS::GLOBAL_VAR_TYPE_BOOL:1826return ShaderLanguage::TYPE_BOOL;1827case RS::GLOBAL_VAR_TYPE_BVEC2:1828return ShaderLanguage::TYPE_BVEC2;1829case RS::GLOBAL_VAR_TYPE_BVEC3:1830return ShaderLanguage::TYPE_BVEC3;1831case RS::GLOBAL_VAR_TYPE_BVEC4:1832return ShaderLanguage::TYPE_BVEC4;1833case RS::GLOBAL_VAR_TYPE_INT:1834return ShaderLanguage::TYPE_INT;1835case RS::GLOBAL_VAR_TYPE_IVEC2:1836return ShaderLanguage::TYPE_IVEC2;1837case RS::GLOBAL_VAR_TYPE_IVEC3:1838return ShaderLanguage::TYPE_IVEC3;1839case RS::GLOBAL_VAR_TYPE_IVEC4:1840return ShaderLanguage::TYPE_IVEC4;1841case RS::GLOBAL_VAR_TYPE_RECT2I:1842return ShaderLanguage::TYPE_IVEC4;1843case RS::GLOBAL_VAR_TYPE_UINT:1844return ShaderLanguage::TYPE_UINT;1845case RS::GLOBAL_VAR_TYPE_UVEC2:1846return ShaderLanguage::TYPE_UVEC2;1847case RS::GLOBAL_VAR_TYPE_UVEC3:1848return ShaderLanguage::TYPE_UVEC3;1849case RS::GLOBAL_VAR_TYPE_UVEC4:1850return ShaderLanguage::TYPE_UVEC4;1851case RS::GLOBAL_VAR_TYPE_FLOAT:1852return ShaderLanguage::TYPE_FLOAT;1853case RS::GLOBAL_VAR_TYPE_VEC2:1854return ShaderLanguage::TYPE_VEC2;1855case RS::GLOBAL_VAR_TYPE_VEC3:1856return ShaderLanguage::TYPE_VEC3;1857case RS::GLOBAL_VAR_TYPE_VEC4:1858return ShaderLanguage::TYPE_VEC4;1859case RS::GLOBAL_VAR_TYPE_COLOR:1860return ShaderLanguage::TYPE_VEC4;1861case RS::GLOBAL_VAR_TYPE_RECT2:1862return ShaderLanguage::TYPE_VEC4;1863case RS::GLOBAL_VAR_TYPE_MAT2:1864return ShaderLanguage::TYPE_MAT2;1865case RS::GLOBAL_VAR_TYPE_MAT3:1866return ShaderLanguage::TYPE_MAT3;1867case RS::GLOBAL_VAR_TYPE_MAT4:1868return ShaderLanguage::TYPE_MAT4;1869case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D:1870return ShaderLanguage::TYPE_MAT3;1871case RS::GLOBAL_VAR_TYPE_TRANSFORM:1872return ShaderLanguage::TYPE_MAT4;1873case RS::GLOBAL_VAR_TYPE_SAMPLER2D:1874return ShaderLanguage::TYPE_SAMPLER2D;1875case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY:1876return ShaderLanguage::TYPE_SAMPLER2DARRAY;1877case RS::GLOBAL_VAR_TYPE_SAMPLER3D:1878return ShaderLanguage::TYPE_SAMPLER3D;1879case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE:1880return ShaderLanguage::TYPE_SAMPLERCUBE;1881case RS::GLOBAL_VAR_TYPE_SAMPLEREXT:1882return ShaderLanguage::TYPE_SAMPLEREXT;1883default:1884return ShaderLanguage::TYPE_MAX; // Invalid or not found.1885}1886}18871888RenderingDevice *RenderingServer::get_rendering_device() const {1889// Return the rendering device we're using globally.1890return RenderingDevice::get_singleton();1891}18921893RenderingDevice *RenderingServer::create_local_rendering_device() const {1894RenderingDevice *device = RenderingDevice::get_singleton();1895if (!device) {1896return nullptr;1897}1898return device->create_local_device();1899}19001901static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {1902Vector<Ref<Image>> images;1903images.resize(p_layers.size());1904for (int i = 0; i < p_layers.size(); i++) {1905images.write[i] = p_layers[i];1906}1907return images;1908}1909RID RenderingServer::_texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type) {1910return texture_2d_layered_create(_get_imgvec(p_layers), p_layered_type);1911}1912RID 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) {1913return texture_3d_create(p_format, p_width, p_height, p_depth, p_mipmaps, _get_imgvec(p_data));1914}19151916void RenderingServer::_texture_3d_update(RID p_texture, const TypedArray<Image> &p_data) {1917texture_3d_update(p_texture, _get_imgvec(p_data));1918}19191920TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const {1921Vector<Ref<Image>> images = texture_3d_get(p_texture);1922TypedArray<Image> ret;1923ret.resize(images.size());1924for (int i = 0; i < images.size(); i++) {1925ret[i] = images[i];1926}1927return ret;1928}19291930TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const {1931List<PropertyInfo> l;1932get_shader_parameter_list(p_shader, &l);1933return convert_property_list(&l);1934}19351936static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) {1937ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RS::SurfaceData());1938ERR_FAIL_COND_V(!p_dictionary.has("format"), RS::SurfaceData());1939ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RS::SurfaceData());1940ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RS::SurfaceData());1941ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RS::SurfaceData());19421943RS::SurfaceData sd;19441945sd.primitive = RS::PrimitiveType(int(p_dictionary["primitive"]));1946sd.format = p_dictionary["format"];1947sd.vertex_data = p_dictionary["vertex_data"];1948if (p_dictionary.has("attribute_data")) {1949sd.attribute_data = p_dictionary["attribute_data"];1950}1951if (p_dictionary.has("skin_data")) {1952sd.skin_data = p_dictionary["skin_data"];1953}19541955sd.vertex_count = p_dictionary["vertex_count"];19561957if (p_dictionary.has("index_data")) {1958sd.index_data = p_dictionary["index_data"];1959ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RS::SurfaceData());1960sd.index_count = p_dictionary["index_count"];1961}19621963sd.aabb = p_dictionary["aabb"];1964if (p_dictionary.has("uv_scale")) {1965sd.uv_scale = p_dictionary["uv_scale"];1966}19671968if (p_dictionary.has("lods")) {1969Array lods = p_dictionary["lods"];1970for (int i = 0; i < lods.size(); i++) {1971Dictionary lod = lods[i];1972ERR_CONTINUE(!lod.has("edge_length"));1973ERR_CONTINUE(!lod.has("index_data"));1974RS::SurfaceData::LOD l;1975l.edge_length = lod["edge_length"];1976l.index_data = lod["index_data"];1977sd.lods.push_back(l);1978}1979}19801981if (p_dictionary.has("bone_aabbs")) {1982Array aabbs = p_dictionary["bone_aabbs"];1983for (int i = 0; i < aabbs.size(); i++) {1984AABB aabb = aabbs[i];1985sd.bone_aabbs.push_back(aabb);1986}1987}19881989if (p_dictionary.has("blend_shape_data")) {1990sd.blend_shape_data = p_dictionary["blend_shape_data"];1991}19921993if (p_dictionary.has("material")) {1994sd.material = p_dictionary["material"];1995}19961997return sd;1998}1999RID RenderingServer::_mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count) {2000Vector<RS::SurfaceData> surfaces;2001for (int i = 0; i < p_surfaces.size(); i++) {2002surfaces.push_back(_dict_to_surf(p_surfaces[i]));2003}2004return mesh_create_from_surfaces(surfaces);2005}2006void RenderingServer::_mesh_add_surface(RID p_mesh, const Dictionary &p_surface) {2007mesh_add_surface(p_mesh, _dict_to_surf(p_surface));2008}2009Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) {2010RS::SurfaceData sd = mesh_get_surface(p_mesh, p_idx);20112012Dictionary d;2013d["primitive"] = sd.primitive;2014d["format"] = sd.format;2015d["vertex_data"] = sd.vertex_data;2016if (sd.attribute_data.size()) {2017d["attribute_data"] = sd.attribute_data;2018}2019if (sd.skin_data.size()) {2020d["skin_data"] = sd.skin_data;2021}2022d["vertex_count"] = sd.vertex_count;2023if (sd.index_count) {2024d["index_data"] = sd.index_data;2025d["index_count"] = sd.index_count;2026}2027d["aabb"] = sd.aabb;2028d["uv_scale"] = sd.uv_scale;20292030if (sd.lods.size()) {2031Array lods;2032for (int i = 0; i < sd.lods.size(); i++) {2033Dictionary ld;2034ld["edge_length"] = sd.lods[i].edge_length;2035ld["index_data"] = sd.lods[i].index_data;2036lods.push_back(lods);2037}2038d["lods"] = lods;2039}20402041if (sd.bone_aabbs.size()) {2042Array aabbs;2043for (int i = 0; i < sd.bone_aabbs.size(); i++) {2044aabbs.push_back(sd.bone_aabbs[i]);2045}2046d["bone_aabbs"] = aabbs;2047}20482049if (sd.blend_shape_data.size()) {2050d["blend_shape_data"] = sd.blend_shape_data;2051}20522053if (sd.material.is_valid()) {2054d["material"] = sd.material;2055}2056return d;2057}20582059TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const {2060List<PropertyInfo> params;2061instance_geometry_get_shader_parameter_list(p_instance, ¶ms);2062return convert_property_list(¶ms);2063}20642065TypedArray<Dictionary> RenderingServer::_canvas_item_get_instance_shader_parameter_list(RID p_instance) const {2066List<PropertyInfo> params;2067canvas_item_get_instance_shader_parameter_list(p_instance, ¶ms);2068return convert_property_list(¶ms);2069}20702071TypedArray<Image> RenderingServer::_bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) {2072TypedArray<RID> mat_overrides;2073for (int i = 0; i < p_material_overrides.size(); i++) {2074mat_overrides.push_back(p_material_overrides[i]);2075}2076return bake_render_uv2(p_base, mat_overrides, p_image_size);2077}20782079void RenderingServer::_particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses) {2080Vector<Transform3D> tbposes;2081tbposes.resize(p_bind_poses.size());2082for (int i = 0; i < p_bind_poses.size(); i++) {2083tbposes.write[i] = p_bind_poses[i];2084}2085particles_set_trail_bind_poses(p_particles, tbposes);2086}20872088String RenderingServer::get_current_rendering_driver_name() const {2089// Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.2090return ::OS::get_singleton()->get_current_rendering_driver_name();2091}20922093String RenderingServer::get_current_rendering_method() const {2094// Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.2095return ::OS::get_singleton()->get_current_rendering_method();2096}20972098Vector<uint8_t> _convert_surface_version_1_to_surface_version_2(uint64_t p_format, Vector<uint8_t> p_vertex_data, uint32_t p_vertex_count, uint32_t p_old_stride, uint32_t p_vertex_size, uint32_t p_normal_size, uint32_t p_position_stride, uint32_t p_normal_tangent_stride) {2099Vector<uint8_t> new_vertex_data;2100new_vertex_data.resize(p_vertex_data.size());2101uint8_t *dst_vertex_ptr = new_vertex_data.ptrw();21022103const uint8_t *src_vertex_ptr = p_vertex_data.ptr();21042105uint32_t position_size = p_position_stride * p_vertex_count;21062107for (uint32_t j = 0; j < RS::ARRAY_COLOR; j++) {2108if (!(p_format & (1ULL << j))) {2109continue;2110}2111switch (j) {2112case RS::ARRAY_VERTEX: {2113if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {2114for (uint32_t i = 0; i < p_vertex_count; i++) {2115const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];2116float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];2117dst[0] = src[0];2118dst[1] = src[1];2119}2120} else {2121for (uint32_t i = 0; i < p_vertex_count; i++) {2122const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];2123float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];2124dst[0] = src[0];2125dst[1] = src[1];2126dst[2] = src[2];2127}2128}2129} break;2130case RS::ARRAY_NORMAL: {2131for (uint32_t i = 0; i < p_vertex_count; i++) {2132const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size];2133uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size];21342135dst[0] = src[0];2136dst[1] = src[1];2137}2138} break;2139case RS::ARRAY_TANGENT: {2140for (uint32_t i = 0; i < p_vertex_count; i++) {2141const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size + p_normal_size];2142uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size + p_normal_size];21432144dst[0] = src[0];2145dst[1] = src[1];2146}2147} break;2148}2149}2150return new_vertex_data;2151}21522153#ifdef TOOLS_ENABLED2154void RenderingServer::set_surface_upgrade_callback(SurfaceUpgradeCallback p_callback) {2155surface_upgrade_callback = p_callback;2156}21572158void RenderingServer::set_warn_on_surface_upgrade(bool p_warn) {2159warn_on_surface_upgrade = p_warn;2160}2161#endif21622163#ifndef DISABLE_DEPRECATED2164void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const String &p_path) {2165uint64_t surface_version = p_surface.format & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2166ERR_FAIL_COND_MSG(surface_version > ARRAY_FLAG_FORMAT_CURRENT_VERSION, "Cannot convert surface with version provided (" + itos((surface_version >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + ") to current version (" + itos((RS::ARRAY_FLAG_FORMAT_CURRENT_VERSION >> RS::ARRAY_FLAG_FORMAT_VERSION_SHIFT) & RS::ARRAY_FLAG_FORMAT_VERSION_MASK) + ")");21672168#ifdef TOOLS_ENABLED2169// Editor callback to ask user about re-saving all meshes.2170if (surface_upgrade_callback && warn_on_surface_upgrade) {2171surface_upgrade_callback();2172}21732174if (warn_on_surface_upgrade) {2175WARN_PRINT_ONCE_ED("At least one surface uses an old surface format and needs to be upgraded. The upgrade happens automatically at load time every time until the mesh is saved again or re-imported. Once saved (or re-imported), this mesh will be incompatible with earlier versions of Godot.");21762177if (!p_path.is_empty()) {2178WARN_PRINT("A surface of " + p_path + " uses an old surface format and needs to be upgraded.");2179}2180}2181#endif21822183if (surface_version == ARRAY_FLAG_FORMAT_VERSION_1) {2184// The only difference for now is that Version 1 uses interleaved vertex positions while version 2 does not.2185// I.e. PNTPNTPNT -> PPPNTNTNT.21862187if (p_surface.vertex_data.size() > 0 && p_surface.vertex_count > 0) {2188int vertex_size = 0;2189int normal_size = 0;2190int tangent_size = 0;2191if (p_surface.format & ARRAY_FORMAT_VERTEX) {2192if (p_surface.format & ARRAY_FLAG_USE_2D_VERTICES) {2193vertex_size = sizeof(float) * 2;2194} else {2195vertex_size = sizeof(float) * 3;2196}2197}2198if (p_surface.format & ARRAY_FORMAT_NORMAL) {2199normal_size += sizeof(uint16_t) * 2;2200}2201if (p_surface.format & ARRAY_FORMAT_TANGENT) {2202tangent_size = sizeof(uint16_t) * 2;2203}2204int stride = p_surface.vertex_data.size() / p_surface.vertex_count;2205int position_stride = vertex_size;2206int normal_tangent_stride = normal_size + tangent_size;22072208p_surface.vertex_data = _convert_surface_version_1_to_surface_version_2(p_surface.format, p_surface.vertex_data, p_surface.vertex_count, stride, vertex_size, normal_size, position_stride, normal_tangent_stride);22092210if (p_surface.blend_shape_data.size() > 0) {2211// The size of one blend shape.2212int divisor = (vertex_size + normal_size + tangent_size) * p_surface.vertex_count;2213ERR_FAIL_COND((p_surface.blend_shape_data.size() % divisor) != 0);22142215uint32_t blend_shape_count = p_surface.blend_shape_data.size() / divisor;22162217Vector<uint8_t> new_blend_shape_data;2218for (uint32_t i = 0; i < blend_shape_count; i++) {2219Vector<uint8_t> bs_data = p_surface.blend_shape_data.slice(i * divisor, (i + 1) * divisor);2220Vector<uint8_t> blend_shape = _convert_surface_version_1_to_surface_version_2(p_surface.format, bs_data, p_surface.vertex_count, stride, vertex_size, normal_size, position_stride, normal_tangent_stride);2221new_blend_shape_data.append_array(blend_shape);2222}22232224ERR_FAIL_COND(p_surface.blend_shape_data.size() != new_blend_shape_data.size());22252226p_surface.blend_shape_data = new_blend_shape_data;2227}2228}2229}2230p_surface.format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2231p_surface.format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2232}2233#endif22342235#ifdef TOOLS_ENABLED2236void RenderingServer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {2237const String pf = p_function;2238if (p_idx == 0) {2239if (pf == "global_shader_parameter_set" || pf == "global_shader_parameter_set_override" ||2240pf == "global_shader_parameter_get" || pf == "global_shader_parameter_get_type" || pf == "global_shader_parameter_remove") {2241for (const StringName &E : global_shader_parameter_get_list()) {2242r_options->push_back(E.operator String().quote());2243}2244} else if (pf == "has_os_feature") {2245for (const String E : { "\"rgtc\"", "\"s3tc\"", "\"bptc\"", "\"etc\"", "\"etc2\"", "\"astc\"" }) {2246r_options->push_back(E);2247}2248}2249}2250Object::get_argument_options(p_function, p_idx, r_options);2251}2252#endif22532254void RenderingServer::_bind_methods() {2255BIND_CONSTANT(NO_INDEX_ARRAY);2256BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);2257BIND_CONSTANT(CANVAS_ITEM_Z_MIN);2258BIND_CONSTANT(CANVAS_ITEM_Z_MAX);2259BIND_CONSTANT(CANVAS_LAYER_MIN);2260BIND_CONSTANT(CANVAS_LAYER_MAX);2261BIND_CONSTANT(MAX_GLOW_LEVELS);2262BIND_CONSTANT(MAX_CURSORS);2263BIND_CONSTANT(MAX_2D_DIRECTIONAL_LIGHTS);2264BIND_CONSTANT(MAX_MESH_SURFACES);22652266/* TEXTURE */22672268ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create);2269ClassDB::bind_method(D_METHOD("texture_2d_layered_create", "layers", "layered_type"), &RenderingServer::_texture_2d_layered_create);2270ClassDB::bind_method(D_METHOD("texture_3d_create", "format", "width", "height", "depth", "mipmaps", "data"), &RenderingServer::_texture_3d_create);2271ClassDB::bind_method(D_METHOD("texture_proxy_create", "base"), &RenderingServer::texture_proxy_create);2272ClassDB::bind_method(D_METHOD("texture_create_from_native_handle", "type", "format", "native_handle", "width", "height", "depth", "layers", "layered_type"), &RenderingServer::texture_create_from_native_handle, DEFVAL(1), DEFVAL(TEXTURE_LAYERED_2D_ARRAY));22732274ClassDB::bind_method(D_METHOD("texture_2d_update", "texture", "image", "layer"), &RenderingServer::texture_2d_update);2275ClassDB::bind_method(D_METHOD("texture_3d_update", "texture", "data"), &RenderingServer::_texture_3d_update);2276ClassDB::bind_method(D_METHOD("texture_proxy_update", "texture", "proxy_to"), &RenderingServer::texture_proxy_update);22772278ClassDB::bind_method(D_METHOD("texture_2d_placeholder_create"), &RenderingServer::texture_2d_placeholder_create);2279ClassDB::bind_method(D_METHOD("texture_2d_layered_placeholder_create", "layered_type"), &RenderingServer::texture_2d_layered_placeholder_create);2280ClassDB::bind_method(D_METHOD("texture_3d_placeholder_create"), &RenderingServer::texture_3d_placeholder_create);22812282ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get);2283ClassDB::bind_method(D_METHOD("texture_2d_layer_get", "texture", "layer"), &RenderingServer::texture_2d_layer_get);2284ClassDB::bind_method(D_METHOD("texture_3d_get", "texture"), &RenderingServer::_texture_3d_get);22852286ClassDB::bind_method(D_METHOD("texture_replace", "texture", "by_texture"), &RenderingServer::texture_replace);2287ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height"), &RenderingServer::texture_set_size_override);22882289ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &RenderingServer::texture_set_path);2290ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &RenderingServer::texture_get_path);22912292ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &RenderingServer::texture_get_format);22932294ClassDB::bind_method(D_METHOD("texture_set_force_redraw_if_visible", "texture", "enable"), &RenderingServer::texture_set_force_redraw_if_visible);2295ClassDB::bind_method(D_METHOD("texture_rd_create", "rd_texture", "layer_type"), &RenderingServer::texture_rd_create, DEFVAL(RenderingServer::TEXTURE_LAYERED_2D_ARRAY));2296ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture, DEFVAL(false));2297ClassDB::bind_method(D_METHOD("texture_get_native_handle", "texture", "srgb"), &RenderingServer::texture_get_native_handle, DEFVAL(false));22982299BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);2300BIND_ENUM_CONSTANT(TEXTURE_TYPE_LAYERED);2301BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);23022303BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY);2304BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP);2305BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP_ARRAY);23062307BIND_ENUM_CONSTANT(CUBEMAP_LAYER_LEFT);2308BIND_ENUM_CONSTANT(CUBEMAP_LAYER_RIGHT);2309BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BOTTOM);2310BIND_ENUM_CONSTANT(CUBEMAP_LAYER_TOP);2311BIND_ENUM_CONSTANT(CUBEMAP_LAYER_FRONT);2312BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BACK);23132314/* SHADER */23152316ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create);2317ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);2318ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint);2319ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);2320ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list);2321ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default);23222323ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0));2324ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0));23252326BIND_ENUM_CONSTANT(SHADER_SPATIAL);2327BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);2328BIND_ENUM_CONSTANT(SHADER_PARTICLES);2329BIND_ENUM_CONSTANT(SHADER_SKY);2330BIND_ENUM_CONSTANT(SHADER_FOG);2331BIND_ENUM_CONSTANT(SHADER_MAX);23322333/* MATERIAL */23342335ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create);2336ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader);2337ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param);2338ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param);2339ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority);23402341ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass);23422343BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);2344BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);23452346/* MESH API */23472348ClassDB::bind_method(D_METHOD("mesh_create_from_surfaces", "surfaces", "blend_shape_count"), &RenderingServer::_mesh_create_from_surfaces, DEFVAL(0));2349ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create);2350ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_count", "array_index"), &RenderingServer::mesh_surface_get_format_offset);2351ClassDB::bind_method(D_METHOD("mesh_surface_get_format_vertex_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_vertex_stride);2352ClassDB::bind_method(D_METHOD("mesh_surface_get_format_normal_tangent_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_normal_tangent_stride);2353ClassDB::bind_method(D_METHOD("mesh_surface_get_format_attribute_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_attribute_stride);2354ClassDB::bind_method(D_METHOD("mesh_surface_get_format_skin_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_skin_stride);2355ClassDB::bind_method(D_METHOD("mesh_surface_get_format_index_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_index_stride);2356ClassDB::bind_method(D_METHOD("mesh_add_surface", "mesh", "surface"), &RenderingServer::_mesh_add_surface);2357ClassDB::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));2358ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count);2359ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode);2360ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode);23612362ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material);2363ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material);2364ClassDB::bind_method(D_METHOD("mesh_get_surface", "mesh", "surface"), &RenderingServer::_mesh_get_surface);2365ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays);2366ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays);2367ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count);2368ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb);2369ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb);2370ClassDB::bind_method(D_METHOD("mesh_surface_remove", "mesh", "surface"), &RenderingServer::mesh_surface_remove);2371ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear);23722373ClassDB::bind_method(D_METHOD("mesh_surface_update_vertex_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_vertex_region);2374ClassDB::bind_method(D_METHOD("mesh_surface_update_attribute_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_attribute_region);2375ClassDB::bind_method(D_METHOD("mesh_surface_update_skin_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_skin_region);2376ClassDB::bind_method(D_METHOD("mesh_surface_update_index_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_index_region);23772378ClassDB::bind_method(D_METHOD("mesh_set_shadow_mesh", "mesh", "shadow_mesh"), &RenderingServer::mesh_set_shadow_mesh);23792380BIND_ENUM_CONSTANT(ARRAY_VERTEX);2381BIND_ENUM_CONSTANT(ARRAY_NORMAL);2382BIND_ENUM_CONSTANT(ARRAY_TANGENT);2383BIND_ENUM_CONSTANT(ARRAY_COLOR);2384BIND_ENUM_CONSTANT(ARRAY_TEX_UV);2385BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);2386BIND_ENUM_CONSTANT(ARRAY_CUSTOM0);2387BIND_ENUM_CONSTANT(ARRAY_CUSTOM1);2388BIND_ENUM_CONSTANT(ARRAY_CUSTOM2);2389BIND_ENUM_CONSTANT(ARRAY_CUSTOM3);2390BIND_ENUM_CONSTANT(ARRAY_BONES);2391BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);2392BIND_ENUM_CONSTANT(ARRAY_INDEX);2393BIND_ENUM_CONSTANT(ARRAY_MAX);23942395BIND_CONSTANT(ARRAY_CUSTOM_COUNT);23962397BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_UNORM);2398BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_SNORM);2399BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_HALF);2400BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_HALF);2401BIND_ENUM_CONSTANT(ARRAY_CUSTOM_R_FLOAT);2402BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_FLOAT);2403BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGB_FLOAT);2404BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_FLOAT);2405BIND_ENUM_CONSTANT(ARRAY_CUSTOM_MAX);24062407BIND_BITFIELD_FLAG(ARRAY_FORMAT_VERTEX);2408BIND_BITFIELD_FLAG(ARRAY_FORMAT_NORMAL);2409BIND_BITFIELD_FLAG(ARRAY_FORMAT_TANGENT);2410BIND_BITFIELD_FLAG(ARRAY_FORMAT_COLOR);2411BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV);2412BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV2);2413BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0);2414BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1);2415BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2);2416BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3);2417BIND_BITFIELD_FLAG(ARRAY_FORMAT_BONES);2418BIND_BITFIELD_FLAG(ARRAY_FORMAT_WEIGHTS);2419BIND_BITFIELD_FLAG(ARRAY_FORMAT_INDEX);24202421BIND_BITFIELD_FLAG(ARRAY_FORMAT_BLEND_SHAPE_MASK);24222423BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BASE);2424BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BITS);2425BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0_SHIFT);2426BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1_SHIFT);2427BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2_SHIFT);2428BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3_SHIFT);24292430BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_MASK);2431BIND_BITFIELD_FLAG(ARRAY_COMPRESS_FLAGS_BASE);24322433BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_2D_VERTICES);2434BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_DYNAMIC_UPDATE);2435BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_8_BONE_WEIGHTS);2436BIND_BITFIELD_FLAG(ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY);24372438BIND_BITFIELD_FLAG(ARRAY_FLAG_COMPRESS_ATTRIBUTES);24392440BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_BASE);2441BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_SHIFT);2442BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_1);2443BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_2);2444BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_CURRENT_VERSION);2445BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_MASK);24462447BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);2448BIND_ENUM_CONSTANT(PRIMITIVE_LINES);2449BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);2450BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);2451BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);2452BIND_ENUM_CONSTANT(PRIMITIVE_MAX);24532454BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);2455BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);24562457/* MULTIMESH API */24582459ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create);2460ClassDB::bind_method(D_METHOD("multimesh_allocate_data", "multimesh", "instances", "transform_format", "color_format", "custom_data_format", "use_indirect"), &RenderingServer::multimesh_allocate_data, DEFVAL(false), DEFVAL(false), DEFVAL(false));2461ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count);2462ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh);2463ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform);2464ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d);2465ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color);2466ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data);2467ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh);2468ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb);2469ClassDB::bind_method(D_METHOD("multimesh_set_custom_aabb", "multimesh", "aabb"), &RenderingServer::multimesh_set_custom_aabb);2470ClassDB::bind_method(D_METHOD("multimesh_get_custom_aabb", "multimesh"), &RenderingServer::multimesh_get_custom_aabb);2471ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform);2472ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d);2473ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color);2474ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data);2475ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);2476ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);2477ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);2478ClassDB::bind_method(D_METHOD("multimesh_get_command_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_command_buffer_rd_rid);2479ClassDB::bind_method(D_METHOD("multimesh_get_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_buffer_rd_rid);2480ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);24812482ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated);2483ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolated", "multimesh", "interpolated"), &RenderingServer::multimesh_set_physics_interpolated);2484ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolation_quality", "multimesh", "quality"), &RenderingServer::multimesh_set_physics_interpolation_quality);2485ClassDB::bind_method(D_METHOD("multimesh_instance_reset_physics_interpolation", "multimesh", "index"), &RenderingServer::multimesh_instance_reset_physics_interpolation);24862487BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);2488BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);2489BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_FAST);2490BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_HIGH);24912492/* SKELETON API */24932494ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create);2495ClassDB::bind_method(D_METHOD("skeleton_allocate_data", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate_data, DEFVAL(false));2496ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count);2497ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform);2498ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform);2499ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d);2500ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d);2501ClassDB::bind_method(D_METHOD("skeleton_set_base_transform_2d", "skeleton", "base_transform"), &RenderingServer::skeleton_set_base_transform_2d);25022503/* Light API */25042505ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);2506ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);2507ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);25082509ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);2510ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);2511ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow);2512ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector);2513ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);2514ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);2515ClassDB::bind_method(D_METHOD("light_set_distance_fade", "decal", "enabled", "begin", "shadow", "length"), &RenderingServer::light_set_distance_fade);2516ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);2517ClassDB::bind_method(D_METHOD("light_set_shadow_caster_mask", "light", "mask"), &RenderingServer::light_set_shadow_caster_mask);2518ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &RenderingServer::light_set_bake_mode);2519ClassDB::bind_method(D_METHOD("light_set_max_sdfgi_cascade", "light", "cascade"), &RenderingServer::light_set_max_sdfgi_cascade);25202521ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);25222523ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode);2524ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);2525ClassDB::bind_method(D_METHOD("light_directional_set_sky_mode", "light", "mode"), &RenderingServer::light_directional_set_sky_mode);25262527ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter);2528ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "enable"), &RenderingServer::lightmaps_set_bicubic_filter);25292530BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST);2531BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR);2532BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS);2533BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);2534BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);2535BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);25362537BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);2538BIND_ENUM_CONSTANT(LIGHT_OMNI);2539BIND_ENUM_CONSTANT(LIGHT_SPOT);25402541BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);2542BIND_ENUM_CONSTANT(LIGHT_PARAM_INDIRECT_ENERGY);2543BIND_ENUM_CONSTANT(LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY);2544BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);2545BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);2546BIND_ENUM_CONSTANT(LIGHT_PARAM_SIZE);2547BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);2548BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);2549BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);2550BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);2551BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);2552BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);2553BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);2554BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_FADE_START);2555BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);2556BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);2557BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_PANCAKE_SIZE);2558BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_OPACITY);2559BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BLUR);2560BIND_ENUM_CONSTANT(LIGHT_PARAM_TRANSMITTANCE_BIAS);2561BIND_ENUM_CONSTANT(LIGHT_PARAM_INTENSITY);2562BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);25632564BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);2565BIND_ENUM_CONSTANT(LIGHT_BAKE_STATIC);2566BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);25672568BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);2569BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);25702571BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);2572BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);2573BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);25742575BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);2576BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_ONLY);2577BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_SKY_ONLY);25782579ClassDB::bind_method(D_METHOD("positional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::positional_soft_shadow_filter_set_quality);2580ClassDB::bind_method(D_METHOD("directional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::directional_soft_shadow_filter_set_quality);2581ClassDB::bind_method(D_METHOD("directional_shadow_atlas_set_size", "size", "is_16bits"), &RenderingServer::directional_shadow_atlas_set_size);25822583BIND_ENUM_CONSTANT(SHADOW_QUALITY_HARD);2584BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_VERY_LOW);2585BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_LOW);2586BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_MEDIUM);2587BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_HIGH);2588BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_ULTRA);2589BIND_ENUM_CONSTANT(SHADOW_QUALITY_MAX);25902591/* REFLECTION PROBE */25922593ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);2594ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);2595ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);2596ClassDB::bind_method(D_METHOD("reflection_probe_set_blend_distance", "probe", "blend_distance"), &RenderingServer::reflection_probe_set_blend_distance);2597ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_ambient_mode);2598ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_color", "probe", "color"), &RenderingServer::reflection_probe_set_ambient_color);2599ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_ambient_energy);2600ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);2601ClassDB::bind_method(D_METHOD("reflection_probe_set_size", "probe", "size"), &RenderingServer::reflection_probe_set_size);2602ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);2603ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);2604ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);2605ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);2606ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);2607ClassDB::bind_method(D_METHOD("reflection_probe_set_reflection_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_reflection_mask);2608ClassDB::bind_method(D_METHOD("reflection_probe_set_resolution", "probe", "resolution"), &RenderingServer::reflection_probe_set_resolution);2609ClassDB::bind_method(D_METHOD("reflection_probe_set_mesh_lod_threshold", "probe", "pixels"), &RenderingServer::reflection_probe_set_mesh_lod_threshold);26102611BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);2612BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);26132614BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_DISABLED);2615BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_ENVIRONMENT);2616BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_COLOR);26172618/* DECAL */26192620ClassDB::bind_method(D_METHOD("decal_create"), &RenderingServer::decal_create);2621ClassDB::bind_method(D_METHOD("decal_set_size", "decal", "size"), &RenderingServer::decal_set_size);2622ClassDB::bind_method(D_METHOD("decal_set_texture", "decal", "type", "texture"), &RenderingServer::decal_set_texture);2623ClassDB::bind_method(D_METHOD("decal_set_emission_energy", "decal", "energy"), &RenderingServer::decal_set_emission_energy);2624ClassDB::bind_method(D_METHOD("decal_set_albedo_mix", "decal", "albedo_mix"), &RenderingServer::decal_set_albedo_mix);2625ClassDB::bind_method(D_METHOD("decal_set_modulate", "decal", "color"), &RenderingServer::decal_set_modulate);2626ClassDB::bind_method(D_METHOD("decal_set_cull_mask", "decal", "mask"), &RenderingServer::decal_set_cull_mask);2627ClassDB::bind_method(D_METHOD("decal_set_distance_fade", "decal", "enabled", "begin", "length"), &RenderingServer::decal_set_distance_fade);2628ClassDB::bind_method(D_METHOD("decal_set_fade", "decal", "above", "below"), &RenderingServer::decal_set_fade);2629ClassDB::bind_method(D_METHOD("decal_set_normal_fade", "decal", "fade"), &RenderingServer::decal_set_normal_fade);26302631ClassDB::bind_method(D_METHOD("decals_set_filter", "filter"), &RenderingServer::decals_set_filter);26322633BIND_ENUM_CONSTANT(DECAL_TEXTURE_ALBEDO);2634BIND_ENUM_CONSTANT(DECAL_TEXTURE_NORMAL);2635BIND_ENUM_CONSTANT(DECAL_TEXTURE_ORM);2636BIND_ENUM_CONSTANT(DECAL_TEXTURE_EMISSION);2637BIND_ENUM_CONSTANT(DECAL_TEXTURE_MAX);26382639BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST);2640BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR);2641BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS);2642BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS);2643BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);2644BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);26452646/* GI API (affects VoxelGI and SDFGI) */26472648ClassDB::bind_method(D_METHOD("gi_set_use_half_resolution", "half_resolution"), &RenderingServer::gi_set_use_half_resolution);26492650/* VOXEL GI API */26512652ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create);2653ClassDB::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);2654ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_size", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_size);2655ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_cells);2656ClassDB::bind_method(D_METHOD("voxel_gi_get_data_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_data_cells);2657ClassDB::bind_method(D_METHOD("voxel_gi_get_distance_field", "voxel_gi"), &RenderingServer::voxel_gi_get_distance_field);2658ClassDB::bind_method(D_METHOD("voxel_gi_get_level_counts", "voxel_gi"), &RenderingServer::voxel_gi_get_level_counts);2659ClassDB::bind_method(D_METHOD("voxel_gi_get_to_cell_xform", "voxel_gi"), &RenderingServer::voxel_gi_get_to_cell_xform);26602661ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_range", "voxel_gi", "range"), &RenderingServer::voxel_gi_set_dynamic_range);2662ClassDB::bind_method(D_METHOD("voxel_gi_set_propagation", "voxel_gi", "amount"), &RenderingServer::voxel_gi_set_propagation);2663ClassDB::bind_method(D_METHOD("voxel_gi_set_energy", "voxel_gi", "energy"), &RenderingServer::voxel_gi_set_energy);2664ClassDB::bind_method(D_METHOD("voxel_gi_set_baked_exposure_normalization", "voxel_gi", "baked_exposure"), &RenderingServer::voxel_gi_set_baked_exposure_normalization);2665ClassDB::bind_method(D_METHOD("voxel_gi_set_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_bias);2666ClassDB::bind_method(D_METHOD("voxel_gi_set_normal_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_normal_bias);2667ClassDB::bind_method(D_METHOD("voxel_gi_set_interior", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_interior);2668ClassDB::bind_method(D_METHOD("voxel_gi_set_use_two_bounces", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_use_two_bounces);26692670ClassDB::bind_method(D_METHOD("voxel_gi_set_quality", "quality"), &RenderingServer::voxel_gi_set_quality);26712672BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_LOW);2673BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_HIGH);26742675/* LIGHTMAP */26762677ClassDB::bind_method(D_METHOD("lightmap_create"), &RenderingServer::lightmap_create);2678ClassDB::bind_method(D_METHOD("lightmap_set_textures", "lightmap", "light", "uses_sh"), &RenderingServer::lightmap_set_textures);2679ClassDB::bind_method(D_METHOD("lightmap_set_probe_bounds", "lightmap", "bounds"), &RenderingServer::lightmap_set_probe_bounds);2680ClassDB::bind_method(D_METHOD("lightmap_set_probe_interior", "lightmap", "interior"), &RenderingServer::lightmap_set_probe_interior);2681ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_data", "lightmap", "points", "point_sh", "tetrahedra", "bsp_tree"), &RenderingServer::lightmap_set_probe_capture_data);2682ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_points", "lightmap"), &RenderingServer::lightmap_get_probe_capture_points);2683ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_sh", "lightmap"), &RenderingServer::lightmap_get_probe_capture_sh);2684ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_tetrahedra", "lightmap"), &RenderingServer::lightmap_get_probe_capture_tetrahedra);2685ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_bsp_tree", "lightmap"), &RenderingServer::lightmap_get_probe_capture_bsp_tree);2686ClassDB::bind_method(D_METHOD("lightmap_set_baked_exposure_normalization", "lightmap", "baked_exposure"), &RenderingServer::lightmap_set_baked_exposure_normalization);26872688ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_update_speed", "speed"), &RenderingServer::lightmap_set_probe_capture_update_speed);26892690/* PARTICLES API */26912692ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create);2693ClassDB::bind_method(D_METHOD("particles_set_mode", "particles", "mode"), &RenderingServer::particles_set_mode);2694ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting);2695ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting);2696ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount);2697ClassDB::bind_method(D_METHOD("particles_set_amount_ratio", "particles", "ratio"), &RenderingServer::particles_set_amount_ratio);2698ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime);2699ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot);2700ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time);2701ClassDB::bind_method(D_METHOD("particles_request_process_time", "particles", "time"), &RenderingServer::particles_request_process_time);2702ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio);2703ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio);2704ClassDB::bind_method(D_METHOD("particles_set_interp_to_end", "particles", "factor"), &RenderingServer::particles_set_interp_to_end);2705ClassDB::bind_method(D_METHOD("particles_set_emitter_velocity", "particles", "velocity"), &RenderingServer::particles_set_emitter_velocity);2706ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb);2707ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale);2708ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates);2709ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material);2710ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps);2711ClassDB::bind_method(D_METHOD("particles_set_interpolate", "particles", "enable"), &RenderingServer::particles_set_interpolate);2712ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta);2713ClassDB::bind_method(D_METHOD("particles_set_collision_base_size", "particles", "size"), &RenderingServer::particles_set_collision_base_size);2714ClassDB::bind_method(D_METHOD("particles_set_transform_align", "particles", "align"), &RenderingServer::particles_set_transform_align);2715ClassDB::bind_method(D_METHOD("particles_set_trails", "particles", "enable", "length_sec"), &RenderingServer::particles_set_trails);2716ClassDB::bind_method(D_METHOD("particles_set_trail_bind_poses", "particles", "bind_poses"), &RenderingServer::_particles_set_trail_bind_poses);27172718ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive);2719ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process);2720ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart);27212722ClassDB::bind_method(D_METHOD("particles_set_subemitter", "particles", "subemitter_particles"), &RenderingServer::particles_set_subemitter);2723ClassDB::bind_method(D_METHOD("particles_emit", "particles", "transform", "velocity", "color", "custom", "emit_flags"), &RenderingServer::particles_emit);27242725ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order);2726ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes);2727ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh);2728ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb);2729ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform);27302731BIND_ENUM_CONSTANT(PARTICLES_MODE_2D);2732BIND_ENUM_CONSTANT(PARTICLES_MODE_3D);27332734BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_DISABLED);2735BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD);2736BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY);2737BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY);27382739BIND_CONSTANT(PARTICLES_EMIT_FLAG_POSITION);2740BIND_CONSTANT(PARTICLES_EMIT_FLAG_ROTATION_SCALE);2741BIND_CONSTANT(PARTICLES_EMIT_FLAG_VELOCITY);2742BIND_CONSTANT(PARTICLES_EMIT_FLAG_COLOR);2743BIND_CONSTANT(PARTICLES_EMIT_FLAG_CUSTOM);27442745BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);2746BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);2747BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);2748BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);27492750/* PARTICLES COLLISION */27512752ClassDB::bind_method(D_METHOD("particles_collision_create"), &RenderingServer::particles_collision_create);2753ClassDB::bind_method(D_METHOD("particles_collision_set_collision_type", "particles_collision", "type"), &RenderingServer::particles_collision_set_collision_type);2754ClassDB::bind_method(D_METHOD("particles_collision_set_cull_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_cull_mask);2755ClassDB::bind_method(D_METHOD("particles_collision_set_sphere_radius", "particles_collision", "radius"), &RenderingServer::particles_collision_set_sphere_radius);2756ClassDB::bind_method(D_METHOD("particles_collision_set_box_extents", "particles_collision", "extents"), &RenderingServer::particles_collision_set_box_extents);2757ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_strength", "particles_collision", "strength"), &RenderingServer::particles_collision_set_attractor_strength);2758ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_directionality", "particles_collision", "amount"), &RenderingServer::particles_collision_set_attractor_directionality);2759ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_attenuation", "particles_collision", "curve"), &RenderingServer::particles_collision_set_attractor_attenuation);2760ClassDB::bind_method(D_METHOD("particles_collision_set_field_texture", "particles_collision", "texture"), &RenderingServer::particles_collision_set_field_texture);27612762ClassDB::bind_method(D_METHOD("particles_collision_height_field_update", "particles_collision"), &RenderingServer::particles_collision_height_field_update);2763ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_resolution", "particles_collision", "resolution"), &RenderingServer::particles_collision_set_height_field_resolution);2764ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_height_field_mask);27652766BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT);2767BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_ATTRACT);2768BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT);2769BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE);2770BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_COLLIDE);2771BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SDF_COLLIDE);2772BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE);27732774BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256);2775BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512);2776BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024);2777BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_2048);2778BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_4096);2779BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192);2780BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);27812782/* FOG VOLUMES */27832784ClassDB::bind_method(D_METHOD("fog_volume_create"), &RenderingServer::fog_volume_create);2785ClassDB::bind_method(D_METHOD("fog_volume_set_shape", "fog_volume", "shape"), &RenderingServer::fog_volume_set_shape);2786ClassDB::bind_method(D_METHOD("fog_volume_set_size", "fog_volume", "size"), &RenderingServer::fog_volume_set_size);2787ClassDB::bind_method(D_METHOD("fog_volume_set_material", "fog_volume", "material"), &RenderingServer::fog_volume_set_material);27882789BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_ELLIPSOID);2790BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CONE);2791BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CYLINDER);2792BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_BOX);2793BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_WORLD);2794BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_MAX);27952796/* VISIBILITY NOTIFIER */27972798ClassDB::bind_method(D_METHOD("visibility_notifier_create"), &RenderingServer::visibility_notifier_create);2799ClassDB::bind_method(D_METHOD("visibility_notifier_set_aabb", "notifier", "aabb"), &RenderingServer::visibility_notifier_set_aabb);2800ClassDB::bind_method(D_METHOD("visibility_notifier_set_callbacks", "notifier", "enter_callable", "exit_callable"), &RenderingServer::visibility_notifier_set_callbacks);28012802/* OCCLUDER */28032804ClassDB::bind_method(D_METHOD("occluder_create"), &RenderingServer::occluder_create);2805ClassDB::bind_method(D_METHOD("occluder_set_mesh", "occluder", "vertices", "indices"), &RenderingServer::occluder_set_mesh);28062807/* CAMERA */28082809ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);2810ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective);2811ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal);2812ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum);2813ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform);2814ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask);2815ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment);2816ClassDB::bind_method(D_METHOD("camera_set_camera_attributes", "camera", "effects"), &RenderingServer::camera_set_camera_attributes);2817ClassDB::bind_method(D_METHOD("camera_set_compositor", "camera", "compositor"), &RenderingServer::camera_set_compositor);2818ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);28192820/* VIEWPORT */28212822ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);2823ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr);2824ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);2825ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);2826ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);2827ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID));2828ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen);2829ClassDB::bind_method(D_METHOD("viewport_set_canvas_cull_mask", "viewport", "canvas_cull_mask"), &RenderingServer::viewport_set_canvas_cull_mask);28302831ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_mode", "viewport", "scaling_3d_mode"), &RenderingServer::viewport_set_scaling_3d_mode);2832ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_scale", "viewport", "scale"), &RenderingServer::viewport_set_scaling_3d_scale);2833ClassDB::bind_method(D_METHOD("viewport_set_fsr_sharpness", "viewport", "sharpness"), &RenderingServer::viewport_set_fsr_sharpness);2834ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias);2835ClassDB::bind_method(D_METHOD("viewport_set_anisotropic_filtering_level", "viewport", "anisotropic_filtering_level"), &RenderingServer::viewport_set_anisotropic_filtering_level);2836ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);2837ClassDB::bind_method(D_METHOD("viewport_get_update_mode", "viewport"), &RenderingServer::viewport_get_update_mode);2838ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);2839ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target);2840ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);2841ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d);2842ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d);2843ClassDB::bind_method(D_METHOD("viewport_set_environment_mode", "viewport", "mode"), &RenderingServer::viewport_set_environment_mode);2844ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera);2845ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario);2846ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);2847ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);2848ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_transforms_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_transforms_to_pixel);2849ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_vertices_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_vertices_to_pixel);28502851ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_filter", "viewport", "filter"), &RenderingServer::viewport_set_default_canvas_item_texture_filter);2852ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_repeat", "viewport", "repeat"), &RenderingServer::viewport_set_default_canvas_item_texture_repeat);28532854ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);2855ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking);28562857ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background);2858ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform);28592860ClassDB::bind_method(D_METHOD("viewport_set_sdf_oversize_and_scale", "viewport", "oversize", "scale"), &RenderingServer::viewport_set_sdf_oversize_and_scale);28612862ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_size", "viewport", "size", "use_16_bits"), &RenderingServer::viewport_set_positional_shadow_atlas_size, DEFVAL(false));2863ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_positional_shadow_atlas_quadrant_subdivision);2864ClassDB::bind_method(D_METHOD("viewport_set_msaa_3d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_3d);2865ClassDB::bind_method(D_METHOD("viewport_set_msaa_2d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_2d);2866ClassDB::bind_method(D_METHOD("viewport_set_use_hdr_2d", "viewport", "enabled"), &RenderingServer::viewport_set_use_hdr_2d);2867ClassDB::bind_method(D_METHOD("viewport_set_screen_space_aa", "viewport", "mode"), &RenderingServer::viewport_set_screen_space_aa);2868ClassDB::bind_method(D_METHOD("viewport_set_use_taa", "viewport", "enable"), &RenderingServer::viewport_set_use_taa);2869ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "enable"), &RenderingServer::viewport_set_use_debanding);2870ClassDB::bind_method(D_METHOD("viewport_set_use_occlusion_culling", "viewport", "enable"), &RenderingServer::viewport_set_use_occlusion_culling);2871ClassDB::bind_method(D_METHOD("viewport_set_occlusion_rays_per_thread", "rays_per_thread"), &RenderingServer::viewport_set_occlusion_rays_per_thread);2872ClassDB::bind_method(D_METHOD("viewport_set_occlusion_culling_build_quality", "quality"), &RenderingServer::viewport_set_occlusion_culling_build_quality);28732874ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "type", "info"), &RenderingServer::viewport_get_render_info);2875ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw);28762877ClassDB::bind_method(D_METHOD("viewport_set_measure_render_time", "viewport", "enable"), &RenderingServer::viewport_set_measure_render_time);2878ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_cpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_cpu);28792880ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_gpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_gpu);28812882ClassDB::bind_method(D_METHOD("viewport_set_vrs_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_mode);2883ClassDB::bind_method(D_METHOD("viewport_set_vrs_update_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_update_mode);2884ClassDB::bind_method(D_METHOD("viewport_set_vrs_texture", "viewport", "texture"), &RenderingServer::viewport_set_vrs_texture);28852886BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_BILINEAR);2887BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR);2888BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR2);2889BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_METALFX_SPATIAL);2890BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_METALFX_TEMPORAL);2891BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_MAX);28922893BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);2894BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); // Then goes to disabled, must be manually updated.2895BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // Default2896BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);2897BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);28982899BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);2900BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);2901BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);29022903BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_DISABLED);2904BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_ENABLED);2905BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_INHERIT);2906BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_MAX);29072908BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_100_PERCENT);2909BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_120_PERCENT);2910BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_150_PERCENT);2911BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_200_PERCENT);2912BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_MAX);29132914BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_100_PERCENT);2915BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_50_PERCENT);2916BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_25_PERCENT);2917BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_MAX);29182919BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);2920BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);2921BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);2922BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);2923BIND_ENUM_CONSTANT(VIEWPORT_MSAA_MAX);29242925BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_DISABLED);2926BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_2X);2927BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_4X);2928BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_8X);2929BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_16X);2930BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_MAX);29312932BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_DISABLED);2933BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_FXAA);2934BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_SMAA);2935BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_MAX);29362937BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW);2938BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM);2939BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH);29402941BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);2942BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME);2943BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);2944BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);29452946BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_VISIBLE);2947BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_SHADOW);2948BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_CANVAS);2949BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_MAX);29502951BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);2952BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);2953BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_LIGHTING);2954BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);2955BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);2956BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER);2957BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO);2958BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING);2959BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION);2960BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS);2961BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);2962BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE);2963BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSAO);2964BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSIL);2965BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_PSSM_SPLITS);2966BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DECAL_ATLAS);2967BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI);2968BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI_PROBES);2969BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_BUFFER);2970BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLE_LOD);2971BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS);2972BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS);2973BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS);2974BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES);2975BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OCCLUDERS);2976BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_MOTION_VECTORS);2977BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_INTERNAL_BUFFER);29782979BIND_ENUM_CONSTANT(VIEWPORT_VRS_DISABLED);2980BIND_ENUM_CONSTANT(VIEWPORT_VRS_TEXTURE);2981BIND_ENUM_CONSTANT(VIEWPORT_VRS_XR);2982BIND_ENUM_CONSTANT(VIEWPORT_VRS_MAX);29832984BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_DISABLED);2985BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ONCE); // Then goes to disabled, must be manually updated.2986BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ALWAYS);2987BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_MAX);29882989/* SKY API */29902991ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create);2992ClassDB::bind_method(D_METHOD("sky_set_radiance_size", "sky", "radiance_size"), &RenderingServer::sky_set_radiance_size);2993ClassDB::bind_method(D_METHOD("sky_set_mode", "sky", "mode"), &RenderingServer::sky_set_mode);2994ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material);2995ClassDB::bind_method(D_METHOD("sky_bake_panorama", "sky", "energy", "bake_irradiance", "size"), &RenderingServer::sky_bake_panorama);29962997BIND_ENUM_CONSTANT(SKY_MODE_AUTOMATIC);2998BIND_ENUM_CONSTANT(SKY_MODE_QUALITY);2999BIND_ENUM_CONSTANT(SKY_MODE_INCREMENTAL);3000BIND_ENUM_CONSTANT(SKY_MODE_REALTIME);30013002/* COMPOSITOR EFFECT API */30033004ClassDB::bind_method(D_METHOD("compositor_effect_create"), &RenderingServer::compositor_effect_create);3005ClassDB::bind_method(D_METHOD("compositor_effect_set_enabled", "effect", "enabled"), &RenderingServer::compositor_effect_set_enabled);3006ClassDB::bind_method(D_METHOD("compositor_effect_set_callback", "effect", "callback_type", "callback"), &RenderingServer::compositor_effect_set_callback);3007ClassDB::bind_method(D_METHOD("compositor_effect_set_flag", "effect", "flag", "set"), &RenderingServer::compositor_effect_set_flag);30083009BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_COLOR);3010BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_DEPTH);3011BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS);3012BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_ROUGHNESS);3013BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_SEPARATE_SPECULAR);30143015BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_OPAQUE);3016BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_OPAQUE);3017BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_SKY);3018BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT);3019BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_TRANSPARENT);3020BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_ANY);30213022/* COMPOSITOR */30233024ClassDB::bind_method(D_METHOD("compositor_create"), &RenderingServer::compositor_create);30253026ClassDB::bind_method(D_METHOD("compositor_set_compositor_effects", "compositor", "effects"), &RenderingServer::compositor_set_compositor_effects);30273028/* ENVIRONMENT */30293030ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create);3031ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background);3032ClassDB::bind_method(D_METHOD("environment_set_camera_id", "env", "id"), &RenderingServer::environment_set_camera_feed_id);3033ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky);3034ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov);3035ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation);3036ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color);3037ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "multiplier", "exposure_value"), &RenderingServer::environment_set_bg_energy);3038ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer);3039ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contribution", "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));3040ClassDB::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);3041ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white"), &RenderingServer::environment_set_tonemap);3042ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "use_1d_color_correction", "color_correction"), &RenderingServer::environment_set_adjustment);3043ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance"), &RenderingServer::environment_set_ssr);3044ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "power", "detail", "horizon", "sharpness", "light_affect", "ao_channel_affect"), &RenderingServer::environment_set_ssao);3045ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "light_color", "light_energy", "sun_scatter", "density", "height", "height_density", "aerial_perspective", "sky_affect", "fog_mode"), &RenderingServer::environment_set_fog, DEFVAL(RS::ENV_FOG_MODE_EXPONENTIAL));3046ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "curve", "begin", "end"), &RenderingServer::environment_set_fog_depth);3047ClassDB::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);3048ClassDB::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);30493050ClassDB::bind_method(D_METHOD("environment_glow_set_use_bicubic_upscale", "enable"), &RenderingServer::environment_glow_set_use_bicubic_upscale);3051ClassDB::bind_method(D_METHOD("environment_set_ssr_roughness_quality", "quality"), &RenderingServer::environment_set_ssr_roughness_quality);3052ClassDB::bind_method(D_METHOD("environment_set_ssao_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssao_quality);3053ClassDB::bind_method(D_METHOD("environment_set_ssil_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssil_quality);3054ClassDB::bind_method(D_METHOD("environment_set_sdfgi_ray_count", "ray_count"), &RenderingServer::environment_set_sdfgi_ray_count);3055ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_converge", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_converge);3056ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_update_light", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_update_light);3057ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_volume_size", "size", "depth"), &RenderingServer::environment_set_volumetric_fog_volume_size);3058ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_filter_active", "active"), &RenderingServer::environment_set_volumetric_fog_filter_active);30593060ClassDB::bind_method(D_METHOD("environment_bake_panorama", "environment", "bake_irradiance", "size"), &RenderingServer::environment_bake_panorama);30613062ClassDB::bind_method(D_METHOD("screen_space_roughness_limiter_set_active", "enable", "amount", "limit"), &RenderingServer::screen_space_roughness_limiter_set_active);3063ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_quality", "quality"), &RenderingServer::sub_surface_scattering_set_quality);3064ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_scale", "scale", "depth_scale"), &RenderingServer::sub_surface_scattering_set_scale);30653066BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);3067BIND_ENUM_CONSTANT(ENV_BG_COLOR);3068BIND_ENUM_CONSTANT(ENV_BG_SKY);3069BIND_ENUM_CONSTANT(ENV_BG_CANVAS);3070BIND_ENUM_CONSTANT(ENV_BG_KEEP);3071BIND_ENUM_CONSTANT(ENV_BG_CAMERA_FEED);3072BIND_ENUM_CONSTANT(ENV_BG_MAX);30733074BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_BG);3075BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_DISABLED);3076BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_COLOR);3077BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_SKY);30783079BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_BG);3080BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_DISABLED);3081BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_SKY);30823083BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_ADDITIVE);3084BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SCREEN);3085BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SOFTLIGHT);3086BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_REPLACE);3087BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_MIX);30883089BIND_ENUM_CONSTANT(ENV_FOG_MODE_EXPONENTIAL);3090BIND_ENUM_CONSTANT(ENV_FOG_MODE_DEPTH);30913092BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);3093BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);3094BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);3095BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);3096BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_AGX);30973098BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_DISABLED);3099BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_LOW);3100BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_MEDIUM);3101BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_HIGH);31023103BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_VERY_LOW);3104BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);3105BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);3106BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);3107BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_ULTRA);31083109BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_VERY_LOW);3110BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_LOW);3111BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_MEDIUM);3112BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_HIGH);3113BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_ULTRA);31143115BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_50_PERCENT);3116BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_75_PERCENT);3117BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_100_PERCENT);31183119BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_4);3120BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_8);3121BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_16);3122BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_32);3123BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_64);3124BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_96);3125BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_128);3126BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_MAX);31273128BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_5_FRAMES);3129BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_10_FRAMES);3130BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_15_FRAMES);3131BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_20_FRAMES);3132BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_25_FRAMES);3133BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_30_FRAMES);3134BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_MAX);31353136BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME);3137BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES);3138BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES);3139BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES);3140BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES);3141BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_MAX);31423143BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_DISABLED);3144BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_LOW);3145BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_MEDIUM);3146BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_HIGH);31473148/* CAMERA EFFECTS */31493150ClassDB::bind_method(D_METHOD("camera_attributes_create"), &RenderingServer::camera_attributes_create);31513152ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_quality", "quality", "use_jitter"), &RenderingServer::camera_attributes_set_dof_blur_quality);3153ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_bokeh_shape", "shape"), &RenderingServer::camera_attributes_set_dof_blur_bokeh_shape);31543155ClassDB::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);3156ClassDB::bind_method(D_METHOD("camera_attributes_set_exposure", "camera_attributes", "multiplier", "normalization"), &RenderingServer::camera_attributes_set_exposure);3157ClassDB::bind_method(D_METHOD("camera_attributes_set_auto_exposure", "camera_attributes", "enable", "min_sensitivity", "max_sensitivity", "speed", "scale"), &RenderingServer::camera_attributes_set_auto_exposure);31583159BIND_ENUM_CONSTANT(DOF_BOKEH_BOX);3160BIND_ENUM_CONSTANT(DOF_BOKEH_HEXAGON);3161BIND_ENUM_CONSTANT(DOF_BOKEH_CIRCLE);31623163BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_VERY_LOW);3164BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);3165BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);3166BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);31673168/* SCENARIO */31693170ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create);3171ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment);3172ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment);3173ClassDB::bind_method(D_METHOD("scenario_set_camera_attributes", "scenario", "effects"), &RenderingServer::scenario_set_camera_attributes);3174ClassDB::bind_method(D_METHOD("scenario_set_compositor", "scenario", "compositor"), &RenderingServer::scenario_set_compositor);31753176/* INSTANCE */31773178ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2);3179ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create);3180ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base);3181ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario);3182ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask);3183ClassDB::bind_method(D_METHOD("instance_set_pivot_data", "instance", "sorting_offset", "use_aabb_center"), &RenderingServer::instance_set_pivot_data);3184ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);3185ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);3186ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);3187ClassDB::bind_method(D_METHOD("instance_set_surface_override_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_override_material);3188ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);3189ClassDB::bind_method(D_METHOD("instance_geometry_set_transparency", "instance", "transparency"), &RenderingServer::instance_geometry_set_transparency);31903191ClassDB::bind_method(D_METHOD("instance_teleport", "instance"), &RenderingServer::instance_teleport);31923193ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);31943195ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton);3196ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin);3197ClassDB::bind_method(D_METHOD("instance_set_visibility_parent", "instance", "parent"), &RenderingServer::instance_set_visibility_parent);3198ClassDB::bind_method(D_METHOD("instance_set_ignore_culling", "instance", "enabled"), &RenderingServer::instance_set_ignore_culling);31993200ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag);3201ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting);3202ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override);3203ClassDB::bind_method(D_METHOD("instance_geometry_set_material_overlay", "instance", "material"), &RenderingServer::instance_geometry_set_material_overlay);3204ClassDB::bind_method(D_METHOD("instance_geometry_set_visibility_range", "instance", "min", "max", "min_margin", "max_margin", "fade_mode"), &RenderingServer::instance_geometry_set_visibility_range);3205ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap);3206ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias);32073208ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter);3209ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter);3210ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value);3211ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list);32123213ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));3214ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));3215ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID()));32163217BIND_ENUM_CONSTANT(INSTANCE_NONE);3218BIND_ENUM_CONSTANT(INSTANCE_MESH);3219BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);3220BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);3221BIND_ENUM_CONSTANT(INSTANCE_PARTICLES_COLLISION);3222BIND_ENUM_CONSTANT(INSTANCE_LIGHT);3223BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);3224BIND_ENUM_CONSTANT(INSTANCE_DECAL);3225BIND_ENUM_CONSTANT(INSTANCE_VOXEL_GI);3226BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP);3227BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER);3228BIND_ENUM_CONSTANT(INSTANCE_VISIBLITY_NOTIFIER);3229BIND_ENUM_CONSTANT(INSTANCE_FOG_VOLUME);3230BIND_ENUM_CONSTANT(INSTANCE_MAX);32313232BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);32333234BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);3235BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_DYNAMIC_GI);3236BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);3237BIND_ENUM_CONSTANT(INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING);3238BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);32393240BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);3241BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);3242BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);3243BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);32443245BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DISABLED);3246BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_SELF);3247BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DEPENDENCIES);32483249/* Bake 3D Object */32503251ClassDB::bind_method(D_METHOD("bake_render_uv2", "base", "material_overrides", "image_size"), &RenderingServer::bake_render_uv2);32523253BIND_ENUM_CONSTANT(BAKE_CHANNEL_ALBEDO_ALPHA);3254BIND_ENUM_CONSTANT(BAKE_CHANNEL_NORMAL);3255BIND_ENUM_CONSTANT(BAKE_CHANNEL_ORM);3256BIND_ENUM_CONSTANT(BAKE_CHANNEL_EMISSION);32573258/* CANVAS (2D) */32593260ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create);3261ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring);3262ClassDB::bind_method(D_METHOD("canvas_set_item_repeat", "item", "repeat_size", "repeat_times"), &RenderingServer::canvas_set_item_repeat);3263ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate);3264ClassDB::bind_method(D_METHOD("canvas_set_disable_scale", "disable"), &RenderingServer::canvas_set_disable_scale);32653266/* CANVAS TEXTURE */32673268ClassDB::bind_method(D_METHOD("canvas_texture_create"), &RenderingServer::canvas_texture_create);3269ClassDB::bind_method(D_METHOD("canvas_texture_set_channel", "canvas_texture", "channel", "texture"), &RenderingServer::canvas_texture_set_channel);3270ClassDB::bind_method(D_METHOD("canvas_texture_set_shading_parameters", "canvas_texture", "base_color", "shininess"), &RenderingServer::canvas_texture_set_shading_parameters);32713272ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_filter", "canvas_texture", "filter"), &RenderingServer::canvas_texture_set_texture_filter);3273ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_repeat", "canvas_texture", "repeat"), &RenderingServer::canvas_texture_set_texture_repeat);32743275BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_DIFFUSE);3276BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_NORMAL);3277BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_SPECULAR);32783279/* CANVAS ITEM */32803281ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create);3282ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent);3283ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_filter", "item", "filter"), &RenderingServer::canvas_item_set_default_texture_filter);3284ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_repeat", "item", "repeat"), &RenderingServer::canvas_item_set_default_texture_repeat);3285ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible);3286ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask);3287ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_layer", "item", "visibility_layer"), &RenderingServer::canvas_item_set_visibility_layer);3288ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform);3289ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip);3290ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode);3291ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));3292ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate);3293ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate);3294ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent);3295ClassDB::bind_method(D_METHOD("canvas_item_set_interpolated", "item", "interpolated"), &RenderingServer::canvas_item_set_interpolated);3296ClassDB::bind_method(D_METHOD("canvas_item_reset_physics_interpolation", "item"), &RenderingServer::canvas_item_reset_physics_interpolation);3297ClassDB::bind_method(D_METHOD("canvas_item_transform_physics_interpolation", "item", "transform"), &RenderingServer::canvas_item_transform_physics_interpolation);32983299/* Primitives */33003301ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(-1.0), DEFVAL(false));3302ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(-1.0), DEFVAL(false));3303ClassDB::bind_method(D_METHOD("canvas_item_add_multiline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_multiline, DEFVAL(-1.0), DEFVAL(false));3304ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color", "antialiased"), &RenderingServer::canvas_item_add_rect, DEFVAL(false));3305ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color", "antialiased"), &RenderingServer::canvas_item_add_circle, DEFVAL(false));3306ClassDB::bind_method(D_METHOD("canvas_item_add_ellipse", "item", "pos", "major", "minor", "color", "antialiased"), &RenderingServer::canvas_item_add_ellipse, DEFVAL(false));3307ClassDB::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));3308ClassDB::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));3309ClassDB::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);3310ClassDB::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));3311ClassDB::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)));3312ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_primitive);3313ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()));3314ClassDB::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));3315ClassDB::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()));3316ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));3317ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture"), &RenderingServer::canvas_item_add_particles);3318ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);3319ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);3320ClassDB::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));3321ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);3322ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);3323ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);3324ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);3325ClassDB::bind_method(D_METHOD("canvas_item_attach_skeleton", "item", "skeleton"), &RenderingServer::canvas_item_attach_skeleton);33263327ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);3328ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);3329ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);3330ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material);33313332ClassDB::bind_method(D_METHOD("canvas_item_set_instance_shader_parameter", "instance", "parameter", "value"), &RenderingServer::canvas_item_set_instance_shader_parameter);3333ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter", "instance", "parameter"), &RenderingServer::canvas_item_get_instance_shader_parameter);3334ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::canvas_item_get_instance_shader_parameter_default_value);3335ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter_list", "instance"), &RenderingServer::_canvas_item_get_instance_shader_parameter_list);33363337ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_notifier", "item", "enable", "area", "enter_callable", "exit_callable"), &RenderingServer::canvas_item_set_visibility_notifier);3338ClassDB::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));33393340ClassDB::bind_method(D_METHOD("debug_canvas_item_get_rect", "item"), &RenderingServer::debug_canvas_item_get_rect);33413342BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);3343BIND_ENUM_CONSTANT(NINE_PATCH_TILE);3344BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);33453346BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);3347BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST);3348BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR);3349BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);3350BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);3351BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC);3352BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC);3353BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_MAX);33543355BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);3356BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);3357BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);3358BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MIRROR);3359BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MAX);33603361BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_DISABLED);3362BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_ONLY);3363BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_AND_DRAW);3364BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_TRANSPARENT);33653366/* CANVAS LIGHT */33673368ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create);3369ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas);3370ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled);3371ClassDB::bind_method(D_METHOD("canvas_light_set_texture_scale", "light", "scale"), &RenderingServer::canvas_light_set_texture_scale);3372ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform);3373ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture);3374ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset);3375ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color);3376ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height);3377ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy);3378ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range);3379ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range);3380ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask);3381ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask);3382ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode);3383ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled);3384ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);3385ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);3386ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);3387ClassDB::bind_method(D_METHOD("canvas_light_set_blend_mode", "light", "mode"), &RenderingServer::canvas_light_set_blend_mode);3388ClassDB::bind_method(D_METHOD("canvas_light_set_interpolated", "light", "interpolated"), &RenderingServer::canvas_light_set_interpolated);3389ClassDB::bind_method(D_METHOD("canvas_light_reset_physics_interpolation", "light"), &RenderingServer::canvas_light_reset_physics_interpolation);3390ClassDB::bind_method(D_METHOD("canvas_light_transform_physics_interpolation", "light", "transform"), &RenderingServer::canvas_light_transform_physics_interpolation);33913392BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_POINT);3393BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_DIRECTIONAL);33943395BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_ADD);3396BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_SUB);3397BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_MIX);33983399BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);3400BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);3401BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);3402BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_MAX);34033404/* CANVAS OCCLUDER */34053406ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create);3407ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas);3408ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled);3409ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon);3410ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_as_sdf_collision", "occluder", "enable"), &RenderingServer::canvas_light_occluder_set_as_sdf_collision);3411ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform);3412ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask);3413ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_interpolated", "occluder", "interpolated"), &RenderingServer::canvas_light_occluder_set_interpolated);3414ClassDB::bind_method(D_METHOD("canvas_light_occluder_reset_physics_interpolation", "occluder"), &RenderingServer::canvas_light_occluder_reset_physics_interpolation);3415ClassDB::bind_method(D_METHOD("canvas_light_occluder_transform_physics_interpolation", "occluder", "transform"), &RenderingServer::canvas_light_occluder_transform_physics_interpolation);34163417/* CANVAS LIGHT OCCLUDER POLYGON */34183419ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create);3420ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape);3421ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode);34223423ClassDB::bind_method(D_METHOD("canvas_set_shadow_texture_size", "size"), &RenderingServer::canvas_set_shadow_texture_size);34243425BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);3426BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);3427BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);34283429/* GLOBAL SHADER UNIFORMS */34303431ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add);3432ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove);3433ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::_global_shader_parameter_get_list);3434ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set);3435ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override);3436ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get);3437ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type);34383439BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL);3440BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2);3441BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC3);3442BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC4);3443BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_INT);3444BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC2);3445BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC3);3446BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC4);3447BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2I);3448BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UINT);3449BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC2);3450BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC3);3451BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC4);3452BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_FLOAT);3453BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC2);3454BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC3);3455BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC4);3456BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_COLOR);3457BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2);3458BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT2);3459BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT3);3460BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT4);3461BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM_2D);3462BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM);3463BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2D);3464BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2DARRAY);3465BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER3D);3466BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLERCUBE);3467BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLEREXT);3468BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAX);34693470/* Free */3471ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free_rid);34723473/* Misc */34743475ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "callable"), &RenderingServer::request_frame_drawn_callback);3476ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed);3477ClassDB::bind_method(D_METHOD("get_rendering_info", "info"), &RenderingServer::get_rendering_info);3478ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);3479ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);3480ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type);3481ClassDB::bind_method(D_METHOD("get_video_adapter_api_version"), &RenderingServer::get_video_adapter_api_version);34823483ClassDB::bind_method(D_METHOD("get_current_rendering_driver_name"), &RenderingServer::get_current_rendering_driver_name);3484ClassDB::bind_method(D_METHOD("get_current_rendering_method"), &RenderingServer::get_current_rendering_method);34853486ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);3487ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);34883489ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);3490ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);34913492ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));3493ClassDB::bind_method(D_METHOD("get_default_clear_color"), &RenderingServer::get_default_clear_color);3494ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);34953496ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);3497ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);34983499ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);3500ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);35013502ClassDB::bind_method(D_METHOD("get_frame_setup_time_cpu"), &RenderingServer::get_frame_setup_time_cpu);35033504ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");35053506BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);3507BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);3508BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);3509BIND_ENUM_CONSTANT(RENDERING_INFO_TEXTURE_MEM_USED);3510BIND_ENUM_CONSTANT(RENDERING_INFO_BUFFER_MEM_USED);3511BIND_ENUM_CONSTANT(RENDERING_INFO_VIDEO_MEM_USED);3512BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_CANVAS);3513BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_MESH);3514BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SURFACE);3515BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_DRAW);3516BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);35173518BIND_ENUM_CONSTANT(PIPELINE_SOURCE_CANVAS);3519BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MESH);3520BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SURFACE);3521BIND_ENUM_CONSTANT(PIPELINE_SOURCE_DRAW);3522BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SPECIALIZATION);3523BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MAX);35243525ADD_SIGNAL(MethodInfo("frame_pre_draw"));3526ADD_SIGNAL(MethodInfo("frame_post_draw"));35273528ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);3529ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));3530ClassDB::bind_method(D_METHOD("get_rendering_device"), &RenderingServer::get_rendering_device);3531ClassDB::bind_method(D_METHOD("create_local_rendering_device"), &RenderingServer::create_local_rendering_device);35323533ClassDB::bind_method(D_METHOD("is_on_render_thread"), &RenderingServer::is_on_render_thread);3534ClassDB::bind_method(D_METHOD("call_on_render_thread", "callable"), &RenderingServer::call_on_render_thread);35353536#ifndef DISABLE_DEPRECATED3537ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);35383539BIND_ENUM_CONSTANT(FEATURE_SHADERS);3540BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);3541#endif3542}35433544void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {3545Vector<Vector3> vertices;3546Vector<Vector3> normals;35473548for (const Geometry3D::MeshData::Face &f : p_mesh_data.faces) {3549for (uint32_t j = 2; j < f.indices.size(); j++) {3550vertices.push_back(p_mesh_data.vertices[f.indices[0]]);3551normals.push_back(f.plane.normal);35523553vertices.push_back(p_mesh_data.vertices[f.indices[j - 1]]);3554normals.push_back(f.plane.normal);35553556vertices.push_back(p_mesh_data.vertices[f.indices[j]]);3557normals.push_back(f.plane.normal);3558}3559}35603561Array d;3562d.resize(RS::ARRAY_MAX);3563d[ARRAY_VERTEX] = vertices;3564d[ARRAY_NORMAL] = normals;3565mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);3566}35673568void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {3569Geometry3D::MeshData mdata = Geometry3D::build_convex_mesh(p_planes);3570mesh_add_surface_from_mesh_data(p_mesh, mdata);3571}35723573RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {3574RID instance = instance_create();3575instance_set_base(instance, p_base);3576instance_set_scenario(instance, p_scenario);3577return instance;3578}35793580bool RenderingServer::is_render_loop_enabled() const {3581return render_loop_enabled;3582}35833584void RenderingServer::set_render_loop_enabled(bool p_enabled) {3585render_loop_enabled = p_enabled;3586}35873588RenderingServer::RenderingServer() {3589//ERR_FAIL_COND(singleton);35903591singleton = this;3592}35933594TypedArray<StringName> RenderingServer::_global_shader_parameter_get_list() const {3595TypedArray<StringName> gsp;3596Vector<StringName> gsp_sn = global_shader_parameter_get_list();3597gsp.resize(gsp_sn.size());3598for (int i = 0; i < gsp_sn.size(); i++) {3599gsp[i] = gsp_sn[i];3600}3601return gsp;3602}36033604void RenderingServer::init() {3605// These are overrides, even if they are false Godot will still3606// import the texture formats that the host platform needs.3607// See `const bool can_s3tc_bptc` in the resource importer.3608GLOBAL_DEF_RST("rendering/textures/vram_compression/import_s3tc_bptc", false);3609GLOBAL_DEF_RST("rendering/textures/vram_compression/import_etc2_astc", false);3610GLOBAL_DEF("rendering/textures/vram_compression/compress_with_gpu", true);3611GLOBAL_DEF("rendering/textures/vram_compression/cache_gpu_compressor", true);36123613GLOBAL_DEF("rendering/textures/lossless_compression/force_png", false);36143615GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/webp_compression/compression_method", PROPERTY_HINT_RANGE, "0,6,1"), 2);3616GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/webp_compression/lossless_compression_factor", PROPERTY_HINT_RANGE, "0,100,1"), 25);36173618GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "1,10000,1,or_greater,suffix:s"), 3600);36193620GLOBAL_DEF_RST("rendering/lights_and_shadows/use_physical_light_units", false);36213622GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"), 4096);3623GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/size.mobile", 2048);3624GLOBAL_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);3625GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile", 0);3626GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/16_bits", true);36273628GLOBAL_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);3629GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);3630GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);36313632GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/2d/shadow_atlas/size", PROPERTY_HINT_RANGE, "128,16384"), 2048);3633GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);3634GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/uniform_set_cache_size", PROPERTY_HINT_RANGE, "256,1048576,1"), 4096);36353636// Number of commands that can be drawn per frame.3637GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/gl_compatibility/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);36383639GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true);3640GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true);3641GLOBAL_DEF("rendering/shader_compiler/shader_cache/use_zstd_compression", true);3642GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug", false);3643GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug.release", true);36443645GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/roughness_layers", PROPERTY_HINT_RANGE, "1,32,1"), 8); // Assumes a 256x256 cubemap3646GLOBAL_DEF_RST("rendering/reflections/sky_reflections/texture_array_reflections", true);3647GLOBAL_DEF("rendering/reflections/sky_reflections/texture_array_reflections.mobile", false);3648GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples", PROPERTY_HINT_RANGE, "0,256,1"), 32);3649GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples.mobile", PROPERTY_HINT_RANGE, "0,128,1"), 16);3650GLOBAL_DEF("rendering/reflections/sky_reflections/fast_filter_high_quality", false);3651GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size", PROPERTY_HINT_RANGE, "0,4096,1"), 256);3652GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size.mobile", PROPERTY_HINT_RANGE, "0,2048,1"), 128);3653GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_count", PROPERTY_HINT_RANGE, "0,256,1"), 64);3654GLOBAL_DEF_RST("rendering/reflections/specular_occlusion/enabled", true);36553656GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false);36573658GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/voxel_gi/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)"), 0);36593660GLOBAL_DEF_RST("rendering/shading/overrides/force_vertex_shading", false);3661GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley", false);3662GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley.mobile", true);36633664GLOBAL_DEF_RST("rendering/driver/depth_prepass/enable", true);3665GLOBAL_DEF_RST("rendering/driver/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");36663667GLOBAL_DEF_RST("rendering/textures/default_filters/use_nearest_mipmap_filter", false);3668GLOBAL_DEF(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);36693670GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/camera/depth_of_field/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slowest)"), 1);3671GLOBAL_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);3672GLOBAL_DEF("rendering/camera/depth_of_field/depth_of_field_use_jitter", false);36733674GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);3675GLOBAL_DEF("rendering/environment/ssao/half_size", true);3676GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);3677GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 2);3678GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);3679GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);36803681GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);3682GLOBAL_DEF("rendering/environment/ssil/half_size", true);3683GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);3684GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 4);3685GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);3686GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);36873688// Move the project setting definitions here so they are available when we init the rendering internals.3689GLOBAL_DEF_BASIC("rendering/viewport/hdr_2d", false);36903691GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_2d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);3692GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);36933694GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);3695GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);3696GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);36973698GLOBAL_DEF_RST(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/quality/smaa_edge_detection_threshold", PROPERTY_HINT_RANGE, "0.01,0.2,0.01"), 0.05);36993700{3701String mode_hints;3702String mode_hints_metal;3703{3704Vector<String> mode_hints_arr = { "Bilinear (Fastest)", "FSR 1.0 (Fast)", "FSR 2.2 (Slow)" };3705mode_hints = String(",").join(mode_hints_arr);37063707mode_hints_arr.push_back("MetalFX (Spatial)");3708mode_hints_arr.push_back("MetalFX (Temporal)");3709mode_hints_metal = String(",").join(mode_hints_arr);3710}37113712GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode", PROPERTY_HINT_ENUM, mode_hints), 0);3713GLOBAL_DEF_NOVAL(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode.ios", PROPERTY_HINT_ENUM, mode_hints_metal), 0);3714GLOBAL_DEF_NOVAL(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode.macos", PROPERTY_HINT_ENUM, mode_hints_metal), 0);3715}3716GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);3717GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);37183719GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);3720GLOBAL_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);3721GLOBAL_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);37223723GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/occlusion_culling/occlusion_rays_per_thread", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), 512);37243725GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slow)"), 1);3726GLOBAL_DEF("rendering/environment/glow/upscale_mode.mobile", 0);37273728GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/screen_space_reflection/roughness_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);37293730GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/subsurface_scattering/subsurface_scattering_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);3731GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.05);3732GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.01);37333734GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/global_shader_variables/buffer_size", PROPERTY_HINT_RANGE, "16,1048576,1"), 65536);37353736GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/probe_capture/update_speed", PROPERTY_HINT_RANGE, "0.001,256,0.001"), 15);3737GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/primitive_meshes/texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.2);3738GLOBAL_DEF("rendering/lightmapping/lightmap_gi/use_bicubic_filter", true);37393740GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/probe_ray_count", PROPERTY_HINT_ENUM, "8 (Fastest),16,32,64,96,128 (Slowest)"), 1);3741GLOBAL_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);3742GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/frames_to_update_lights", PROPERTY_HINT_ENUM, "1 (Slower),2,4,8,16 (Faster)"), 2);37433744GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_size", PROPERTY_HINT_RANGE, "16,512,1"), 64);3745GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_depth", PROPERTY_HINT_RANGE, "16,512,1"), 64);3746GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/use_filter", PROPERTY_HINT_ENUM, "No (Faster),Yes (Higher Quality)"), 1);37473748GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10);3749GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000);37503751GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"), 512);37523753// OpenGL limits3754GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_elements", PROPERTY_HINT_RANGE, "1024,65536,1"), 65536);3755GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_lights", PROPERTY_HINT_RANGE, "2,256,1"), 32);3756GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_lights_per_object", PROPERTY_HINT_RANGE, "2,1024,1"), 8);37573758GLOBAL_DEF_RST_BASIC("xr/shaders/enabled", false);37593760GLOBAL_DEF("debug/shader_language/warnings/enable", true);3761GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false);37623763#ifdef DEBUG_ENABLED3764for (int i = 0; i < (int)ShaderWarning::WARNING_MAX; i++) {3765GLOBAL_DEF("debug/shader_language/warnings/" + ShaderWarning::get_name_from_code((ShaderWarning::Code)i).to_lower(), true);3766}3767#endif3768}37693770RenderingServer::~RenderingServer() {3771singleton = nullptr;3772}377337743775