-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Document global and per-instance uniforms in Shading language #6414
Document global and per-instance uniforms in Shading language #6414
Conversation
cc @clayjohn :) Looks good to me and spotted nothing on a first glance, will give it a more thorough read later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I left a few comments and suggestions
I'm copying the team color bit below as it was removed from the docs (but it wasn't part of the original blog post). Still, it may be useful for others in the future.
@clayjohn Do you know the answer to the questions in OP? This would help flesh out the documentation 🙂 |
1e02b90
to
0e369eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does using GeometryInstance3D.get_instance_shader_parameter() have a performance cost like getting global uniform values through a script? I don't get any warning when using it, but I also can't seem to get any value from it anyway.
Not really, it is just reading from a hashmap
What's the difference between RenderingServer's global_shader_parameter_set() and global_shader_parameter_set_override()? I'm not sure what use cases each method has in practice. The former fails with an error if the uniform doesn't exist, while the latter fails silently. Only the latter fails early if the uniform's type extends Object.
- Each uniform variable stores the value and override separately: https://github.com/godotengine/godot/blob/e3a51e53ef055a1fe94351b68173c6dfcd2cb371/servers/rendering/renderer_rd/storage_rd/material_storage.h#L123-L124
Its for use by the ShaderGlobalOverrides
node
Is a default value assigned to a global uniform ever used? Shader compilation fails if the global uniform isn't defined in the project settings.
I don't think so. Imagine if you had multiple shaders that each used a different default value, which one should be picked?
0e369eb
to
5d61587
Compare
See #5121. This takes some parts from https://godotengine.org/article/godot-40-gets-global-and-instance-shader-uniforms (thanks reduz 🙂).
Some questions I have to further complete this documentation:
GeometryInstance3D.get_instance_shader_parameter()
have a performance cost like getting global uniform values through a script? I don't get any warning when using it, but I also can't seem to get any value from it anyway.global_shader_parameter_set()
andglobal_shader_parameter_set_override()
? I'm not sure what use cases each method has in practice. The former fails with an error if the uniform doesn't exist, while the latter fails silently. Only the latter fails early if the uniform's type extends Object.