Mathematical images and animations

I just came across this and thought it was incredible.

Sorry if this has been posted before.

https://www.youtube.com/watch?v=z_xM_jD08OM

What program is this made in? I did a little looking around but I am not sure I even understand how he is doing this.

I am assuming all this could be done in Blender.

There isn’t a program. He says in his comments he’s just doing it with math and shaders.

He seems to have made a lot of articles and some tutorials of how he does some of the stuff. Otherwise he just seems good at it.

It’s basically programmed as a shader - code that runs directly on a GPU

The source code is at https://www.shadertoy.com/view/4tByz3

This sort of scene could be made in Blender, but some people like the challenge of doing it entirely in code.

1 Like

The guy has a web page where he explains a lot of his stuff. http://iquilezles.org/www/index.htm

Be warned: he’s a hard-core demoscene OG who now works at Pixar.

One of his most popular products, Elevated (https://www.youtube.com/watch?v=jB0vBmiTr6o) only takes 4 kilobytes of space and renders all you see and hear.

I guess where I am confused is where he says no program is used!?!?

What is he typing these equations into?
what is displaying the image?

Is this like creating your own OSL shader in Blender?

Computer processors take machine code as an input that they read from an executable file. The challenge is simply to type out the variation of bytes that produces the most impressive end result. Of course there’s tooling. Most of it uses various tailor-made synths and exe-packers plus C.

I tried taking a look at it, I kind of get what he is doing but this feels so over my head. That video is amazing.

The comments said that, the comments below the video take up more space than the video did. Thats crazy!!

I am assuming you need to be a math genius to do stuff like this? I still struggle with the Cycles math nodes.

Is it possible to create one of his scenes in blender with only using math nodes?

Either that or spend your entire life doing it.

1 Like

To do this sort of thing in Blender you would probably use Python. Doing it in a node-based system, even if possible (Can Animation Nodes generate meshes and textures?), would create an enormous node tree.

1 Like

Since no one answered the question directly, I’ll take my captain obvious’ hat and explain how this is done.

He makes it sound like this scene is the graph of a complex mathematical equation, and implies there was no program involved to further imply this idea. He is lying; or, to be more precise, he’s misleading people into a lie he never states explicitly. This is a simple volumetric ray tracer written in shader language where models are defined by implicit equations.

What he means by “no program” is “I wrote a small program”, and what he means by “no 3d POLY models” is “I used a different representation than the one used in most 3d programs”.

The fact he wrote a small program is obvious so I’m just going to skip that. The only thing to mention here is that the program he wrote is running not on your processor, but on your GPU as a shader. This is probably why he suggests there are “no programs involved”, besides the fact the wrote the program himself. By definition, a shader is a small program whose main function is to “shade”, or to calculate lighting, but modern cards are able to run arbitrary code. That is what is known as a compute shader, or a general purpose shader program.

As for the models themselves, they’re volumetric models derived from implicit equations. This is why he claims this is a “mathematical scene”, but it’s no more a mathematical representation of a 3d world than a Blender scene is. It’s just a different representation.

To understand what an implicit volumetric definition is, let us analyze a simple 2d circle. The equation could be:

x^2 + y^2 - c^2 = 0

This is an implicit circle of radius c. Any solution to this equation is a point on the circle’s perimeter. This is what the graph of the equation really is: the set of all points that solve it. Hence, to “render” this circle’s outline, you could “cast 2d rays”, testing all (x, y) coordinates along this ray against the equation to see if (x, y) should be drawn. If the equation is true, then (x, y) lie on the circle’s perimeter. Because you “march” along the ray, this is called ray marching.

The reason this is called a “volumetric” representation is because we can tell what’s inside and outside the circle based on a Signed Distance Funcion(SDF), hence we are aware of the volume, not just the surface of the object. The SDF is a signed function that evaluates to less than 0 if a given point P lies inside a certain volume, greater than 0 if it lies outside said volume, and 0 if it lies exactly on the surface.

Let D(P, Q) be the shortest distance function between points P and Q, and let O be the origin of a circle. For a circle, the SDF would then be the function that “checks” whether the distance from P to O is less than the radius r of the circle. In mathematical language:

F(P, r) = D(P, O) - r

This is what he means by “there no poly models”. Models were built from similar fundamental implicit equations, and more complicated ones are derived from said primitive equations. They’re then rendered through this process. There’s also a technique for describing implicit volumetric models using a hierarchical tree structure with boolean operations whose concepts he may or may not have applied mentally when building the scene. He also wrote definitions for simple math and linear algebra functions to help with coordinate space transformations, and performs most computations inline(so if you’re not familiar with them, it looks like magic).

How does this differ from the usual representation? Most 3d programs care only for the surface of the model and have no interest for the volume(ever noticed 3d models are “hollow”, not solid?). To describe the surface we approximate it through a finite set of polygons, and the surface itself is calculated from interpolation of surface information during a several steps process called rasterization.

In the end of the day this is still the same basic math any graphics programmer knows by heart, so he’s no more a math genius than the Blender devs are. I will say though that even if the math is nothing special, putting something into practice something is. That’s worth more than theoretical knowledge in this field.

2 Likes

Thank you so much for breaking that down for me. It makes so much more sense to me.

I really appreciate it.

You’re welcome.

For anyone who may come across this thread in the future, and also in the unlikely event the author of the shader stumbles upon it, this internet stranger apologizes for sounding condescending by calling this project “basic math”, specially towards those who don’t understand how it’s done.

That shader is one beautiful procedural scene and a perfect practical example of mathematical beauty. Anyone capable of doing that is well versed in Linear Algebra, Calculus and Graphics Programming, and that takes a lot of time and dedication. So cheers.

1 Like