summaryrefslogtreecommitdiffstats
path: root/scene/resources/material.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-06-29 22:55:11 -0300
committerreduz <reduzio@gmail.com>2021-06-30 14:14:41 -0300
commit85cf99f28e93556f1298a5136254253f9da82b9a (patch)
treed38bc6dde1d41417149a8b37111abcba1e6dc4af /scene/resources/material.cpp
parentbcd1fc832fff5c1cc1efa4d2450b9e2919b972c9 (diff)
downloadredot-engine-85cf99f28e93556f1298a5136254253f9da82b9a.tar.gz
Deprecate ImmediateGeometry
* Removed entirely from RenderingServer. * Replaced by ImmediateMesh resource. * ImmediateMesh replaces ImmediateGeometry, but could use more optimization in the future. * Sprite3D and AnimatedSprite3D work again, ported from Godot 3.x (though a lot of work was needed to adapt them to Godot 4). * RootMotionView works again. * Polygon3D editor works again.
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r--scene/resources/material.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index cb66d5724d..d391540a0b 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -2077,7 +2077,7 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel()
return refraction_texture_channel;
}
-RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y) {
+Ref<Material> BaseMaterial3D::get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y, RID *r_shader_rid) {
int version = 0;
if (p_shaded) {
version = 1;
@@ -2102,7 +2102,10 @@ RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, b
}
if (materials_for_2d[version].is_valid()) {
- return materials_for_2d[version]->get_rid();
+ if (r_shader_rid) {
+ *r_shader_rid = materials_for_2d[version]->get_shader_rid();
+ }
+ return materials_for_2d[version];
}
Ref<StandardMaterial3D> material;
@@ -2120,7 +2123,11 @@ RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, b
materials_for_2d[version] = material;
- return materials_for_2d[version]->get_rid();
+ if (r_shader_rid) {
+ *r_shader_rid = materials_for_2d[version]->get_shader_rid();
+ }
+
+ return materials_for_2d[version];
}
void BaseMaterial3D::set_on_top_of_alpha() {
@@ -2189,6 +2196,8 @@ BaseMaterial3D::EmissionOperator BaseMaterial3D::get_emission_operator() const {
}
RID BaseMaterial3D::get_shader_rid() const {
+ MutexLock lock(material_mutex);
+ ((BaseMaterial3D *)this)->_update_shader();
ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
return shader_map[current_key].shader;
}