Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create a new material by dragging a shader on user-exported properties if they're not *specifically* ShaderMaterials #81722

Closed
mieldepoche opened this issue Sep 16, 2023 · 1 comment · Fixed by #82093

Comments

@mieldepoche
Copy link
Contributor

Godot version

4.1.1

System information

linux

Issue description

simplescreenrecorder-2023-09-16_07.31.44.webm

as you can see, I can't automatically create a new ShaderMaterial by dropping a shader on a material slot when the material slot is one I exported from a script, unless I set the export type to ShaderMaterial specifically (not showcased in video).

Steps to reproduce

@export var wont_work: Material
@export var will_work: ShaderMaterial

and then drop a Shader resource on both of those in the inspector.

Minimal reproduction project

the script above and an empty .gdshader file

@mieldepoche mieldepoche changed the title can't create a new material by dragging a shader on user-exported properties if they're not *specifically* ShaderMaterials Can't create a new material by dragging a shader on user-exported properties if they're not *specifically* ShaderMaterials Sep 16, 2023
@jsjtxietian
Copy link
Contributor

jsjtxietian commented Sep 20, 2023

Is this expected or a bug?

The export property's base_type in editor_resource_picker is Material for won't work and ShaderMaterial for will work, but the
GeometryInstance3D's material field's base_type is BaseMaterial3D,ShaderMaterial.

And in _get_allowed_types , for a ShaderMaterial, it will insert a Shader to allowed_types, but for Material it won't do so. That's why we can't drag a shader directly to the exported material property.

if (p_with_convert) {
if (base == "BaseMaterial3D") {
p_vector->insert("Texture2D");
} else if (base == "ShaderMaterial") {
p_vector->insert("Shader");
} else if (base == "Texture2D") {
p_vector->insert("Image");
}
}

For a quick fix, we can insert a Shader to allowed_types for Material too. But it might have some unexpected behaviour. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants