feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void RendererCameraAttributes::camera_attributes_set_dof_blur(RID p_camera_attri
|
|||
ERR_FAIL_NULL(cam_attributes);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && (p_far_enable || p_near_enable)) {
|
||||
WARN_PRINT_ONCE_ED("DoF blur is only available when using the Forward+ or Mobile rendering backends.");
|
||||
WARN_PRINT_ONCE_ED("DoF blur is only available when using the Forward+ or Mobile renderers.");
|
||||
}
|
||||
#endif
|
||||
cam_attributes->dof_blur_far_enabled = p_far_enable;
|
||||
|
|
@ -145,7 +145,7 @@ void RendererCameraAttributes::camera_attributes_set_auto_exposure(RID p_camera_
|
|||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Auto exposure is only available when using the Forward+ or Mobile rendering backends.");
|
||||
WARN_PRINT_ONCE_ED("Auto exposure is only available when using the Forward+ or Mobile renderers.");
|
||||
}
|
||||
#endif
|
||||
cam_attributes->use_auto_exposure = p_enable;
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ public:
|
|||
RendererCameraAttributes();
|
||||
~RendererCameraAttributes();
|
||||
|
||||
CameraAttributes *get_camera_attributes(RID p_rid) { return camera_attributes_owner.get_or_null(p_rid); };
|
||||
bool owns_camera_attributes(RID p_rid) { return camera_attributes_owner.owns(p_rid); };
|
||||
CameraAttributes *get_camera_attributes(RID p_rid) { return camera_attributes_owner.get_or_null(p_rid); }
|
||||
bool owns_camera_attributes(RID p_rid) { return camera_attributes_owner.owns(p_rid); }
|
||||
|
||||
RID camera_attributes_allocate();
|
||||
void camera_attributes_initialize(RID p_rid);
|
||||
|
|
|
|||
|
|
@ -189,6 +189,18 @@ RS::EnvironmentReflectionSource RendererEnvironmentStorage::environment_get_refl
|
|||
return env->reflection_source;
|
||||
}
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_NULL(env);
|
||||
env->camera_feed_id = p_camera_feed_id;
|
||||
}
|
||||
|
||||
int RendererEnvironmentStorage::environment_get_camera_feed_id(RID p_env) const {
|
||||
Environment *env = environment_owner.get_or_null(p_env);
|
||||
ERR_FAIL_NULL_V(env, -1);
|
||||
return env->camera_feed_id;
|
||||
}
|
||||
|
||||
// Tonemap
|
||||
|
||||
void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white) {
|
||||
|
|
@ -329,7 +341,7 @@ void RendererEnvironmentStorage::environment_set_volumetric_fog(RID p_env, bool
|
|||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Volumetric fog can only be enabled when using the Forward+ rendering backend.");
|
||||
WARN_PRINT_ONCE_ED("Volumetric fog can only be enabled when using the Forward+ renderer.");
|
||||
}
|
||||
#endif
|
||||
env->volumetric_fog_enabled = p_enable;
|
||||
|
|
@ -524,7 +536,7 @@ void RendererEnvironmentStorage::environment_set_ssr(RID p_env, bool p_enable, i
|
|||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space reflections (SSR) can only be enabled when using the Forward+ rendering backend.");
|
||||
WARN_PRINT_ONCE_ED("Screen-space reflections (SSR) can only be enabled when using the Forward+ renderer.");
|
||||
}
|
||||
#endif
|
||||
env->ssr_enabled = p_enable;
|
||||
|
|
@ -571,7 +583,7 @@ void RendererEnvironmentStorage::environment_set_ssao(RID p_env, bool p_enable,
|
|||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space ambient occlusion (SSAO) can only be enabled when using the Forward+ rendering backend.");
|
||||
WARN_PRINT_ONCE_ED("Screen-space ambient occlusion (SSAO) can only be enabled when using the Forward+ renderer.");
|
||||
}
|
||||
#endif
|
||||
env->ssao_enabled = p_enable;
|
||||
|
|
@ -646,7 +658,7 @@ void RendererEnvironmentStorage::environment_set_ssil(RID p_env, bool p_enable,
|
|||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("Screen-space indirect lighting (SSIL) can only be enabled when using the Forward+ rendering backend.");
|
||||
WARN_PRINT_ONCE_ED("Screen-space indirect lighting (SSIL) can only be enabled when using the Forward+ renderer.");
|
||||
}
|
||||
#endif
|
||||
env->ssil_enabled = p_enable;
|
||||
|
|
@ -693,7 +705,7 @@ void RendererEnvironmentStorage::environment_set_sdfgi(RID p_env, bool p_enable,
|
|||
ERR_FAIL_NULL(env);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) {
|
||||
WARN_PRINT_ONCE_ED("SDFGI can only be enabled when using the Forward+ rendering backend.");
|
||||
WARN_PRINT_ONCE_ED("SDFGI can only be enabled when using the Forward+ renderer.");
|
||||
}
|
||||
#endif
|
||||
env->sdfgi_enabled = p_enable;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ private:
|
|||
float ambient_light_energy = 1.0;
|
||||
float ambient_sky_contribution = 1.0;
|
||||
RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG;
|
||||
int camera_feed_id = 0;
|
||||
|
||||
// Tonemap
|
||||
RS::EnvironmentToneMapper tone_mapper;
|
||||
|
|
@ -181,10 +182,8 @@ public:
|
|||
void environment_set_bg_energy(RID p_env, float p_multiplier, float p_exposure_value);
|
||||
void environment_set_canvas_max_layer(RID p_env, int p_max_layer);
|
||||
void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG);
|
||||
// FIXME: Disabled during Vulkan refactoring, should be ported.
|
||||
#if 0
|
||||
void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id);
|
||||
#endif
|
||||
int environment_get_camera_feed_id(RID p_env) const;
|
||||
|
||||
RS::EnvironmentBG environment_get_background(RID p_env) const;
|
||||
RID environment_get_sky(RID p_env) const;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ public:
|
|||
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
|
||||
virtual void light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) = 0;
|
||||
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
|
||||
virtual void light_set_shadow_caster_mask(RID p_light, uint32_t p_caster_mask) = 0;
|
||||
virtual uint32_t light_get_shadow_caster_mask(RID p_light) const = 0;
|
||||
virtual void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) = 0;
|
||||
virtual void light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) = 0;
|
||||
|
||||
|
|
@ -109,6 +111,7 @@ public:
|
|||
virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) = 0;
|
||||
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
|
||||
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
|
||||
virtual void reflection_probe_set_blend_distance(RID p_probe, float p_blend_distance) = 0;
|
||||
virtual void reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) = 0;
|
||||
virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) = 0;
|
||||
virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) = 0;
|
||||
|
|
@ -173,6 +176,10 @@ public:
|
|||
virtual void lightmap_set_probe_capture_update_speed(float p_speed) = 0;
|
||||
virtual float lightmap_get_probe_capture_update_speed() const = 0;
|
||||
|
||||
virtual void lightmap_set_shadowmask_textures(RID p_lightmap, RID p_shadow) = 0;
|
||||
virtual RS::ShadowmaskMode lightmap_get_shadowmask_mode(RID p_lightmap) = 0;
|
||||
virtual void lightmap_set_shadowmask_mode(RID p_lightmap, RS::ShadowmaskMode p_mode) = 0;
|
||||
|
||||
/* LIGHTMAP INSTANCE */
|
||||
|
||||
virtual RID lightmap_instance_create(RID p_lightmap) = 0;
|
||||
|
|
@ -186,12 +193,12 @@ public:
|
|||
|
||||
virtual void shadow_atlas_set_size(RID p_atlas, int p_size, bool p_use_16_bits = true) = 0;
|
||||
virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) = 0;
|
||||
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) = 0;
|
||||
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_instance, float p_coverage, uint64_t p_light_version) = 0;
|
||||
|
||||
virtual void shadow_atlas_update(RID p_atlas) = 0;
|
||||
|
||||
virtual void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = true) = 0;
|
||||
virtual int get_directional_light_shadow_size(RID p_light_intance) = 0;
|
||||
virtual int get_directional_light_shadow_size(RID p_light_instance) = 0;
|
||||
virtual void set_directional_shadow_count(int p_count) = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
class RendererMaterialStorage {
|
||||
public:
|
||||
virtual ~RendererMaterialStorage(){};
|
||||
virtual ~RendererMaterialStorage() {}
|
||||
|
||||
/* GLOBAL SHADER UNIFORM API */
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) = 0;
|
||||
|
|
@ -87,6 +87,7 @@ public:
|
|||
|
||||
virtual bool material_is_animated(RID p_material) = 0;
|
||||
virtual bool material_casts_shadows(RID p_material) = 0;
|
||||
virtual RS::CullMode material_get_cull_mode(RID p_material) const = 0;
|
||||
|
||||
struct InstanceShaderParam {
|
||||
PropertyInfo info;
|
||||
|
|
|
|||
493
engine/servers/rendering/storage/mesh_storage.cpp
Normal file
493
engine/servers/rendering/storage/mesh_storage.cpp
Normal file
|
|
@ -0,0 +1,493 @@
|
|||
/**************************************************************************/
|
||||
/* mesh_storage.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "mesh_storage.h"
|
||||
|
||||
#include "core/math/transform_interpolator.h"
|
||||
|
||||
#if defined(DEBUG_ENABLED) && defined(TOOLS_ENABLED)
|
||||
#include "core/config/project_settings.h"
|
||||
#endif
|
||||
|
||||
RID RendererMeshStorage::multimesh_allocate() {
|
||||
return _multimesh_allocate();
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_initialize(RID p_rid) {
|
||||
_multimesh_initialize(p_rid);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_free(RID p_rid) {
|
||||
_multimesh_free(p_rid);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data, bool p_use_indirect) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi) {
|
||||
mmi->_transform_format = p_transform_format;
|
||||
mmi->_use_colors = p_use_colors;
|
||||
mmi->_use_custom_data = p_use_custom_data;
|
||||
mmi->_num_instances = p_instances;
|
||||
|
||||
mmi->_vf_size_xform = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
|
||||
mmi->_vf_size_color = p_use_colors ? 4 : 0;
|
||||
mmi->_vf_size_data = p_use_custom_data ? 4 : 0;
|
||||
|
||||
mmi->_stride = mmi->_vf_size_xform + mmi->_vf_size_color + mmi->_vf_size_data;
|
||||
|
||||
int size_in_floats = p_instances * mmi->_stride;
|
||||
mmi->_data_curr.resize_zeroed(size_in_floats);
|
||||
mmi->_data_prev.resize_zeroed(size_in_floats);
|
||||
mmi->_data_interpolated.resize_zeroed(size_in_floats);
|
||||
}
|
||||
|
||||
_multimesh_allocate_data(p_multimesh, p_instances, p_transform_format, p_use_colors, p_use_custom_data, p_use_indirect);
|
||||
}
|
||||
|
||||
int RendererMeshStorage::multimesh_get_instance_count(RID p_multimesh) const {
|
||||
return _multimesh_get_instance_count(p_multimesh);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
|
||||
_multimesh_set_mesh(p_multimesh, p_mesh);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi && mmi->interpolated) {
|
||||
ERR_FAIL_COND(p_index >= mmi->_num_instances);
|
||||
ERR_FAIL_COND(mmi->_vf_size_xform != 12);
|
||||
|
||||
int start = p_index * mmi->_stride;
|
||||
float *ptr = mmi->_data_curr.ptrw();
|
||||
ptr += start;
|
||||
|
||||
const Transform3D &t = p_transform;
|
||||
ptr[0] = t.basis.rows[0][0];
|
||||
ptr[1] = t.basis.rows[0][1];
|
||||
ptr[2] = t.basis.rows[0][2];
|
||||
ptr[3] = t.origin.x;
|
||||
ptr[4] = t.basis.rows[1][0];
|
||||
ptr[5] = t.basis.rows[1][1];
|
||||
ptr[6] = t.basis.rows[1][2];
|
||||
ptr[7] = t.origin.y;
|
||||
ptr[8] = t.basis.rows[2][0];
|
||||
ptr[9] = t.basis.rows[2][1];
|
||||
ptr[10] = t.basis.rows[2][2];
|
||||
ptr[11] = t.origin.z;
|
||||
|
||||
_multimesh_add_to_interpolation_lists(p_multimesh, *mmi);
|
||||
|
||||
#if defined(DEBUG_ENABLED) && defined(TOOLS_ENABLED)
|
||||
if (!Engine::get_singleton()->is_in_physics_frame()) {
|
||||
PHYSICS_INTERPOLATION_WARNING("MultiMesh interpolation is being triggered from outside physics process, this might lead to issues");
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_multimesh_instance_set_transform(p_multimesh, p_index, p_transform);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
|
||||
_multimesh_instance_set_transform_2d(p_multimesh, p_index, p_transform);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi && mmi->interpolated) {
|
||||
ERR_FAIL_COND(p_index >= mmi->_num_instances);
|
||||
ERR_FAIL_COND(mmi->_vf_size_color == 0);
|
||||
|
||||
int start = (p_index * mmi->_stride) + mmi->_vf_size_xform;
|
||||
float *ptr = mmi->_data_curr.ptrw();
|
||||
ptr += start;
|
||||
|
||||
if (mmi->_vf_size_color == 4) {
|
||||
for (int n = 0; n < 4; n++) {
|
||||
ptr[n] = p_color.components[n];
|
||||
}
|
||||
} else {
|
||||
#ifdef DEV_ENABLED
|
||||
// The options are currently 4 or zero, but just in case this changes in future...
|
||||
ERR_FAIL_COND(mmi->_vf_size_color != 0);
|
||||
#endif
|
||||
}
|
||||
_multimesh_add_to_interpolation_lists(p_multimesh, *mmi);
|
||||
return;
|
||||
}
|
||||
|
||||
_multimesh_instance_set_color(p_multimesh, p_index, p_color);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi && mmi->interpolated) {
|
||||
ERR_FAIL_COND(p_index >= mmi->_num_instances);
|
||||
ERR_FAIL_COND(mmi->_vf_size_data == 0);
|
||||
|
||||
int start = (p_index * mmi->_stride) + mmi->_vf_size_xform + mmi->_vf_size_color;
|
||||
float *ptr = mmi->_data_curr.ptrw();
|
||||
ptr += start;
|
||||
|
||||
if (mmi->_vf_size_data == 4) {
|
||||
for (int n = 0; n < 4; n++) {
|
||||
ptr[n] = p_color.components[n];
|
||||
}
|
||||
} else {
|
||||
#ifdef DEV_ENABLED
|
||||
// The options are currently 4 or zero, but just in case this changes in future...
|
||||
ERR_FAIL_COND(mmi->_vf_size_data != 0);
|
||||
#endif
|
||||
}
|
||||
_multimesh_add_to_interpolation_lists(p_multimesh, *mmi);
|
||||
return;
|
||||
}
|
||||
|
||||
_multimesh_instance_set_custom_data(p_multimesh, p_index, p_color);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) {
|
||||
_multimesh_set_custom_aabb(p_multimesh, p_aabb);
|
||||
}
|
||||
|
||||
AABB RendererMeshStorage::multimesh_get_custom_aabb(RID p_multimesh) const {
|
||||
return _multimesh_get_custom_aabb(p_multimesh);
|
||||
}
|
||||
|
||||
RID RendererMeshStorage::multimesh_get_mesh(RID p_multimesh) const {
|
||||
return _multimesh_get_mesh(p_multimesh);
|
||||
}
|
||||
|
||||
Transform3D RendererMeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
|
||||
return _multimesh_instance_get_transform(p_multimesh, p_index);
|
||||
}
|
||||
|
||||
Transform2D RendererMeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
|
||||
return _multimesh_instance_get_transform_2d(p_multimesh, p_index);
|
||||
}
|
||||
|
||||
Color RendererMeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
|
||||
return _multimesh_instance_get_color(p_multimesh, p_index);
|
||||
}
|
||||
|
||||
Color RendererMeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
|
||||
return _multimesh_instance_get_custom_data(p_multimesh, p_index);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi && mmi->interpolated) {
|
||||
ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), vformat("Buffer should have %d elements, got %d instead.", mmi->_data_curr.size(), p_buffer.size()));
|
||||
|
||||
mmi->_data_curr = p_buffer;
|
||||
_multimesh_add_to_interpolation_lists(p_multimesh, *mmi);
|
||||
|
||||
#if defined(DEBUG_ENABLED) && defined(TOOLS_ENABLED)
|
||||
if (!Engine::get_singleton()->is_in_physics_frame()) {
|
||||
PHYSICS_INTERPOLATION_WARNING("MultiMesh interpolation is being triggered from outside physics process, this might lead to issues");
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_multimesh_set_buffer(p_multimesh, p_buffer);
|
||||
}
|
||||
|
||||
RID RendererMeshStorage::multimesh_get_command_buffer_rd_rid(RID p_multimesh) const {
|
||||
return _multimesh_get_command_buffer_rd_rid(p_multimesh);
|
||||
}
|
||||
|
||||
RID RendererMeshStorage::multimesh_get_buffer_rd_rid(RID p_multimesh) const {
|
||||
return _multimesh_get_buffer_rd_rid(p_multimesh);
|
||||
}
|
||||
|
||||
Vector<float> RendererMeshStorage::multimesh_get_buffer(RID p_multimesh) const {
|
||||
return _multimesh_get_buffer(p_multimesh);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_buffer_interpolated(RID p_multimesh, const Vector<float> &p_buffer, const Vector<float> &p_buffer_prev) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi) {
|
||||
ERR_FAIL_COND_MSG(p_buffer.size() != mmi->_data_curr.size(), vformat("Buffer for current frame should have %d elements, got %d instead.", mmi->_data_curr.size(), p_buffer.size()));
|
||||
ERR_FAIL_COND_MSG(p_buffer_prev.size() != mmi->_data_prev.size(), vformat("Buffer for previous frame should have %d elements, got %d instead.", mmi->_data_prev.size(), p_buffer_prev.size()));
|
||||
|
||||
// We are assuming that mmi->interpolated is the case. (Can possibly assert this?)
|
||||
// Even if this flag hasn't been set - just calling this function suggests interpolation is desired.
|
||||
mmi->_data_prev = p_buffer_prev;
|
||||
mmi->_data_curr = p_buffer;
|
||||
_multimesh_add_to_interpolation_lists(p_multimesh, *mmi);
|
||||
|
||||
#if defined(DEBUG_ENABLED) && defined(TOOLS_ENABLED)
|
||||
if (!Engine::get_singleton()->is_in_physics_frame()) {
|
||||
PHYSICS_INTERPOLATION_WARNING("MultiMesh interpolation is being triggered from outside physics process, this might lead to issues");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_physics_interpolated(RID p_multimesh, bool p_interpolated) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi) {
|
||||
mmi->interpolated = p_interpolated;
|
||||
}
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_physics_interpolation_quality(RID p_multimesh, RS::MultimeshPhysicsInterpolationQuality p_quality) {
|
||||
ERR_FAIL_COND((p_quality < 0) || (p_quality > 1));
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi) {
|
||||
mmi->quality = (int)p_quality;
|
||||
}
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_instance_reset_physics_interpolation(RID p_multimesh, int p_index) {
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(p_multimesh);
|
||||
if (mmi) {
|
||||
ERR_FAIL_INDEX(p_index, mmi->_num_instances);
|
||||
|
||||
float *w = mmi->_data_prev.ptrw();
|
||||
const float *r = mmi->_data_curr.ptr();
|
||||
int start = p_index * mmi->_stride;
|
||||
|
||||
for (int n = 0; n < mmi->_stride; n++) {
|
||||
w[start + n] = r[start + n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RendererMeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
|
||||
return _multimesh_set_visible_instances(p_multimesh, p_visible);
|
||||
}
|
||||
|
||||
int RendererMeshStorage::multimesh_get_visible_instances(RID p_multimesh) const {
|
||||
return _multimesh_get_visible_instances(p_multimesh);
|
||||
}
|
||||
|
||||
AABB RendererMeshStorage::multimesh_get_aabb(RID p_multimesh) {
|
||||
return _multimesh_get_aabb(p_multimesh);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::_multimesh_add_to_interpolation_lists(RID p_multimesh, MultiMeshInterpolator &r_mmi) {
|
||||
if (!r_mmi.on_interpolate_update_list) {
|
||||
r_mmi.on_interpolate_update_list = true;
|
||||
_interpolation_data.multimesh_interpolate_update_list.push_back(p_multimesh);
|
||||
}
|
||||
|
||||
if (!r_mmi.on_transform_update_list) {
|
||||
r_mmi.on_transform_update_list = true;
|
||||
_interpolation_data.multimesh_transform_update_list_curr->push_back(p_multimesh);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererMeshStorage::InterpolationData::notify_free_multimesh(RID p_rid) {
|
||||
// If the instance was on any of the lists, remove.
|
||||
multimesh_interpolate_update_list.erase_multiple_unordered(p_rid);
|
||||
multimesh_transform_update_lists[0].erase_multiple_unordered(p_rid);
|
||||
multimesh_transform_update_lists[1].erase_multiple_unordered(p_rid);
|
||||
}
|
||||
|
||||
void RendererMeshStorage::update_interpolation_tick(bool p_process) {
|
||||
// Detect any that were on the previous transform list that are no longer active,
|
||||
// we should remove them from the interpolate list.
|
||||
|
||||
for (unsigned int n = 0; n < _interpolation_data.multimesh_transform_update_list_prev->size(); n++) {
|
||||
const RID &rid = (*_interpolation_data.multimesh_transform_update_list_prev)[n];
|
||||
|
||||
bool active = true;
|
||||
|
||||
// No longer active? (Either the instance deleted or no longer being transformed.)
|
||||
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(rid);
|
||||
if (mmi && !mmi->on_transform_update_list) {
|
||||
active = false;
|
||||
mmi->on_interpolate_update_list = false;
|
||||
|
||||
// Make sure the most recent transform is set...
|
||||
mmi->_data_interpolated = mmi->_data_curr; // TODO: Copy data rather than use Packed = function?
|
||||
|
||||
// ... and that both prev and current are the same, just in case of any interpolations.
|
||||
mmi->_data_prev = mmi->_data_curr;
|
||||
}
|
||||
|
||||
if (!mmi) {
|
||||
active = false;
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
_interpolation_data.multimesh_interpolate_update_list.erase(rid);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_process) {
|
||||
for (unsigned int i = 0; i < _interpolation_data.multimesh_transform_update_list_curr->size(); i++) {
|
||||
const RID &rid = (*_interpolation_data.multimesh_transform_update_list_curr)[i];
|
||||
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(rid);
|
||||
if (mmi) {
|
||||
// Reset for next tick.
|
||||
mmi->on_transform_update_list = false;
|
||||
mmi->_data_prev = mmi->_data_curr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any have left the transform list, remove from the interpolate list.
|
||||
|
||||
// We maintain a mirror list for the transform updates, so we can detect when an instance
|
||||
// is no longer being transformed, and remove it from the interpolate list.
|
||||
SWAP(_interpolation_data.multimesh_transform_update_list_curr, _interpolation_data.multimesh_transform_update_list_prev);
|
||||
|
||||
// Prepare for the next iteration.
|
||||
_interpolation_data.multimesh_transform_update_list_curr->clear();
|
||||
}
|
||||
|
||||
void RendererMeshStorage::update_interpolation_frame(bool p_process) {
|
||||
if (p_process) {
|
||||
// Only need 32 bits for interpolation, don't use real_t.
|
||||
float f = Engine::get_singleton()->get_physics_interpolation_fraction();
|
||||
|
||||
for (unsigned int c = 0; c < _interpolation_data.multimesh_interpolate_update_list.size(); c++) {
|
||||
const RID &rid = _interpolation_data.multimesh_interpolate_update_list[c];
|
||||
|
||||
// We could use the TransformInterpolator here to slerp transforms, but that might be too expensive,
|
||||
// so just using a Basis lerp for now.
|
||||
MultiMeshInterpolator *mmi = _multimesh_get_interpolator(rid);
|
||||
if (mmi) {
|
||||
// Make sure arrays are the correct size.
|
||||
DEV_ASSERT(mmi->_data_prev.size() == mmi->_data_curr.size());
|
||||
|
||||
if (mmi->_data_interpolated.size() < mmi->_data_curr.size()) {
|
||||
mmi->_data_interpolated.resize(mmi->_data_curr.size());
|
||||
}
|
||||
DEV_ASSERT(mmi->_data_interpolated.size() >= mmi->_data_curr.size());
|
||||
|
||||
DEV_ASSERT((mmi->_data_curr.size() % mmi->_stride) == 0);
|
||||
int num = mmi->_data_curr.size() / mmi->_stride;
|
||||
|
||||
const float *pf_prev = mmi->_data_prev.ptr();
|
||||
const float *pf_curr = mmi->_data_curr.ptr();
|
||||
float *pf_int = mmi->_data_interpolated.ptrw();
|
||||
|
||||
bool use_lerp = mmi->quality == 0;
|
||||
|
||||
// Temporary transform (needed for swizzling).
|
||||
Transform3D tp, tc, tr; // (transform prev, curr and result)
|
||||
|
||||
// Test for cache friendliness versus doing branchless.
|
||||
for (int n = 0; n < num; n++) {
|
||||
// Transform.
|
||||
if (use_lerp) {
|
||||
for (int i = 0; i < mmi->_vf_size_xform; i++) {
|
||||
pf_int[i] = Math::lerp(pf_prev[i], pf_curr[i], f);
|
||||
}
|
||||
} else {
|
||||
// Silly swizzling, this will slow things down.
|
||||
// No idea why it is using this format...
|
||||
// ... maybe due to the shader.
|
||||
tp.basis.rows[0][0] = pf_prev[0];
|
||||
tp.basis.rows[0][1] = pf_prev[1];
|
||||
tp.basis.rows[0][2] = pf_prev[2];
|
||||
tp.basis.rows[1][0] = pf_prev[4];
|
||||
tp.basis.rows[1][1] = pf_prev[5];
|
||||
tp.basis.rows[1][2] = pf_prev[6];
|
||||
tp.basis.rows[2][0] = pf_prev[8];
|
||||
tp.basis.rows[2][1] = pf_prev[9];
|
||||
tp.basis.rows[2][2] = pf_prev[10];
|
||||
tp.origin.x = pf_prev[3];
|
||||
tp.origin.y = pf_prev[7];
|
||||
tp.origin.z = pf_prev[11];
|
||||
|
||||
tc.basis.rows[0][0] = pf_curr[0];
|
||||
tc.basis.rows[0][1] = pf_curr[1];
|
||||
tc.basis.rows[0][2] = pf_curr[2];
|
||||
tc.basis.rows[1][0] = pf_curr[4];
|
||||
tc.basis.rows[1][1] = pf_curr[5];
|
||||
tc.basis.rows[1][2] = pf_curr[6];
|
||||
tc.basis.rows[2][0] = pf_curr[8];
|
||||
tc.basis.rows[2][1] = pf_curr[9];
|
||||
tc.basis.rows[2][2] = pf_curr[10];
|
||||
tc.origin.x = pf_curr[3];
|
||||
tc.origin.y = pf_curr[7];
|
||||
tc.origin.z = pf_curr[11];
|
||||
|
||||
TransformInterpolator::interpolate_transform_3d(tp, tc, tr, f);
|
||||
|
||||
pf_int[0] = tr.basis.rows[0][0];
|
||||
pf_int[1] = tr.basis.rows[0][1];
|
||||
pf_int[2] = tr.basis.rows[0][2];
|
||||
pf_int[4] = tr.basis.rows[1][0];
|
||||
pf_int[5] = tr.basis.rows[1][1];
|
||||
pf_int[6] = tr.basis.rows[1][2];
|
||||
pf_int[8] = tr.basis.rows[2][0];
|
||||
pf_int[9] = tr.basis.rows[2][1];
|
||||
pf_int[10] = tr.basis.rows[2][2];
|
||||
pf_int[3] = tr.origin.x;
|
||||
pf_int[7] = tr.origin.y;
|
||||
pf_int[11] = tr.origin.z;
|
||||
}
|
||||
|
||||
pf_prev += mmi->_vf_size_xform;
|
||||
pf_curr += mmi->_vf_size_xform;
|
||||
pf_int += mmi->_vf_size_xform;
|
||||
|
||||
// Color.
|
||||
if (mmi->_vf_size_color == 4) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pf_int[i] = Math::lerp(pf_prev[i], pf_curr[i], f);
|
||||
}
|
||||
|
||||
pf_prev += 4;
|
||||
pf_curr += 4;
|
||||
pf_int += 4;
|
||||
}
|
||||
|
||||
// Custom data.
|
||||
if (mmi->_vf_size_data == 4) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pf_int[i] = Math::lerp(pf_prev[i], pf_curr[i], f);
|
||||
}
|
||||
|
||||
pf_prev += 4;
|
||||
pf_curr += 4;
|
||||
pf_int += 4;
|
||||
}
|
||||
}
|
||||
|
||||
_multimesh_set_buffer(rid, mmi->_data_interpolated);
|
||||
|
||||
// TODO: Make sure AABBs are constantly up to date through the interpolation?
|
||||
// NYI.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ public:
|
|||
|
||||
virtual void mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) = 0;
|
||||
|
||||
virtual void mesh_surface_remove(RID p_mesh, int p_surface) = 0;
|
||||
virtual void mesh_clear(RID p_mesh) = 0;
|
||||
|
||||
virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) = 0;
|
||||
|
|
@ -89,39 +90,114 @@ public:
|
|||
virtual void update_mesh_instances() = 0;
|
||||
|
||||
/* MULTIMESH API */
|
||||
struct MultiMeshInterpolator {
|
||||
RS::MultimeshTransformFormat _transform_format = RS::MULTIMESH_TRANSFORM_3D;
|
||||
bool _use_colors = false;
|
||||
bool _use_custom_data = false;
|
||||
|
||||
virtual RID multimesh_allocate() = 0;
|
||||
virtual void multimesh_initialize(RID p_rid) = 0;
|
||||
virtual void multimesh_free(RID p_rid) = 0;
|
||||
// The stride of the buffer in floats.
|
||||
int _stride = 0;
|
||||
|
||||
virtual void multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
|
||||
// Vertex format sizes in floats.
|
||||
int _vf_size_xform = 0;
|
||||
int _vf_size_color = 0;
|
||||
int _vf_size_data = 0;
|
||||
|
||||
virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
|
||||
// Set by allocate, can be used to prevent indexing out of range.
|
||||
int _num_instances = 0;
|
||||
|
||||
virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
|
||||
virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) = 0;
|
||||
virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
|
||||
virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
|
||||
virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) = 0;
|
||||
// Quality determines whether to use lerp or slerp etc.
|
||||
int quality = 0;
|
||||
bool interpolated = false;
|
||||
bool on_interpolate_update_list = false;
|
||||
bool on_transform_update_list = false;
|
||||
|
||||
virtual void multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) = 0;
|
||||
virtual AABB multimesh_get_custom_aabb(RID p_multimesh) const = 0;
|
||||
Vector<float> _data_prev;
|
||||
Vector<float> _data_curr;
|
||||
Vector<float> _data_interpolated;
|
||||
};
|
||||
|
||||
virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
|
||||
virtual RID multimesh_allocate();
|
||||
virtual void multimesh_initialize(RID p_rid);
|
||||
virtual void multimesh_free(RID p_rid);
|
||||
|
||||
virtual Transform3D multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
|
||||
virtual void multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false, bool p_use_indirect = false);
|
||||
|
||||
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
|
||||
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0;
|
||||
virtual int multimesh_get_instance_count(RID p_multimesh) const;
|
||||
|
||||
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
|
||||
virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
|
||||
virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
|
||||
virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform);
|
||||
virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform);
|
||||
virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color);
|
||||
virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color);
|
||||
|
||||
virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
|
||||
virtual void multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb);
|
||||
virtual AABB multimesh_get_custom_aabb(RID p_multimesh) const;
|
||||
|
||||
virtual RID multimesh_get_mesh(RID p_multimesh) const;
|
||||
|
||||
virtual Transform3D multimesh_instance_get_transform(RID p_multimesh, int p_index) const;
|
||||
virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const;
|
||||
virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const;
|
||||
virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const;
|
||||
|
||||
virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer);
|
||||
virtual RID multimesh_get_command_buffer_rd_rid(RID p_multimesh) const;
|
||||
virtual RID multimesh_get_buffer_rd_rid(RID p_multimesh) const;
|
||||
virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const;
|
||||
|
||||
virtual void multimesh_set_buffer_interpolated(RID p_multimesh, const Vector<float> &p_buffer, const Vector<float> &p_buffer_prev);
|
||||
virtual void multimesh_set_physics_interpolated(RID p_multimesh, bool p_interpolated);
|
||||
virtual void multimesh_set_physics_interpolation_quality(RID p_multimesh, RS::MultimeshPhysicsInterpolationQuality p_quality);
|
||||
virtual void multimesh_instance_reset_physics_interpolation(RID p_multimesh, int p_index);
|
||||
|
||||
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
|
||||
virtual int multimesh_get_visible_instances(RID p_multimesh) const;
|
||||
|
||||
virtual AABB multimesh_get_aabb(RID p_multimesh);
|
||||
|
||||
virtual RID _multimesh_allocate() = 0;
|
||||
virtual void _multimesh_initialize(RID p_rid) = 0;
|
||||
virtual void _multimesh_free(RID p_rid) = 0;
|
||||
|
||||
virtual void _multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false, bool p_use_indirect = false) = 0;
|
||||
|
||||
virtual int _multimesh_get_instance_count(RID p_multimesh) const = 0;
|
||||
|
||||
virtual void _multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
|
||||
virtual void _multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) = 0;
|
||||
virtual void _multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
|
||||
virtual void _multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
|
||||
virtual void _multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) = 0;
|
||||
|
||||
virtual void _multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) = 0;
|
||||
virtual AABB _multimesh_get_custom_aabb(RID p_multimesh) const = 0;
|
||||
|
||||
virtual RID _multimesh_get_mesh(RID p_multimesh) const = 0;
|
||||
|
||||
virtual Transform3D _multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Transform2D _multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Color _multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
|
||||
virtual Color _multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
|
||||
|
||||
virtual void _multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
|
||||
virtual RID _multimesh_get_command_buffer_rd_rid(RID p_multimesh) const = 0;
|
||||
virtual RID _multimesh_get_buffer_rd_rid(RID p_multimesh) const = 0;
|
||||
virtual Vector<float> _multimesh_get_buffer(RID p_multimesh) const = 0;
|
||||
|
||||
virtual void _multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
|
||||
virtual int _multimesh_get_visible_instances(RID p_multimesh) const = 0;
|
||||
|
||||
virtual AABB _multimesh_get_aabb(RID p_multimesh) = 0;
|
||||
|
||||
// Multimesh is responsible for allocating / destroying a MultiMeshInterpolator object.
|
||||
// This allows shared functionality for interpolation across backends.
|
||||
virtual MultiMeshInterpolator *_multimesh_get_interpolator(RID p_multimesh) const = 0;
|
||||
|
||||
private:
|
||||
void _multimesh_add_to_interpolation_lists(RID p_multimesh, MultiMeshInterpolator &r_mmi);
|
||||
|
||||
public:
|
||||
/* SKELETON API */
|
||||
|
||||
virtual RID skeleton_allocate() = 0;
|
||||
|
|
@ -137,6 +213,19 @@ public:
|
|||
virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0;
|
||||
|
||||
virtual void skeleton_update_dependency(RID p_base, DependencyTracker *p_instance) = 0;
|
||||
|
||||
/* INTERPOLATION */
|
||||
|
||||
struct InterpolationData {
|
||||
void notify_free_multimesh(RID p_rid);
|
||||
LocalVector<RID> multimesh_interpolate_update_list;
|
||||
LocalVector<RID> multimesh_transform_update_lists[2];
|
||||
LocalVector<RID> *multimesh_transform_update_list_curr = &multimesh_transform_update_lists[0];
|
||||
LocalVector<RID> *multimesh_transform_update_list_prev = &multimesh_transform_update_lists[1];
|
||||
} _interpolation_data;
|
||||
|
||||
void update_interpolation_tick(bool p_process = true);
|
||||
void update_interpolation_frame(bool p_process = true);
|
||||
};
|
||||
|
||||
#endif // MESH_STORAGE_H
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public:
|
|||
virtual void particles_set_lifetime(RID p_particles, double p_lifetime) = 0;
|
||||
virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0;
|
||||
virtual void particles_set_pre_process_time(RID p_particles, double p_time) = 0;
|
||||
virtual void particles_request_process_time(RID p_particles, real_t p_request_process_time) = 0;
|
||||
virtual void particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) = 0;
|
||||
virtual void particles_set_randomness_ratio(RID p_particles, real_t p_ratio) = 0;
|
||||
virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
|
||||
|
|
@ -67,6 +68,8 @@ public:
|
|||
|
||||
virtual void particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) = 0;
|
||||
|
||||
virtual void particles_set_seed(RID p_particles, uint32_t p_seed) = 0;
|
||||
|
||||
virtual void particles_set_trails(RID p_particles, bool p_enable, double p_length) = 0;
|
||||
virtual void particles_set_trail_bind_poses(RID p_particles, const Vector<Transform3D> &p_bind_poses) = 0;
|
||||
|
||||
|
|
@ -117,6 +120,8 @@ public:
|
|||
virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) = 0; //for SDF and vector field
|
||||
virtual AABB particles_collision_get_aabb(RID p_particles_collision) const = 0;
|
||||
virtual bool particles_collision_is_heightfield(RID p_particles_collision) const = 0;
|
||||
virtual uint32_t particles_collision_get_height_field_mask(RID p_particles_collision) const = 0;
|
||||
virtual void particles_collision_set_height_field_mask(RID p_particles_collision, uint32_t p_heightfield_mask) = 0;
|
||||
|
||||
//used from 2D and 3D
|
||||
virtual RID particles_collision_instance_create(RID p_collision) = 0;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void RenderSceneBuffersConfiguration::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("get_scaling_3d_mode"), &RenderSceneBuffersConfiguration::get_scaling_3d_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_scaling_3d_mode", "scaling_3d_mode"), &RenderSceneBuffersConfiguration::set_scaling_3d_mode);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast),FSR 2.2 (Slow)"), "set_scaling_3d_mode", "get_scaling_3d_mode"); // TODO VIEWPORT_SCALING_3D_MODE_OFF is possible here too, but we can't specify an enum string for it.
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast),FSR 2.2 (Slow),MetalFX (Spatial),MetalFX (Temporal)"), "set_scaling_3d_mode", "get_scaling_3d_mode"); // TODO VIEWPORT_SCALING_3D_MODE_OFF is possible here too, but we can't specify an enum string for it.
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_msaa_3d"), &RenderSceneBuffersConfiguration::get_msaa_3d);
|
||||
ClassDB::bind_method(D_METHOD("set_msaa_3d", "msaa_3d"), &RenderSceneBuffersConfiguration::set_msaa_3d);
|
||||
|
|
@ -66,6 +66,10 @@ void RenderSceneBuffersConfiguration::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_texture_mipmap_bias"), &RenderSceneBuffersConfiguration::get_texture_mipmap_bias);
|
||||
ClassDB::bind_method(D_METHOD("set_texture_mipmap_bias", "texture_mipmap_bias"), &RenderSceneBuffersConfiguration::set_texture_mipmap_bias);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "texture_mipmap_bias"), "set_texture_mipmap_bias", "get_texture_mipmap_bias");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_anisotropic_filtering_level"), &RenderSceneBuffersConfiguration::get_anisotropic_filtering_level);
|
||||
ClassDB::bind_method(D_METHOD("set_anisotropic_filtering_level", "anisotropic_filtering_level"), &RenderSceneBuffersConfiguration::set_anisotropic_filtering_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "anisotropic_filtering_level"), "set_anisotropic_filtering_level", "get_anisotropic_filtering_level");
|
||||
}
|
||||
|
||||
void RenderSceneBuffers::_bind_methods() {
|
||||
|
|
@ -76,12 +80,13 @@ void RenderSceneBuffersExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_configure, "config");
|
||||
GDVIRTUAL_BIND(_set_fsr_sharpness, "fsr_sharpness");
|
||||
GDVIRTUAL_BIND(_set_texture_mipmap_bias, "texture_mipmap_bias");
|
||||
GDVIRTUAL_BIND(_set_anisotropic_filtering_level, "anisotropic_filtering_level");
|
||||
GDVIRTUAL_BIND(_set_use_debanding, "use_debanding");
|
||||
}
|
||||
|
||||
void RenderSceneBuffersExtension::configure(const RenderSceneBuffersConfiguration *p_config) {
|
||||
GDVIRTUAL_CALL(_configure, p_config);
|
||||
};
|
||||
}
|
||||
|
||||
void RenderSceneBuffersExtension::set_fsr_sharpness(float p_fsr_sharpness) {
|
||||
GDVIRTUAL_CALL(_set_fsr_sharpness, p_fsr_sharpness);
|
||||
|
|
@ -91,6 +96,10 @@ void RenderSceneBuffersExtension::set_texture_mipmap_bias(float p_texture_mipmap
|
|||
GDVIRTUAL_CALL(_set_texture_mipmap_bias, p_texture_mipmap_bias);
|
||||
}
|
||||
|
||||
void RenderSceneBuffersExtension::set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) {
|
||||
GDVIRTUAL_CALL(_set_anisotropic_filtering_level, p_anisotropic_filtering_level);
|
||||
}
|
||||
|
||||
void RenderSceneBuffersExtension::set_use_debanding(bool p_use_debanding) {
|
||||
GDVIRTUAL_CALL(_set_use_debanding, p_use_debanding);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ private:
|
|||
RS::ViewportScaling3DMode scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_OFF;
|
||||
RS::ViewportMSAA msaa_3d = RS::VIEWPORT_MSAA_DISABLED;
|
||||
RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED;
|
||||
RS::ViewportAnisotropicFiltering anisotropic_filtering_level = RS::VIEWPORT_ANISOTROPY_4X;
|
||||
|
||||
float fsr_sharpness = 0.0;
|
||||
float texture_mipmap_bias = 0.0;
|
||||
|
|
@ -84,6 +85,9 @@ public:
|
|||
float get_texture_mipmap_bias() const { return texture_mipmap_bias; }
|
||||
void set_texture_mipmap_bias(float p_texture_mipmap_bias) { texture_mipmap_bias = p_texture_mipmap_bias; }
|
||||
|
||||
RS::ViewportAnisotropicFiltering get_anisotropic_filtering_level() const { return anisotropic_filtering_level; }
|
||||
void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) { anisotropic_filtering_level = p_anisotropic_filtering_level; }
|
||||
|
||||
bool get_use_taa() const { return use_taa; }
|
||||
void set_use_taa(bool p_use_taa) { use_taa = p_use_taa; }
|
||||
|
||||
|
|
@ -91,7 +95,7 @@ public:
|
|||
void set_use_debanding(bool p_use_debanding) { use_debanding = p_use_debanding; }
|
||||
|
||||
RenderSceneBuffersConfiguration() {}
|
||||
virtual ~RenderSceneBuffersConfiguration(){};
|
||||
virtual ~RenderSceneBuffersConfiguration() {}
|
||||
};
|
||||
|
||||
class RenderSceneBuffers : public RefCounted {
|
||||
|
|
@ -101,14 +105,15 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
RenderSceneBuffers(){};
|
||||
virtual ~RenderSceneBuffers(){};
|
||||
RenderSceneBuffers() {}
|
||||
virtual ~RenderSceneBuffers() {}
|
||||
|
||||
virtual void configure(const RenderSceneBuffersConfiguration *p_config) = 0;
|
||||
|
||||
// for those settings that are unlikely to require buffers to be recreated, we'll add setters
|
||||
virtual void set_fsr_sharpness(float p_fsr_sharpness) = 0;
|
||||
virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) = 0;
|
||||
virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) = 0;
|
||||
virtual void set_use_debanding(bool p_use_debanding) = 0;
|
||||
};
|
||||
|
||||
|
|
@ -121,15 +126,17 @@ protected:
|
|||
GDVIRTUAL1(_configure, const RenderSceneBuffersConfiguration *)
|
||||
GDVIRTUAL1(_set_fsr_sharpness, float)
|
||||
GDVIRTUAL1(_set_texture_mipmap_bias, float)
|
||||
GDVIRTUAL1(_set_anisotropic_filtering_level, int)
|
||||
GDVIRTUAL1(_set_use_debanding, bool)
|
||||
|
||||
public:
|
||||
virtual ~RenderSceneBuffersExtension(){};
|
||||
virtual ~RenderSceneBuffersExtension() {}
|
||||
|
||||
virtual void configure(const RenderSceneBuffersConfiguration *p_config) override;
|
||||
|
||||
virtual void set_fsr_sharpness(float p_fsr_sharpness) override;
|
||||
virtual void set_texture_mipmap_bias(float p_texture_mipmap_bias) override;
|
||||
virtual void set_anisotropic_filtering_level(RS::ViewportAnisotropicFiltering p_anisotropic_filtering_level) override;
|
||||
virtual void set_use_debanding(bool p_use_debanding) override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,9 +59,8 @@ public:
|
|||
virtual void canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) = 0;
|
||||
|
||||
/* Texture API */
|
||||
virtual bool can_create_resources_async() const = 0;
|
||||
|
||||
virtual ~RendererTextureStorage(){};
|
||||
virtual ~RendererTextureStorage() {}
|
||||
|
||||
virtual RID texture_allocate() = 0;
|
||||
virtual void texture_free(RID p_rid) = 0;
|
||||
|
|
@ -69,10 +68,14 @@ public:
|
|||
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) = 0;
|
||||
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0;
|
||||
virtual void texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) = 0;
|
||||
virtual void texture_external_initialize(RID p_texture, int p_width, int p_height, uint64_t p_external_buffer) = 0;
|
||||
virtual void texture_proxy_initialize(RID p_texture, RID p_base) = 0; //all slices, then all the mipmaps, must be coherent
|
||||
|
||||
virtual RID texture_create_from_native_handle(RS::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers = 1, RS::TextureLayeredType p_layered_type = RS::TEXTURE_LAYERED_2D_ARRAY) = 0;
|
||||
|
||||
virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0;
|
||||
virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) = 0;
|
||||
virtual void texture_external_update(RID p_proxy, int p_width, int p_height, uint64_t p_external_buffer) = 0;
|
||||
virtual void texture_proxy_update(RID p_proxy, RID p_base) = 0;
|
||||
|
||||
//these two APIs can be used together or in combination with the others.
|
||||
|
|
@ -175,13 +178,21 @@ public:
|
|||
virtual RID render_target_get_vrs_texture(RID p_render_target) const = 0;
|
||||
|
||||
// override color, depth and velocity buffers (depth and velocity only for 3D)
|
||||
virtual void render_target_set_override(RID p_render_target, RID p_color_texture, RID p_depth_texture, RID p_velocity_texture) = 0;
|
||||
virtual void render_target_set_override(RID p_render_target, RID p_color_texture, RID p_depth_texture, RID p_velocity_texture, RID p_velocity_depth_texture) = 0;
|
||||
virtual RID render_target_get_override_color(RID p_render_target) const = 0;
|
||||
virtual RID render_target_get_override_depth(RID p_render_target) const = 0;
|
||||
virtual RID render_target_get_override_velocity(RID p_render_target) const = 0;
|
||||
virtual RID render_target_get_override_velocity_depth(RID p_render_target) const = 0;
|
||||
|
||||
virtual void render_target_set_render_region(RID p_render_target, const Rect2i &p_render_region) = 0;
|
||||
virtual Rect2i render_target_get_render_region(RID p_render_target) const = 0;
|
||||
|
||||
// get textures
|
||||
virtual RID render_target_get_texture(RID p_render_target) = 0;
|
||||
|
||||
// Motion vectors
|
||||
virtual void render_target_set_velocity_target_size(RID p_render_target, const Size2i &p_target_size) = 0;
|
||||
virtual Size2i render_target_get_velocity_target_size(RID p_render_target) const = 0;
|
||||
};
|
||||
|
||||
#endif // TEXTURE_STORAGE_H
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ public:
|
|||
virtual String get_video_adapter_api_version() const = 0;
|
||||
|
||||
virtual Size2i get_maximum_viewport_size() const = 0;
|
||||
virtual uint32_t get_maximum_shader_varyings() const = 0;
|
||||
virtual uint64_t get_maximum_uniform_buffer_size() const = 0;
|
||||
};
|
||||
|
||||
#endif // RENDERER_UTILITIES_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue