writing a heat simulation with a recursive shader?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sortai

I’m trying to buil a 2d heat diffusion simulation; I know how to do this in shadertoy by using a shader that takes its own buffer as a texture, but I can’t find a way to do this in godot.
To be more clear, what I’m trying to do is make a shader that, given an initial texture that encodes a heat field, computes the next ‘frame’ of the evolution of the field; I know how to write such a shader, the problem is that I haven’t found a way to implement the loop, to feed it a previous ‘evaluation’ as a texture.
I’m not sure if I’m using the proper terminology here, I’ll attach a shadertoy examples by other people to explain the kind of behaviour I’d like to achieve.
example 1
example 2
example 3