Skip to content

Conversation

@paddy-exe
Copy link
Contributor

@paddy-exe paddy-exe commented Nov 14, 2024

Adds support for 2d instance shader parameters. Cherrypicked the original PR as first commit.

Supersedes #97058
Fixes #62943

Also works with use_parent_material:

image

Testing project (taken from original PR):
test_pr_97058.zip

@akien-mga
Copy link
Member

Can you link that original PR? Is this new PR meant to supersede it, or it's a follow-up and KoBeWi's PR needs to be merged first?

@akien-mga akien-mga added this to the 4.x milestone Nov 14, 2024
@paddy-exe
Copy link
Contributor Author

Can you link that original PR? Is this new PR meant to supersede it, or it's a follow-up and KoBeWi's PR needs to be merged first?

It's the follow-up PR to #97058 but it is in VERY early stages. I am trying to wrap my head around the code. Clay gave me instructions on how it could be done for the compatability renderer. All the rest is already done

@paddy-exe paddy-exe changed the title Instance uniforms compatability renderer Implement 2D instance uniforms Nov 14, 2024
@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 6f26927 to e77c9a8 Compare November 18, 2024 16:14
@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from e77c9a8 to 2365b66 Compare November 19, 2024 13:25
@clayjohn
Copy link
Member

I started writing up what to do, then I realized it was less work for me to just show you, so here is a patch that gets 2D instance uniforms working in 2D.

0001-Finish-GLES3-support.patch

The final piece before this is ready is getting it to work with the "use_parent_material" property. CanvasItems often inherit the material from their parent. Currently it mostly works, but the editor doesn't expose the instance property for updating so you can't set the instance uniform in the editor.

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 2365b66 to 8cf5298 Compare November 26, 2024 08:14
@paddy-exe
Copy link
Contributor Author

I started writing up what to do, then I realized it was less work for me to just show you, so here is a patch that gets 2D instance uniforms working in 2D.

0001-Finish-GLES3-support.patch

The final piece before this is ready is getting it to work with the "use_parent_material" property. CanvasItems often inherit the material from their parent. Currently it mostly works, but the editor doesn't expose the instance property for updating so you can't set the instance uniform in the editor.

Thank you! I applied your patch except for this part as I couldn't figure out where this goes:

material_storage->shaders.canvas_shader.version_set_uniform(CanvasShaderGLES3::SPECULAR_SHININESS_IN, state.canvas_instance_batches[i].specular_shininess, shader_version, variant, specialization);

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch 3 times, most recently from 214632e to 678adc6 Compare November 26, 2024 15:49
@paddy-exe paddy-exe marked this pull request as ready for review November 26, 2024 15:50
@paddy-exe paddy-exe requested review from a team as code owners November 26, 2024 15:50
@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 678adc6 to c399835 Compare November 26, 2024 15:59
@paddy-exe
Copy link
Contributor Author

paddy-exe commented Nov 26, 2024

Updated with all feedback. Once the code changes are approved I will squash them so we have one commit at the end. The current two commits are for easier checking of the changes I made versus the previous authors made.

Will need to put all previous authors in the commit description as well

@paddy-exe paddy-exe requested a review from clayjohn November 26, 2024 16:34
Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also suggest touching on the descriptions of the equivalent methods for instance geometry, so that they're consistent with the ones added in this PR (which are slightly better formatted). But it doesn't have to be done in this PR.

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from c399835 to 1c1f66f Compare November 27, 2024 09:26
@paddy-exe paddy-exe requested a review from clayjohn November 27, 2024 11:30
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected in all rendering methods.

Testing project: test_pr_99230.zip

@huwpascoe
Copy link
Contributor

I'd like to test this, is it possible to get those conflicts resolved?

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 1c1f66f to 73ec629 Compare December 16, 2024 17:15
@paddy-exe
Copy link
Contributor Author

@huwpascoe Conflicts resolved.

Be aware that currently the editor doesn't show the parent material properties when use_parent_material is enabled. Still working on that part.

@huwpascoe
Copy link
Contributor

Be aware that currently the editor doesn't show the parent material properties when use_parent_material is enabled. Still working on that part.

I didn't even know that was a feature....well I remember enough about my own work to fix that!

@paddy-exe Here is a patch that implements the parent materials.
0001-implement-use_parent_material.patch

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 73ec629 to 40cf1d8 Compare December 17, 2024 11:54
@paddy-exe
Copy link
Contributor Author

Alright, patch applied. Works great. Thank you for the assistance with this @huwpascoe. Squashed into one commit. Adjusted the code to AThousandShip's codestyle feedback.

@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from 40cf1d8 to a1f86f0 Compare December 17, 2024 16:43
Co-authored-by: kobewi <[email protected]>
Co-authored-by: yesfish <[email protected]>
Co-authored-by: Álex Román Núñez <[email protected]>
@paddy-exe paddy-exe force-pushed the instance_uniforms_compatability_renderer branch from a1f86f0 to ceefc0d Compare December 17, 2024 22:59
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Tested locally and confirmed it is still working including with use_parent_material. I think it is ready to merge to get broader testing!!

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Dec 18, 2024
@Repiteo Repiteo merged commit d3e5b62 into godotengine:master Dec 20, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 20, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instance uniforms are not implemented for 2D shaders