mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Fix spatial shader conversion with texture
This commit is contained in:
parent
f52ab8d864
commit
3bd2a4c421
@ -449,8 +449,16 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re
|
||||
VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
|
||||
Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
|
||||
smat->set_shader_param(E->get().name, value);
|
||||
|
||||
// Texture parameter has to be treated specially since SpatialMaterial saved it
|
||||
// as RID but ShaderMaterial needs Texture itself
|
||||
Ref<Texture> texture = mat->get_texture_by_name(E->get().name);
|
||||
if (texture.is_valid()) {
|
||||
smat->set_shader_param(E->get().name, texture);
|
||||
} else {
|
||||
Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
|
||||
smat->set_shader_param(E->get().name, value);
|
||||
}
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user