Released at FieldFX 2020, 4KB Executable Graphics (a single 4KB executable file generates this image, with no external data).

Download on Demozoo

Glass rendering

I’ve always loved the way glass refracts and reflects, and rendering it is sooooo much fun.

So, lots of glass. I havent done any comparisons, but my path tracer should produce pretty realistic results - it handles fresnel reflections, refraction, internal relection etc. There are a few sphere lights around the scene to produce caustics.

My last few pieces have been a bit heavy, resulting in a noisy image. I wanted to make something fast this time, so I could push quality in other ways, so instead of an SDF / raymarching setup I went with pure analytic intersections (i.e. calculate which object the ray will hit and jump directly there, instead of marching into the scene in a loop).

The downside: you’re stuck with simple geometry (or triangle based meshes - but that has its own set of problems).

So, I decided to stick with spheres, and for interest slice them up.


Having some meaning in a piece is important to me, and with only slices of spheres to play with it needed to be abstract.

I went with a transgender theme again (indicated by the colours - the stripes in the marble form a trans flag).

On the left, an initial pile of glass - interesting, but wrong. In the middle, the true shape is understood, and the order has been established. Finally, the parts come together in a cohesive whole, and a perfect sphere is formed.

This reflects the transformation process the identity goes through in some transgender people: recognising that the shape of the self is wrong, figuring out the true identity, and reconstruction in the true form.


Starting with the stage and lighting, I initially added a floor, a back wall (which is glossy so there’s some reflected light) and a couple of lights. This is a zoomed out view, with the floor set to checkerboard to make it easier to see what’s going on:


Depth of Field is actually turned right down, but I have another camera setting that makes the edges of the image out of focus - with a wider lens it becomes much more obvious than in the final image.

Zooming back in, the basic layout plan was to have 3 spheres:


Finally I took each sphere and split it into 5 slices, and moved the pieces about a bit.

This is the raw output from the renderer:


The final stage is colour grading, because I got my grading code working for this one :D I only used about 30% of the controls in the end, since it didn’t need much else.

My process for colour grading is to switch to YUV colour space (a single mat3 multiply), then work on luma and chroma seperately, then back to RGB.

The first step is to increase saturation:


I applied a cyan tint to remove the pink tint in the image. This lets the light colour shine through (see how the wall is more pink and the floor is more blue - the ambient colour is set to blue sky, red horizon):


I shifted the tint further into blue/green in the shadows, which looks like it’s gone too far:


But when the highlights are shifted more towards orange it balances that and gives a nice tonal range across the whole image:


The last thing I want to mention is the important of lots of light bounces with glass. Because there are so many potential paths through the surface (reflection or refraction at the surface, reflection or refraction at the exit, paths that hit multiple glass surfaces, and paths that take many internal reflections…) it’s essential to allow a large number of bounces per ray.

I settled on 25 in the end, here’s a video showing what happens as the bounce count goes from 2-25: