-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Support uniform arrays in the shader language #931
Comments
Any news on that? Some of the most performant terminal emulators use uniform arrays to pass info into shaders that draw the terminal. (Link to an example to come when I find one that's not webgl) |
@Zireael07 Not sure what kind of news you want. It has been a popular feature request for a few years. But it will take a lot of work to add. Once someone does the work, it will get added. |
It's trivial for me to implement it on the shader part, but it needs to be properly handled by the editor which is hard and some types are not simply supported as Arrays + currently (in 4.0) uniforms have bugs like: godotengine/godot#45213 |
@Chaosus is it possible to implement it without editor support? For now it would be okay if you could only set array uniforms through code. |
Well, I could try. |
Will there be support for sampler2d and sampler2dArray arrays in the future? The idea is simple - I want to load several textures into the shader and select one of them during its operation (using an additional UV). This will reduce the number of materials and drawcalls. |
@Lexpartizan sampler2d arrays are working in mine PR, also I've tested an array of |
@Chaosus Wow! Big Thanks! |
Is it possible to use a uniform array without a predetermined size? |
You can't - it's not supported in GLSL either (at least for vertex/fragment shaders). |
@Chaosus do you know any viable alternative? What I am trying to achieve is to send array of Vec3 coordinates to the shader. Maybe with SSBO, if Godot supports that |
Large amount of vec3 coordinates may send in a form of texture, or just use the buffer with the largest of size to be expected. |
Original issue: godotengine/godot#10751. Originally from 2017 and was last flagged as a 4.0 release milestone.
Describe the project you are working on:
Color LUT shader. Examples: Palette shifting shaders, LUT adjustments for monitor profiles, etc.
Describe the problem or limitation you are having in your project:
Currently, LUTs for interacting between shaders and the rest of Godot require converting them to a texture so they can be passed to a uniform Sampler2D. This adds extra processing overhead, is inconvenient, and makes shaders less portable without an associated tool node to assist the process.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Uniform arrays reduce the overhead and glue necessary to make the above shader types work.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
This would produce the standard "array (size 0)" context in the inspector, with a subcontext dropdown containing array (size 2) of color rows for each element.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Sometimes. Workarounds depend on whether the data can fit into a supported uniform type such as Vec4, mat4 or similar. A more generalized workaround involves glue code in a tool script which can generate an ImageTexture suitable to be bussed and decoded from a uniform Sampler2D within a given shader.
Is there a reason why this should be core and not an add-on in the asset library?:
The shading language cannot be user-extended.
The text was updated successfully, but these errors were encountered: