godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 68 forks source link

Allow using dynamic uniform arrays in GLSL #9301

Open jxo opened 3 months ago

jxo commented 3 months ago

Describe the project you are working on

Shader will use like this.

layout(set = 0, binding =5) uniform sampler2D texturesMap[];

the textureMap size will be a variable.

Describe the problem or limitation you are having in your project

Godot will get set bindings from byte code,will get size 0, it will set descriptorCount to 0, in uniform_set_create will complain the size is not correct.

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

Maybe reset the descriptorCount in uniform_set_create

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

I'm not sure how to do that now.

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

May be useful for some purpose.

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

Should in core. Relate to vulkan device

Calinou commented 3 months ago

As I understand it, this proposal is about using GLSL directly in Godot, not the Godot shader language. Is that correct?

clayjohn commented 2 months ago

For context, the reason we don't support this currently is that Godot shaders have to run when using OpenGL/WebGL as well which doesn't support this feature.

Ideally, to support texture arrays in shaders we would modify the syntax slightly to make it work with our internal shader templates and work in all rendering backends.

If we want to support texture arrays in GDShaders, then we need to figure out a way that it can work with all backends.

Ultimately, I think the best way to support this feature is through shader templates: https://github.com/godotengine/godot-proposals/issues/8366