|Topic was automatically imported from the old Question2Answer platform.
I want to create a brush to paint over a texture. It would be something similar to the thing demonstrated in this PR: Add erase and brush_transfer method in Image Class by zhagsenkk · Pull Request #23187 · godotengine/godot · GitHub
As it is said in this discussion, there are the methods
blit_texture that can accomplish something very similar. The problem is that, as far as I know, there is no way to control the alpha channel with this methods. The brush would need to have a transparency option, so several textures could be applied with different levels of alpha… And the same texture need to have different alpha levels at different places. If I understood correctly, it is not possible to do this with the methods mentioned above (not even with the brush / erased proposed in the PR).
So I wonder what could I do to have a flexible brush. I know that there is
set_pixel, but I do not know if it would be overkill. Also I have read that it has a very poor performance…
Any ideas? Thank you very much.
The problem is that, as far as I know, there is no way to control the alpha channel with this methods
For a custom painting use case, I doubt the alpha changes while you paint, is it? Because then you can just precalculate that alpha in your brush image before painting, for example when the user changes transparency option.
I know that there is set_pixel, but I do not know if it would be overkill
It is surely slower, but I’ve been using that just fine in my terrain plugin to paint over large images. It starts to lag only with brushes larger than 50 pixels (while also using a system to only upload what changed).
On the other hand, if speed is a concern and your image isn’t too big, you could use a GPU-driven approach and use a non-clearing viewport instead.
I believe I need alpha changes… In fact what I want to do is a kind of terrain editor for 2D textures.
I mean, let’s say I paint something with alpha=0.2. Then, I move to another part of the texture, I choose alpha=0.4 and I start to paint. If I understood well, methods like
blend_texture need a “brush” that is in fact the same size as the original texture, so what is does is a blend between the two. Therefore, it is not possible to select a different blend I’m different regions… I would have to change brush alpha, changing then all the changes.
If set_pixel lags for something larger than 50x50, then maybe is not good enough… I don’t know. Do you have example of good use of set_pixel and/or the GPU approach?
Thank you very much!
VictorSeven | 2019-08-10 13:13