Closed redhog closed 2 years ago
The fractal library should be easy enough to integrate in InfiniteGlass. The function generate_fractal
returns an image that you can display. Might even be possible to animate or change every T amount of time, if animation is too slow.
That is super cool! I wonder which of these could be implemented purely in the fragment shader?
Is there a Python to GLSL converter/generator? That would be something useful.
I don't think so, and there's another thing: GLSL shaders have a quite... interesting processing model.
In short, the pipeline works like this:
You can do a lot of weird and cool stuff in the fragment shader - but it has to be sort of "local" - it can not output more than one pixel, and it can not read the output of other pixels. But it does know its own coordinate, and it can access textures to look up values at some coordinate in those textures.
Oh, and for extra fun: There is NO way to debug this shit. You can't even add debug prints. All you can do is change the output values of a shader...
This one should be a good starting point. https://github.com/neozhaoliang/pywonderland/blob/master/src/fractal3d/fractal3d.py
Oh cooooool!
Here's my OpenGL version of Lyapunov fractal that I found on my hard drive: https://github.com/alexkh/gllyap
Cool! That looks awesome! I think I might spend some time on this once islands are done maybe...
Or you can give it a try. This is where you'll have to integrate it:
https://github.com/redhog/InfiniteGlass/tree/master/glass-theme/glass_theme/shaders/root
(this draws a square covering the entire screen under all windows, and the fragment shader can then be used to draw whatever you want)
k, Lyapunov background seems to be working. I only changed one file: glass-theme/glass_theme/shaders/root/fragment.glsl https://github.com/alexkh/InfiniteGlass/commit/7a7e7637e4b9111a1efeeddccba6b1a926fbf975#diff-5984784349a72c05728c803f0f50663d
This is fantastic @alexkh !!!
@redhog hold your breath, I asked him if he could make it configurable and animated. Ah!
Should not have closed this, as we might want to experiment with other fractals too?
Btw, Lyapunov fractal has that special parameter: it will give quite different pictures depending on the pattern of permutations. If you look closely at this part of the code: for (int i = 0; i < FRACTAL_PRECISION; i++) { x = w1p.xx(1.0-x); h += log2(abs(w1p.x(1.0-2.0x))); x = w2p.xx(1.0-x); h += log2(abs(w2p.x(1.0-2.0x))); x = w3p.yx(1.0-x); h += log2(abs(w3p.y(1.0-2.0x))); x = w4p.xx(1.0-x); h += log2(abs(w4p.x(1.0-2.0x))); x = w5p.yx(1.0-x); h += log2(abs(w5p.y(1.0-2.0x))); } you'll notice that this particular fractal has classical pattern AABAB. The difference between lines is whether x or y of the point is used in the permutation. This particular fractal is featured in all tutorials and in Wikipedia: https://en.wikipedia.org/wiki/Lyapunov_fractal But there can be a huge variety of patterns giving different results. I'm not even sure what would be the optimal way to implement the ability to specify the pattern in InfiniteGlass settings. Also, it might be cool to set initial center and zoom level, no?
Interesting. I had never seen this type of fractal before went and read up on it on wikipedia
Cool. You do something slightly differently from wikipedia though, where you set r_n not to a or b, but to some fraction of them?
I'm getting black screen and need to switch to another terminal and type killall -9 Xorg to exit when I try to set my ~/.config/glass/theme.json to: { "name": "glass_theme.default.Theme", "args": { "latlon": [70., 18.], "mode": "no_splash", "define_BACKGROUND_TYPE": 1, "define_FRACTAL_PRECISION": 100, "define_BACKGROUND_COLOR_TRANSFORM": "transpose(mat4(0.0, 0.0, 0.0, 1.0, -0.5, 0.0, 0.0, 1.0, -0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0))" } }
Is there a way to assign Ctrl-Alt-Backspace to exit InfiniteGlass? At least that'd simplify debugging a bit...
Btw, since the fractal doesn't really extend infinitely, maybe we could make it repeat after X units in each direction, but with a different parameter?
Not at all. Bind whatever keybinding you want in input.json to "send_exit".
Do you get any interesting output on stderr/stdout of glass-ghosts / the whole session when this happens?
Any shader compile errors should dump stuff there... And so should any OpenGL error...
Interesting. I had never seen this type of fractal before went and read up on it on wikipedia
Cool. You do something slightly differently from wikipedia though, where you set r_n not to a or b, but to some fraction of them?
I probably took that fractal from Shadertoy, I used it just to test my OpenGL init code back in the days. It might be modified, but I guess the same configuration princible applies. Don't forget: we can scale it up and it will be more "infinite", no?
True... But there are large fairly homogenous areas (at least if your N iterations isn't large enough)
I think I should give you free reign to experiment with this. We can easily have multiple backgrounds / presets to chose from...
Technically, any fractal is limited in space, and they all require tons of iterations to give pretty results...
Even this gives me black screen, and it does not even show the splash: { "name": "glass_theme.default.Theme", "args": { "latlon": [70., 18.], "define_BACKGROUND_TYPE": 1 } }
On latest master? Works for me... Do you run InfiniteGlass with "make"?
That's why I'm proposing we do
x = p.x % 5.;
y = p.y % 5.;
w4 = sin(0.1 * floor(p.x / 5));
w5 = sin(0.1 * floor(p.y / 5));
or something along those lines...
no, i run it with "startx"
You can also reload glass-theme using:
glass-action component restart glass-theme
Aha. Then you should have stderr/out in ~/.glass.log, check that file and see what it has dumped there...
It is generally a good idea to run tail -f on that file on the console... InfiniteGlass is far from super-stable yet.
You can also set debugging options in ~/.config/glass/session.sh to trigger more output (just export GLASS_DEBUG_XXXXX=1).
K, I figured it out: the json parser does not tolerate tab character, which is weird. Also, instead of giving up and moving on, it enters an infinite loop trying to re-read the config file, which is also kinda weird.
yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token in "/home/sv/.config/glass/theme.json", line 5, column 1
It's not an infinite loop actually: The component (glass-theme) exits with a non-zero exit code (that's what python does on an exception if there is no exception handler catching it), and glass-ghosts will restart any component that fails this way. It's a bit stupid when it happens on start-up, but for things like glass-input, if it happens in the middle of your session because say a function you bound to a key crashes it, it makes sense to just get it back up so your whole session doesn't screw up for you...
If you want to see the animation, i made a shadertoy version: https://www.shadertoy.com/view/WdscWH
It's quite disturbing. Good job. :tada:
Hm, maybe we do need animated drawing like that. It looks super surealistic!
Moved the config language (JSON5) stuff to https://github.com/redhog/InfiniteGlass/issues/70
Btw, shadertoy seems like a really good tool for experimenting with this easily :)
Just found out that the static shader's author is Inigo Quiles (creator of Shadertoy) himself, so we must credit him in the shader code. I still have no Idea who added animation to it, so for now les't just state:
// Original code author: Inigo Quilez 2013 https://www.shadertoy.com/view/Mds3R8 // Animation: author unknown :-(
I have contacted him with a DM on twitter to clear up the attribution and licensing stuff.
Just found out that the static shader's author is Inigo Quiles (creator of Shadertoy) himself, so we must credit him in the shader code. I still have no Idea who added animation to it, so for now les't just state:
// Original code author: Inigo Quilez 2013 https://www.shadertoy.com/view/Mds3R8 // Animation: author unknown :-(
@alexkh Absolutely honourable thing you did here. Keep it up!
a little bug in the shader: h /= 200.0 5.0; should be: h /= FRACTAL_PRECISION 5.0;
Oh, that's really pretty!
This one is worth sharing. https://www.reddit.com/r/Unity3D/comments/fo334b/magnetic_fields
Licensed version of the above mandelbrot code: https://github.com/WebManifestation/mandelbrot-GLSL
https://github.com/danilobellini/fractal