-
-
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 #97058
base: master
Are you sure you want to change the base?
Conversation
Parameter list doesn't work properly. It's not updated right when modifying shaders and some operations may replace it with nulls: godot.windows.editor.dev.x86_64_PfbFzWf1sD.mp4Other than that they look functional, which is nice. |
Fixed the instances not being freed. I spent 3 hours trying to figure out why the parameter list is broken and found no solution. Essentially the MaterialStorage fails to update correctly when the shader is changed. The uniforms default values for instance variables are initialized to nil. A workaround is to reload the scene/project. So the parameter list failing to refresh seems to be an unrelated issue. |
cb7e597
to
49b0ac9
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.
Tested locally (rebased on top of master
99a7a9c), it works as expected in Forward+ and Mobile.
When running in Compatibility, you get a shader compilation error like in 3D (as expected):
SHADER ERROR: Uniform instances are not supported in gl_compatibility shaders.
Testing project: test_pr_97058.zip
PS: What is this checkbox for? It's present for both 3D and 3D per-instance uniforms. I can't uncheck it (nothing happens when I click it), regardless of whether the value is modified from its default or not.
Don't know, I think it was like that in 4.2 as well. |
To update property list, you need to use godot/scene/3d/visual_instance_3d.cpp Lines 244 to 246 in 02b16d2
However modifying shader does not add the CanvasItem to _instance_update_list , I think it also has to be done manually.The parameters no longer become null, so the list not updating is only an inconvenience now. Also if you want the instance parameters to have revert button, you need to implement |
9e9820d
to
88316b9
Compare
88316b9
to
8687e49
Compare
Redid everything from the ground up, refactored all the common code into a class. Everything should work identically to the 3D instances now. |
8687e49
to
cb70b7b
Compare
@@ -52,6 +52,8 @@ struct InstanceData { | |||
#endif | |||
vec2 color_texture_pixel_size; | |||
uint lights[4]; | |||
uint instance_uniforms_ofs; |
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.
I haven't taken a look at the whole thing, but just a reminder that this needs to be removed before this PR is finished. We need to avoid bloating the instance struct at all costs
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.
Once #97340 is merged then I'll have the space for it I reckon.
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.
Why is that? #97340 clears up a spot in the instance buffer, but uses that spot for its own needs
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.
...oh. I need to find some space then.
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.
Here is the space that you can use once #97340 merges:
736081e
to
db276ca
Compare
db276ca
to
045b5cf
Compare
Please squash the commits as it's required by our pipeline (see https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html). |
Do I need to do anything special to keep the other contributor's names or do I just squash? |
You will need to have the "Co-Authored by:" lines for both of them (one is already there). I suggest waiting to squash until you are finished with the PR and it is ready to merge. |
Co-authored-by: Álex Román Núñez <eirexe123@gmail.com>
3e740af
to
6cd556f
Compare
Any idea on if/when this will get added to the main branch? |
Depends on #97340. Soon as it's merged, I'll submit the final revision and then it's in the hands of the maintainers. |
From KoBeWi to EIREXE to here. Issue #62943.
instvartest.zip
I wanted to fit
instance_uniforms_ofs
into one of the unused push constant slots, but I couldn't figure out how to get that working easily. So with the path of least resistance, that's another 16 bytes to the instance data. Not ideal, but it's working.I intend to bring this long-standing PR to completion.