diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-10-20 23:55:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 23:55:58 +0200 |
commit | 8cb76888aefbbf2891440a5e485219a60886ac3a (patch) | |
tree | 163098640e1ca26f38182779192e9e6f31f460eb /scene | |
parent | 7969565de731a67e77a3a475de75088d87b36e4f (diff) | |
parent | 3bd2a4c42169eb141a71fb30e4786d4339e3789a (diff) |
Merge pull request #12228 from hi-ogawa/fix-spatial-shader-conversion-with-texture
Fix spatial shader conversion with texture
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/material.cpp | 9 | ||||
-rw-r--r-- | scene/resources/material.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 2936df7a51..898a594498 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1242,6 +1242,15 @@ Ref<Texture> SpatialMaterial::get_texture(TextureParam p_param) const { return textures[p_param]; } +Ref<Texture> SpatialMaterial::get_texture_by_name(StringName p_name) const { + for (int i = 0; i < (int)SpatialMaterial::TEXTURE_MAX; i++) { + TextureParam param = TextureParam(i); + if (p_name == shader_names->texture_names[param]) + return textures[param]; + } + return Ref<Texture>(); +} + void SpatialMaterial::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) { property.usage = 0; diff --git a/scene/resources/material.h b/scene/resources/material.h index c0e007ac5f..2425f1a174 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -510,6 +510,8 @@ public: void set_texture(TextureParam p_param, const Ref<Texture> &p_texture); Ref<Texture> get_texture(TextureParam p_param) const; + // Used only for shader material conversion + Ref<Texture> get_texture_by_name(StringName p_name) const; void set_feature(Feature p_feature, bool p_enabled); bool get_feature(Feature p_feature) const; |