this post demonstrates how you can draw an apple on a table, using only mathematics.

this evening i decided not to code for me, but for the people out there again. so, i recorded this live coding session. as i already explained, it’s not easy to show what one can visually/cinematically/musicaly achieve with maths with a just 8 minutes coding session. indeed, in a 4 minutes of coding you can go only that far. in 20 minutes you can get some more sophisticated graphcis, but still there is no room for playing with content or look. so, this time, i decided to give myself 40 minutes to create something a little bit better. so, i took my compiler and live coding framework, and started to code an “apple on a table” image from scratch, only with mathematics. no txtures, no 3d models, no photoshop, no nothing. just 40 minutes of formulas.

of course, 40 minutes of code jam become less efficient (efficiency measured as visual awesomeness divided by development time) than when you do a 4 minutes production. when i improvise i waste lot of time thinking, wandering and even looking for stupid bugs, and the more complex the target image is, and therefore the code, the more i have of those. so this video is full of dead time where not much happens in terms of content evolution. i hope you enjoy it anyways.

in terms of nerdy content, this video shows how to quickly write a small raytracer/raymarcher, from scratch, how to then model a procedural apple and a ground plane afterwards, and lastly how to procedurally shaded it (textured and lighted) the models. as a bonus, the process involves implementing some sort of primitive perlin noise function, a few local lighting equations, some fake soft shadow technique, some fake ambient occlusion tricks, and a camera system, among other things. again, 40 minutes only allows you to go that far, so both the procedural modeling and the texturing are pretty simple.

finally, before i leave you with the video, some technical comments about the video recording itself: you’ll notice some cuts/discontinuities in the footage. that’s cause the graphics driver halted rendering more than once during the recording (not sure why), so i lost a few frames.

ok, here goes the live coding session. i hope you enjoy it!