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