From 3237e05c3608fc900cb30519ffd3b15ddb064c9f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 22 Sep 2017 09:20:28 -0300 Subject: Ability to convert from SpatialMaterial to ShaderMaterial --- scene/resources/material.cpp | 6 ++++++ scene/resources/material.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'scene/resources') diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 553e9b9905..ae858e862c 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1611,6 +1611,12 @@ float SpatialMaterial::get_distance_fade_min_distance() const { return distance_fade_min_distance; } +RID SpatialMaterial::get_shader_rid() const { + + ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); + return shader_map[current_key].shader; +} + void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); diff --git a/scene/resources/material.h b/scene/resources/material.h index 0c33891897..721514f586 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -579,6 +579,8 @@ public: static RID get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass); + RID get_shader_rid() const; + SpatialMaterial(); virtual ~SpatialMaterial(); }; -- cgit v1.2.3