- Edited
Hi all,
this is what I am trying to do, all in 2D: - Draw an object with _draw commands on a CanvasItem - take the drawn stuff from a texture, apply a shader to it - take that as a texture/image and do image processing with it (e.g. erosion on a height map, and blend more noise in), - and finally blend that through another image/color filter (possibly a shader), where the user gets to see it as the end result.
So ideally, I need all of that to happen without the user seeing any of that on screen, only the last step as end result.
I understand that I can use _draw commands on an image when its data is locked; I understand how to program simple shaders as well both in code and with the visual shader. But I have a hard time wrapping my head around how to combine this. How do I get the drawn result of a CanvasItem shaded, and that Texture2D live back into a shader where it can be processed further? On the visual shader I can not for the life of me use a Viewport Texture as the Editor claims the Resource is "not local".
I've looked around a bit, but the whole thing seems rather convoluted as a concept if you need to do multi-step image processing. So, a long rant short -- what is the best workflow for getting these steps done:
- getting canvas draw operation onto a buffered texture,
- getting that as input texture into a shader and produce a shaded output texture, 3 getting that output texture back onto a CanvasItem or ImageRect or somesuch, which can draw in a blend/mix/add mode?
Also, how big is the speed difference between shader operations and draw commands on images? I know the latter must be slower for certain tasks, but are there any where the speed is compatible, or is the use of shaders always faster than any canvas _draw operations?
Thank you for your suggestions.