How can I use this shader in UE4?
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
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.
answered May 16 '19 at 04:20 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here