A GLSL version of smallpt

smallpt is a bare minimum path tracer written under 100 lines of C++, featuring diffuse, and specular reflection, and refraction. Using the detailed explanation slides by David Cline, I experimented porting it to GLSL on Shadertoy.

This proved to be an interesting experiment that brought a few lessons.

You can see the shader and tweak it here. By default it uses 6 samples per pixel, and 3 bounces, which allows it to run smoothly on average hardware. I found 40 samples per pixel and 5 bounces to give nice results while maintaining interactive framerate.

Path tracing, 40 samples per pixel, 5 bounces

Path tracing, 40 samples per pixel, 5 bounces

Update: since GLSL Sandbox has a feature, reading from the previous frame buffer, that Shadertoy is missing at the moment, I thought it’d be interesting try it to have the image converging over time. A little hacking later, a minute or so worth of rendering got me this kind of result: Given the effort, I am really pleased by the result.

Path tracing, 40 samples per pixel, 5 bounces

Path tracing, unknown number of samples per pixel, 7 bounces

A raytracer under a hundred lines of C++

On his website Kevin Beason presents a Monte Carlo ray tracer written with 99 lines of C++, generating a picture of a Cornell box with global illumination. Beyond the interesting experiment and the fact it can generate a binary of 4kB, I find very valuable the fact there are slides explaining all the code.

An image in the rain

A typhoon passed over Japan a couple of days ago, causing, at least in Tokyo, no more trouble than some serious rain and a couple of broken umbrellas. It was also an opportunity for photographers to catch some interesting scenes. This image in particular grabbed – as in, took and refused to give back – my attention.

Vertical version - 90度回転

With the kind permission of its author, Héctor García (aka. kirai / kirainet)

A real gem.

I have to disagree with the author when he argues the result is marred by the unbalanced composition (see the description on the Flickr page). I think on the contrary it makes the scene more vivid, more intense and in a sense, more fragile, bringing back the movement and life the high shutter speed froze away. It would have been so less interesting if it was perfectly aligned and balanced.

On a side note, also notice how the lines draw the attention on the model as the vanishing point is out of the frame. If it was within it, the feeling would be very different as the attention would drift toward the end of the street.

Last but not least, look at this light! Look at the warm reflections, the rim on the arm, the scattering through the drops…

This is exactly the sort of light I was referring to when I chose the title of this blog.

Update: Kirai made the following video out of some of the shots taken during that session.

Chaos Constructions 2011 invitation, by Quite

Not exactly recent news: last Summer the Russian demoscene group Quite presented this 64kB intro as an invitation to the demoparty Chaos Constructions that took place in Saint Petersburg. I find very inspiring the way it uses reflections and chromatic dispersion to craft the final images.

You can get the binary version from the Pouët page.

Epsilon, a 64k intro by Mercury

Last weekend the demogroup Mercury released at Tokyo Demo Fest the final version of their invitation to the upcoming Revision party: a 64kB demo called Epsilon. While the complexity of the scenes is very limited, the rendering, seemingly a raymarching shader, features a couple of very noteworthy real-time effects including ambient occlusion, reflexion (up to two iterations it seems) and refraction, caustics, and an hexagonal bokeh depth of field.