Add support for per-surface, instance uniforms in shaders when using MeshInstance2D and ArrayMesh #13023
stuckupfool
started this conversation in
2D
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm starting a discussion about adding support for using MeshInstance2D's instance shader parameters in conjunction with ArrayMesh's multi-surface concept, that allows assigning a different material to each surface in a mesh. While I haven't encountered this limitation personally, I believe this also applies to using MeshInstance3D in conjunction with 3-dimensional ArrayMeshes. The underlying limitation is that MeshInstance2D's SetInstanceShaderParameter uses the same values for each surface in the ArrayMesh which limits flexibility. The other option is to use ShaderMaterial's SetShaderParameter on each surface's material. However, this will also use the same value for each surface unless the ShaderMaterial is duplicated so that each surface has a unique instance, except this is the whole purpose of using instance uniforms.
Individually these features are very useful in reducing the number of ShaderMaterial and ArrayMesh instances needed to render complex scenes. It would be great if these features could be used in conjunction to realize the same savings as currently a developer must do one of the following to work-around this:
However both of these workarounds lead to some "extra" ShaderMaterial / ArrayMesh instances. For my project I plan to utilize the 2nd workaround for the time being as that seems like it would result in less overhead.
I would be amenable to implementing this feature in Godot if there's enough interest from the community.
Beta Was this translation helpful? Give feedback.
All reactions