Volumetric Materials

Below are some examples of complex volumetric materials.

Multiple materials can be interpolated based on a distance to another object, which may be another object visible in the scene, or one purely used by the material. In addition to the diffuse colour, blended materials may have different values for other properties like roughness, shininess and emission.

Lava Rock eroded_ring

The lava/rock material here is defined by the signed distance from a plane with the outer/positive area having the rock, the inner the lava. The outer material on the torus is defined by the distance from the pre-eroded torus.

The size of the blend region is easily adjusted. Effects like dithering to the blended region can be achieved simply by adding noise (e.g. 3D perlin noise) to object defining the blend region.

Red Gold Fractal Multi Colour KIFS

Fractals composed of multiple materials can be created by copying the transformed position during the fractals construction and using distances from it for the material interpolation.

I’ve recently also added support for textures. Textures can be used as the source of diffuse for a material or used for as input into other functions (e.g. using them to do displacements).

Light and Shadow

Some recent images generated with my in development Signed Distance Function editor:

Rock Garden Alien Structure

curled trophy

pillars shapes

The renderer supports such features as:

  • Compositing of multiple SDF-based objects in the same scene, including casting shadows between objects
  • Deferred rendering with physically based lighting
  • Multiple materials per SDF
  • Dynamic bounding volume computation for minimal over draw
  • Optional per light occlusion based shadows
  • Ambient occlusion approximation
  • Anti-aliasing

UPDATE: Added a couple of my newest images with some nice soft shadow effects.

Signed Waves

Some experiments on the theme of waves I did last year.

The idea with the first two images was to have the tubes in the background be displaced and twisted by the foreground object creating this wavy lines effect:

torus sphere

Below, an attempt to create fake ocean waves with by creating a sine wave from the distance of the Signed Distance Function of the objects. The second image shows the concentric rings of the distance from the nearest object used to create the waves:

water waves

Fractal Pottery

Below are some renders of pottery with KIFS fractal patterns I made a while ago with my in development SDF editing software.

These were made to explore ways of projecting fractal patterns onto other objects and also the potential applications for 3D printing.

bowl mug vase

Here are few examples of the quality of the editors mesh generation export option previewed in MeshLab:

mug-mesh2 mug-mesh

Looping Fractal Zooms

This concept came from seeing a perfectly looping animated GIF of a zoom into 2D fractal. While the animation really looped every few seconds, the self similarity of the fractal and the lack of an noticeable cuts produced the illusion that the zoom was going on forever.

This made me think about how I could use this technique with 3D ray marched fractals, and also the potential for generating other looping animations as well using ray marching (more to come!).

(GIF version: kifs_zoom.gif)

To achieve this effect I set up several different scaled copies of the same fractal positioned on top far corner of each other so that an animated camera zoom onto a particular spot of one would end with an identical image to the initial video frame. Then I just needed to make the animation loop for the infinite zoom effect.

What is kind of intriguing is that although the video is only 3 seconds long, if you follow a particular feature from when it appears it stays on screen about twice that long, since there’s really several copies of the same feature visible at once.

Here’s another variation of the same idea.

(GIF version: kifs_zoom2.gif)

You can view see the original two shaders in my Gallery on ShaderToy.

More Alien Vistas

Today I played around with a technique for combining different distance functions. It proved quite an effective way of producing interesting planet-like objects, among other things.

Here are a few variations I encountered through experimentation:

The middle panel looks like it would make a nice piece of album cover art.

Inventing On Principle Applied to Shader Editing

Recently I have been playing around with GLSL Sanbox (github), a what-you-see-is-what-you-get shader editor that runs in any WebGL capable browser (such as Firefox, Chrome and Safari). It gives you a transparent editor pane in the foreground and the resulting compiled fragment shader rendered behind it. Code is recompiled dynamically as the code changes. The latest version even has syntax and error highlighting, even bracket matching.

There have been a few other Webgl based shader editors like this in the past such as Shader Toy by Iñigo Quílez (aka IQ of Demo Scene group RGBA) and his more recent (though I believe unpublished) editor used in his fascinating live coding videos.

Finished compositions are published to a gallery with the source code attached, and can be ‘forked’ to create additional works. Generally the author will leave their twitter account name in the source code.

I have been trying to get to grips with some more advanced raycasting concepts, and being able to code something up in sandbox and see the effect of every change is immensely useful.

Below are a bunch of my GLSL sandbox creations (batman symbol added by @emackey):



GLSL Sandbox is just the latest example of the merit of software development tools that provide immediate feedback, and highlights the major advantages of scripting languages have over heavy compiled languages with long build and linking times that make experimentation costly and tedious. Inventing on Principle, a presentation by Bret Victor, is a great introduction to this topic.

I would really like a save draft button that saves shaders locally so I have some place to save things that are a work in progress, I might have to look at how I can add this.

Update: Fixed links to point at glslsandbox.com.

Remixing Distance Fields

Last year I got fairly obsessed with distance field raycasting and fractals. Recently a few developments in that field have rekindled my interest in the whole phenomenon.

Most of the people playing around with the Mandelbulb and it’s variants back in early 2010 were either mathematicians or graphics programmers, and while there were some technically impressive images and movies, they mostly weren’t that well composed in an artistic sense.

More recently the tools for creating these fractals have become popular amongst artists in on-line communities and some really amazing work is being produced. MandelBulb 3D seems to have become the most popular piece of software used to compose fractal images and movies.

Perhaps the single best feature of this program is the ability to shares the settings of your images by copy pasting a twitter-eque short string of hieroglyphics to other people online. Often people attach these settings as a comment on their image, so other people can reproduce these works or ‘remix’ them for their own creations. I’m particularly found of pieces by Hal Tenny like this. His pictures are inspired by a earlier image named ‘Spudsville‘ created by lenord that included the parameters used in the image, allowing spin off works to happen.

I’ve been working away on a new fractal explorer application of my own. I’ve experimented with various optimizations to the conventional GPU ray casting techniques and I think I’m making some progress.

These images are of the fairly new Kaleidoscopic IFS fractal published by Knighty on Fractal Forums composed with the application I’m working on:


Show Your True Colours

This last week saw the release of fairly significant update to Gource – replacing the out dated, 3DFX-era rendering code, with something a bit more modern, utilizing more recent OpenGL features like GLSL pixel shaders and VBOs.

A lot of the improvements are under the hood, but the first thing you’ll probably notice is the elimination of banding artifacts in Bloom, the illuminated fog Gource places around directories. This effect is pretty tough on the ‘colour space’ of so called Truecolor, the maximum colour depth on consumer monitors and display devices, which provides 256 different shades of grey to play with.

When you render a gradient across the screen, there are 3 or 4 times more pixels than there are shades of each colour, producing visible ‘bands’ of the same shade. If multiple gradients like this get blended together, as happens with bloom, you simply run out of ‘in between’ colours and the issue becomes more exaggerated, as seen below (contrast adjusted for emphasis):


Those aren’t compression artifacts you’re seeing!

Gource now uses colour diffusion to combat this problem. Instead of sampling the exact gradient of bloom for the distance of a pixel from the centre of a directory, we take a fuzzy sample in that vicinity instead. When zoomed in, you can see the picture is now slightly noisy, but the banding is completely eliminated. Viewed at the intended resolution, you can’t really see the trickery going on – in fact the effect even seems somewhat more natural, a bit closer to how light bouncing off particles of mist would actually behave.


The other improvement is speed – everything is now drawn with VBOs, large batches of objects geometry passed to the GPU in as few shipments as possible, eliminating CPU and IO bottle necks. Shadows cast by files and users are now done in a second pass on GPU using the same geometry as used for the lit pass – making them really cheap compared to before when we effectively wore the cost of having to draw the whole scene twice.

Text is now drawn in single pass, including shadows, using some fragment shader magic (take two samples of the font texture, offset by 1-by-1 pixels, blend appropriately). Given the ridiculous amount of file, user and directory names Gource draws at once with some projects (Linux Kernel Git import commit, I’m looking at you), doing half as much work there makes a big difference.

New Zealand Open Source Awards

I discovered today that Gource is a finalist in the Contributor category for the NZOSA awards. Exciting stuff! A full list of nominations is here.

I’m currently taking a working holiday to make some progress on a short film presentation of Gource for the Onward!.

Update: here’s the video presented at Onward!:

Craig Anslow presented the video on my behalf (thanks again Craig!), and we did a short Q/A over Skype afterwards. The music in the video is Aksjomat przemijania (Axiom of going by) by Dieter Werner. I suggest checking out his other work!