Porting a Reaction-Diffusion system from ShaderToy to Gen

syrinx's icon

Hi folks,

I'm trying to port this reaction-diffusion system from Shadertoy to Gen. The user who posted it, cornusammonis, has a lot of really nice shaders up, and I would love to get some of them working in Max.

I'm able to get movement that's initially somewhat close to the original. After a few seconds, though, the system starts to show a diagonal banding artifact, which isn't present in the original. Whereas the Shadertoy version yields a tendril-like output, the Gen one gives a blobbier result, for lack of a more technical term. Could one of you Gen/jit.gl.pix wizards out there please lend a hand?

I'm wondering if part of the issue is the floating point precision in Gen. So far I haven't been able to find any info on whether Shadertoy defaults to float32 or float64 precision. Inasmuch as jit.gl.pix tops out at float32, though, I wonder if that's contributing to the difference. Are there any plans to introduce float64 support in jit.gl.pix, or is there a workaround?

Also, I have a suspicion that part of the problem might have to do with the way I've dealt with line 41 in the first jit.gl.pix (bufA), where the Laplacian is calculated. In that line, the three-component vectors corresponding to the 3x3 neighbourhood around the target pixel are summed into three groups (centre, orthogonal and diagonal) and then multiplied by three scalars (_K0, _K1 and _K2). In the Shadertoy code it's defined as a vec3. Since GenExpr is typeless, I'm just assuming that multiplying a vec3 by a scalar will result in a vec3. I'm worried that my questionable command of GenExpr syntax is causing issues here.

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

syrinx's icon

Never mind, got it!

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

maaark's icon

Was trying to port this one sometime back with no luck, and almost no reply to my questions. This is great! Will be taking this apart to learn from :)