Shaders from Shadertoy with multiple buffers in jit.gl.pix?

syrinx's icon

Hello all,

I'm once again trying to port a shader from Shadertoy to GenExpr. This time, it's this Wave Propagation Effect one from tomkh. This shader forms a key part of an another shader that I'd really like to get working in jit.gl.pix - Milky by huwb. I'm tackling the wave propagation shader first because it's less complex (no raymarching), but I'm running into some problems, which I think are related to the fact that the shader uses multiple buffers for feedback. I haven't ported any multi-buffer shaders and I'm not certain of my approach.

The wave shader uses two identical feedback buffers (Buf A and Buf B) to handle the wave propagation and manage the generation of impulses in the system, the latter either via mouse input or random placement (giving a nice rain effect). Both of these buffers take feedback from themselves at the current pixel location as well as from the opposite buffer at the four neighbouring pixels. The values of these pixels are used to compute outward-moving waves. Buffer A's output is passed on to the image channel (not sure if that's the correct term), which does the colourization for output.

By default, the shader on Shadertoy is set to use a texture and do some texture displacement. I'm not trying to do that yet, so to get an idea of what I'm trying to accomplish, please set line 22 in the image buffer to #define TEXTURED 0 .

I've been able to get pretty close in jit.gl.pix, but I'm unable to get the waves to propagate outward. I think the issue is related to line 52 of Buf B, which is where the sampling of the neighbouring pixels happens. I have this commented out in the patch, but if you uncomment it, you'll see that the output immediately goes totally black.

I'm wondering if anyone has any tips on working with multiple buffers and can point out where I'm going wrong here. There are a ton of amazing shaders on Shadertoy that use multiple buffers, so it would be great to have an understanding of the general principle of how to implement this in Gen. Thanks in advance!

Max Patch
Copy patch and select New From Clipboard in Max.