Path: blob/master/servers/rendering/rendering_server.cpp
20843 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/math/geometry_3d.h"35#include "core/variant/typed_array.h"36#include "servers/rendering/shader_language.h"37#include "servers/rendering/shader_warnings.h"3839RenderingServer *RenderingServer::singleton = nullptr;40RenderingServer *(*RenderingServer::create_func)() = nullptr;4142RenderingServer *RenderingServer::get_singleton() {43return singleton;44}4546RenderingServer *RenderingServer::create() {47ERR_FAIL_COND_V(singleton, nullptr);4849if (create_func) {50return create_func();51}5253return nullptr;54}5556Array RenderingServer::_texture_debug_usage_bind() {57List<TextureInfo> list;58texture_debug_usage(&list);59Array arr;60for (const TextureInfo &E : list) {61Dictionary dict;62dict["texture"] = E.texture;63dict["width"] = E.width;64dict["height"] = E.height;65dict["depth"] = E.depth;66dict["format"] = E.format;67dict["bytes"] = E.bytes;68dict["path"] = E.path;69arr.push_back(dict);70}71return arr;72}7374static PackedInt64Array to_int_array(const Vector<ObjectID> &ids) {75PackedInt64Array a;76a.resize(ids.size());77for (int i = 0; i < ids.size(); ++i) {78a.write[i] = ids[i];79}80return a;81}8283PackedInt64Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {84Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);85return to_int_array(ids);86}8788PackedInt64Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {89Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);90return to_int_array(ids);91}9293PackedInt64Array RenderingServer::_instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario) const {94Vector<Plane> planes;95for (int i = 0; i < p_convex.size(); ++i) {96const Variant &v = p_convex[i];97ERR_FAIL_COND_V(v.get_type() != Variant::PLANE, PackedInt64Array());98planes.push_back(v);99}100101Vector<ObjectID> ids = instances_cull_convex(planes, p_scenario);102return to_int_array(ids);103}104105RID RenderingServer::get_test_texture() {106if (test_texture.is_valid()) {107return test_texture;108};109110#define TEST_TEXTURE_SIZE 256111112Vector<uint8_t> test_data;113test_data.resize(TEST_TEXTURE_SIZE * TEST_TEXTURE_SIZE * 3);114115{116uint8_t *w = test_data.ptrw();117118for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {119for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {120Color c;121int r = 255 - (x + y) / 2;122123if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {124c.r = y;125c.g = r;126c.b = x;127128} else {129c.r = r;130c.g = x;131c.b = y;132}133134w[(y * TEST_TEXTURE_SIZE + x) * 3 + 0] = uint8_t(CLAMP(c.r, 0, 255));135w[(y * TEST_TEXTURE_SIZE + x) * 3 + 1] = uint8_t(CLAMP(c.g, 0, 255));136w[(y * TEST_TEXTURE_SIZE + x) * 3 + 2] = uint8_t(CLAMP(c.b, 0, 255));137}138}139}140141Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data));142143test_texture = texture_2d_create(data);144145return test_texture;146}147148void RenderingServer::_free_internal_rids() {149if (test_texture.is_valid()) {150free_rid(test_texture);151}152if (white_texture.is_valid()) {153free_rid(white_texture);154}155if (test_material.is_valid()) {156free_rid(test_material);157}158}159160RID RenderingServer::_make_test_cube() {161Vector<Vector3> vertices;162Vector<Vector3> normals;163Vector<float> tangents;164Vector<Vector3> uvs;165166#define ADD_VTX(m_idx) \167vertices.push_back(face_points[m_idx]); \168normals.push_back(normal_points[m_idx]); \169tangents.push_back(normal_points[m_idx][1]); \170tangents.push_back(normal_points[m_idx][2]); \171tangents.push_back(normal_points[m_idx][0]); \172tangents.push_back(1.0); \173uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));174175for (int i = 0; i < 6; i++) {176Vector3 face_points[4];177Vector3 normal_points[4];178float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };179180for (int j = 0; j < 4; j++) {181float v[3];182v[0] = 1.0;183v[1] = 1 - 2 * ((j >> 1) & 1);184v[2] = v[1] * (1 - 2 * (j & 1));185186for (int k = 0; k < 3; k++) {187if (i < 3) {188face_points[j][(i + k) % 3] = v[k];189} else {190face_points[3 - j][(i + k) % 3] = -v[k];191}192}193normal_points[j] = Vector3();194normal_points[j][i % 3] = (i >= 3 ? -1 : 1);195}196197// Tri 1198ADD_VTX(0);199ADD_VTX(1);200ADD_VTX(2);201// Tri 2202ADD_VTX(2);203ADD_VTX(3);204ADD_VTX(0);205}206207RID test_cube = mesh_create();208209Array d;210d.resize(RS::ARRAY_MAX);211d[RenderingServer::ARRAY_NORMAL] = normals;212d[RenderingServer::ARRAY_TANGENT] = tangents;213d[RenderingServer::ARRAY_TEX_UV] = uvs;214d[RenderingServer::ARRAY_VERTEX] = vertices;215216Vector<int> indices;217indices.resize(vertices.size());218for (int i = 0; i < vertices.size(); i++) {219indices.set(i, i);220}221d[RenderingServer::ARRAY_INDEX] = indices;222223mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);224225/*226test_material = fixed_material_create();227//material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);228fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );229fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );230fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );231232fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );233fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );234*/235mesh_surface_set_material(test_cube, 0, test_material);236237return test_cube;238}239240RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, real_t p_radius) {241Vector<Vector3> vertices;242Vector<Vector3> normals;243const double lat_step = Math::TAU / p_lats;244const double lon_step = Math::TAU / p_lons;245246for (int i = 1; i <= p_lats; i++) {247double lat0 = lat_step * (i - 1) - Math::TAU / 4;248double z0 = Math::sin(lat0);249double zr0 = Math::cos(lat0);250251double lat1 = lat_step * i - Math::TAU / 4;252double z1 = Math::sin(lat1);253double zr1 = Math::cos(lat1);254255for (int j = p_lons; j >= 1; j--) {256double lng0 = lon_step * (j - 1);257double x0 = Math::cos(lng0);258double y0 = Math::sin(lng0);259260double lng1 = lon_step * j;261double x1 = Math::cos(lng1);262double y1 = Math::sin(lng1);263264Vector3 v[4] = {265Vector3(x1 * zr0, z0, y1 * zr0),266Vector3(x1 * zr1, z1, y1 * zr1),267Vector3(x0 * zr1, z1, y0 * zr1),268Vector3(x0 * zr0, z0, y0 * zr0)269};270271#define ADD_POINT(m_idx) \272normals.push_back(v[m_idx]); \273vertices.push_back(v[m_idx] * p_radius);274275ADD_POINT(0);276ADD_POINT(1);277ADD_POINT(2);278279ADD_POINT(2);280ADD_POINT(3);281ADD_POINT(0);282}283}284285RID mesh = mesh_create();286Array d;287d.resize(RS::ARRAY_MAX);288289d[ARRAY_VERTEX] = vertices;290d[ARRAY_NORMAL] = normals;291292mesh_add_surface_from_arrays(mesh, PRIMITIVE_TRIANGLES, d);293294return mesh;295}296297RID RenderingServer::get_white_texture() {298if (white_texture.is_valid()) {299return white_texture;300}301302Vector<uint8_t> wt;303wt.resize(16 * 3);304{305uint8_t *w = wt.ptrw();306for (int i = 0; i < 16 * 3; i++) {307w[i] = 255;308}309}310Ref<Image> white = memnew(Image(4, 4, false, Image::FORMAT_RGB8, wt));311white_texture = texture_2d_create(white);312return white_texture;313}314315void _get_axis_angle(const Vector3 &p_normal, const Vector4 &p_tangent, float &r_angle, Vector3 &r_axis) {316Vector3 normal = p_normal.normalized();317Vector3 tangent = Vector3(p_tangent.x, p_tangent.y, p_tangent.z).normalized();318float d = p_tangent.w;319Vector3 binormal = normal.cross(tangent).normalized();320real_t angle;321322Basis tbn = Basis();323tbn.rows[0] = tangent;324tbn.rows[1] = binormal;325tbn.rows[2] = normal;326tbn.get_axis_angle(r_axis, angle);327r_angle = float(angle);328329if (d < 0.0) {330r_angle = CLAMP((1.0 - r_angle / Math::PI) * 0.5, 0.0, 0.49999);331} else {332r_angle = CLAMP((r_angle / Math::PI) * 0.5 + 0.5, 0.500008, 1.0);333}334}335336// The inputs to this function should match the outputs of _get_axis_angle. I.e. p_axis is a normalized vector337// and p_angle includes the binormal direction.338void _get_tbn_from_axis_angle(const Vector3 &p_axis, float p_angle, Vector3 &r_normal, Vector4 &r_tangent) {339float binormal_sign = p_angle > 0.5 ? 1.0 : -1.0;340float angle = Math::abs(p_angle * 2.0 - 1.0) * Math::PI;341342Basis tbn = Basis(p_axis, angle);343Vector3 tan = tbn.rows[0];344r_tangent = Vector4(tan.x, tan.y, tan.z, binormal_sign);345r_normal = tbn.rows[2];346}347348AABB _compute_aabb_from_points(const Vector3 *p_data, int p_length) {349if (p_length == 0) {350return AABB();351}352353Vector3 min = p_data[0];354Vector3 max = p_data[0];355356for (int i = 1; i < p_length; ++i) {357min = min.min(p_data[i]);358max = max.max(p_data[i]);359}360361return AABB(min, max - min);362}363364Error 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) {365uint8_t *vw = r_vertex_array.ptrw();366uint8_t *aw = r_attrib_array.ptrw();367uint8_t *sw = r_skin_array.ptrw();368369uint8_t *iw = nullptr;370if (r_index_array.size()) {371iw = r_index_array.ptrw();372}373374int max_bone = 0;375376// Preprocess UVs if compression is enabled377if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && ((p_format & RS::ARRAY_FORMAT_TEX_UV) || (p_format & RS::ARRAY_FORMAT_TEX_UV2))) {378const Vector2 *uv_src = nullptr;379if (p_format & RS::ARRAY_FORMAT_TEX_UV) {380Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV];381uv_src = array.ptr();382}383384const Vector2 *uv2_src = nullptr;385if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {386Vector<Vector2> array = p_arrays[RS::ARRAY_TEX_UV2];387uv2_src = array.ptr();388}389390Vector2 max_val = Vector2(0.0, 0.0);391Vector2 min_val = Vector2(0.0, 0.0);392Vector2 max_val2 = Vector2(0.0, 0.0);393Vector2 min_val2 = Vector2(0.0, 0.0);394395for (int i = 0; i < p_vertex_array_len; i++) {396if (p_format & RS::ARRAY_FORMAT_TEX_UV) {397max_val = max_val.max(uv_src[i]);398min_val = min_val.min(uv_src[i]);399}400if (p_format & RS::ARRAY_FORMAT_TEX_UV2) {401max_val2 = max_val2.max(uv2_src[i]);402min_val2 = min_val2.min(uv2_src[i]);403}404}405406max_val = max_val.abs().max(min_val.abs());407max_val2 = max_val2.abs().max(min_val2.abs());408409if (min_val.x >= 0.0 && min_val2.x >= 0.0 && max_val.x <= 1.0 && max_val2.x <= 1.0 &&410min_val.y >= 0.0 && min_val2.y >= 0.0 && max_val.y <= 1.0 && max_val2.y <= 1.0) {411// When all channels are in the 0-1 range, we will compress to 16-bit without scaling to412// preserve the bits as best as possible.413r_uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);414} else {415r_uv_scale = Vector4(max_val.x, max_val.y, max_val2.x, max_val2.y) * Vector4(2.0, 2.0, 2.0, 2.0);416}417}418419for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {420if (!(p_format & (1ULL << ai))) { // No array421continue;422}423424switch (ai) {425case RS::ARRAY_VERTEX: {426if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {427Vector<Vector2> array = p_arrays[ai];428ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);429430const Vector2 *src = array.ptr();431432// Setting vertices means regenerating the AABB.433Rect2 aabb;434435{436for (int i = 0; i < p_vertex_array_len; i++) {437float vector[2] = { (float)src[i].x, (float)src[i].y };438439memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2);440441if (i == 0) {442aabb = Rect2(src[i], SMALL_VEC2); // Must have a bit of size.443} else {444aabb.expand_to(src[i]);445}446}447}448449r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));450451} else {452Vector<Vector3> array = p_arrays[ai];453ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);454455const Vector3 *src = array.ptr();456457r_aabb = _compute_aabb_from_points(src, p_vertex_array_len);458r_aabb.size = r_aabb.size.max(SMALL_VEC3);459460if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {461if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {462// Early out if we are only setting vertex positions.463for (int i = 0; i < p_vertex_array_len; i++) {464Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;465uint16_t vector[4] = {466(uint16_t)CLAMP(pos.x * 65535, 0, 65535),467(uint16_t)CLAMP(pos.y * 65535, 0, 65535),468(uint16_t)CLAMP(pos.z * 65535, 0, 65535),469(uint16_t)0470};471472memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);473}474continue;475}476477// Validate normal and tangent arrays.478ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);479480Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];481ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);482const Vector3 *normal_src = normal_array.ptr();483484Variant::Type tangent_type = p_arrays[RS::ARRAY_TANGENT].get_type();485ERR_FAIL_COND_V(tangent_type != Variant::PACKED_FLOAT32_ARRAY && tangent_type != Variant::PACKED_FLOAT64_ARRAY && tangent_type != Variant::NIL, ERR_INVALID_PARAMETER);486487// We need a different version if using double precision tangents.488if (tangent_type == Variant::PACKED_FLOAT32_ARRAY) {489Vector<float> tangent_array = p_arrays[RS::ARRAY_TANGENT];490ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);491const float *tangent_src = tangent_array.ptr();492493// Set data for vertex, normal, and tangent.494for (int i = 0; i < p_vertex_array_len; i++) {495float angle = 0.0;496Vector3 axis;497Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);498_get_axis_angle(normal_src[i], tangent, angle, axis);499500// Store axis.501{502Vector2 res = axis.octahedron_encode();503uint16_t vector[2] = {504(uint16_t)CLAMP(res.x * 65535, 0, 65535),505(uint16_t)CLAMP(res.y * 65535, 0, 65535),506};507508memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);509}510511// Store vertex position + angle.512{513Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;514uint16_t vector[4] = {515(uint16_t)CLAMP(pos.x * 65535, 0, 65535),516(uint16_t)CLAMP(pos.y * 65535, 0, 65535),517(uint16_t)CLAMP(pos.z * 65535, 0, 65535),518(uint16_t)CLAMP(angle * 65535, 0, 65535)519};520521memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);522}523}524} else if (tangent_type == Variant::PACKED_FLOAT64_ARRAY) {525Vector<double> tangent_array = p_arrays[RS::ARRAY_TANGENT];526ERR_FAIL_COND_V(tangent_array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);527const double *tangent_src = tangent_array.ptr();528529// Set data for vertex, normal, and tangent.530for (int i = 0; i < p_vertex_array_len; i++) {531float angle;532Vector3 axis;533Vector4 tangent = Vector4(tangent_src[i * 4 + 0], tangent_src[i * 4 + 1], tangent_src[i * 4 + 2], tangent_src[i * 4 + 3]);534_get_axis_angle(normal_src[i], tangent, angle, axis);535536// Store axis.537{538Vector2 res = axis.octahedron_encode();539uint16_t vector[2] = {540(uint16_t)CLAMP(res.x * 65535, 0, 65535),541(uint16_t)CLAMP(res.y * 65535, 0, 65535),542};543544memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);545}546547// Store vertex position + angle.548{549Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;550uint16_t vector[4] = {551(uint16_t)CLAMP(pos.x * 65535, 0, 65535),552(uint16_t)CLAMP(pos.y * 65535, 0, 65535),553(uint16_t)CLAMP(pos.z * 65535, 0, 65535),554(uint16_t)CLAMP(angle * 65535, 0, 65535)555};556557memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);558}559}560} else { // No tangent array.561// Set data for vertex, normal, and tangent.562for (int i = 0; i < p_vertex_array_len; i++) {563float angle;564Vector3 axis;565// Generate an arbitrary vector that is tangential to normal.566// This assumes that the normal is never (0,0,0).567Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();568Vector4 tangent = Vector4(tan.x, tan.y, tan.z, 1.0);569_get_axis_angle(normal_src[i], tangent, angle, axis);570571// Store axis.572{573Vector2 res = axis.octahedron_encode();574uint16_t vector[2] = {575(uint16_t)CLAMP(res.x * 65535, 0, 65535),576(uint16_t)CLAMP(res.y * 65535, 0, 65535),577};578579memcpy(&vw[p_offsets[RS::ARRAY_NORMAL] + i * p_normal_stride], vector, 4);580}581582// Store vertex position + angle.583{584Vector3 pos = (src[i] - r_aabb.position) / r_aabb.size;585uint16_t vector[4] = {586(uint16_t)CLAMP(pos.x * 65535, 0, 65535),587(uint16_t)CLAMP(pos.y * 65535, 0, 65535),588(uint16_t)CLAMP(pos.z * 65535, 0, 65535),589(uint16_t)CLAMP(angle * 65535, 0, 65535)590};591592memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(uint16_t) * 4);593}594}595}596} else {597for (int i = 0; i < p_vertex_array_len; i++) {598float vector[3] = { (float)src[i].x, (float)src[i].y, (float)src[i].z };599600memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 3);601}602}603}604605} break;606case RS::ARRAY_NORMAL: {607// If using compression we store normal while storing vertices.608if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {609ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);610611Vector<Vector3> array = p_arrays[ai];612ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);613614const Vector3 *src = array.ptr();615for (int i = 0; i < p_vertex_array_len; i++) {616Vector2 res = src[i].octahedron_encode();617uint16_t vector[2] = {618(uint16_t)CLAMP(res.x * 65535, 0, 65535),619(uint16_t)CLAMP(res.y * 65535, 0, 65535),620};621622memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);623}624}625} break;626627case RS::ARRAY_TANGENT: {628// If using compression we store tangent while storing vertices.629if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {630Variant::Type type = p_arrays[ai].get_type();631ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY && type != Variant::NIL, ERR_INVALID_PARAMETER);632633if (type == Variant::PACKED_FLOAT32_ARRAY) {634Vector<float> array = p_arrays[ai];635ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);636const float *src_ptr = array.ptr();637638for (int i = 0; i < p_vertex_array_len; i++) {639const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);640Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);641uint16_t vector[2] = {642(uint16_t)CLAMP(res.x * 65535, 0, 65535),643(uint16_t)CLAMP(res.y * 65535, 0, 65535),644};645646if (vector[0] == 0 && vector[1] == 65535) {647// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.648// So we sanitize here.649vector[0] = 65535;650}651652memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);653}654} else if (type == Variant::PACKED_FLOAT64_ARRAY) {655Vector<double> array = p_arrays[ai];656ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);657const double *src_ptr = array.ptr();658659for (int i = 0; i < p_vertex_array_len; i++) {660const Vector3 src(src_ptr[i * 4 + 0], src_ptr[i * 4 + 1], src_ptr[i * 4 + 2]);661Vector2 res = src.octahedron_tangent_encode(src_ptr[i * 4 + 3]);662uint16_t vector[2] = {663(uint16_t)CLAMP(res.x * 65535, 0, 65535),664(uint16_t)CLAMP(res.y * 65535, 0, 65535),665};666667if (vector[0] == 0 && vector[1] == 65535) {668// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.669// So we sanitize here.670vector[0] = 65535;671}672673memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);674}675} else { // No tangent array.676ERR_FAIL_COND_V(p_arrays[RS::ARRAY_NORMAL].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);677678Vector<Vector3> normal_array = p_arrays[RS::ARRAY_NORMAL];679ERR_FAIL_COND_V(normal_array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);680const Vector3 *normal_src = normal_array.ptr();681// Set data for tangent.682for (int i = 0; i < p_vertex_array_len; i++) {683// Generate an arbitrary vector that is tangential to normal.684// This assumes that the normal is never (0,0,0).685Vector3 tan = Vector3(normal_src[i].z, -normal_src[i].x, normal_src[i].y).cross(normal_src[i].normalized()).normalized();686Vector2 res = tan.octahedron_tangent_encode(1.0);687uint16_t vector[2] = {688(uint16_t)CLAMP(res.x * 65535, 0, 65535),689(uint16_t)CLAMP(res.y * 65535, 0, 65535),690};691692if (vector[0] == 0 && vector[1] == 65535) {693// (1, 1) and (0, 1) decode to the same value, but (0, 1) messes with our compression detection.694// So we sanitize here.695vector[0] = 65535;696}697698memcpy(&vw[p_offsets[ai] + i * p_normal_stride], vector, 4);699}700}701}702} break;703case RS::ARRAY_COLOR: {704ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);705706Vector<Color> array = p_arrays[ai];707708ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);709710const Color *src = array.ptr();711for (int i = 0; i < p_vertex_array_len; i++) {712uint8_t color8[4] = {713uint8_t(CLAMP(src[i].r * 255.0, 0.0, 255.0)),714uint8_t(CLAMP(src[i].g * 255.0, 0.0, 255.0)),715uint8_t(CLAMP(src[i].b * 255.0, 0.0, 255.0)),716uint8_t(CLAMP(src[i].a * 255.0, 0.0, 255.0))717};718memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color8, 4);719}720} break;721case RS::ARRAY_TEX_UV: {722ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);723724Vector<Vector2> array = p_arrays[ai];725726ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);727728const Vector2 *src = array.ptr();729if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {730for (int i = 0; i < p_vertex_array_len; i++) {731Vector2 vec = src[i];732if (!r_uv_scale.is_zero_approx()) {733// Normalize into 0-1 from possible range -uv_scale - uv_scale.734vec = vec / (Vector2(r_uv_scale.x, r_uv_scale.y)) + Vector2(0.5, 0.5);735}736737uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };738memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);739}740} else {741for (int i = 0; i < p_vertex_array_len; i++) {742float uv[2] = { (float)src[i].x, (float)src[i].y };743memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);744}745}746} break;747748case RS::ARRAY_TEX_UV2: {749ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);750751Vector<Vector2> array = p_arrays[ai];752753ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);754755const Vector2 *src = array.ptr();756757if (p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) {758for (int i = 0; i < p_vertex_array_len; i++) {759Vector2 vec = src[i];760if (!r_uv_scale.is_zero_approx()) {761// Normalize into 0-1 from possible range -uv_scale - uv_scale.762vec = vec / (Vector2(r_uv_scale.z, r_uv_scale.w)) + Vector2(0.5, 0.5);763}764uint16_t uv[2] = { (uint16_t)CLAMP(vec.x * 65535, 0, 65535), (uint16_t)CLAMP(vec.y * 65535, 0, 65535) };765memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 4);766}767} else {768for (int i = 0; i < p_vertex_array_len; i++) {769float uv[2] = { (float)src[i].x, (float)src[i].y };770memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4);771}772}773} break;774case RS::ARRAY_CUSTOM0:775case RS::ARRAY_CUSTOM1:776case RS::ARRAY_CUSTOM2:777case RS::ARRAY_CUSTOM3: {778uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (ai - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;779switch (type) {780case ARRAY_CUSTOM_RGBA8_UNORM:781case ARRAY_CUSTOM_RGBA8_SNORM:782case ARRAY_CUSTOM_RG_HALF: {783// Size 4784ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);785786Vector<uint8_t> array = p_arrays[ai];787788ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER);789790const uint8_t *src = array.ptr();791792for (int i = 0; i < p_vertex_array_len; i++) {793memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 4], 4);794}795796} break;797case ARRAY_CUSTOM_RGBA_HALF: {798// Size 8799ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER);800801Vector<uint8_t> array = p_arrays[ai];802803ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 8, ERR_INVALID_PARAMETER);804805const uint8_t *src = array.ptr();806807for (int i = 0; i < p_vertex_array_len; i++) {808memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * 8], 8);809}810} break;811case ARRAY_CUSTOM_R_FLOAT:812case ARRAY_CUSTOM_RG_FLOAT:813case ARRAY_CUSTOM_RGB_FLOAT:814case ARRAY_CUSTOM_RGBA_FLOAT: {815// RF816ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);817818Vector<float> array = p_arrays[ai];819int32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;820821ERR_FAIL_COND_V(array.size() != p_vertex_array_len * s, ERR_INVALID_PARAMETER);822823const float *src = array.ptr();824825for (int i = 0; i < p_vertex_array_len; i++) {826memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], &src[i * s], sizeof(float) * s);827}828} break;829default: {830}831}832833} break;834case RS::ARRAY_WEIGHTS: {835Variant::Type type = p_arrays[ai].get_type();836ERR_FAIL_COND_V(type != Variant::PACKED_FLOAT32_ARRAY && type != Variant::PACKED_FLOAT64_ARRAY, ERR_INVALID_PARAMETER);837uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;838if (type == Variant::PACKED_FLOAT32_ARRAY) {839Vector<float> array = p_arrays[ai];840ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);841const float *src = array.ptr();842{843uint16_t data[8];844for (int i = 0; i < p_vertex_array_len; i++) {845for (uint32_t j = 0; j < bone_count; j++) {846data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);847}848849memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);850}851}852} else { // PACKED_FLOAT64_ARRAY853Vector<double> array = p_arrays[ai];854ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);855const double *src = array.ptr();856{857uint16_t data[8];858for (int i = 0; i < p_vertex_array_len; i++) {859for (uint32_t j = 0; j < bone_count; j++) {860data[j] = CLAMP(src[i * bone_count + j] * 65535, 0, 65535);861}862863memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);864}865}866}867} break;868case RS::ARRAY_BONES: {869ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);870871Vector<int> array = p_arrays[ai];872873uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;874875ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER);876877const int *src = array.ptr();878879uint16_t data[8];880881for (int i = 0; i < p_vertex_array_len; i++) {882for (uint32_t j = 0; j < bone_count; j++) {883data[j] = src[i * bone_count + j];884max_bone = MAX(data[j], max_bone);885}886887memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count);888}889890} break;891892case RS::ARRAY_INDEX: {893ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);894ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);895ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);896897Vector<int> indices = p_arrays[ai];898ERR_FAIL_COND_V(indices.is_empty(), ERR_INVALID_PARAMETER);899ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER);900901/* determine whether using 16 or 32 bits indices */902903const int *src = indices.ptr();904905for (int i = 0; i < p_index_array_len; i++) {906if (p_vertex_array_len <= (1 << 16) && p_vertex_array_len > 0) {907uint16_t v = src[i];908909memcpy(&iw[i * 2], &v, 2);910} else {911uint32_t v = src[i];912913memcpy(&iw[i * 4], &v, 4);914}915}916} break;917default: {918ERR_FAIL_V(ERR_INVALID_DATA);919}920}921}922923if (p_format & RS::ARRAY_FORMAT_BONES) {924// Create AABBs for each detected bone.925int total_bones = max_bone + 1;926927bool first = r_bone_aabb.is_empty();928929r_bone_aabb.resize(total_bones);930931int weight_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;932933if (first) {934for (int i = 0; i < total_bones; i++) {935r_bone_aabb.write[i].size = Vector3(-1, -1, -1); // Negative means unused.936}937}938939Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];940Vector<int> bones = p_arrays[RS::ARRAY_BONES];941Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS];942943bool any_valid = false;944945if (vertices.size() && bones.size() == vertices.size() * weight_count && weights.size() == bones.size()) {946int vs = vertices.size();947const Vector3 *rv = vertices.ptr();948const int *rb = bones.ptr();949const float *rw = weights.ptr();950951AABB *bptr = r_bone_aabb.ptrw();952953for (int i = 0; i < vs; i++) {954Vector3 v = rv[i];955for (int j = 0; j < weight_count; j++) {956int idx = rb[i * weight_count + j];957float w = rw[i * weight_count + j];958if (w == 0) {959continue; //break;960}961ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);962963if (bptr[idx].size.x < 0) {964// First965bptr[idx] = AABB(v, SMALL_VEC3);966any_valid = true;967} else {968bptr[idx].expand_to(v);969}970}971}972}973974if (!any_valid && first) {975r_bone_aabb.clear();976}977}978return OK;979}980981uint32_t RenderingServer::mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const {982ERR_FAIL_INDEX_V(p_array_index, ARRAY_MAX, 0);983p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;984uint32_t offsets[ARRAY_MAX];985uint32_t vstr;986uint32_t ntstr;987uint32_t astr;988uint32_t sstr;989mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);990return offsets[p_array_index];991}992993uint32_t RenderingServer::mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {994p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;995uint32_t offsets[ARRAY_MAX];996uint32_t vstr;997uint32_t ntstr;998uint32_t astr;999uint32_t sstr;1000mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1001return vstr;1002}10031004uint32_t RenderingServer::mesh_surface_get_format_normal_tangent_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1005p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1006uint32_t offsets[ARRAY_MAX];1007uint32_t vstr;1008uint32_t ntstr;1009uint32_t astr;1010uint32_t sstr;1011mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1012return ntstr;1013}10141015uint32_t RenderingServer::mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1016p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1017uint32_t offsets[ARRAY_MAX];1018uint32_t vstr;1019uint32_t ntstr;1020uint32_t astr;1021uint32_t sstr;1022mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1023return astr;1024}10251026uint32_t RenderingServer::mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1027p_format = uint64_t(p_format) & ~ARRAY_FORMAT_INDEX;1028uint32_t offsets[ARRAY_MAX];1029uint32_t vstr;1030uint32_t ntstr;1031uint32_t astr;1032uint32_t sstr;1033mesh_surface_make_offsets_from_format(p_format, p_vertex_len, 0, offsets, vstr, ntstr, astr, sstr);1034return sstr;1035}10361037uint32_t RenderingServer::mesh_surface_get_format_index_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const {1038if (!(p_format & ARRAY_FORMAT_INDEX)) {1039return 0;1040}10411042// Determine whether using 16 or 32 bits indices.1043if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1044return 2;1045} else {1046return 4;1047}1048}10491050void 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 {1051r_vertex_element_size = 0;1052r_normal_element_size = 0;1053r_attrib_element_size = 0;1054r_skin_element_size = 0;10551056uint32_t *size_accum = nullptr;10571058for (int i = 0; i < RS::ARRAY_MAX; i++) {1059r_offsets[i] = 0; // Reset10601061if (i == RS::ARRAY_VERTEX) {1062size_accum = &r_vertex_element_size;1063} else if (i == RS::ARRAY_NORMAL) {1064size_accum = &r_normal_element_size;1065} else if (i == RS::ARRAY_COLOR) {1066size_accum = &r_attrib_element_size;1067} else if (i == RS::ARRAY_BONES) {1068size_accum = &r_skin_element_size;1069}10701071if (!(p_format & (1ULL << i))) { // No array1072continue;1073}10741075int elem_size = 0;10761077switch (i) {1078case RS::ARRAY_VERTEX: {1079if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {1080elem_size = 2;1081} else {1082elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 2 : 3;1083}10841085elem_size *= sizeof(float);1086} break;1087case RS::ARRAY_NORMAL: {1088elem_size = 4;1089} break;1090case RS::ARRAY_TANGENT: {1091elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 0 : 4;1092} break;1093case RS::ARRAY_COLOR: {1094elem_size = 4;1095} break;1096case RS::ARRAY_TEX_UV: {1097elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;1098} break;1099case RS::ARRAY_TEX_UV2: {1100elem_size = (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) ? 4 : 8;1101} break;1102case RS::ARRAY_CUSTOM0:1103case RS::ARRAY_CUSTOM1:1104case RS::ARRAY_CUSTOM2:1105case RS::ARRAY_CUSTOM3: {1106uint64_t format = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + (ARRAY_FORMAT_CUSTOM_BITS * (i - ARRAY_CUSTOM0)))) & ARRAY_FORMAT_CUSTOM_MASK;1107switch (format) {1108case ARRAY_CUSTOM_RGBA8_UNORM: {1109elem_size = 4;1110} break;1111case ARRAY_CUSTOM_RGBA8_SNORM: {1112elem_size = 4;1113} break;1114case ARRAY_CUSTOM_RG_HALF: {1115elem_size = 4;1116} break;1117case ARRAY_CUSTOM_RGBA_HALF: {1118elem_size = 8;1119} break;1120case ARRAY_CUSTOM_R_FLOAT: {1121elem_size = 4;1122} break;1123case ARRAY_CUSTOM_RG_FLOAT: {1124elem_size = 8;1125} break;1126case ARRAY_CUSTOM_RGB_FLOAT: {1127elem_size = 12;1128} break;1129case ARRAY_CUSTOM_RGBA_FLOAT: {1130elem_size = 16;1131} break;1132}1133} break;1134case RS::ARRAY_WEIGHTS: {1135uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;1136elem_size = sizeof(uint16_t) * bone_count;11371138} break;1139case RS::ARRAY_BONES: {1140uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;1141elem_size = sizeof(uint16_t) * bone_count;1142} break;1143case RS::ARRAY_INDEX: {1144if (p_index_len <= 0) {1145ERR_PRINT("index_array_len==NO_INDEX_ARRAY");1146break;1147}1148/* determine whether using 16 or 32 bits indices */1149if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1150elem_size = 2;1151} else {1152elem_size = 4;1153}1154r_offsets[i] = elem_size;1155continue;1156}1157default: {1158ERR_FAIL();1159}1160}11611162if (size_accum != nullptr) {1163r_offsets[i] = (*size_accum);1164if (i == RS::ARRAY_NORMAL || i == RS::ARRAY_TANGENT) {1165r_offsets[i] += r_vertex_element_size * p_vertex_len;1166}1167(*size_accum) += elem_size;1168} else {1169r_offsets[i] = 0;1170}1171}1172}11731174Error 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) {1175ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);1176ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);11771178uint64_t format = 0;11791180// Validation1181int index_array_len = 0;1182int array_len = 0;11831184for (int i = 0; i < p_arrays.size(); i++) {1185if (p_arrays[i].get_type() == Variant::NIL) {1186continue;1187}11881189format |= (1ULL << i);11901191if (i == RS::ARRAY_VERTEX) {1192switch (p_arrays[i].get_type()) {1193case Variant::PACKED_VECTOR2_ARRAY: {1194Vector<Vector2> v2 = p_arrays[i];1195array_len = v2.size();1196format |= ARRAY_FLAG_USE_2D_VERTICES;1197} break;1198case Variant::PACKED_VECTOR3_ARRAY: {1199ERR_FAIL_COND_V(p_compress_format & ARRAY_FLAG_USE_2D_VERTICES, ERR_INVALID_PARAMETER);1200Vector<Vector3> v3 = p_arrays[i];1201array_len = v3.size();1202} break;1203default: {1204ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Vertex array must be a PackedVector2Array or PackedVector3Array.");1205} break;1206}1207ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);1208} else if (i == RS::ARRAY_NORMAL) {1209if (p_arrays[RS::ARRAY_TANGENT].get_type() == Variant::NIL) {1210// We must use tangents if using normals.1211format |= (1ULL << RS::ARRAY_TANGENT);1212}1213} else if (i == RS::ARRAY_BONES) {1214switch (p_arrays[i].get_type()) {1215case Variant::PACKED_INT32_ARRAY: {1216Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];1217Vector<int32_t> bones = p_arrays[i];1218int32_t bone_8_group_count = bones.size() / (ARRAY_WEIGHTS_SIZE * 2);1219int32_t vertex_count = vertices.size();1220if (vertex_count == bone_8_group_count) {1221format |= RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS;1222}1223} break;1224default: {1225ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Bones array must be a PackedInt32Array.");1226} break;1227}1228} else if (i == RS::ARRAY_INDEX) {1229index_array_len = PackedInt32Array(p_arrays[i]).size();1230}1231}12321233if (p_blend_shapes.size()) {1234// Validate format for morphs.1235for (int i = 0; i < p_blend_shapes.size(); i++) {1236uint32_t bsformat = 0;1237Array arr = p_blend_shapes[i];1238for (int j = 0; j < arr.size(); j++) {1239if (arr[j].get_type() != Variant::NIL) {1240bsformat |= (1 << j);1241}1242}1243if (bsformat & RS::ARRAY_FORMAT_NORMAL) {1244// We must use tangents if using normals.1245bsformat |= RS::ARRAY_FORMAT_TANGENT;1246}12471248ERR_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.");1249}1250}12511252for (uint32_t i = 0; i < RS::ARRAY_CUSTOM_COUNT; ++i) {1253// Include custom array format type.1254if (format & (1ULL << (ARRAY_CUSTOM0 + i))) {1255format |= (RS::ARRAY_FORMAT_CUSTOM_MASK << (RS::ARRAY_FORMAT_CUSTOM_BASE + i * RS::ARRAY_FORMAT_CUSTOM_BITS)) & p_compress_format;1256}1257}12581259uint32_t offsets[RS::ARRAY_MAX];12601261uint32_t vertex_element_size;1262uint32_t normal_element_size;1263uint32_t attrib_element_size;1264uint32_t skin_element_size;12651266uint64_t mask = (1ULL << ARRAY_MAX) - 1ULL;1267format |= (~mask) & p_compress_format; // Make the full format.12681269// Force version to the current version as this function will always return a surface with the current version.1270format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);1271format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);12721273mesh_surface_make_offsets_from_format(format, array_len, index_array_len, offsets, vertex_element_size, normal_element_size, attrib_element_size, skin_element_size);12741275if ((format & RS::ARRAY_FORMAT_VERTEX) == 0 && !(format & RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY)) {1276ERR_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.");1277// Set the flag here after warning to suppress errors down the pipeline.1278format |= RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY;1279}12801281if ((format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES) && ((format & RS::ARRAY_FORMAT_NORMAL) || (format & RS::ARRAY_FORMAT_TANGENT))) {1282// If using normals or tangents, then we need all three.1283ERR_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.");1284ERR_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.");1285}12861287int vertex_array_size = (vertex_element_size + normal_element_size) * array_len;1288int attrib_array_size = attrib_element_size * array_len;1289int skin_array_size = skin_element_size * array_len;1290int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len;12911292Vector<uint8_t> vertex_array;1293vertex_array.resize(vertex_array_size);12941295Vector<uint8_t> attrib_array;1296attrib_array.resize(attrib_array_size);12971298Vector<uint8_t> skin_array;1299skin_array.resize(skin_array_size);13001301Vector<uint8_t> index_array;1302index_array.resize(index_array_size);13031304AABB aabb;1305Vector<AABB> bone_aabb;13061307Vector4 uv_scale = Vector4(0.0, 0.0, 0.0, 0.0);13081309Error 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);1310ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Invalid array format for surface.");13111312Vector<uint8_t> blend_shape_data;13131314if (p_blend_shapes.size()) {1315uint32_t bs_format = format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK;1316for (int i = 0; i < p_blend_shapes.size(); i++) {1317Vector<uint8_t> vertex_array_shape;1318vertex_array_shape.resize(vertex_array_size);1319Vector<uint8_t> noindex;1320Vector<uint8_t> noattrib;1321Vector<uint8_t> noskin;13221323AABB laabb;1324Vector4 bone_uv_scale; // Not used.1325Error 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);1326aabb.merge_with(laabb);1327ERR_FAIL_COND_V_MSG(err2 != OK, ERR_INVALID_DATA, "Invalid blend shape array format for surface.");13281329blend_shape_data.append_array(vertex_array_shape);1330}1331}1332Vector<SurfaceData::LOD> lods;1333if (index_array_len) {1334LocalVector<Variant> keys = p_lods.get_key_list();1335keys.sort(); // otherwise lod levels may get skipped1336for (const Variant &E : keys) {1337float distance = E;1338ERR_CONTINUE(distance <= 0.0);1339Vector<int> indices = p_lods[E];1340ERR_CONTINUE(indices.is_empty());1341uint32_t index_count = indices.size();1342ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller..13431344const int *r = indices.ptr();13451346Vector<uint8_t> data;1347if (array_len <= 65536) {1348// 16 bits indices1349data.resize(indices.size() * 2);1350uint8_t *w = data.ptrw();1351uint16_t *index_ptr = (uint16_t *)w;1352for (uint32_t i = 0; i < index_count; i++) {1353index_ptr[i] = r[i];1354}1355} else {1356// 32 bits indices1357data.resize(indices.size() * 4);1358uint8_t *w = data.ptrw();1359uint32_t *index_ptr = (uint32_t *)w;1360for (uint32_t i = 0; i < index_count; i++) {1361index_ptr[i] = r[i];1362}1363}13641365SurfaceData::LOD lod;1366lod.edge_length = distance;1367lod.index_data = data;1368lods.push_back(lod);1369}1370}13711372SurfaceData &surface_data = *r_surface_data;1373surface_data.format = format;1374surface_data.primitive = p_primitive;1375surface_data.aabb = aabb;1376surface_data.vertex_data = vertex_array;1377surface_data.attribute_data = attrib_array;1378surface_data.skin_data = skin_array;1379surface_data.vertex_count = array_len;1380surface_data.index_data = index_array;1381surface_data.index_count = index_array_len;1382surface_data.blend_shape_data = blend_shape_data;1383surface_data.bone_aabbs = bone_aabb;1384surface_data.lods = lods;1385surface_data.uv_scale = uv_scale;13861387return OK;1388}13891390void 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) {1391SurfaceData sd;1392Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);1393if (err != OK) {1394return;1395}1396mesh_add_surface(p_mesh, sd);1397}13981399Array 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 {1400uint32_t offsets[RS::ARRAY_MAX];14011402uint32_t vertex_elem_size;1403uint32_t normal_elem_size;1404uint32_t attrib_elem_size;1405uint32_t skin_elem_size;1406mesh_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);14071408Array ret;1409ret.resize(RS::ARRAY_MAX);14101411const uint8_t *r = p_vertex_data.ptr();1412const uint8_t *ar = p_attrib_data.ptr();1413const uint8_t *sr = p_skin_data.ptr();14141415for (int i = 0; i < RS::ARRAY_MAX; i++) {1416if (!(p_format & (1ULL << i))) {1417continue;1418}14191420switch (i) {1421case RS::ARRAY_VERTEX: {1422if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {1423Vector<Vector2> arr_2d;1424arr_2d.resize(p_vertex_len);14251426{1427Vector2 *w = arr_2d.ptrw();14281429for (int j = 0; j < p_vertex_len; j++) {1430const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);1431w[j] = Vector2(v[0], v[1]);1432}1433}14341435ret[i] = arr_2d;1436} else {1437Vector<Vector3> arr_3d;1438arr_3d.resize(p_vertex_len);14391440{1441Vector3 *w = arr_3d.ptrw();14421443if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1444// We only have vertices to read, so just read them and skip everything else.1445if (!(p_format & RS::ARRAY_FORMAT_NORMAL)) {1446for (int j = 0; j < p_vertex_len; j++) {1447const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);1448Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);1449w[j] = (vec * p_aabb.size) + p_aabb.position;1450}1451continue;1452}14531454Vector<Vector3> normals;1455normals.resize(p_vertex_len);1456Vector3 *normalsw = normals.ptrw();14571458Vector<float> tangents;1459tangents.resize(p_vertex_len * 4);1460float *tangentsw = tangents.ptrw();14611462for (int j = 0; j < p_vertex_len; j++) {1463const uint32_t n = *(const uint32_t *)&r[j * normal_elem_size + offsets[RS::ARRAY_NORMAL]];1464Vector3 axis = Vector3::octahedron_decode(Vector2((n & 0xFFFF) / 65535.0, ((n >> 16) & 0xFFFF) / 65535.0));14651466const uint16_t *v = reinterpret_cast<const uint16_t *>(&r[j * vertex_elem_size + offsets[i]]);1467Vector3 vec = Vector3(float(v[0]) / 65535.0, float(v[1]) / 65535.0, float(v[2]) / 65535.0);1468float angle = float(v[3]) / 65535.0;1469w[j] = (vec * p_aabb.size) + p_aabb.position;14701471Vector3 normal;1472Vector4 tan;1473_get_tbn_from_axis_angle(axis, angle, normal, tan);14741475normalsw[j] = normal;1476tangentsw[j * 4 + 0] = tan.x;1477tangentsw[j * 4 + 1] = tan.y;1478tangentsw[j * 4 + 2] = tan.z;1479tangentsw[j * 4 + 3] = tan.w;1480}1481ret[RS::ARRAY_NORMAL] = normals;1482ret[RS::ARRAY_TANGENT] = tangents;14831484} else {1485for (int j = 0; j < p_vertex_len; j++) {1486const float *v = reinterpret_cast<const float *>(&r[j * vertex_elem_size + offsets[i]]);1487w[j] = Vector3(v[0], v[1], v[2]);1488}1489}1490}14911492ret[i] = arr_3d;1493}14941495} break;1496case RS::ARRAY_NORMAL: {1497if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {1498Vector<Vector3> arr;1499arr.resize(p_vertex_len);15001501Vector3 *w = arr.ptrw();15021503for (int j = 0; j < p_vertex_len; j++) {1504const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];15051506w[j] = Vector3::octahedron_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0));1507}15081509ret[i] = arr;1510}1511} break;15121513case RS::ARRAY_TANGENT: {1514if (!(p_format & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES)) {1515Vector<float> arr;1516arr.resize(p_vertex_len * 4);15171518float *w = arr.ptrw();15191520for (int j = 0; j < p_vertex_len; j++) {1521const uint32_t v = *(const uint32_t *)&r[j * normal_elem_size + offsets[i]];1522float tangent_sign;1523Vector3 res = Vector3::octahedron_tangent_decode(Vector2((v & 0xFFFF) / 65535.0, ((v >> 16) & 0xFFFF) / 65535.0), &tangent_sign);1524w[j * 4 + 0] = res.x;1525w[j * 4 + 1] = res.y;1526w[j * 4 + 2] = res.z;1527w[j * 4 + 3] = tangent_sign;1528}15291530ret[i] = arr;1531}1532} break;1533case RS::ARRAY_COLOR: {1534Vector<Color> arr;1535arr.resize(p_vertex_len);15361537Color *w = arr.ptrw();15381539for (int32_t j = 0; j < p_vertex_len; j++) {1540const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);15411542w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);1543}15441545ret[i] = arr;1546} break;1547case RS::ARRAY_TEX_UV: {1548Vector<Vector2> arr;1549arr.resize(p_vertex_len);15501551Vector2 *w = arr.ptrw();1552if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1553for (int j = 0; j < p_vertex_len; j++) {1554const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);1555Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);1556if (!p_uv_scale.is_zero_approx()) {1557vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.x, p_uv_scale.y);1558}15591560w[j] = vec;1561}1562} else {1563for (int j = 0; j < p_vertex_len; j++) {1564const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1565w[j] = Vector2(v[0], v[1]);1566}1567}1568ret[i] = arr;1569} break;15701571case RS::ARRAY_TEX_UV2: {1572Vector<Vector2> arr;1573arr.resize(p_vertex_len);15741575Vector2 *w = arr.ptrw();15761577if (p_format & ARRAY_FLAG_COMPRESS_ATTRIBUTES) {1578for (int j = 0; j < p_vertex_len; j++) {1579const uint16_t *v = reinterpret_cast<const uint16_t *>(&ar[j * attrib_elem_size + offsets[i]]);1580Vector2 vec = Vector2(float(v[0]) / 65535.0, float(v[1]) / 65535.0);1581if (!p_uv_scale.is_zero_approx()) {1582vec = (vec - Vector2(0.5, 0.5)) * Vector2(p_uv_scale.z, p_uv_scale.w);1583}1584w[j] = vec;1585}1586} else {1587for (int j = 0; j < p_vertex_len; j++) {1588const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1589w[j] = Vector2(v[0], v[1]);1590}1591}15921593ret[i] = arr;15941595} break;1596case RS::ARRAY_CUSTOM0:1597case RS::ARRAY_CUSTOM1:1598case RS::ARRAY_CUSTOM2:1599case RS::ARRAY_CUSTOM3: {1600uint32_t type = (p_format >> (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * (i - RS::ARRAY_CUSTOM0))) & ARRAY_FORMAT_CUSTOM_MASK;1601switch (type) {1602case ARRAY_CUSTOM_RGBA8_UNORM:1603case ARRAY_CUSTOM_RGBA8_SNORM:1604case ARRAY_CUSTOM_RG_HALF:1605case ARRAY_CUSTOM_RGBA_HALF: {1606// Size 41607int s = type == ARRAY_CUSTOM_RGBA_HALF ? 8 : 4;1608Vector<uint8_t> arr;1609arr.resize(p_vertex_len * s);16101611uint8_t *w = arr.ptrw();16121613for (int j = 0; j < p_vertex_len; j++) {1614const uint8_t *v = reinterpret_cast<const uint8_t *>(&ar[j * attrib_elem_size + offsets[i]]);1615memcpy(&w[j * s], v, s);1616}16171618ret[i] = arr;16191620} break;1621case ARRAY_CUSTOM_R_FLOAT:1622case ARRAY_CUSTOM_RG_FLOAT:1623case ARRAY_CUSTOM_RGB_FLOAT:1624case ARRAY_CUSTOM_RGBA_FLOAT: {1625uint32_t s = type - ARRAY_CUSTOM_R_FLOAT + 1;16261627Vector<float> arr;1628arr.resize(s * p_vertex_len);16291630float *w = arr.ptrw();16311632for (int j = 0; j < p_vertex_len; j++) {1633const float *v = reinterpret_cast<const float *>(&ar[j * attrib_elem_size + offsets[i]]);1634memcpy(&w[j * s], v, s * sizeof(float));1635}1636ret[i] = arr;16371638} break;1639default: {1640}1641}16421643} break;1644case RS::ARRAY_WEIGHTS: {1645uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;16461647Vector<float> arr;1648arr.resize(p_vertex_len * bone_count);1649{1650float *w = arr.ptrw();16511652for (int j = 0; j < p_vertex_len; j++) {1653const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];1654for (uint32_t k = 0; k < bone_count; k++) {1655w[j * bone_count + k] = float(v[k] / 65535.0);1656}1657}1658}16591660ret[i] = arr;16611662} break;1663case RS::ARRAY_BONES: {1664uint32_t bone_count = (p_format & ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? 8 : 4;16651666Vector<int> arr;1667arr.resize(p_vertex_len * bone_count);16681669int *w = arr.ptrw();16701671for (int j = 0; j < p_vertex_len; j++) {1672const uint16_t *v = (const uint16_t *)&sr[j * skin_elem_size + offsets[i]];1673for (uint32_t k = 0; k < bone_count; k++) {1674w[j * bone_count + k] = v[k];1675}1676}16771678ret[i] = arr;16791680} break;1681case RS::ARRAY_INDEX: {1682/* determine whether using 16 or 32 bits indices */16831684const uint8_t *ir = p_index_data.ptr();16851686Vector<int> arr;1687arr.resize(p_index_len);1688if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {1689int *w = arr.ptrw();16901691for (int j = 0; j < p_index_len; j++) {1692const uint16_t *v = (const uint16_t *)&ir[j * 2];1693w[j] = *v;1694}1695} else {1696int *w = arr.ptrw();16971698for (int j = 0; j < p_index_len; j++) {1699const int *v = (const int *)&ir[j * 4];1700w[j] = *v;1701}1702}1703ret[i] = arr;1704} break;1705default: {1706ERR_FAIL_V(ret);1707}1708}1709}17101711return ret;1712}17131714Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {1715SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1716return mesh_create_arrays_from_surface_data(sd);1717}17181719Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {1720SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1721ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());17221723Dictionary ret;17241725for (int i = 0; i < sd.lods.size(); i++) {1726Vector<int> lods;1727if (sd.vertex_count <= 65536) {1728uint32_t lc = sd.lods[i].index_data.size() / 2;1729lods.resize(lc);1730const uint8_t *r = sd.lods[i].index_data.ptr();1731const uint16_t *rptr = (const uint16_t *)r;1732int *w = lods.ptrw();1733for (uint32_t j = 0; j < lc; j++) {1734w[j] = rptr[j];1735}1736} else {1737uint32_t lc = sd.lods[i].index_data.size() / 4;1738lods.resize(lc);1739const uint8_t *r = sd.lods[i].index_data.ptr();1740const uint32_t *rptr = (const uint32_t *)r;1741int *w = lods.ptrw();1742for (uint32_t j = 0; j < lc; j++) {1743w[j] = rptr[j];1744}1745}17461747ret[sd.lods[i].edge_length] = lods;1748}17491750return ret;1751}17521753TypedArray<Array> RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {1754SurfaceData sd = mesh_get_surface(p_mesh, p_surface);1755ERR_FAIL_COND_V(sd.vertex_count == 0, Array());17561757Vector<uint8_t> blend_shape_data = sd.blend_shape_data;17581759if (blend_shape_data.size() > 0) {1760uint32_t bs_offsets[RS::ARRAY_MAX];1761uint32_t bs_format = (sd.format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK);1762uint32_t vertex_elem_size;1763uint32_t normal_elem_size;1764uint32_t attrib_elem_size;1765uint32_t skin_elem_size;17661767mesh_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);17681769int divisor = (vertex_elem_size + normal_elem_size) * sd.vertex_count;1770ERR_FAIL_COND_V((blend_shape_data.size() % divisor) != 0, Array());17711772uint32_t blend_shape_count = blend_shape_data.size() / divisor;17731774ERR_FAIL_COND_V(blend_shape_count != (uint32_t)mesh_get_blend_shape_count(p_mesh), Array());17751776TypedArray<Array> blend_shape_array;1777blend_shape_array.resize(mesh_get_blend_shape_count(p_mesh));1778for (uint32_t i = 0; i < blend_shape_count; i++) {1779Vector<uint8_t> bs_data = blend_shape_data.slice(i * divisor, (i + 1) * divisor);1780Vector<uint8_t> unused;1781blend_shape_array.set(i, _get_array_from_surface(bs_format, bs_data, unused, unused, sd.vertex_count, unused, 0, sd.aabb, sd.uv_scale));1782}17831784return blend_shape_array;1785} else {1786return TypedArray<Array>();1787}1788}17891790Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {1791Vector<uint8_t> vertex_data = p_data.vertex_data;1792Vector<uint8_t> attrib_data = p_data.attribute_data;1793Vector<uint8_t> skin_data = p_data.skin_data;17941795ERR_FAIL_COND_V(vertex_data.is_empty() && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array());1796int vertex_len = p_data.vertex_count;17971798Vector<uint8_t> index_data = p_data.index_data;1799int index_len = p_data.index_count;18001801uint64_t format = p_data.format;18021803return _get_array_from_surface(format, vertex_data, attrib_data, skin_data, vertex_len, index_data, index_len, p_data.aabb, p_data.uv_scale);1804}1805#if 01806Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {1807Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);1808Array arr;1809for (int i = 0; i < vec.size(); i++) {1810arr[i] = vec[i];1811}1812return arr;1813}1814#endif18151816Rect2 RenderingServer::debug_canvas_item_get_rect(RID p_item) {1817#ifdef TOOLS_ENABLED1818return _debug_canvas_item_get_rect(p_item);1819#else1820return Rect2();1821#endif1822}18231824int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) {1825switch (p_type) {1826case RS::GLOBAL_VAR_TYPE_BOOL:1827return ShaderLanguage::TYPE_BOOL;1828case RS::GLOBAL_VAR_TYPE_BVEC2:1829return ShaderLanguage::TYPE_BVEC2;1830case RS::GLOBAL_VAR_TYPE_BVEC3:1831return ShaderLanguage::TYPE_BVEC3;1832case RS::GLOBAL_VAR_TYPE_BVEC4:1833return ShaderLanguage::TYPE_BVEC4;1834case RS::GLOBAL_VAR_TYPE_INT:1835return ShaderLanguage::TYPE_INT;1836case RS::GLOBAL_VAR_TYPE_IVEC2:1837return ShaderLanguage::TYPE_IVEC2;1838case RS::GLOBAL_VAR_TYPE_IVEC3:1839return ShaderLanguage::TYPE_IVEC3;1840case RS::GLOBAL_VAR_TYPE_IVEC4:1841return ShaderLanguage::TYPE_IVEC4;1842case RS::GLOBAL_VAR_TYPE_RECT2I:1843return ShaderLanguage::TYPE_IVEC4;1844case RS::GLOBAL_VAR_TYPE_UINT:1845return ShaderLanguage::TYPE_UINT;1846case RS::GLOBAL_VAR_TYPE_UVEC2:1847return ShaderLanguage::TYPE_UVEC2;1848case RS::GLOBAL_VAR_TYPE_UVEC3:1849return ShaderLanguage::TYPE_UVEC3;1850case RS::GLOBAL_VAR_TYPE_UVEC4:1851return ShaderLanguage::TYPE_UVEC4;1852case RS::GLOBAL_VAR_TYPE_FLOAT:1853return ShaderLanguage::TYPE_FLOAT;1854case RS::GLOBAL_VAR_TYPE_VEC2:1855return ShaderLanguage::TYPE_VEC2;1856case RS::GLOBAL_VAR_TYPE_VEC3:1857return ShaderLanguage::TYPE_VEC3;1858case RS::GLOBAL_VAR_TYPE_VEC4:1859return ShaderLanguage::TYPE_VEC4;1860case RS::GLOBAL_VAR_TYPE_COLOR:1861return ShaderLanguage::TYPE_VEC4;1862case RS::GLOBAL_VAR_TYPE_RECT2:1863return ShaderLanguage::TYPE_VEC4;1864case RS::GLOBAL_VAR_TYPE_MAT2:1865return ShaderLanguage::TYPE_MAT2;1866case RS::GLOBAL_VAR_TYPE_MAT3:1867return ShaderLanguage::TYPE_MAT3;1868case RS::GLOBAL_VAR_TYPE_MAT4:1869return ShaderLanguage::TYPE_MAT4;1870case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D:1871return ShaderLanguage::TYPE_MAT3;1872case RS::GLOBAL_VAR_TYPE_TRANSFORM:1873return ShaderLanguage::TYPE_MAT4;1874case RS::GLOBAL_VAR_TYPE_SAMPLER2D:1875return ShaderLanguage::TYPE_SAMPLER2D;1876case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY:1877return ShaderLanguage::TYPE_SAMPLER2DARRAY;1878case RS::GLOBAL_VAR_TYPE_SAMPLER3D:1879return ShaderLanguage::TYPE_SAMPLER3D;1880case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE:1881return ShaderLanguage::TYPE_SAMPLERCUBE;1882case RS::GLOBAL_VAR_TYPE_SAMPLEREXT:1883return ShaderLanguage::TYPE_SAMPLEREXT;1884default:1885return ShaderLanguage::TYPE_MAX; // Invalid or not found.1886}1887}18881889Rect2 RenderingServer::get_splash_stretched_screen_rect(const Size2 &p_image_size, const Size2 &p_window_size, SplashStretchMode p_stretch_mode) {1890Size2 imgsize = p_image_size;1891Rect2 screenrect;1892switch (p_stretch_mode) {1893case SplashStretchMode::SPLASH_STRETCH_MODE_DISABLED: {1894screenrect.size = imgsize;1895screenrect.position = ((p_window_size - screenrect.size) / 2.0).floor();1896} break;1897case SplashStretchMode::SPLASH_STRETCH_MODE_KEEP: {1898if (p_window_size.width > p_window_size.height) {1899// Scale horizontally.1900screenrect.size.y = p_window_size.height;1901screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;1902screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;1903} else {1904// Scale vertically.1905screenrect.size.x = p_window_size.width;1906screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;1907screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;1908}1909} break;1910case SplashStretchMode::SPLASH_STRETCH_MODE_KEEP_WIDTH: {1911// Scale vertically.1912screenrect.size.x = p_window_size.width;1913screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;1914screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;1915} break;1916case SplashStretchMode::SPLASH_STRETCH_MODE_KEEP_HEIGHT: {1917// Scale horizontally.1918screenrect.size.y = p_window_size.height;1919screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;1920screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;1921} break;1922case SplashStretchMode::SPLASH_STRETCH_MODE_COVER: {1923double window_aspect = (double)p_window_size.width / p_window_size.height;1924double img_aspect = imgsize.width / imgsize.height;19251926if (window_aspect > img_aspect) {1927// Scale vertically.1928screenrect.size.x = p_window_size.width;1929screenrect.size.y = imgsize.height * p_window_size.width / imgsize.width;1930screenrect.position.y = (p_window_size.height - screenrect.size.y) / 2;1931} else {1932// Scale horizontally.1933screenrect.size.y = p_window_size.height;1934screenrect.size.x = imgsize.width * p_window_size.height / imgsize.height;1935screenrect.position.x = (p_window_size.width - screenrect.size.x) / 2;1936}1937} break;1938case SplashStretchMode::SPLASH_STRETCH_MODE_IGNORE: {1939screenrect.size.x = p_window_size.width;1940screenrect.size.y = p_window_size.height;1941} break;1942}1943return screenrect;1944}19451946RenderingDevice *RenderingServer::get_rendering_device() const {1947// Return the rendering device we're using globally.1948return RenderingDevice::get_singleton();1949}19501951RenderingDevice *RenderingServer::create_local_rendering_device() const {1952RenderingDevice *device = RenderingDevice::get_singleton();1953if (!device) {1954return nullptr;1955}1956return device->create_local_device();1957}19581959static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {1960Vector<Ref<Image>> images;1961images.resize(p_layers.size());1962for (int i = 0; i < p_layers.size(); i++) {1963images.write[i] = p_layers[i];1964}1965return images;1966}1967RID RenderingServer::_texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type) {1968return texture_2d_layered_create(_get_imgvec(p_layers), p_layered_type);1969}1970RID 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) {1971return texture_3d_create(p_format, p_width, p_height, p_depth, p_mipmaps, _get_imgvec(p_data));1972}19731974void RenderingServer::_texture_3d_update(RID p_texture, const TypedArray<Image> &p_data) {1975texture_3d_update(p_texture, _get_imgvec(p_data));1976}19771978TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const {1979Vector<Ref<Image>> images = texture_3d_get(p_texture);1980TypedArray<Image> ret;1981ret.resize(images.size());1982for (int i = 0; i < images.size(); i++) {1983ret[i] = images[i];1984}1985return ret;1986}19871988TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const {1989List<PropertyInfo> l;1990get_shader_parameter_list(p_shader, &l);1991return convert_property_list(&l);1992}19931994static RS::SurfaceData _dict_to_surf(const Dictionary &p_dictionary) {1995ERR_FAIL_COND_V(!p_dictionary.has("primitive"), RS::SurfaceData());1996ERR_FAIL_COND_V(!p_dictionary.has("format"), RS::SurfaceData());1997ERR_FAIL_COND_V(!p_dictionary.has("vertex_data"), RS::SurfaceData());1998ERR_FAIL_COND_V(!p_dictionary.has("vertex_count"), RS::SurfaceData());1999ERR_FAIL_COND_V(!p_dictionary.has("aabb"), RS::SurfaceData());20002001RS::SurfaceData sd;20022003sd.primitive = RS::PrimitiveType(int(p_dictionary["primitive"]));2004sd.format = p_dictionary["format"];2005sd.vertex_data = p_dictionary["vertex_data"];2006if (p_dictionary.has("attribute_data")) {2007sd.attribute_data = p_dictionary["attribute_data"];2008}2009if (p_dictionary.has("skin_data")) {2010sd.skin_data = p_dictionary["skin_data"];2011}20122013sd.vertex_count = p_dictionary["vertex_count"];20142015if (p_dictionary.has("index_data")) {2016sd.index_data = p_dictionary["index_data"];2017ERR_FAIL_COND_V(!p_dictionary.has("index_count"), RS::SurfaceData());2018sd.index_count = p_dictionary["index_count"];2019}20202021sd.aabb = p_dictionary["aabb"];2022if (p_dictionary.has("uv_scale")) {2023sd.uv_scale = p_dictionary["uv_scale"];2024}20252026if (p_dictionary.has("lods")) {2027Array lods = p_dictionary["lods"];2028for (int i = 0; i < lods.size(); i++) {2029Dictionary lod = lods[i];2030ERR_CONTINUE(!lod.has("edge_length"));2031ERR_CONTINUE(!lod.has("index_data"));2032RS::SurfaceData::LOD l;2033l.edge_length = lod["edge_length"];2034l.index_data = lod["index_data"];2035sd.lods.push_back(l);2036}2037}20382039if (p_dictionary.has("bone_aabbs")) {2040Array aabbs = p_dictionary["bone_aabbs"];2041for (int i = 0; i < aabbs.size(); i++) {2042AABB aabb = aabbs[i];2043sd.bone_aabbs.push_back(aabb);2044}2045}20462047if (p_dictionary.has("blend_shape_data")) {2048sd.blend_shape_data = p_dictionary["blend_shape_data"];2049}20502051if (p_dictionary.has("material")) {2052sd.material = p_dictionary["material"];2053}20542055return sd;2056}2057RID RenderingServer::_mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count) {2058Vector<RS::SurfaceData> surfaces;2059for (int i = 0; i < p_surfaces.size(); i++) {2060surfaces.push_back(_dict_to_surf(p_surfaces[i]));2061}2062return mesh_create_from_surfaces(surfaces);2063}2064void RenderingServer::_mesh_add_surface(RID p_mesh, const Dictionary &p_surface) {2065mesh_add_surface(p_mesh, _dict_to_surf(p_surface));2066}2067Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) {2068RS::SurfaceData sd = mesh_get_surface(p_mesh, p_idx);20692070Dictionary d;2071d["primitive"] = sd.primitive;2072d["format"] = sd.format;2073d["vertex_data"] = sd.vertex_data;2074if (sd.attribute_data.size()) {2075d["attribute_data"] = sd.attribute_data;2076}2077if (sd.skin_data.size()) {2078d["skin_data"] = sd.skin_data;2079}2080d["vertex_count"] = sd.vertex_count;2081if (sd.index_count) {2082d["index_data"] = sd.index_data;2083d["index_count"] = sd.index_count;2084}2085d["aabb"] = sd.aabb;2086d["uv_scale"] = sd.uv_scale;20872088if (sd.lods.size()) {2089Array lods;2090for (int i = 0; i < sd.lods.size(); i++) {2091Dictionary ld;2092ld["edge_length"] = sd.lods[i].edge_length;2093ld["index_data"] = sd.lods[i].index_data;2094lods.push_back(ld);2095}2096d["lods"] = lods;2097}20982099if (sd.bone_aabbs.size()) {2100Array aabbs;2101for (int i = 0; i < sd.bone_aabbs.size(); i++) {2102aabbs.push_back(sd.bone_aabbs[i]);2103}2104d["bone_aabbs"] = aabbs;2105}21062107if (sd.blend_shape_data.size()) {2108d["blend_shape_data"] = sd.blend_shape_data;2109}21102111if (sd.material.is_valid()) {2112d["material"] = sd.material;2113}2114return d;2115}21162117TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const {2118List<PropertyInfo> params;2119instance_geometry_get_shader_parameter_list(p_instance, ¶ms);2120return convert_property_list(¶ms);2121}21222123TypedArray<Dictionary> RenderingServer::_canvas_item_get_instance_shader_parameter_list(RID p_instance) const {2124List<PropertyInfo> params;2125canvas_item_get_instance_shader_parameter_list(p_instance, ¶ms);2126return convert_property_list(¶ms);2127}21282129TypedArray<Image> RenderingServer::_bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) {2130TypedArray<RID> mat_overrides;2131for (int i = 0; i < p_material_overrides.size(); i++) {2132mat_overrides.push_back(p_material_overrides[i]);2133}2134return bake_render_uv2(p_base, mat_overrides, p_image_size);2135}21362137void RenderingServer::_particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses) {2138Vector<Transform3D> tbposes;2139tbposes.resize(p_bind_poses.size());2140for (int i = 0; i < p_bind_poses.size(); i++) {2141tbposes.write[i] = p_bind_poses[i];2142}2143particles_set_trail_bind_poses(p_particles, tbposes);2144}21452146String RenderingServer::get_current_rendering_driver_name() const {2147// Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.2148return ::OS::get_singleton()->get_current_rendering_driver_name();2149}21502151String RenderingServer::get_current_rendering_method() const {2152// Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here.2153return ::OS::get_singleton()->get_current_rendering_method();2154}21552156Vector<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) {2157Vector<uint8_t> new_vertex_data;2158new_vertex_data.resize(p_vertex_data.size());2159uint8_t *dst_vertex_ptr = new_vertex_data.ptrw();21602161const uint8_t *src_vertex_ptr = p_vertex_data.ptr();21622163uint32_t position_size = p_position_stride * p_vertex_count;21642165for (uint32_t j = 0; j < RS::ARRAY_COLOR; j++) {2166if (!(p_format & (1ULL << j))) {2167continue;2168}2169switch (j) {2170case RS::ARRAY_VERTEX: {2171if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {2172for (uint32_t i = 0; i < p_vertex_count; i++) {2173const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];2174float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];2175dst[0] = src[0];2176dst[1] = src[1];2177}2178} else {2179for (uint32_t i = 0; i < p_vertex_count; i++) {2180const float *src = (const float *)&src_vertex_ptr[i * p_old_stride];2181float *dst = (float *)&dst_vertex_ptr[i * p_position_stride];2182dst[0] = src[0];2183dst[1] = src[1];2184dst[2] = src[2];2185}2186}2187} break;2188case RS::ARRAY_NORMAL: {2189for (uint32_t i = 0; i < p_vertex_count; i++) {2190const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size];2191uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size];21922193dst[0] = src[0];2194dst[1] = src[1];2195}2196} break;2197case RS::ARRAY_TANGENT: {2198for (uint32_t i = 0; i < p_vertex_count; i++) {2199const uint16_t *src = (const uint16_t *)&src_vertex_ptr[i * p_old_stride + p_vertex_size + p_normal_size];2200uint16_t *dst = (uint16_t *)&dst_vertex_ptr[i * p_normal_tangent_stride + position_size + p_normal_size];22012202dst[0] = src[0];2203dst[1] = src[1];2204}2205} break;2206}2207}2208return new_vertex_data;2209}22102211#ifdef TOOLS_ENABLED2212void RenderingServer::set_surface_upgrade_callback(SurfaceUpgradeCallback p_callback) {2213surface_upgrade_callback = p_callback;2214}22152216void RenderingServer::set_warn_on_surface_upgrade(bool p_warn) {2217warn_on_surface_upgrade = p_warn;2218}2219#endif22202221#ifndef DISABLE_DEPRECATED2222void RenderingServer::fix_surface_compatibility(SurfaceData &p_surface, const String &p_path) {2223uint64_t surface_version = p_surface.format & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2224ERR_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) + ")");22252226#ifdef TOOLS_ENABLED2227// Editor callback to ask user about re-saving all meshes.2228if (surface_upgrade_callback && warn_on_surface_upgrade) {2229surface_upgrade_callback();2230}22312232if (warn_on_surface_upgrade) {2233WARN_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.");22342235if (!p_path.is_empty()) {2236WARN_PRINT("A surface of " + p_path + " uses an old surface format and needs to be upgraded.");2237}2238}2239#endif22402241if (surface_version == ARRAY_FLAG_FORMAT_VERSION_1) {2242// The only difference for now is that Version 1 uses interleaved vertex positions while version 2 does not.2243// I.e. PNTPNTPNT -> PPPNTNTNT.22442245if (p_surface.vertex_data.size() > 0 && p_surface.vertex_count > 0) {2246int vertex_size = 0;2247int normal_size = 0;2248int tangent_size = 0;2249if (p_surface.format & ARRAY_FORMAT_VERTEX) {2250if (p_surface.format & ARRAY_FLAG_USE_2D_VERTICES) {2251vertex_size = sizeof(float) * 2;2252} else {2253vertex_size = sizeof(float) * 3;2254}2255}2256if (p_surface.format & ARRAY_FORMAT_NORMAL) {2257normal_size += sizeof(uint16_t) * 2;2258}2259if (p_surface.format & ARRAY_FORMAT_TANGENT) {2260tangent_size = sizeof(uint16_t) * 2;2261}2262int stride = p_surface.vertex_data.size() / p_surface.vertex_count;2263int position_stride = vertex_size;2264int normal_tangent_stride = normal_size + tangent_size;22652266p_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);22672268if (p_surface.blend_shape_data.size() > 0) {2269// The size of one blend shape.2270int divisor = (vertex_size + normal_size + tangent_size) * p_surface.vertex_count;2271ERR_FAIL_COND((p_surface.blend_shape_data.size() % divisor) != 0);22722273uint32_t blend_shape_count = p_surface.blend_shape_data.size() / divisor;22742275Vector<uint8_t> new_blend_shape_data;2276for (uint32_t i = 0; i < blend_shape_count; i++) {2277Vector<uint8_t> bs_data = p_surface.blend_shape_data.slice(i * divisor, (i + 1) * divisor);2278Vector<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);2279new_blend_shape_data.append_array(blend_shape);2280}22812282ERR_FAIL_COND(p_surface.blend_shape_data.size() != new_blend_shape_data.size());22832284p_surface.blend_shape_data = new_blend_shape_data;2285}2286}2287}2288p_surface.format &= ~(ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2289p_surface.format |= ARRAY_FLAG_FORMAT_CURRENT_VERSION & (ARRAY_FLAG_FORMAT_VERSION_MASK << ARRAY_FLAG_FORMAT_VERSION_SHIFT);2290}2291#endif22922293#ifdef TOOLS_ENABLED2294void RenderingServer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {2295const String pf = p_function;2296if (p_idx == 0) {2297if (pf == "global_shader_parameter_set" || pf == "global_shader_parameter_set_override" ||2298pf == "global_shader_parameter_get" || pf == "global_shader_parameter_get_type" || pf == "global_shader_parameter_remove") {2299for (const StringName &E : global_shader_parameter_get_list()) {2300r_options->push_back(E.operator String().quote());2301}2302} else if (pf == "has_os_feature") {2303for (const String E : { "\"rgtc\"", "\"s3tc\"", "\"bptc\"", "\"etc\"", "\"etc2\"", "\"astc\"" }) {2304r_options->push_back(E);2305}2306}2307}2308Object::get_argument_options(p_function, p_idx, r_options);2309}2310#endif23112312void RenderingServer::_bind_methods() {2313BIND_CONSTANT(NO_INDEX_ARRAY);2314BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);2315BIND_CONSTANT(CANVAS_ITEM_Z_MIN);2316BIND_CONSTANT(CANVAS_ITEM_Z_MAX);2317BIND_CONSTANT(CANVAS_LAYER_MIN);2318BIND_CONSTANT(CANVAS_LAYER_MAX);2319BIND_CONSTANT(MAX_GLOW_LEVELS);2320BIND_CONSTANT(MAX_CURSORS);2321BIND_CONSTANT(MAX_2D_DIRECTIONAL_LIGHTS);2322BIND_CONSTANT(MAX_MESH_SURFACES);23232324/* TEXTURE */23252326ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create);2327ClassDB::bind_method(D_METHOD("texture_2d_layered_create", "layers", "layered_type"), &RenderingServer::_texture_2d_layered_create);2328ClassDB::bind_method(D_METHOD("texture_3d_create", "format", "width", "height", "depth", "mipmaps", "data"), &RenderingServer::_texture_3d_create);2329ClassDB::bind_method(D_METHOD("texture_proxy_create", "base"), &RenderingServer::texture_proxy_create);2330ClassDB::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));2331ClassDB::bind_method(D_METHOD("texture_drawable_create", "width", "height", "format", "color", "with_mipmaps"), &RenderingServer::texture_drawable_create, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(false));23322333ClassDB::bind_method(D_METHOD("texture_2d_update", "texture", "image", "layer"), &RenderingServer::texture_2d_update);2334ClassDB::bind_method(D_METHOD("texture_3d_update", "texture", "data"), &RenderingServer::_texture_3d_update);2335ClassDB::bind_method(D_METHOD("texture_proxy_update", "texture", "proxy_to"), &RenderingServer::texture_proxy_update);23362337ClassDB::bind_method(D_METHOD("texture_drawable_blit_rect", "textures", "rect", "material", "modulate", "source_textures", "to_mipmap"), &RenderingServer::texture_drawable_blit_rect, DEFVAL(0));23382339ClassDB::bind_method(D_METHOD("texture_2d_placeholder_create"), &RenderingServer::texture_2d_placeholder_create);2340ClassDB::bind_method(D_METHOD("texture_2d_layered_placeholder_create", "layered_type"), &RenderingServer::texture_2d_layered_placeholder_create);2341ClassDB::bind_method(D_METHOD("texture_3d_placeholder_create"), &RenderingServer::texture_3d_placeholder_create);23422343ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get);2344ClassDB::bind_method(D_METHOD("texture_2d_layer_get", "texture", "layer"), &RenderingServer::texture_2d_layer_get);2345ClassDB::bind_method(D_METHOD("texture_3d_get", "texture"), &RenderingServer::_texture_3d_get);23462347ClassDB::bind_method(D_METHOD("texture_drawable_generate_mipmaps", "texture"), &RenderingServer::texture_drawable_generate_mipmaps);2348ClassDB::bind_method(D_METHOD("texture_drawable_get_default_material"), &RenderingServer::texture_drawable_get_default_material);23492350ClassDB::bind_method(D_METHOD("texture_replace", "texture", "by_texture"), &RenderingServer::texture_replace);2351ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height"), &RenderingServer::texture_set_size_override);23522353ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &RenderingServer::texture_set_path);2354ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &RenderingServer::texture_get_path);23552356ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &RenderingServer::texture_get_format);23572358ClassDB::bind_method(D_METHOD("texture_set_force_redraw_if_visible", "texture", "enable"), &RenderingServer::texture_set_force_redraw_if_visible);2359ClassDB::bind_method(D_METHOD("texture_rd_create", "rd_texture", "layer_type"), &RenderingServer::texture_rd_create, DEFVAL(RenderingServer::TEXTURE_LAYERED_2D_ARRAY));2360ClassDB::bind_method(D_METHOD("texture_get_rd_texture", "texture", "srgb"), &RenderingServer::texture_get_rd_texture, DEFVAL(false));2361ClassDB::bind_method(D_METHOD("texture_get_native_handle", "texture", "srgb"), &RenderingServer::texture_get_native_handle, DEFVAL(false));23622363BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);2364BIND_ENUM_CONSTANT(TEXTURE_TYPE_LAYERED);2365BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);23662367BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY);2368BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP);2369BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP_ARRAY);23702371BIND_ENUM_CONSTANT(CUBEMAP_LAYER_LEFT);2372BIND_ENUM_CONSTANT(CUBEMAP_LAYER_RIGHT);2373BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BOTTOM);2374BIND_ENUM_CONSTANT(CUBEMAP_LAYER_TOP);2375BIND_ENUM_CONSTANT(CUBEMAP_LAYER_FRONT);2376BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BACK);23772378BIND_ENUM_CONSTANT(TEXTURE_DRAWABLE_FORMAT_RGBA8);2379BIND_ENUM_CONSTANT(TEXTURE_DRAWABLE_FORMAT_RGBA8_SRGB);2380BIND_ENUM_CONSTANT(TEXTURE_DRAWABLE_FORMAT_RGBAH);2381BIND_ENUM_CONSTANT(TEXTURE_DRAWABLE_FORMAT_RGBAF);23822383/* SHADER */23842385ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create);2386ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);2387ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint);2388ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);2389ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list);2390ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default);23912392ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0));2393ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0));23942395BIND_ENUM_CONSTANT(SHADER_SPATIAL);2396BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);2397BIND_ENUM_CONSTANT(SHADER_PARTICLES);2398BIND_ENUM_CONSTANT(SHADER_SKY);2399BIND_ENUM_CONSTANT(SHADER_FOG);2400BIND_ENUM_CONSTANT(SHADER_TEXTURE_BLIT);2401BIND_ENUM_CONSTANT(SHADER_MAX);24022403/* MATERIAL */24042405ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create);2406ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader);2407ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param);2408ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param);2409ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority);24102411ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass);24122413ClassDB::bind_method(D_METHOD("material_set_use_debanding", "enable"), &RenderingServer::material_set_use_debanding);24142415BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN);2416BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX);24172418/* MESH API */24192420ClassDB::bind_method(D_METHOD("mesh_create_from_surfaces", "surfaces", "blend_shape_count"), &RenderingServer::_mesh_create_from_surfaces, DEFVAL(0));2421ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create);2422ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_count", "array_index"), &RenderingServer::mesh_surface_get_format_offset);2423ClassDB::bind_method(D_METHOD("mesh_surface_get_format_vertex_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_vertex_stride);2424ClassDB::bind_method(D_METHOD("mesh_surface_get_format_normal_tangent_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_normal_tangent_stride);2425ClassDB::bind_method(D_METHOD("mesh_surface_get_format_attribute_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_attribute_stride);2426ClassDB::bind_method(D_METHOD("mesh_surface_get_format_skin_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_skin_stride);2427ClassDB::bind_method(D_METHOD("mesh_surface_get_format_index_stride", "format", "vertex_count"), &RenderingServer::mesh_surface_get_format_index_stride);2428ClassDB::bind_method(D_METHOD("mesh_add_surface", "mesh", "surface"), &RenderingServer::_mesh_add_surface);2429ClassDB::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));2430ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count);2431ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode);2432ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode);24332434ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material);2435ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material);2436ClassDB::bind_method(D_METHOD("mesh_get_surface", "mesh", "surface"), &RenderingServer::_mesh_get_surface);2437ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays);2438ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays);2439ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count);2440ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb);2441ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb);2442ClassDB::bind_method(D_METHOD("mesh_surface_remove", "mesh", "surface"), &RenderingServer::mesh_surface_remove);2443ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear);24442445ClassDB::bind_method(D_METHOD("mesh_surface_update_vertex_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_vertex_region);2446ClassDB::bind_method(D_METHOD("mesh_surface_update_attribute_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_attribute_region);2447ClassDB::bind_method(D_METHOD("mesh_surface_update_skin_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_skin_region);2448ClassDB::bind_method(D_METHOD("mesh_surface_update_index_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_index_region);24492450ClassDB::bind_method(D_METHOD("mesh_set_shadow_mesh", "mesh", "shadow_mesh"), &RenderingServer::mesh_set_shadow_mesh);24512452BIND_ENUM_CONSTANT(ARRAY_VERTEX);2453BIND_ENUM_CONSTANT(ARRAY_NORMAL);2454BIND_ENUM_CONSTANT(ARRAY_TANGENT);2455BIND_ENUM_CONSTANT(ARRAY_COLOR);2456BIND_ENUM_CONSTANT(ARRAY_TEX_UV);2457BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);2458BIND_ENUM_CONSTANT(ARRAY_CUSTOM0);2459BIND_ENUM_CONSTANT(ARRAY_CUSTOM1);2460BIND_ENUM_CONSTANT(ARRAY_CUSTOM2);2461BIND_ENUM_CONSTANT(ARRAY_CUSTOM3);2462BIND_ENUM_CONSTANT(ARRAY_BONES);2463BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);2464BIND_ENUM_CONSTANT(ARRAY_INDEX);2465BIND_ENUM_CONSTANT(ARRAY_MAX);24662467BIND_CONSTANT(ARRAY_CUSTOM_COUNT);24682469BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_UNORM);2470BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA8_SNORM);2471BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_HALF);2472BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_HALF);2473BIND_ENUM_CONSTANT(ARRAY_CUSTOM_R_FLOAT);2474BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RG_FLOAT);2475BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGB_FLOAT);2476BIND_ENUM_CONSTANT(ARRAY_CUSTOM_RGBA_FLOAT);2477BIND_ENUM_CONSTANT(ARRAY_CUSTOM_MAX);24782479BIND_BITFIELD_FLAG(ARRAY_FORMAT_VERTEX);2480BIND_BITFIELD_FLAG(ARRAY_FORMAT_NORMAL);2481BIND_BITFIELD_FLAG(ARRAY_FORMAT_TANGENT);2482BIND_BITFIELD_FLAG(ARRAY_FORMAT_COLOR);2483BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV);2484BIND_BITFIELD_FLAG(ARRAY_FORMAT_TEX_UV2);2485BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0);2486BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1);2487BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2);2488BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3);2489BIND_BITFIELD_FLAG(ARRAY_FORMAT_BONES);2490BIND_BITFIELD_FLAG(ARRAY_FORMAT_WEIGHTS);2491BIND_BITFIELD_FLAG(ARRAY_FORMAT_INDEX);24922493BIND_BITFIELD_FLAG(ARRAY_FORMAT_BLEND_SHAPE_MASK);24942495BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BASE);2496BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_BITS);2497BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM0_SHIFT);2498BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM1_SHIFT);2499BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM2_SHIFT);2500BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM3_SHIFT);25012502BIND_BITFIELD_FLAG(ARRAY_FORMAT_CUSTOM_MASK);2503BIND_BITFIELD_FLAG(ARRAY_COMPRESS_FLAGS_BASE);25042505BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_2D_VERTICES);2506BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_DYNAMIC_UPDATE);2507BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_8_BONE_WEIGHTS);2508BIND_BITFIELD_FLAG(ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY);25092510BIND_BITFIELD_FLAG(ARRAY_FLAG_COMPRESS_ATTRIBUTES);25112512BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_BASE);2513BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_SHIFT);2514BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_1);2515BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_2);2516BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_CURRENT_VERSION);2517BIND_BITFIELD_FLAG(ARRAY_FLAG_FORMAT_VERSION_MASK);25182519BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);2520BIND_ENUM_CONSTANT(PRIMITIVE_LINES);2521BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);2522BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);2523BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);2524BIND_ENUM_CONSTANT(PRIMITIVE_MAX);25252526BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);2527BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);25282529/* MULTIMESH API */25302531ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create);2532ClassDB::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));2533ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count);2534ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh);2535ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform);2536ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d);2537ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color);2538ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data);2539ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh);2540ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb);2541ClassDB::bind_method(D_METHOD("multimesh_set_custom_aabb", "multimesh", "aabb"), &RenderingServer::multimesh_set_custom_aabb);2542ClassDB::bind_method(D_METHOD("multimesh_get_custom_aabb", "multimesh"), &RenderingServer::multimesh_get_custom_aabb);2543ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform);2544ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d);2545ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color);2546ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data);2547ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);2548ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);2549ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);2550ClassDB::bind_method(D_METHOD("multimesh_get_command_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_command_buffer_rd_rid);2551ClassDB::bind_method(D_METHOD("multimesh_get_buffer_rd_rid", "multimesh"), &RenderingServer::multimesh_get_buffer_rd_rid);2552ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);25532554ClassDB::bind_method(D_METHOD("multimesh_set_buffer_interpolated", "multimesh", "buffer", "buffer_previous"), &RenderingServer::multimesh_set_buffer_interpolated);2555ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolated", "multimesh", "interpolated"), &RenderingServer::multimesh_set_physics_interpolated);2556ClassDB::bind_method(D_METHOD("multimesh_set_physics_interpolation_quality", "multimesh", "quality"), &RenderingServer::multimesh_set_physics_interpolation_quality);2557ClassDB::bind_method(D_METHOD("multimesh_instance_reset_physics_interpolation", "multimesh", "index"), &RenderingServer::multimesh_instance_reset_physics_interpolation);2558ClassDB::bind_method(D_METHOD("multimesh_instances_reset_physics_interpolation", "multimesh"), &RenderingServer::multimesh_instances_reset_physics_interpolation);25592560BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_2D);2561BIND_ENUM_CONSTANT(MULTIMESH_TRANSFORM_3D);2562BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_FAST);2563BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_HIGH);25642565/* SKELETON API */25662567ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create);2568ClassDB::bind_method(D_METHOD("skeleton_allocate_data", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate_data, DEFVAL(false));2569ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count);2570ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform);2571ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform);2572ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d);2573ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d);2574ClassDB::bind_method(D_METHOD("skeleton_set_base_transform_2d", "skeleton", "base_transform"), &RenderingServer::skeleton_set_base_transform_2d);25752576/* Light API */25772578ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);2579ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);2580ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);25812582ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);2583ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);2584ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow);2585ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector);2586ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);2587ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);2588ClassDB::bind_method(D_METHOD("light_set_distance_fade", "decal", "enabled", "begin", "shadow", "length"), &RenderingServer::light_set_distance_fade);2589ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);2590ClassDB::bind_method(D_METHOD("light_set_shadow_caster_mask", "light", "mask"), &RenderingServer::light_set_shadow_caster_mask);2591ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &RenderingServer::light_set_bake_mode);2592ClassDB::bind_method(D_METHOD("light_set_max_sdfgi_cascade", "light", "cascade"), &RenderingServer::light_set_max_sdfgi_cascade);25932594ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);25952596ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode);2597ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);2598ClassDB::bind_method(D_METHOD("light_directional_set_sky_mode", "light", "mode"), &RenderingServer::light_directional_set_sky_mode);25992600ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter);2601ClassDB::bind_method(D_METHOD("lightmaps_set_bicubic_filter", "enable"), &RenderingServer::lightmaps_set_bicubic_filter);26022603BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST);2604BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR);2605BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS);2606BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);2607BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);2608BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);26092610BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL);2611BIND_ENUM_CONSTANT(LIGHT_OMNI);2612BIND_ENUM_CONSTANT(LIGHT_SPOT);26132614BIND_ENUM_CONSTANT(LIGHT_PARAM_ENERGY);2615BIND_ENUM_CONSTANT(LIGHT_PARAM_INDIRECT_ENERGY);2616BIND_ENUM_CONSTANT(LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY);2617BIND_ENUM_CONSTANT(LIGHT_PARAM_SPECULAR);2618BIND_ENUM_CONSTANT(LIGHT_PARAM_RANGE);2619BIND_ENUM_CONSTANT(LIGHT_PARAM_SIZE);2620BIND_ENUM_CONSTANT(LIGHT_PARAM_ATTENUATION);2621BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ANGLE);2622BIND_ENUM_CONSTANT(LIGHT_PARAM_SPOT_ATTENUATION);2623BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_MAX_DISTANCE);2624BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET);2625BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET);2626BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET);2627BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_FADE_START);2628BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_NORMAL_BIAS);2629BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS);2630BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_PANCAKE_SIZE);2631BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_OPACITY);2632BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BLUR);2633BIND_ENUM_CONSTANT(LIGHT_PARAM_TRANSMITTANCE_BIAS);2634BIND_ENUM_CONSTANT(LIGHT_PARAM_INTENSITY);2635BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);26362637BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);2638BIND_ENUM_CONSTANT(LIGHT_BAKE_STATIC);2639BIND_ENUM_CONSTANT(LIGHT_BAKE_DYNAMIC);26402641BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);2642BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);26432644BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);2645BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS);2646BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS);26472648BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY);2649BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_ONLY);2650BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL_SKY_MODE_SKY_ONLY);26512652ClassDB::bind_method(D_METHOD("positional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::positional_soft_shadow_filter_set_quality);2653ClassDB::bind_method(D_METHOD("directional_soft_shadow_filter_set_quality", "quality"), &RenderingServer::directional_soft_shadow_filter_set_quality);2654ClassDB::bind_method(D_METHOD("directional_shadow_atlas_set_size", "size", "is_16bits"), &RenderingServer::directional_shadow_atlas_set_size);26552656BIND_ENUM_CONSTANT(SHADOW_QUALITY_HARD);2657BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_VERY_LOW);2658BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_LOW);2659BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_MEDIUM);2660BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_HIGH);2661BIND_ENUM_CONSTANT(SHADOW_QUALITY_SOFT_ULTRA);2662BIND_ENUM_CONSTANT(SHADOW_QUALITY_MAX);26632664/* REFLECTION PROBE */26652666ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);2667ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);2668ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);2669ClassDB::bind_method(D_METHOD("reflection_probe_set_blend_distance", "probe", "blend_distance"), &RenderingServer::reflection_probe_set_blend_distance);2670ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_ambient_mode);2671ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_color", "probe", "color"), &RenderingServer::reflection_probe_set_ambient_color);2672ClassDB::bind_method(D_METHOD("reflection_probe_set_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_ambient_energy);2673ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);2674ClassDB::bind_method(D_METHOD("reflection_probe_set_size", "probe", "size"), &RenderingServer::reflection_probe_set_size);2675ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);2676ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);2677ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);2678ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);2679ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);2680ClassDB::bind_method(D_METHOD("reflection_probe_set_reflection_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_reflection_mask);2681ClassDB::bind_method(D_METHOD("reflection_probe_set_resolution", "probe", "resolution"), &RenderingServer::reflection_probe_set_resolution);2682ClassDB::bind_method(D_METHOD("reflection_probe_set_mesh_lod_threshold", "probe", "pixels"), &RenderingServer::reflection_probe_set_mesh_lod_threshold);26832684BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);2685BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);26862687BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_DISABLED);2688BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_ENVIRONMENT);2689BIND_ENUM_CONSTANT(REFLECTION_PROBE_AMBIENT_COLOR);26902691/* DECAL */26922693ClassDB::bind_method(D_METHOD("decal_create"), &RenderingServer::decal_create);2694ClassDB::bind_method(D_METHOD("decal_set_size", "decal", "size"), &RenderingServer::decal_set_size);2695ClassDB::bind_method(D_METHOD("decal_set_texture", "decal", "type", "texture"), &RenderingServer::decal_set_texture);2696ClassDB::bind_method(D_METHOD("decal_set_emission_energy", "decal", "energy"), &RenderingServer::decal_set_emission_energy);2697ClassDB::bind_method(D_METHOD("decal_set_albedo_mix", "decal", "albedo_mix"), &RenderingServer::decal_set_albedo_mix);2698ClassDB::bind_method(D_METHOD("decal_set_modulate", "decal", "color"), &RenderingServer::decal_set_modulate);2699ClassDB::bind_method(D_METHOD("decal_set_cull_mask", "decal", "mask"), &RenderingServer::decal_set_cull_mask);2700ClassDB::bind_method(D_METHOD("decal_set_distance_fade", "decal", "enabled", "begin", "length"), &RenderingServer::decal_set_distance_fade);2701ClassDB::bind_method(D_METHOD("decal_set_fade", "decal", "above", "below"), &RenderingServer::decal_set_fade);2702ClassDB::bind_method(D_METHOD("decal_set_normal_fade", "decal", "fade"), &RenderingServer::decal_set_normal_fade);27032704ClassDB::bind_method(D_METHOD("decals_set_filter", "filter"), &RenderingServer::decals_set_filter);27052706BIND_ENUM_CONSTANT(DECAL_TEXTURE_ALBEDO);2707BIND_ENUM_CONSTANT(DECAL_TEXTURE_NORMAL);2708BIND_ENUM_CONSTANT(DECAL_TEXTURE_ORM);2709BIND_ENUM_CONSTANT(DECAL_TEXTURE_EMISSION);2710BIND_ENUM_CONSTANT(DECAL_TEXTURE_MAX);27112712BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST);2713BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR);2714BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS);2715BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS);2716BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS_ANISOTROPIC);2717BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC);27182719/* GI API (affects VoxelGI and SDFGI) */27202721ClassDB::bind_method(D_METHOD("gi_set_use_half_resolution", "half_resolution"), &RenderingServer::gi_set_use_half_resolution);27222723/* VOXEL GI API */27242725ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create);2726ClassDB::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);2727ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_size", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_size);2728ClassDB::bind_method(D_METHOD("voxel_gi_get_octree_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_octree_cells);2729ClassDB::bind_method(D_METHOD("voxel_gi_get_data_cells", "voxel_gi"), &RenderingServer::voxel_gi_get_data_cells);2730ClassDB::bind_method(D_METHOD("voxel_gi_get_distance_field", "voxel_gi"), &RenderingServer::voxel_gi_get_distance_field);2731ClassDB::bind_method(D_METHOD("voxel_gi_get_level_counts", "voxel_gi"), &RenderingServer::voxel_gi_get_level_counts);2732ClassDB::bind_method(D_METHOD("voxel_gi_get_to_cell_xform", "voxel_gi"), &RenderingServer::voxel_gi_get_to_cell_xform);27332734ClassDB::bind_method(D_METHOD("voxel_gi_set_dynamic_range", "voxel_gi", "range"), &RenderingServer::voxel_gi_set_dynamic_range);2735ClassDB::bind_method(D_METHOD("voxel_gi_set_propagation", "voxel_gi", "amount"), &RenderingServer::voxel_gi_set_propagation);2736ClassDB::bind_method(D_METHOD("voxel_gi_set_energy", "voxel_gi", "energy"), &RenderingServer::voxel_gi_set_energy);2737ClassDB::bind_method(D_METHOD("voxel_gi_set_baked_exposure_normalization", "voxel_gi", "baked_exposure"), &RenderingServer::voxel_gi_set_baked_exposure_normalization);2738ClassDB::bind_method(D_METHOD("voxel_gi_set_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_bias);2739ClassDB::bind_method(D_METHOD("voxel_gi_set_normal_bias", "voxel_gi", "bias"), &RenderingServer::voxel_gi_set_normal_bias);2740ClassDB::bind_method(D_METHOD("voxel_gi_set_interior", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_interior);2741ClassDB::bind_method(D_METHOD("voxel_gi_set_use_two_bounces", "voxel_gi", "enable"), &RenderingServer::voxel_gi_set_use_two_bounces);27422743ClassDB::bind_method(D_METHOD("voxel_gi_set_quality", "quality"), &RenderingServer::voxel_gi_set_quality);27442745BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_LOW);2746BIND_ENUM_CONSTANT(VOXEL_GI_QUALITY_HIGH);27472748/* LIGHTMAP */27492750ClassDB::bind_method(D_METHOD("lightmap_create"), &RenderingServer::lightmap_create);2751ClassDB::bind_method(D_METHOD("lightmap_set_textures", "lightmap", "light", "uses_sh"), &RenderingServer::lightmap_set_textures);2752ClassDB::bind_method(D_METHOD("lightmap_set_probe_bounds", "lightmap", "bounds"), &RenderingServer::lightmap_set_probe_bounds);2753ClassDB::bind_method(D_METHOD("lightmap_set_probe_interior", "lightmap", "interior"), &RenderingServer::lightmap_set_probe_interior);2754ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_data", "lightmap", "points", "point_sh", "tetrahedra", "bsp_tree"), &RenderingServer::lightmap_set_probe_capture_data);2755ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_points", "lightmap"), &RenderingServer::lightmap_get_probe_capture_points);2756ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_sh", "lightmap"), &RenderingServer::lightmap_get_probe_capture_sh);2757ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_tetrahedra", "lightmap"), &RenderingServer::lightmap_get_probe_capture_tetrahedra);2758ClassDB::bind_method(D_METHOD("lightmap_get_probe_capture_bsp_tree", "lightmap"), &RenderingServer::lightmap_get_probe_capture_bsp_tree);2759ClassDB::bind_method(D_METHOD("lightmap_set_baked_exposure_normalization", "lightmap", "baked_exposure"), &RenderingServer::lightmap_set_baked_exposure_normalization);27602761ClassDB::bind_method(D_METHOD("lightmap_set_probe_capture_update_speed", "speed"), &RenderingServer::lightmap_set_probe_capture_update_speed);27622763/* PARTICLES API */27642765ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create);2766ClassDB::bind_method(D_METHOD("particles_set_mode", "particles", "mode"), &RenderingServer::particles_set_mode);2767ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting);2768ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting);2769ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount);2770ClassDB::bind_method(D_METHOD("particles_set_amount_ratio", "particles", "ratio"), &RenderingServer::particles_set_amount_ratio);2771ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime);2772ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot);2773ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time);2774ClassDB::bind_method(D_METHOD("particles_request_process_time", "particles", "time"), &RenderingServer::particles_request_process_time);2775ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio);2776ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio);2777ClassDB::bind_method(D_METHOD("particles_set_interp_to_end", "particles", "factor"), &RenderingServer::particles_set_interp_to_end);2778ClassDB::bind_method(D_METHOD("particles_set_emitter_velocity", "particles", "velocity"), &RenderingServer::particles_set_emitter_velocity);2779ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb);2780ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale);2781ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates);2782ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material);2783ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps);2784ClassDB::bind_method(D_METHOD("particles_set_interpolate", "particles", "enable"), &RenderingServer::particles_set_interpolate);2785ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta);2786ClassDB::bind_method(D_METHOD("particles_set_collision_base_size", "particles", "size"), &RenderingServer::particles_set_collision_base_size);2787ClassDB::bind_method(D_METHOD("particles_set_transform_align", "particles", "align"), &RenderingServer::particles_set_transform_align);2788ClassDB::bind_method(D_METHOD("particles_set_trails", "particles", "enable", "length_sec"), &RenderingServer::particles_set_trails);2789ClassDB::bind_method(D_METHOD("particles_set_trail_bind_poses", "particles", "bind_poses"), &RenderingServer::_particles_set_trail_bind_poses);27902791ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive);2792ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process);2793ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart);27942795ClassDB::bind_method(D_METHOD("particles_set_subemitter", "particles", "subemitter_particles"), &RenderingServer::particles_set_subemitter);2796ClassDB::bind_method(D_METHOD("particles_emit", "particles", "transform", "velocity", "color", "custom", "emit_flags"), &RenderingServer::particles_emit);27972798ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order);2799ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes);2800ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh);2801ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb);2802ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform);28032804BIND_ENUM_CONSTANT(PARTICLES_MODE_2D);2805BIND_ENUM_CONSTANT(PARTICLES_MODE_3D);28062807BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_DISABLED);2808BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD);2809BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY);2810BIND_ENUM_CONSTANT(PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY);28112812BIND_CONSTANT(PARTICLES_EMIT_FLAG_POSITION);2813BIND_CONSTANT(PARTICLES_EMIT_FLAG_ROTATION_SCALE);2814BIND_CONSTANT(PARTICLES_EMIT_FLAG_VELOCITY);2815BIND_CONSTANT(PARTICLES_EMIT_FLAG_COLOR);2816BIND_CONSTANT(PARTICLES_EMIT_FLAG_CUSTOM);28172818BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_INDEX);2819BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_LIFETIME);2820BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_REVERSE_LIFETIME);2821BIND_ENUM_CONSTANT(PARTICLES_DRAW_ORDER_VIEW_DEPTH);28222823/* PARTICLES COLLISION */28242825ClassDB::bind_method(D_METHOD("particles_collision_create"), &RenderingServer::particles_collision_create);2826ClassDB::bind_method(D_METHOD("particles_collision_set_collision_type", "particles_collision", "type"), &RenderingServer::particles_collision_set_collision_type);2827ClassDB::bind_method(D_METHOD("particles_collision_set_cull_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_cull_mask);2828ClassDB::bind_method(D_METHOD("particles_collision_set_sphere_radius", "particles_collision", "radius"), &RenderingServer::particles_collision_set_sphere_radius);2829ClassDB::bind_method(D_METHOD("particles_collision_set_box_extents", "particles_collision", "extents"), &RenderingServer::particles_collision_set_box_extents);2830ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_strength", "particles_collision", "strength"), &RenderingServer::particles_collision_set_attractor_strength);2831ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_directionality", "particles_collision", "amount"), &RenderingServer::particles_collision_set_attractor_directionality);2832ClassDB::bind_method(D_METHOD("particles_collision_set_attractor_attenuation", "particles_collision", "curve"), &RenderingServer::particles_collision_set_attractor_attenuation);2833ClassDB::bind_method(D_METHOD("particles_collision_set_field_texture", "particles_collision", "texture"), &RenderingServer::particles_collision_set_field_texture);28342835ClassDB::bind_method(D_METHOD("particles_collision_height_field_update", "particles_collision"), &RenderingServer::particles_collision_height_field_update);2836ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_resolution", "particles_collision", "resolution"), &RenderingServer::particles_collision_set_height_field_resolution);2837ClassDB::bind_method(D_METHOD("particles_collision_set_height_field_mask", "particles_collision", "mask"), &RenderingServer::particles_collision_set_height_field_mask);28382839BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT);2840BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_ATTRACT);2841BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT);2842BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE);2843BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_BOX_COLLIDE);2844BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_SDF_COLLIDE);2845BIND_ENUM_CONSTANT(PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE);28462847BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256);2848BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512);2849BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024);2850BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_2048);2851BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_4096);2852BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192);2853BIND_ENUM_CONSTANT(PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);28542855/* FOG VOLUMES */28562857ClassDB::bind_method(D_METHOD("fog_volume_create"), &RenderingServer::fog_volume_create);2858ClassDB::bind_method(D_METHOD("fog_volume_set_shape", "fog_volume", "shape"), &RenderingServer::fog_volume_set_shape);2859ClassDB::bind_method(D_METHOD("fog_volume_set_size", "fog_volume", "size"), &RenderingServer::fog_volume_set_size);2860ClassDB::bind_method(D_METHOD("fog_volume_set_material", "fog_volume", "material"), &RenderingServer::fog_volume_set_material);28612862BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_ELLIPSOID);2863BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CONE);2864BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_CYLINDER);2865BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_BOX);2866BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_WORLD);2867BIND_ENUM_CONSTANT(FOG_VOLUME_SHAPE_MAX);28682869/* VISIBILITY NOTIFIER */28702871ClassDB::bind_method(D_METHOD("visibility_notifier_create"), &RenderingServer::visibility_notifier_create);2872ClassDB::bind_method(D_METHOD("visibility_notifier_set_aabb", "notifier", "aabb"), &RenderingServer::visibility_notifier_set_aabb);2873ClassDB::bind_method(D_METHOD("visibility_notifier_set_callbacks", "notifier", "enter_callable", "exit_callable"), &RenderingServer::visibility_notifier_set_callbacks);28742875/* OCCLUDER */28762877ClassDB::bind_method(D_METHOD("occluder_create"), &RenderingServer::occluder_create);2878ClassDB::bind_method(D_METHOD("occluder_set_mesh", "occluder", "vertices", "indices"), &RenderingServer::occluder_set_mesh);28792880/* CAMERA */28812882ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);2883ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective);2884ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal);2885ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum);2886ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform);2887ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask);2888ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment);2889ClassDB::bind_method(D_METHOD("camera_set_camera_attributes", "camera", "effects"), &RenderingServer::camera_set_camera_attributes);2890ClassDB::bind_method(D_METHOD("camera_set_compositor", "camera", "compositor"), &RenderingServer::camera_set_compositor);2891ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);28922893/* VIEWPORT */28942895ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);2896#ifndef XR_DISABLED2897ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr);2898#endif // XR_DISABLED2899ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);2900ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);2901ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);2902ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID));2903ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen);2904ClassDB::bind_method(D_METHOD("viewport_set_canvas_cull_mask", "viewport", "canvas_cull_mask"), &RenderingServer::viewport_set_canvas_cull_mask);29052906ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_mode", "viewport", "scaling_3d_mode"), &RenderingServer::viewport_set_scaling_3d_mode);2907ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_scale", "viewport", "scale"), &RenderingServer::viewport_set_scaling_3d_scale);2908ClassDB::bind_method(D_METHOD("viewport_set_fsr_sharpness", "viewport", "sharpness"), &RenderingServer::viewport_set_fsr_sharpness);2909ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias);2910ClassDB::bind_method(D_METHOD("viewport_set_anisotropic_filtering_level", "viewport", "anisotropic_filtering_level"), &RenderingServer::viewport_set_anisotropic_filtering_level);2911ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);2912ClassDB::bind_method(D_METHOD("viewport_get_update_mode", "viewport"), &RenderingServer::viewport_get_update_mode);2913ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);2914ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target);2915ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);2916ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d);2917ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d);2918ClassDB::bind_method(D_METHOD("viewport_set_environment_mode", "viewport", "mode"), &RenderingServer::viewport_set_environment_mode);2919ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera);2920ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario);2921ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);2922ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);2923ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_transforms_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_transforms_to_pixel);2924ClassDB::bind_method(D_METHOD("viewport_set_snap_2d_vertices_to_pixel", "viewport", "enabled"), &RenderingServer::viewport_set_snap_2d_vertices_to_pixel);29252926ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_filter", "viewport", "filter"), &RenderingServer::viewport_set_default_canvas_item_texture_filter);2927ClassDB::bind_method(D_METHOD("viewport_set_default_canvas_item_texture_repeat", "viewport", "repeat"), &RenderingServer::viewport_set_default_canvas_item_texture_repeat);29282929ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);2930ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking);29312932ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background);2933ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform);29342935ClassDB::bind_method(D_METHOD("viewport_set_sdf_oversize_and_scale", "viewport", "oversize", "scale"), &RenderingServer::viewport_set_sdf_oversize_and_scale);29362937ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_size", "viewport", "size", "use_16_bits"), &RenderingServer::viewport_set_positional_shadow_atlas_size, DEFVAL(false));2938ClassDB::bind_method(D_METHOD("viewport_set_positional_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_positional_shadow_atlas_quadrant_subdivision);2939ClassDB::bind_method(D_METHOD("viewport_set_msaa_3d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_3d);2940ClassDB::bind_method(D_METHOD("viewport_set_msaa_2d", "viewport", "msaa"), &RenderingServer::viewport_set_msaa_2d);2941ClassDB::bind_method(D_METHOD("viewport_set_use_hdr_2d", "viewport", "enabled"), &RenderingServer::viewport_set_use_hdr_2d);2942ClassDB::bind_method(D_METHOD("viewport_set_screen_space_aa", "viewport", "mode"), &RenderingServer::viewport_set_screen_space_aa);2943ClassDB::bind_method(D_METHOD("viewport_set_use_taa", "viewport", "enable"), &RenderingServer::viewport_set_use_taa);2944ClassDB::bind_method(D_METHOD("viewport_set_use_debanding", "viewport", "enable"), &RenderingServer::viewport_set_use_debanding);2945ClassDB::bind_method(D_METHOD("viewport_set_use_occlusion_culling", "viewport", "enable"), &RenderingServer::viewport_set_use_occlusion_culling);2946ClassDB::bind_method(D_METHOD("viewport_set_occlusion_rays_per_thread", "rays_per_thread"), &RenderingServer::viewport_set_occlusion_rays_per_thread);2947ClassDB::bind_method(D_METHOD("viewport_set_occlusion_culling_build_quality", "quality"), &RenderingServer::viewport_set_occlusion_culling_build_quality);29482949ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "type", "info"), &RenderingServer::viewport_get_render_info);2950ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw);29512952ClassDB::bind_method(D_METHOD("viewport_set_measure_render_time", "viewport", "enable"), &RenderingServer::viewport_set_measure_render_time);2953ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_cpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_cpu);29542955ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_gpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_gpu);29562957ClassDB::bind_method(D_METHOD("viewport_set_vrs_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_mode);2958ClassDB::bind_method(D_METHOD("viewport_set_vrs_update_mode", "viewport", "mode"), &RenderingServer::viewport_set_vrs_update_mode);2959ClassDB::bind_method(D_METHOD("viewport_set_vrs_texture", "viewport", "texture"), &RenderingServer::viewport_set_vrs_texture);29602961BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_BILINEAR);2962BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR);2963BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR2);2964BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_METALFX_SPATIAL);2965BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_METALFX_TEMPORAL);2966BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_MAX);29672968BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);2969BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); // Then goes to disabled, must be manually updated.2970BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // Default2971BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);2972BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);29732974BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);2975BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_NEVER);2976BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ONLY_NEXT_FRAME);29772978BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_DISABLED);2979BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_ENABLED);2980BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_INHERIT);2981BIND_ENUM_CONSTANT(VIEWPORT_ENVIRONMENT_MAX);29822983BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_100_PERCENT);2984BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_120_PERCENT);2985BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_150_PERCENT);2986BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_200_PERCENT);2987BIND_ENUM_CONSTANT(VIEWPORT_SDF_OVERSIZE_MAX);29882989BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_100_PERCENT);2990BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_50_PERCENT);2991BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_25_PERCENT);2992BIND_ENUM_CONSTANT(VIEWPORT_SDF_SCALE_MAX);29932994BIND_ENUM_CONSTANT(VIEWPORT_MSAA_DISABLED);2995BIND_ENUM_CONSTANT(VIEWPORT_MSAA_2X);2996BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);2997BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);2998BIND_ENUM_CONSTANT(VIEWPORT_MSAA_MAX);29993000BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_DISABLED);3001BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_2X);3002BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_4X);3003BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_8X);3004BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_16X);3005BIND_ENUM_CONSTANT(VIEWPORT_ANISOTROPY_MAX);30063007BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_DISABLED);3008BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_FXAA);3009BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_SMAA);3010BIND_ENUM_CONSTANT(VIEWPORT_SCREEN_SPACE_AA_MAX);30113012BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW);3013BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM);3014BIND_ENUM_CONSTANT(VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH);30153016BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);3017BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME);3018BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);3019BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);30203021BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_VISIBLE);3022BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_SHADOW);3023BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_CANVAS);3024BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_TYPE_MAX);30253026BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);3027BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_UNSHADED);3028BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_LIGHTING);3029BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OVERDRAW);3030BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_WIREFRAME);3031BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER);3032BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO);3033BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING);3034BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION);3035BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS);3036BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);3037BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE);3038BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSAO);3039BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SSIL);3040BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_PSSM_SPLITS);3041BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DECAL_ATLAS);3042BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI);3043BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_SDFGI_PROBES);3044BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_GI_BUFFER);3045BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLE_LOD);3046BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS);3047BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS);3048BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS);3049BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES);3050BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_OCCLUDERS);3051BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_MOTION_VECTORS);3052BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_INTERNAL_BUFFER);30533054BIND_ENUM_CONSTANT(VIEWPORT_VRS_DISABLED);3055BIND_ENUM_CONSTANT(VIEWPORT_VRS_TEXTURE);3056BIND_ENUM_CONSTANT(VIEWPORT_VRS_XR);3057BIND_ENUM_CONSTANT(VIEWPORT_VRS_MAX);30583059BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_DISABLED);3060BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ONCE); // Then goes to disabled, must be manually updated.3061BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_ALWAYS);3062BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_MAX);30633064/* SKY API */30653066ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create);3067ClassDB::bind_method(D_METHOD("sky_set_radiance_size", "sky", "radiance_size"), &RenderingServer::sky_set_radiance_size);3068ClassDB::bind_method(D_METHOD("sky_set_mode", "sky", "mode"), &RenderingServer::sky_set_mode);3069ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material);3070ClassDB::bind_method(D_METHOD("sky_bake_panorama", "sky", "energy", "bake_irradiance", "size"), &RenderingServer::sky_bake_panorama);30713072BIND_ENUM_CONSTANT(SKY_MODE_AUTOMATIC);3073BIND_ENUM_CONSTANT(SKY_MODE_QUALITY);3074BIND_ENUM_CONSTANT(SKY_MODE_INCREMENTAL);3075BIND_ENUM_CONSTANT(SKY_MODE_REALTIME);30763077/* COMPOSITOR EFFECT API */30783079ClassDB::bind_method(D_METHOD("compositor_effect_create"), &RenderingServer::compositor_effect_create);3080ClassDB::bind_method(D_METHOD("compositor_effect_set_enabled", "effect", "enabled"), &RenderingServer::compositor_effect_set_enabled);3081ClassDB::bind_method(D_METHOD("compositor_effect_set_callback", "effect", "callback_type", "callback"), &RenderingServer::compositor_effect_set_callback);3082ClassDB::bind_method(D_METHOD("compositor_effect_set_flag", "effect", "flag", "set"), &RenderingServer::compositor_effect_set_flag);30833084BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_COLOR);3085BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_ACCESS_RESOLVED_DEPTH);3086BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS);3087BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_ROUGHNESS);3088BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_FLAG_NEEDS_SEPARATE_SPECULAR);30893090BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_OPAQUE);3091BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_OPAQUE);3092BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_SKY);3093BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT);3094BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_POST_TRANSPARENT);3095BIND_ENUM_CONSTANT(COMPOSITOR_EFFECT_CALLBACK_TYPE_ANY);30963097/* COMPOSITOR */30983099ClassDB::bind_method(D_METHOD("compositor_create"), &RenderingServer::compositor_create);31003101ClassDB::bind_method(D_METHOD("compositor_set_compositor_effects", "compositor", "effects"), &RenderingServer::compositor_set_compositor_effects);31023103/* ENVIRONMENT */31043105ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create);3106ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background);3107ClassDB::bind_method(D_METHOD("environment_set_camera_id", "env", "id"), &RenderingServer::environment_set_camera_feed_id);3108ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky);3109ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov);3110ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation);3111ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color);3112ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "multiplier", "exposure_value"), &RenderingServer::environment_set_bg_energy);3113ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer);3114ClassDB::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));3115ClassDB::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);3116ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white"), &RenderingServer::environment_set_tonemap);3117ClassDB::bind_method(D_METHOD("environment_set_tonemap_agx_contrast", "env", "agx_contrast"), &RenderingServer::environment_set_tonemap_agx_contrast);3118ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "use_1d_color_correction", "color_correction"), &RenderingServer::environment_set_adjustment);3119ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance"), &RenderingServer::environment_set_ssr);3120ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "power", "detail", "horizon", "sharpness", "light_affect", "ao_channel_affect"), &RenderingServer::environment_set_ssao);3121ClassDB::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));3122ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "curve", "begin", "end"), &RenderingServer::environment_set_fog_depth);3123ClassDB::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);3124ClassDB::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);31253126ClassDB::bind_method(D_METHOD("environment_glow_set_use_bicubic_upscale", "enable"), &RenderingServer::environment_glow_set_use_bicubic_upscale);3127ClassDB::bind_method(D_METHOD("environment_set_ssr_half_size", "half_size"), &RenderingServer::environment_set_ssr_half_size);3128ClassDB::bind_method(D_METHOD("environment_set_ssr_roughness_quality", "quality"), &RenderingServer::environment_set_ssr_roughness_quality);3129ClassDB::bind_method(D_METHOD("environment_set_ssao_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssao_quality);3130ClassDB::bind_method(D_METHOD("environment_set_ssil_quality", "quality", "half_size", "adaptive_target", "blur_passes", "fadeout_from", "fadeout_to"), &RenderingServer::environment_set_ssil_quality);3131ClassDB::bind_method(D_METHOD("environment_set_sdfgi_ray_count", "ray_count"), &RenderingServer::environment_set_sdfgi_ray_count);3132ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_converge", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_converge);3133ClassDB::bind_method(D_METHOD("environment_set_sdfgi_frames_to_update_light", "frames"), &RenderingServer::environment_set_sdfgi_frames_to_update_light);3134ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_volume_size", "size", "depth"), &RenderingServer::environment_set_volumetric_fog_volume_size);3135ClassDB::bind_method(D_METHOD("environment_set_volumetric_fog_filter_active", "active"), &RenderingServer::environment_set_volumetric_fog_filter_active);31363137ClassDB::bind_method(D_METHOD("environment_bake_panorama", "environment", "bake_irradiance", "size"), &RenderingServer::environment_bake_panorama);31383139ClassDB::bind_method(D_METHOD("screen_space_roughness_limiter_set_active", "enable", "amount", "limit"), &RenderingServer::screen_space_roughness_limiter_set_active);3140ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_quality", "quality"), &RenderingServer::sub_surface_scattering_set_quality);3141ClassDB::bind_method(D_METHOD("sub_surface_scattering_set_scale", "scale", "depth_scale"), &RenderingServer::sub_surface_scattering_set_scale);31423143BIND_ENUM_CONSTANT(ENV_BG_CLEAR_COLOR);3144BIND_ENUM_CONSTANT(ENV_BG_COLOR);3145BIND_ENUM_CONSTANT(ENV_BG_SKY);3146BIND_ENUM_CONSTANT(ENV_BG_CANVAS);3147BIND_ENUM_CONSTANT(ENV_BG_KEEP);3148BIND_ENUM_CONSTANT(ENV_BG_CAMERA_FEED);3149BIND_ENUM_CONSTANT(ENV_BG_MAX);31503151BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_BG);3152BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_DISABLED);3153BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_COLOR);3154BIND_ENUM_CONSTANT(ENV_AMBIENT_SOURCE_SKY);31553156BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_BG);3157BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_DISABLED);3158BIND_ENUM_CONSTANT(ENV_REFLECTION_SOURCE_SKY);31593160BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_ADDITIVE);3161BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SCREEN);3162BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_SOFTLIGHT);3163BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_REPLACE);3164BIND_ENUM_CONSTANT(ENV_GLOW_BLEND_MODE_MIX);31653166BIND_ENUM_CONSTANT(ENV_FOG_MODE_EXPONENTIAL);3167BIND_ENUM_CONSTANT(ENV_FOG_MODE_DEPTH);31683169BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_LINEAR);3170BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_REINHARD);3171BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_FILMIC);3172BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_ACES);3173BIND_ENUM_CONSTANT(ENV_TONE_MAPPER_AGX);31743175BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_DISABLED);3176BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_LOW);3177BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_MEDIUM);3178BIND_ENUM_CONSTANT(ENV_SSR_ROUGHNESS_QUALITY_HIGH);31793180BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_VERY_LOW);3181BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_LOW);3182BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_MEDIUM);3183BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_HIGH);3184BIND_ENUM_CONSTANT(ENV_SSAO_QUALITY_ULTRA);31853186BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_VERY_LOW);3187BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_LOW);3188BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_MEDIUM);3189BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_HIGH);3190BIND_ENUM_CONSTANT(ENV_SSIL_QUALITY_ULTRA);31913192BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_50_PERCENT);3193BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_75_PERCENT);3194BIND_ENUM_CONSTANT(ENV_SDFGI_Y_SCALE_100_PERCENT);31953196BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_4);3197BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_8);3198BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_16);3199BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_32);3200BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_64);3201BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_96);3202BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_128);3203BIND_ENUM_CONSTANT(ENV_SDFGI_RAY_COUNT_MAX);32043205BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_5_FRAMES);3206BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_10_FRAMES);3207BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_15_FRAMES);3208BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_20_FRAMES);3209BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_25_FRAMES);3210BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_IN_30_FRAMES);3211BIND_ENUM_CONSTANT(ENV_SDFGI_CONVERGE_MAX);32123213BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME);3214BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES);3215BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES);3216BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES);3217BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES);3218BIND_ENUM_CONSTANT(ENV_SDFGI_UPDATE_LIGHT_MAX);32193220BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_DISABLED);3221BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_LOW);3222BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_MEDIUM);3223BIND_ENUM_CONSTANT(SUB_SURFACE_SCATTERING_QUALITY_HIGH);32243225/* CAMERA EFFECTS */32263227ClassDB::bind_method(D_METHOD("camera_attributes_create"), &RenderingServer::camera_attributes_create);32283229ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_quality", "quality", "use_jitter"), &RenderingServer::camera_attributes_set_dof_blur_quality);3230ClassDB::bind_method(D_METHOD("camera_attributes_set_dof_blur_bokeh_shape", "shape"), &RenderingServer::camera_attributes_set_dof_blur_bokeh_shape);32313232ClassDB::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);3233ClassDB::bind_method(D_METHOD("camera_attributes_set_exposure", "camera_attributes", "multiplier", "normalization"), &RenderingServer::camera_attributes_set_exposure);3234ClassDB::bind_method(D_METHOD("camera_attributes_set_auto_exposure", "camera_attributes", "enable", "min_sensitivity", "max_sensitivity", "speed", "scale"), &RenderingServer::camera_attributes_set_auto_exposure);32353236BIND_ENUM_CONSTANT(DOF_BOKEH_BOX);3237BIND_ENUM_CONSTANT(DOF_BOKEH_HEXAGON);3238BIND_ENUM_CONSTANT(DOF_BOKEH_CIRCLE);32393240BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_VERY_LOW);3241BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);3242BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);3243BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);32443245/* SCENARIO */32463247ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create);3248ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment);3249ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment);3250ClassDB::bind_method(D_METHOD("scenario_set_camera_attributes", "scenario", "effects"), &RenderingServer::scenario_set_camera_attributes);3251ClassDB::bind_method(D_METHOD("scenario_set_compositor", "scenario", "compositor"), &RenderingServer::scenario_set_compositor);32523253/* INSTANCE */32543255ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2);3256ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create);3257ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base);3258ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario);3259ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask);3260ClassDB::bind_method(D_METHOD("instance_set_pivot_data", "instance", "sorting_offset", "use_aabb_center"), &RenderingServer::instance_set_pivot_data);3261ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);3262ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);3263ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);3264ClassDB::bind_method(D_METHOD("instance_set_surface_override_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_override_material);3265ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);3266ClassDB::bind_method(D_METHOD("instance_geometry_set_transparency", "instance", "transparency"), &RenderingServer::instance_geometry_set_transparency);32673268ClassDB::bind_method(D_METHOD("instance_teleport", "instance"), &RenderingServer::instance_teleport);32693270ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);32713272ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton);3273ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin);3274ClassDB::bind_method(D_METHOD("instance_set_visibility_parent", "instance", "parent"), &RenderingServer::instance_set_visibility_parent);3275ClassDB::bind_method(D_METHOD("instance_set_ignore_culling", "instance", "enabled"), &RenderingServer::instance_set_ignore_culling);32763277ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag);3278ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting);3279ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override);3280ClassDB::bind_method(D_METHOD("instance_geometry_set_material_overlay", "instance", "material"), &RenderingServer::instance_geometry_set_material_overlay);3281ClassDB::bind_method(D_METHOD("instance_geometry_set_visibility_range", "instance", "min", "max", "min_margin", "max_margin", "fade_mode"), &RenderingServer::instance_geometry_set_visibility_range);3282ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap);3283ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias);32843285ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter);3286ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter);3287ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value);3288ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list);32893290ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));3291ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));3292ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID()));32933294BIND_ENUM_CONSTANT(INSTANCE_NONE);3295BIND_ENUM_CONSTANT(INSTANCE_MESH);3296BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);3297BIND_ENUM_CONSTANT(INSTANCE_PARTICLES);3298BIND_ENUM_CONSTANT(INSTANCE_PARTICLES_COLLISION);3299BIND_ENUM_CONSTANT(INSTANCE_LIGHT);3300BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);3301BIND_ENUM_CONSTANT(INSTANCE_DECAL);3302BIND_ENUM_CONSTANT(INSTANCE_VOXEL_GI);3303BIND_ENUM_CONSTANT(INSTANCE_LIGHTMAP);3304BIND_ENUM_CONSTANT(INSTANCE_OCCLUDER);3305BIND_ENUM_CONSTANT(INSTANCE_VISIBLITY_NOTIFIER);3306BIND_ENUM_CONSTANT(INSTANCE_FOG_VOLUME);3307BIND_ENUM_CONSTANT(INSTANCE_MAX);33083309BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);33103311BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_BAKED_LIGHT);3312BIND_ENUM_CONSTANT(INSTANCE_FLAG_USE_DYNAMIC_GI);3313BIND_ENUM_CONSTANT(INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE);3314BIND_ENUM_CONSTANT(INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING);3315BIND_ENUM_CONSTANT(INSTANCE_FLAG_MAX);33163317BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_OFF);3318BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_ON);3319BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);3320BIND_ENUM_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);33213322BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DISABLED);3323BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_SELF);3324BIND_ENUM_CONSTANT(VISIBILITY_RANGE_FADE_DEPENDENCIES);33253326/* Bake 3D Object */33273328ClassDB::bind_method(D_METHOD("bake_render_uv2", "base", "material_overrides", "image_size"), &RenderingServer::bake_render_uv2);33293330BIND_ENUM_CONSTANT(BAKE_CHANNEL_ALBEDO_ALPHA);3331BIND_ENUM_CONSTANT(BAKE_CHANNEL_NORMAL);3332BIND_ENUM_CONSTANT(BAKE_CHANNEL_ORM);3333BIND_ENUM_CONSTANT(BAKE_CHANNEL_EMISSION);33343335/* CANVAS (2D) */33363337ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create);3338ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring);3339ClassDB::bind_method(D_METHOD("canvas_set_item_repeat", "item", "repeat_size", "repeat_times"), &RenderingServer::canvas_set_item_repeat);3340ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate);3341ClassDB::bind_method(D_METHOD("canvas_set_disable_scale", "disable"), &RenderingServer::canvas_set_disable_scale);33423343/* CANVAS TEXTURE */33443345ClassDB::bind_method(D_METHOD("canvas_texture_create"), &RenderingServer::canvas_texture_create);3346ClassDB::bind_method(D_METHOD("canvas_texture_set_channel", "canvas_texture", "channel", "texture"), &RenderingServer::canvas_texture_set_channel);3347ClassDB::bind_method(D_METHOD("canvas_texture_set_shading_parameters", "canvas_texture", "base_color", "shininess"), &RenderingServer::canvas_texture_set_shading_parameters);33483349ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_filter", "canvas_texture", "filter"), &RenderingServer::canvas_texture_set_texture_filter);3350ClassDB::bind_method(D_METHOD("canvas_texture_set_texture_repeat", "canvas_texture", "repeat"), &RenderingServer::canvas_texture_set_texture_repeat);33513352BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_DIFFUSE);3353BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_NORMAL);3354BIND_ENUM_CONSTANT(CANVAS_TEXTURE_CHANNEL_SPECULAR);33553356/* CANVAS ITEM */33573358ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create);3359ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent);3360ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_filter", "item", "filter"), &RenderingServer::canvas_item_set_default_texture_filter);3361ClassDB::bind_method(D_METHOD("canvas_item_set_default_texture_repeat", "item", "repeat"), &RenderingServer::canvas_item_set_default_texture_repeat);3362ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible);3363ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask);3364ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_layer", "item", "visibility_layer"), &RenderingServer::canvas_item_set_visibility_layer);3365ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform);3366ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip);3367ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode);3368ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));3369ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate);3370ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate);3371ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent);3372ClassDB::bind_method(D_METHOD("canvas_item_set_interpolated", "item", "interpolated"), &RenderingServer::canvas_item_set_interpolated);3373ClassDB::bind_method(D_METHOD("canvas_item_reset_physics_interpolation", "item"), &RenderingServer::canvas_item_reset_physics_interpolation);3374ClassDB::bind_method(D_METHOD("canvas_item_transform_physics_interpolation", "item", "transform"), &RenderingServer::canvas_item_transform_physics_interpolation);33753376/* Primitives */33773378ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(-1.0), DEFVAL(false));3379ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(-1.0), DEFVAL(false));3380ClassDB::bind_method(D_METHOD("canvas_item_add_multiline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_multiline, DEFVAL(-1.0), DEFVAL(false));3381ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color", "antialiased"), &RenderingServer::canvas_item_add_rect, DEFVAL(false));3382ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color", "antialiased"), &RenderingServer::canvas_item_add_circle, DEFVAL(false));3383ClassDB::bind_method(D_METHOD("canvas_item_add_ellipse", "item", "pos", "major", "minor", "color", "antialiased"), &RenderingServer::canvas_item_add_ellipse, DEFVAL(false));3384ClassDB::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));3385ClassDB::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));3386ClassDB::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);3387ClassDB::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));3388ClassDB::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)));3389ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_primitive);3390ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()));3391ClassDB::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));3392ClassDB::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()));3393ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));3394ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture"), &RenderingServer::canvas_item_add_particles);3395ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);3396ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);3397ClassDB::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));3398ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);3399ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);3400ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);3401ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);3402ClassDB::bind_method(D_METHOD("canvas_item_attach_skeleton", "item", "skeleton"), &RenderingServer::canvas_item_attach_skeleton);34033404ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);3405ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);3406ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);3407ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material);34083409ClassDB::bind_method(D_METHOD("canvas_item_set_instance_shader_parameter", "instance", "parameter", "value"), &RenderingServer::canvas_item_set_instance_shader_parameter);3410ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter", "instance", "parameter"), &RenderingServer::canvas_item_get_instance_shader_parameter);3411ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::canvas_item_get_instance_shader_parameter_default_value);3412ClassDB::bind_method(D_METHOD("canvas_item_get_instance_shader_parameter_list", "instance"), &RenderingServer::_canvas_item_get_instance_shader_parameter_list);34133414ClassDB::bind_method(D_METHOD("canvas_item_set_visibility_notifier", "item", "enable", "area", "enter_callable", "exit_callable"), &RenderingServer::canvas_item_set_visibility_notifier);3415ClassDB::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));34163417ClassDB::bind_method(D_METHOD("debug_canvas_item_get_rect", "item"), &RenderingServer::debug_canvas_item_get_rect);34183419BIND_ENUM_CONSTANT(NINE_PATCH_STRETCH);3420BIND_ENUM_CONSTANT(NINE_PATCH_TILE);3421BIND_ENUM_CONSTANT(NINE_PATCH_TILE_FIT);34223423BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_DEFAULT);3424BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST);3425BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR);3426BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);3427BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);3428BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC);3429BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC);3430BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_FILTER_MAX);34313432BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);3433BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);3434BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);3435BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MIRROR);3436BIND_ENUM_CONSTANT(CANVAS_ITEM_TEXTURE_REPEAT_MAX);34373438BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_DISABLED);3439BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_ONLY);3440BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_CLIP_AND_DRAW);3441BIND_ENUM_CONSTANT(CANVAS_GROUP_MODE_TRANSPARENT);34423443/* CANVAS LIGHT */34443445ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create);3446ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas);3447ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled);3448ClassDB::bind_method(D_METHOD("canvas_light_set_texture_scale", "light", "scale"), &RenderingServer::canvas_light_set_texture_scale);3449ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform);3450ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture);3451ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset);3452ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color);3453ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height);3454ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy);3455ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range);3456ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range);3457ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask);3458ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask);3459ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode);3460ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled);3461ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);3462ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);3463ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);3464ClassDB::bind_method(D_METHOD("canvas_light_set_blend_mode", "light", "mode"), &RenderingServer::canvas_light_set_blend_mode);3465ClassDB::bind_method(D_METHOD("canvas_light_set_interpolated", "light", "interpolated"), &RenderingServer::canvas_light_set_interpolated);3466ClassDB::bind_method(D_METHOD("canvas_light_reset_physics_interpolation", "light"), &RenderingServer::canvas_light_reset_physics_interpolation);3467ClassDB::bind_method(D_METHOD("canvas_light_transform_physics_interpolation", "light", "transform"), &RenderingServer::canvas_light_transform_physics_interpolation);34683469BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_POINT);3470BIND_ENUM_CONSTANT(CANVAS_LIGHT_MODE_DIRECTIONAL);34713472BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_ADD);3473BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_SUB);3474BIND_ENUM_CONSTANT(CANVAS_LIGHT_BLEND_MODE_MIX);34753476BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_NONE);3477BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF5);3478BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_PCF13);3479BIND_ENUM_CONSTANT(CANVAS_LIGHT_FILTER_MAX);34803481/* CANVAS OCCLUDER */34823483ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create);3484ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas);3485ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled);3486ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon);3487ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_as_sdf_collision", "occluder", "enable"), &RenderingServer::canvas_light_occluder_set_as_sdf_collision);3488ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform);3489ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask);3490ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_interpolated", "occluder", "interpolated"), &RenderingServer::canvas_light_occluder_set_interpolated);3491ClassDB::bind_method(D_METHOD("canvas_light_occluder_reset_physics_interpolation", "occluder"), &RenderingServer::canvas_light_occluder_reset_physics_interpolation);3492ClassDB::bind_method(D_METHOD("canvas_light_occluder_transform_physics_interpolation", "occluder", "transform"), &RenderingServer::canvas_light_occluder_transform_physics_interpolation);34933494/* CANVAS LIGHT OCCLUDER POLYGON */34953496ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create);3497ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape);3498ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode);34993500ClassDB::bind_method(D_METHOD("canvas_set_shadow_texture_size", "size"), &RenderingServer::canvas_set_shadow_texture_size);35013502BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_DISABLED);3503BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE);3504BIND_ENUM_CONSTANT(CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE);35053506/* GLOBAL SHADER UNIFORMS */35073508ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add);3509ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove);3510ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::_global_shader_parameter_get_list);3511ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set);3512ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override);3513ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get);3514ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type);35153516BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL);3517BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2);3518BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC3);3519BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC4);3520BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_INT);3521BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC2);3522BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC3);3523BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_IVEC4);3524BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2I);3525BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UINT);3526BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC2);3527BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC3);3528BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_UVEC4);3529BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_FLOAT);3530BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC2);3531BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC3);3532BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_VEC4);3533BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_COLOR);3534BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_RECT2);3535BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT2);3536BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT3);3537BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAT4);3538BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM_2D);3539BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_TRANSFORM);3540BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2D);3541BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER2DARRAY);3542BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLER3D);3543BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLERCUBE);3544BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_SAMPLEREXT);3545BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAX);35463547/* Free */3548ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free_rid);35493550/* Misc */35513552ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "callable"), &RenderingServer::request_frame_drawn_callback);3553ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed);3554ClassDB::bind_method(D_METHOD("get_rendering_info", "info"), &RenderingServer::get_rendering_info);3555ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);3556ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);3557ClassDB::bind_method(D_METHOD("get_video_adapter_type"), &RenderingServer::get_video_adapter_type);3558ClassDB::bind_method(D_METHOD("get_video_adapter_api_version"), &RenderingServer::get_video_adapter_api_version);35593560ClassDB::bind_method(D_METHOD("get_current_rendering_driver_name"), &RenderingServer::get_current_rendering_driver_name);3561ClassDB::bind_method(D_METHOD("get_current_rendering_method"), &RenderingServer::get_current_rendering_method);35623563ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);3564ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);35653566ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);3567ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);35683569ClassDB::bind_method(D_METHOD("set_boot_image_with_stretch", "image", "color", "stretch_mode", "use_filter"), &RenderingServer::set_boot_image_with_stretch, DEFVAL(true));3570#ifndef DISABLE_DEPRECATED3571ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));3572#endif3573ClassDB::bind_method(D_METHOD("get_default_clear_color"), &RenderingServer::get_default_clear_color);3574ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);35753576ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);3577ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);35783579ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);3580ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);35813582ClassDB::bind_method(D_METHOD("get_frame_setup_time_cpu"), &RenderingServer::get_frame_setup_time_cpu);35833584ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");35853586BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME);3587BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME);3588BIND_ENUM_CONSTANT(RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME);3589BIND_ENUM_CONSTANT(RENDERING_INFO_TEXTURE_MEM_USED);3590BIND_ENUM_CONSTANT(RENDERING_INFO_BUFFER_MEM_USED);3591BIND_ENUM_CONSTANT(RENDERING_INFO_VIDEO_MEM_USED);3592BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_CANVAS);3593BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_MESH);3594BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SURFACE);3595BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_DRAW);3596BIND_ENUM_CONSTANT(RENDERING_INFO_PIPELINE_COMPILATIONS_SPECIALIZATION);35973598BIND_ENUM_CONSTANT(PIPELINE_SOURCE_CANVAS);3599BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MESH);3600BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SURFACE);3601BIND_ENUM_CONSTANT(PIPELINE_SOURCE_DRAW);3602BIND_ENUM_CONSTANT(PIPELINE_SOURCE_SPECIALIZATION);3603BIND_ENUM_CONSTANT(PIPELINE_SOURCE_MAX);36043605BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_DISABLED);3606BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP);3607BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP_WIDTH);3608BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_KEEP_HEIGHT);3609BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_COVER);3610BIND_ENUM_CONSTANT(SPLASH_STRETCH_MODE_IGNORE);36113612ADD_SIGNAL(MethodInfo("frame_pre_draw"));3613ADD_SIGNAL(MethodInfo("frame_post_draw"));36143615ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);3616ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));3617ClassDB::bind_method(D_METHOD("get_rendering_device"), &RenderingServer::get_rendering_device);3618ClassDB::bind_method(D_METHOD("create_local_rendering_device"), &RenderingServer::create_local_rendering_device);36193620ClassDB::bind_method(D_METHOD("is_on_render_thread"), &RenderingServer::is_on_render_thread);3621ClassDB::bind_method(D_METHOD("call_on_render_thread", "callable"), &RenderingServer::call_on_render_thread);36223623#ifndef DISABLE_DEPRECATED3624ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);36253626BIND_ENUM_CONSTANT(FEATURE_SHADERS);3627BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED);3628#endif3629}36303631void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {3632Vector<Vector3> vertices;3633Vector<Vector3> normals;36343635for (const Geometry3D::MeshData::Face &f : p_mesh_data.faces) {3636for (uint32_t j = 2; j < f.indices.size(); j++) {3637vertices.push_back(p_mesh_data.vertices[f.indices[0]]);3638normals.push_back(f.plane.normal);36393640vertices.push_back(p_mesh_data.vertices[f.indices[j - 1]]);3641normals.push_back(f.plane.normal);36423643vertices.push_back(p_mesh_data.vertices[f.indices[j]]);3644normals.push_back(f.plane.normal);3645}3646}36473648Array d;3649d.resize(RS::ARRAY_MAX);3650d[ARRAY_VERTEX] = vertices;3651d[ARRAY_NORMAL] = normals;3652mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);3653}36543655void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {3656Geometry3D::MeshData mdata = Geometry3D::build_convex_mesh(p_planes);3657mesh_add_surface_from_mesh_data(p_mesh, mdata);3658}36593660#ifndef DISABLE_DEPRECATED3661void RenderingServer::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {3662SplashStretchMode stretch_mode = map_scaling_option_to_stretch_mode(p_scale);3663set_boot_image_with_stretch(p_image, p_color, stretch_mode, p_use_filter);3664}3665#endif36663667RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {3668RID instance = instance_create();3669instance_set_base(instance, p_base);3670instance_set_scenario(instance, p_scenario);3671return instance;3672}36733674bool RenderingServer::is_render_loop_enabled() const {3675return render_loop_enabled;3676}36773678void RenderingServer::set_render_loop_enabled(bool p_enabled) {3679render_loop_enabled = p_enabled;3680}36813682RenderingServer::RenderingServer() {3683//ERR_FAIL_COND(singleton);36843685singleton = this;3686}36873688TypedArray<StringName> RenderingServer::_global_shader_parameter_get_list() const {3689TypedArray<StringName> gsp;3690Vector<StringName> gsp_sn = global_shader_parameter_get_list();3691gsp.resize(gsp_sn.size());3692for (int i = 0; i < gsp_sn.size(); i++) {3693gsp[i] = gsp_sn[i];3694}3695return gsp;3696}36973698void RenderingServer::init() {3699// These are overrides, even if they are false Godot will still3700// import the texture formats that the host platform needs.3701// See `const bool can_s3tc_bptc` in the resource importer.3702GLOBAL_DEF_RST("rendering/textures/vram_compression/import_s3tc_bptc", false);3703GLOBAL_DEF_RST("rendering/textures/vram_compression/import_etc2_astc", false);3704GLOBAL_DEF("rendering/textures/vram_compression/compress_with_gpu", true);3705GLOBAL_DEF("rendering/textures/vram_compression/cache_gpu_compressor", true);37063707GLOBAL_DEF("rendering/textures/lossless_compression/force_png", false);37083709GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/webp_compression/compression_method", PROPERTY_HINT_RANGE, "0,6,1"), 2);3710GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/webp_compression/lossless_compression_factor", PROPERTY_HINT_RANGE, "0,100,1"), 25);37113712GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "1,10000,1,or_greater,suffix:s"), 3600);37133714GLOBAL_DEF_RST("rendering/lights_and_shadows/use_physical_light_units", false);37153716GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384"), 4096);3717GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/size.mobile", 2048);3718GLOBAL_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);3719GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile", 0);3720GLOBAL_DEF("rendering/lights_and_shadows/directional_shadow/16_bits", true);37213722GLOBAL_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);3723GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);3724GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);37253726GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/2d/shadow_atlas/size", PROPERTY_HINT_RANGE, "128,16384"), 2048);3727GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);3728GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/uniform_set_cache_size", PROPERTY_HINT_RANGE, "256,1048576,1"), 4096);37293730// Number of commands that can be drawn per frame.3731GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/gl_compatibility/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);37323733GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true);3734GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true);3735GLOBAL_DEF("rendering/shader_compiler/shader_cache/use_zstd_compression", true);3736GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug", false);3737GLOBAL_DEF("rendering/shader_compiler/shader_cache/strip_debug.release", true);37383739GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/roughness_layers", PROPERTY_HINT_RANGE, "1,32,1"), 7);3740GLOBAL_DEF_RST("rendering/reflections/sky_reflections/texture_array_reflections", true);3741GLOBAL_DEF("rendering/reflections/sky_reflections/texture_array_reflections.mobile", false);3742GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples", PROPERTY_HINT_RANGE, "0,256,1"), 32);3743GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/sky_reflections/ggx_samples.mobile", PROPERTY_HINT_RANGE, "0,128,1"), 16);3744GLOBAL_DEF("rendering/reflections/sky_reflections/fast_filter_high_quality", false);3745GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size", PROPERTY_HINT_RANGE, "4,4096,1"), 256);3746GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_size.mobile", PROPERTY_HINT_RANGE, "4,2048,1"), 128);3747GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/reflections/reflection_atlas/reflection_count", PROPERTY_HINT_RANGE, "1,256,1"), 64);3748GLOBAL_DEF_RST("rendering/reflections/specular_occlusion/enabled", true);37493750GLOBAL_DEF("rendering/global_illumination/gi/use_half_resolution", false);37513752GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/voxel_gi/quality", PROPERTY_HINT_ENUM, "Low (4 Cones - Fast),High (6 Cones - Slow)"), 0);37533754GLOBAL_DEF_RST("rendering/shading/overrides/force_vertex_shading", false);3755GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley", false);3756GLOBAL_DEF("rendering/shading/overrides/force_lambert_over_burley.mobile", true);37573758GLOBAL_DEF_RST("rendering/driver/depth_prepass/enable", true);3759GLOBAL_DEF_RST("rendering/driver/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");37603761GLOBAL_DEF_RST("rendering/textures/default_filters/use_nearest_mipmap_filter", false);3762GLOBAL_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);37633764GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/camera/depth_of_field/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slowest)"), 1);3765GLOBAL_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);3766GLOBAL_DEF("rendering/camera/depth_of_field/depth_of_field_use_jitter", false);37673768GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);3769GLOBAL_DEF("rendering/environment/ssao/half_size", true);3770GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);3771GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssao/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 2);3772GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);3773GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssao/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);37743775GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/quality", PROPERTY_HINT_ENUM, "Very Low (Fast),Low (Fast),Medium (Average),High (Slow),Ultra (Custom)"), 2);3776GLOBAL_DEF("rendering/environment/ssil/half_size", true);3777GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/adaptive_target", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), 0.5);3778GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/ssil/blur_passes", PROPERTY_HINT_RANGE, "0,6"), 4);3779GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);3780GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);37813782// Move the project setting definitions here so they are available when we init the rendering internals.3783GLOBAL_DEF_BASIC("rendering/viewport/hdr_2d", false);37843785GLOBAL_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);3786GLOBAL_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);37873788GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);3789GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);3790GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);37913792GLOBAL_DEF_RST(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/quality/smaa_edge_detection_threshold", PROPERTY_HINT_RANGE, "0.01,0.2,0.01"), 0.05);37933794GLOBAL_DEF("rendering/anti_aliasing/quality/use_debanding", false);37953796{3797String mode_hints;3798String mode_hints_metal;3799{3800Vector<String> mode_hints_arr = { "Bilinear (Fastest)", "FSR 1.0 (Fast)", "FSR 2.2 (Slow)" };3801mode_hints = String(",").join(mode_hints_arr);38023803mode_hints_arr.push_back("MetalFX (Spatial)");3804mode_hints_arr.push_back("MetalFX (Temporal)");3805mode_hints_metal = String(",").join(mode_hints_arr);3806}38073808GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode", PROPERTY_HINT_ENUM, mode_hints), 0);3809GLOBAL_DEF_NOVAL(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode.ios", PROPERTY_HINT_ENUM, mode_hints_metal), 0);3810GLOBAL_DEF_NOVAL(PropertyInfo(Variant::INT, "rendering/scaling_3d/mode.macos", PROPERTY_HINT_ENUM, mode_hints_metal), 0);3811}3812GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);3813GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);38143815GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);3816GLOBAL_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);3817GLOBAL_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);38183819GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/occlusion_culling/occlusion_rays_per_thread", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), 512);38203821GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slow)"), 1);3822GLOBAL_DEF("rendering/environment/glow/upscale_mode.mobile", 0);38233824GLOBAL_DEF("rendering/environment/screen_space_reflection/half_size", true);38253826GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/subsurface_scattering/subsurface_scattering_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low (Fast),Medium (Average),High (Slow)"), 1);3827GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.05);3828GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/subsurface_scattering/subsurface_scattering_depth_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001"), 0.01);38293830GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/limits/global_shader_variables/buffer_size", PROPERTY_HINT_RANGE, "16,1048576,1"), 65536);38313832GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/probe_capture/update_speed", PROPERTY_HINT_RANGE, "0.001,256,0.001"), 15);3833GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/lightmapping/primitive_meshes/texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.2);3834GLOBAL_DEF("rendering/lightmapping/lightmap_gi/use_bicubic_filter", true);38353836GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/probe_ray_count", PROPERTY_HINT_ENUM, "8 (Fastest),16,32,64,96,128 (Slowest)"), 1);3837GLOBAL_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);3838GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/global_illumination/sdfgi/frames_to_update_lights", PROPERTY_HINT_ENUM, "1 (Slower),2,4,8,16 (Faster)"), 2);38393840GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_size", PROPERTY_HINT_RANGE, "16,512,1"), 64);3841GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/volume_depth", PROPERTY_HINT_RANGE, "16,512,1"), 64);3842GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/environment/volumetric_fog/use_filter", PROPERTY_HINT_ENUM, "No (Faster),Yes (Higher Quality)"), 1);38433844GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/update_iterations_per_frame", PROPERTY_HINT_RANGE, "0,1024,1"), 10);3845GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/spatial_indexer/threaded_cull_minimum_instances", PROPERTY_HINT_RANGE, "32,65536,1"), 1000);38463847GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1"), 512);38483849// OpenGL limits3850GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_elements", PROPERTY_HINT_RANGE, "1024,65536,1"), 65536);3851GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_lights", PROPERTY_HINT_RANGE, "2,256,1"), 32);3852GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_lights_per_object", PROPERTY_HINT_RANGE, "2,1024,1"), 8);38533854#ifndef XR_DISABLED3855GLOBAL_DEF_RST_BASIC("xr/shaders/enabled", false);3856#endif // XR_DISABLED38573858GLOBAL_DEF("debug/shader_language/warnings/enable", true);3859GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false);38603861#ifdef DEBUG_ENABLED3862for (int i = 0; i < (int)ShaderWarning::WARNING_MAX; i++) {3863GLOBAL_DEF("debug/shader_language/warnings/" + ShaderWarning::get_name_from_code((ShaderWarning::Code)i).to_lower(), true);3864}3865#endif3866}38673868RenderingServer::~RenderingServer() {3869singleton = nullptr;3870}387138723873