How can I use this shader in UE4?

I have tried for many times ,there is a big problem

How can I use recursive function in UE4 material editor or any other way to achieve this kind of effect

You can search for Custom material node which enables you to paste direct shader code for more complex functions. That way you can avoid spaghetti shader but be aware that it might use more instructions at the and as it would prevent Unreal from doing Constants Folding optimization. Most of the time it is not an issue, just be aware of it.

Those are buffers. Shaders can’t access surrounding pixels, primery because GPU does not guaranty that other pixels are already done as GPU specifications don’t define how those pixels are generated by GPU and what order they are. So instead you need to run one shader that do first pass in to the buffer inside GPU memory and then access that buffer like a texture in 2nd shader, that does things based on what shader 1 did.

This requires doing things in CPU, and in shader toy you do that by creating buffer tab and in UE4 you can do this by rendering to Render Target:

RenderTaget then can be accessed same as a texture exactly as what shadertoy shader does

It all fell into place ,thanks for your response.