Coordinate mapping between sphere, disc and square

This paper, published by Martin Lambers in the Journal of Computer Graphics Techniques, compares different mappings between sphere and disc, and between disc and square. It is worth noting that the source code is available on the publication page.

Mappings between Sphere, Disc, and Square.

Abstract:
A variety of mappings between a sphere and a disc and between a disc and a square, as well as combinations of both, are used in computer graphics applications, resulting in mappings between spheres and squares. Many options exist for each type of mapping; to pick the right methods for a given application requires knowledge about the nature and magnitude of mapping distortions.

This paper provides an overview of forward and inverse mappings between a unit sphere, a unit disc, and a unit square. Quality measurements relevant for computer graphics applications are derived from tools used in the field of map projection, and a comparative analysis of the mapping methods is given.

Issues when rendering cones on a GPU

Eric Haines reminds in a blog article the problems that arise when rendering a cone, which are surprisingly tricky for such a seemingly simple task. A discussion on the topic also spawned on Twitter.

Illustration of texture mapping issues.

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.