Some GLSL imagery

Hello. It’s been a long time. Let’s ignore that.

In a recent urge to put more FOSS apps on my Android phone, I installed a marvelous application called Shader Editor.  The app is basically just a GLSL editor that compiles the code live. You can use then use these shader files to make them animated wallpapers for your phone.

There exists a web-app for this too, for those who don’t like writing code on a phone (it’s a nightmare, really!). It’s called GLSLSandbox. You can hence write the code online and send it to your phone for Shader Editor to make a wallpaper out of it.

So for example writing the following code in the app:

#extension GL_OES_standard_derivatives : enable
precision highp float;
precision mediump float;

#define PI 3.14159268
uniform vec2 resolution;
uniform float time;

vec2 invert(vec2 x)
float d=x.x*x.x +x.y*x.y;
return vec2( x.x/d,-x.y/d);

vec2 cube(vec2 x)
{ return vec2(x.x*x.x*x.x- 3.0*x.x*x.y*x.y,
-x.y*x.y*x.y +3.0*x.x*x.x*x.y) ;

vec3 design(float scal)
if(abs(scal) <0.54)
return vec3(0.350+0.1*sin(scal),0.230,0.25);
return vec3(0.3,0.1+0.05*sin(2.0*scal) ,0.2*scal);
void main(void) {
float mx = max(resolution.x, resolution.y);
vec2 uv = gl_FragCoord.xy / mx;
vec2 center = resolution / mx * 0.5;
float t = time * 0.40;

float scalar=sin(40.0*uv.x) *
sin(t+20.0*uv.x-1.732*20.0*uv.y) *

scalar=sin(8.0*scalar) ;
gl_FragColor = vec4(design(scalar), 1.0);

Gives the following result (recorded from GLSLSandbox):


Soon I found myself doodling with this app, through which I created some trippy visuals that I would like to share. I’ll add them soon in a different blogpost.


A new dimension

I am on a path to learn Blender, the open-source computer graphics software. This way, I can now start creating 3d visuals, rather than the plain old 2-dimensional imagery.

Since I have just started (and since I’m extremely busy with exams), I’ll do something really quick and small.

I recently read about permutohedrons, and one particular thing that struck me was that the Permutohedron of the group {\mathbf{S}_3}, which is the symmetric group of order 3, is a hexagon.

I’ll briefly describe what I’m talking about. A permutahedron of a symmetric group of order {n} (denoted by {\mathbf{S}_n}), which is nothing but the group of all permutations of {n} distinct items, is an {n-1} dimensional polyhedron in the space {\mathbb{R}^n} whose vertices are formed by the set {\{(\sigma(1),\sigma(2),\sigma(3)\dots \sigma(n))\}_{\sigma \in \mathbf{S}_n}}.

In other words, take the coordinate {(1,2,3\dots n) \in \mathbb{R}^n} and shuffle the numbers 1,2,3 etc. among themselves to get the vertices of the polyhedron.

Now when {n=3}, this results in a hexagon inside {\mathbb{R}^3}. This fact is quite exciting to think about, so I made a little visualization of it. Here’s the output: