godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

Expose StandardMaterial3D conversion to ShaderMaterial to scripting #9781

Open Souchy opened 3 months ago

Souchy commented 3 months ago

Describe the project you are working on

Use case:

Describe the problem or limitation you are having in your project

Currently there is no way to convert a StandardMaterial3D to ShaderMaterial, or to get its shader.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add public conversion functions to each type of Material. Add public functions to get the shader and textures from Materials so we can do our own conversion logic.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I'm not sure, adding those bindings to BaseMaterial3D::_bind_methods didn't do anything for me.

ClassDB::bind_method(D_METHOD("get_shader_rid"), &BaseMaterial3D::get_shader_rid);
ClassDB::bind_method(D_METHOD("get_texture_by_name"), &BaseMaterial3D::get_texture_by_name);

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not as far as I know

Is there a reason why this should be core and not an add-on in the asset library?

^

sivercone commented 1 month ago

I second this issue—I'm dealing with a similar problem. I use a custom shader on top of a StandardMaterial3D that's been converted to ShaderMaterial. Every time I reimport a model, I have to manually go through the process of converting and reapplying the custom shader. Imagine doing this for a large number of models; it's quite time-consuming. It would be incredibly helpful if there were a way to automate this conversion through code. This feature would not only save a lot of time but also streamline the workflow significantly.

albertok commented 1 month ago

I have the same use cases.

Would it be more user friendly if StandardMaterial and ORMMaterial had a feature to extend shader code?

Was looking at a way to automate it with a tool script but it seems there isnt a clear way of automating a conversion to Shader Material.