Ask HN: Help with GLSL Bi-Laplacian

1 danwills 1 7/16/2025, 12:24:28 PM
Can anyone help me with any hints about writing (in glsl) a bi-laplacian function that can take a neighborhood size? (I am not a mathematician, but I heard that the bi-laplacian of X is the laplacian-of-the-laplacian of X)

I have these existing implementations for laplacian and bilaplacian and they work great, but are fixed-size (basically the smallest-possible) and don't have any weighting because I guess that's close-to-meaningless for the smallest-possible neighborhood?:

vec3 laplacian = ( a_n + a_e + a_s + a_w - 4.0 * a ) / ( h * h );

vec3 bilaplacian = ( a_n2 + a_e2 + a_s2 + a_w2 + 2.0 * ( a_ne + a_se + a_sw + a_nw ) - 8.0 * ( a_n + a_e + a_s + a_w ) + 20.0 * a ) / ( h * h * h * h );

I already have a 'laplaceSize' function that I can pass a size to, to get a larger neighborhood - it iterates in 2D over the cells that are covered by the specified half-width, and weights them with a smoothstep. Works great, but I want a bi-laplacian equivalent.

So far I haven't been able to work out how to do an arbitrarily-sized bi-laplacian for the life of me! I'd really like to have one though because I'd like to use it in my playful KSE (Kuramoto Sivashinsky Equation) experiments.

If anyone's keen to help, I am happy to send some fun example RD/KSE-simulation glsl shaders that I've been working on (and want to be able to make use a larger neighborhood) that should work in the 'Shader Editor' Android app by Markus Fisch (here's the source but it's also on the App-Store):

https://github.com/markusfisch/ShaderEditor

Comments (1)

danwills ยท 1d ago
Here's a screenshot of what one of the KSE-based shaders I've been playing with usually looks like:

https://photos.app.goo.gl/NnfjxUwR5ZuH4KkJ6

It's basically KSE but with hue-rotation happening in various-ways so it's really more like 3 separate KSE sims that feed into each other in a cycle. I think it's pretty fun! Happy to share code if it is of interest!