-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Implement 2D instance shader parameters #87966
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Álex Román Núñez <eirexe123@gmail.com>
be52e66
to
5573d75
Compare
Okay, I just realised I didn't actually get it to work, I think a redesign of canvas.glsl is needed because there's no space in the push constant to fit an instance ID, if it's fine i'll take a look at making it work like scene.glsl does. |
I dont know much about rendering, but you are talking about this #80458, right? |
Yes, exactly, lol, i'll just wait for that to get merged then |
This is a great first step towards adding support for instance shader parameters. The missing piece is mapping the instance id to the global array. Here is what that looks like in the Forward+ renderer: godot/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp Line 728 in a9bb850
As you pointed out, there isn't room for that extra parameter in the current approach because push constants have such a limited size. That being said #80458 isn't really a full solution either as we will run into cache alignment issues if we start using a SSBO but then use 132 bytes for each instance |
What about moving something less important from the push constant to the instance buffers? godot/servers/rendering/renderer_rd/renderer_canvas_render_rd.h Lines 379 to 383 in 7c38376
That feels like something that should be part of shaders that have specular enabled, creating a shininess per-instance variable. (and can't imagine many people are using specular on their canvases in the first place...) But I don't have much of a grasp on how this part of the engine works, just wondering! |
Hello, any news about that ? Instance uniforms are a must for anyone making a vampire survivor's like game. |
Rebased from @KoBeWi 's PR #77594
I also fixed it, so it actually works, although I am not entirely sure the code I wrote is fine, if someone from rendering could comb over it I'd be thankful.
Original PR text:
Closes #62943
I wrote this a while ago and decided to rebase and test it again now. This seems to work the same as in 3D (no wonder, since it's a 1:1 copy-paste), i.e. the parameters appear in the inspector, they have correct default value etc.
The only problem is that changing the parameter has no effect. It always uses the default for the given type (not even the defined default). But it's probably the only missing bit, so if anyone can help, the feature would be finished.