Hacker News new | past | comments | ask | show | jobs | submit login
Painting a Selfie Girl, with Maths [video] (youtube.com)
175 points by Tomte on Nov 30, 2020 | hide | past | favorite | 17 comments



And the best thing is the author shared it as a shader toy: https://www.shadertoy.com/view/WsSBzh


And he's also the co-creator of the website.


Great, was not aware of that at all. Was quite flabbergasted at how so little (albeit very dense) code could generate such a lively scene without any use of textures etc.


Then you should definitely look into the "Demoscene". It's basically a subculture built around writing impressive little graphics demos.

What exactly makes them impressive depends on the category, e.g. a limited hardware platform like some 80s computer, or limited space. A popular category is "4k", meaning that the program has to fit into 4096 bytes. 4k demos can actually get quite visually complex and even feature music.

Many modern games that let you explore gigantic, seemingly infinite spaces (e.g. Minecraft, No Man's Sky) owe a lot to the ideas that originated in the Demoscene.


His personal website is also a goldmine. I enjoyed a lot his early demos https://www.iquilezles.org/prods/index.htm


The distance field is a standard technique for this. What I'm less clear about is how the designer comes up with the shape equations; is there some sort of tool offscreen, like a more conventional constructional solid geometry one, or do you just try things?


At one point in the video they said they've cleaned up the design process for the sake of pedagogy, and they mentioned a few times to reference their previous videos for some of the equations, so I imagine it's a mix of experimenting and experience.


A signed distance field is absolutely not a typical way of creating hero geometry, that's why this is interesting.


Inigo has a rare and brilliant mind. I wouldn't be surprised if he just... thought about it in his head.


This is a great video. Not only is it really interesting, but the sound, the transitions, his voice, everything is just perfect.

What I do not really understand: Are all these functions (for example sdfCone()) generic modelling terminology or are they specific to a certain tool?


Adding to the other explanations: I think the way you go about it is to simply google some SDF implementations of primitives (looking for them on shadertoy will already give you a basic set pretty quickly), and you can expect that implementation to take an arbitrary position in space, some parameters describing the primitive, and it will return the distance to the surface from that point - negative if the point is inside the primitive.

Then all you need is some function that does raymarching and a bunch of other tricks to do shading. It's all part of graphics processing, so there is definitely some common terminology there.

For some SDFs you could start with IQ's page: https://www.iquilezles.org/www/articles/distfunctions/distfu...


sdf stands for "signed distance function". It helps the magic of ShaderToy [0] to obtain real time rendering in the browser. Note how the animations on the ShaderToy website aren't videos but real-time renderings. See e.g. how straightforward the coneSdf is implemented [1].

[0] https://www.shadertoy.com/

[1] https://www.shadertoy.com/view/4l3BW7

    float coneSDF( vec3 p, vec2 c )
    {
        float q = length(p.xz);
        return dot(c,vec2(q,p.y));
    }


They are fairly generic within the family of tools based on signed distance fields - which is mostly graphics programmers writing code in Shadertoy, but also underlies things like Dreams on PS4


This is one of the more interesting links I've followed from HN in a while. Thanks!


That was far more interesting than I expected. Thank you.


For those who haven't heard of him, this guy is a Pixar veteran and an absolute wizard of computer graphics: https://www.cgw.com/Publications/CGW/2012/Volume-35-Issue-4-...

> Quilez describes the method he used to generate the 15 types of foliage, rocks, and even small flies as “painting with code.” The code exists as a Pixar RenderMan plug-in written in C++; that is, a DSO. When Quilez started, he rendered with PRMan 15, then, as time passed, changed to Version 16.

> “It was quite fun using a compiler to produce assets,” Quilez says. “Going from the flat world into a super-dense 3D world was all my work. Moss with small clover leaves around it, bracken, hummocks, hanging moss, all the leaves and pine needles, lichen, grass and flowers, heather, birch trees, gorse, Scotch broom, the distant trees and rocks, the small dots that were flies, all were specific pieces of code; all the shapes, the colors, everything is in the code. We didn’t write a tool that an artist would use; there’s no user interface. Usually we use code to glue things together. In this case, we thought of code as assets.” At first, Quilez planned to hard-code only moss and grass, but the result was so successful he ended up writing specific code for many more types of vegetation. “I abstracted the code and found the parts they all had in common, but in principle, each is different,” he says. “They share the logic, of course.”

> He treated the vegetation that grew on the rocks, trees, and up from the ground differently from that without supporting geometry. For the former: “We’d start with 3D models and go polygon by polygon in the mesh,” Quilez explains. “For every quad, we would generate random points, and from those points we would grow flowers, leaves, and something else.”

> For the latter: “When we didn’t have a mesh,” Quilez explains, “we’d place cubes where we wanted things to grow. These weren’t polygons; they were mathematical descriptions: This is the center, these are the sides, end of story. The code would use that to generate detail inside. We generated bushes out of nowhere.” Quilez didn’t use typical plant-growing rules to produce the grass, moss, and other vegetation. “The problem with L-systems and other old-school techniques is that you have to encode the rules,” he says. “If you want to change something, you have to change the rules, which isn’t intuitive. When we wanted to change something, we’d go into the code and make the change.”

His ShaderToy profile is quite something as well: https://www.shadertoy.com/view/4ttSWf


Brilliant! A combination of artistic talent and math, well done!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: