Inigo Quilez   ::     ::  
1402 blog posts, written between 2008 and 2016. These are mostly short observations, funny thoughts and word playing. Some are embarrasingly corny, some more deep. I keep it here mostly a little time capsule for myself, organized by month:



<
December 2013
>
mathimage #46: another terrain
2013-12-30
I had no time to do any exploration of looks or algorithms or maths this time, so I made a bald terrain with a layer of white, which is a no brainer. However, I decided to put myself out of my comfort zone regarding the color palette, and push the colors a bit beyond where I would normally stop drifting from more photo-real colors, sort of to take a measurement of what people's taste is in terms of color. I'm always too scared of color grading too much my images for the fear of falling into a "instagram" kind of cheesy look. However I think I have learnt that I can push colors to extremes much further than I thought I could, and still get good responses.In fact, it seems people react really well to these colors.



For the more technically curious, the terrain is a distance field as usual, nothing special worth mentioning. There's one shadow-casting light and 2 extra point lights without shadows. No indirect lighting effects whatsoever, although there's some fake occlusion is used as usual. Also, for the first time, I changed the diffuse response from my usual Lambert to Oren-Nayar. Nothing else, it's all pretty straightforward and available in the code linked below!

The raltime version, with code/maths open for you to explore, here: https://www.shadertoy.com/view/MdBGzG
poetry and comedy
2013-12-28
I think there's something that poetry and humor/comedy share that makes them both exciting and appealing to our brains: the fact that we have to complete the missing connections. Poetry forces you to extract meaning and connect different ideas otherwise unrelated by means of analogy and allegory. So does comedy and jokes with their final twist.

When those connections are formed there's some sparkly joy happening in the brain. In poetry it lasts longer and you have the time to feel its flavor. In comedy it happens more suddenly and at the end in form of mental tickles that provokes laughter

Just an impression
probably today
2013-12-26
to the question "What day is it?", the answer "It's today" seems to work pretty much always within a very small margin of error

seriously. i don't know what day it is
mathimage #45: and old experiment
2013-12-24
This one was completely improvised again. One of the emails I got today was about one article in my site that I wrote 12 years ago. I still remember all the details of it of course, but since the technology I used back then is sort of obsolete these days, I had to quickly remake the experiment in order to be able to point him to some reference code. It didn't take more than 25 minutes, but it was sort of a sweet exercise to bring that random experiment back to life.

After 25 more minutes of improvisation on top of that I got this pure 2D effect that in fact looks like 3D. I had fun with the colors and patterns and "lighting" (of which there isn't technically any really).



This thing moves realtime of course, so if you want to see it, or explore the code that produces it, click here: https://www.shadertoy.com/view/lsSGRc
i've missed it
2013-12-22
ahhhh, what a beautiful morning. lovely lovely lovely, why? because it's raining. and the air smells different when it does. in a very good way, and in a very familiar way. i missed it so much. that's why i have wide opened the windows of my apartment this morning, to let the rain come in.
short sighted liberals
2013-12-20
It seems to me like for some liberals not all people are born equal after all.

You might expect that while the conservatives are still stuck in the concern for color, liberals would have opened their minds and hearts to a more globally aware attitude by now. However, it sometimes seems to me that for some liberals the matter is not whether the people are of color or not anymore, but from _where_ in the world the people of color are. Like if liberal ideals only applied in their own national backyard, and all affairs beyond the fence of their country simply were not of their concern. Especially if the country is a country of brown people, indeed.

Very well done, short sighted liberals.
mathimage #44: dolphin
2013-12-18
Here goes another mathematical image or formulanimation around sea life. And again, just as like with the fish, I had to compromise detail for compatibility. But there it is, a simple mathematical dolphin with a simple mathematical animation galloping an equally mathematical sea.

The interesting bit of this image is the way the water splashes are made. Given that the whole image is a volume and hence an implicit shape, and that the animation is stateless and also an implicit function of time, there's no way I can use physics simulation for the water animation nor a cheap way to use sprites or particles for the water splashes. Instead, the water surface function evaluates the dolphins volumetric definition and computes the closest distance to it. Then, the water isosurface pushes itself upwards by that distance such that the water connects more or less naturally with the dolphin. This distortion is driven by the same trigonometric/harmonic rhythm that drives the jumping cycle of the dolphin, so that it only happens in the ascending segment for the back part of the tail and for the descending segment in the front.

The swimming animation is a regular cosine function, and so is the jumping as well just with a frequency one fifth of the swimming frequency (but bigger amplitude of course). The final animation is an interpolation between the two, such that both swimming and jumping occur.



The raltime version, with code/maths open for you to explore, here: https://www.shadertoy.com/view/4sS3zG
on ray-sphere
2013-12-16
Speaking of xmas balls and maths, when performing the intersection of a ray (originating at ro and traveling towards the normalized direction rd) with a sphere (or radius sr and position sc) I see people doing this all the time:

float iSphere( in vec3 sc, in float sr, in vec3 ro, in vec3 rd )
{
vec3 oc = ro - sc;
float b = 2.0 * dot(rd, oc);
float c = dot(oc, oc) - sr*sr;
float t = b*b - 4.0*a*c;
if( t > 0.0)
t = (-b - sqrt(t)) / 2.0;
return t;
}


Meaning they systematically forget to simplify the expression and destroy all the 2.0 and 4.0 coefficients, which cancel each other. Please, use this:

float iSphere( in vec3 sc, in float sr, in vec3 ro, in vec3 rd )
{
vec3 oc = ro - sc;
float b = dot(rd, oc);
float c = dot(oc, oc) - sr*sr;
float t = b*b - c;
if( t > 0.0)
t = -b - sqrt(t);
return t;
}


Not that the performance will change a lot, but do it for the karma?
complementary
2013-12-14
I have had the xmas tree in my living room, with its shinny balls and lights on and everything, for a year now. I have switched it on almost every day of 2013.

However, when everybody else unpacks and installs their xmas tree this week, I packed mine and gave it back to its real owner, from who I borrowed it all this time. I'll celebrate xmas of course, I love it, but I enjoyed a lot celebrating January, February, March, and all the other months till December as well.
A useful family of functions for sculpting
2013-12-12
One formula that I use a lot for create shapes such as tree leaves, petals, fish (see a few posts below), dolphins, mushrooms, and many others,



is the following:



which I extracted by generalizing the parabola 4·x·(1-x). It works in the domain [0..1], which is convenient because then one can easily stretch or compress the whole shape by a simple multiplication. It's equally useful to normalize its range such that the returned values are always in the [0..1] interval. For that, one needs to look at its derivative



and extract the value of x at witch it becomes zero (besides the trivial solutions x=0 and x=1), and then make sure k is such that the function reaches 1 at that point. In other words, x=a/(a+b) and

what the fuck?
2013-12-10
america never stops surprising me with surreal (and embarrassing to its other first-world colleague countries) lunatic idiosyncrasies.

i just learned that dildos are illegal in some states of the US.

no . kidding . this is real. i repeat - it . is . real

instant demotion to freedomless/fundamentalistic nation for this one. seriously. what the fuck?

i'm sorry i'm this harsh, but there are some basics and important principles that i don't tolerate seeing broken in nations that claim to be free

humorous words
2013-12-08
there is the berry.

and also the blueberry, the blackberry, the raspberry, the strawberry and the cranberry.

and then there is the dingleberry.

i love it. we have a funny word for "dingleberry" in spanish as well - we call it "tarzanillo", or "little Tarzan" if translated, for obvious reasons. no kidding.
teo-logía
2013-12-06
de alguna manera relacionado con la entrada anterior:
telepathy doesn't work
2013-12-04
it's tuesday morning in the city, and as such, there's live all around us. mornings like this you can see some people rushing to work with a cup of coffee in their hands down the escalators, just like in the hollywood movies.

today it's one of those days, and for some reason i am in such an escalator with a pile of people in line. and unfortunately for those rushing to work, there's a guy in front of us blocking the escalator. when the sound of the train announces its immediate arrival, the people in the line gets tense. they are certainly going to miss their train unless the man blocking the escalator starts walking down it rather than keeping still staring at the walls. people try to move down the escalator but struggle to pass by him. a couple of them will make it, but for the most part all these people will miss their train. and we all know it.

and so, given the amount of concentrated hate directed straight at this man at this very moment, if there ever was any possibility telepathy would exist, some sort of awareness or feeling of discomfort or itchiness or something should awake in this man right now. however there he is, happy, absorbed, unaware, living his day and life not knowing he's been furiously hated.
a hidden irony
2013-12-02
How ironic (and sad) it felt this unfortunate precipitation-free year when they pointed at those californian mountains from the car and said "look, that's the Sierra Nevada range" and they barely had any snow.

Ie, "Sierra Nevada" literally means "Mountain Range Covered by Snow" in Spanish

I wonder how many californians know that