Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative to #688, much more straightforward way to handle layer blending now that we use Godot 4, but I would really appreciate feedback as I'm not sure if this is the best way to handle layer blending and if it has any disadvantages over any other methods. CC @AlphinAlbukhari @mrtripie.
I also didn't encounter any layer limit with this method, I tested up to 300 layers and it seemed to be working perfectly with no performance issue. I did have to add a 1024 layer limit though in order to pass opacities and blend modes for each layer as arrays to the shader, since shaders don't support uniform arrays with unknown sizes. I am worried that 1024 might be too high for certain GPUs, so we may have to lower the number even more. Alternatively, we could either pass opacities and blend modes as textures, where each pixel would represent a layer, or we could change the shader code during runtime to update the size of the array, although I am worried this might affect performance as we would re-generate the shader every time we add or remove a layer.
Current blending modes supported (thanks to #688 and https://godotshaders.com/snippet/blending-modes/):
This PR only works as a preview, I would like feedback first to ensure that this method is indeed a good one before I continue the work.
To-do:
Can be done after this PR is merged: