Cannot stop looking at the video. True computer art!
Thanks

Do you plan to do anything with the FX yet?
No, it was just for fun.
And most 4kb-intros are already full of this stuff since a couple of years

would love to hear some theory on this one too.
It's just raymarching a cube which twists around multiple axes.
Raymarching steps along a ray from the camera through each pixel of the screen and tries to find the intersection with the object.
In contrast to raytracing it doesn't compute the exact intersection point with any of those ray/something-intersection-formulars.
Instead it computes the minimum distance to the object at the current position and advances along the ray by this "safe" distance iteratively:
// the ray: pos + t * dir
vec3 pos= currentPixelOnScreen;
vec3 dir= normalize(pos - cameraPosition);
float t= 0.0;
vec3 curPos;
const float EPS = 0.01;
const float maxDistance= 10.0; // we certainly didn't hit a unit-cube when we are here.
for (int it=0; it < maximumIterations; it++)
{
curPos= pos + dir * t;
float dist= minimumDistanceToCube( curPos );
// curPos is near enough to the cube?
if ( abs( dist ) < EPS )
break;
// ray didn't hit anything?
if ( t > maxDistance )
break;
// advance along ray
t += dist;
}
if ( t < maxDistance )
doSomeFancyShading( curPos );
And to find the minimum distance of a ray with an axis-aligned box at the center:
float minimumDistanceToCube( vec3 pos )
{
// cube reaches from -1..+1 in all directions
vec3 dist= abs( pos ) - vec3(1.0, 1.0, 1.0);
// negative distances are inside the cube: clamp to 0
dist= max( dist, 0.0 );
// get maximum of dist.xyz
return max( max(dist.x, dist.y), dist.z );
}
(so we're not rotating the cube but the camera)
To twist the cube around one axis you can simply rotate "pos".
"pos" always rotates around the cube's center (because it's at 0,0,0).
float minimumDistanceToTwistedCube(vec3 pos)
{
// rotation angle according to "x"
float rx= sin(pos.x + time)*scale;
// 2d rotation matrix around x
vec3 tmp= pos;
float c = cos(rx);
float s = sin(rx);
// pos.x keeps constant when rotating around the x axis
pos.y = c * tmp.y - s * tmp.z;
pos.z = s * tmp.y + c * tmp.z;
// distance to center
vec3 dist= abs(pos) - vec3(1.0, 1.0, 1.0);
// negative distances are inside the cube: clamp to 0
dist= max( dist, 0.0 );
// get euclidian distance to smooth distance at the edges
// and use a much smaller step size to safely catch the twisted edges
return length( dist ) * 0.2;
}
The version in the video just rotates around the x, y and z axis simultaneously.