-
-
Notifications
You must be signed in to change notification settings - Fork 20.9k
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
Visual shader editor node preview shader compilation fails with instance uniforms #72617
Comments
There is a function that decides whether previews are allowed to be shown. It should be able to detect if an instant uniform is used and then just not allow the preview to be shown. |
Or, in the spirit of my renderer feature support flags proposal it could disable them if instance uniforms are not supported for canvas_item shaders in the current renderer, and define that in the renderer. So that if instance uniforms are supported for canvas_item shaders in the future this functionality will adapt automatically. |
I don't think we should use macros for something like this. At most we should convert the instance uniform into a regular uniform |
Looking into this a little, its going to require a decent amount of work. Right now we have a function to check if a given node will show the preview icon; The trouble is, this check isn't recursive. So If I have something like an instance uniform, or a depth texture node, the next node will still show the preview port, even though it shouldn't. @Chaosus Should we make |
I guess we should focus our forces to implement the canvas item instances instead. |
Well, the problem still presents itself for other things like varyings and depth_texture. |
Ah, then yes, recursive check should be added like I already did for recursive connections (#35362). |
I think I could fix it. |
After thinking some more about this, isn't it the case that within the context of the shader editor previews all uniforms can actually be considered basic shader uniforms (or even constants?) with the uniform default value (or 0 I guess if it doesn't have one)? I'm not sure about varyings but I guess depth_textures could also be just be given a default value in the previews. This would require some substitutions in the shader code generated for the previews, but would have the benefit of being able to show previews, work on all renderers and allows the user to see changes to the previews by changing these default values. While hiding the previews might be correct if these can't be generated now, it's also quite confusing and bad from a usability point of view. And if that's also a lot of work to achieve cascading correctly I wonder if it's worth the effort? |
Godot version
4.0b17
System information
macOS 13.2
Issue description
If you make a visual spatial shader and that uses an instance uniform and you have some nodes with previews (the little graphic view) for example like this:
You will get a strange error in the output whenever you load the shader like this:
After a lot of experimenting the reason for this seems to be that the visual shader editor is actually also generating canvas_item shaders to render the little node previews (an elegant solution!). And for this shader code it's using the uniforms the nodes are connected to. However, this doesn't seem to account for the fact that we now have instance uniforms that are supported in spatial visual shaders, but not in canvas_item shaders. So it's failing to compile the shaders for the previews and outputs this error in the process. The failures have probably been happening since instance uniforms were added, but the error reporting has been added more recently so I started seeing these in one of the later beta versions.
This doesn't seem to affect the generated shader performance, but it's outputting some confusing errors (took me a good while to figure out) and the previews for the nodes just show all white so you could say it affects the usability of the shader editor.
Steps to reproduce
Minimal reproduction project
The shader from the example: VisualShaderInstanceUniform.zip
The text was updated successfully, but these errors were encountered: