2008-07-08 21:47 D012345
A video I made earlier this year:
Download links:
Which reminds me, I need to move this blog to my main website so that I can use <embed> tags...
A video I made earlier this year:
Download links:
Which reminds me, I need to move this blog to my main website so that I can use <embed> tags...
ray42 was nice as it was, but I got fed up with having to recompile each time I wanted to render a new scene, and C++ isn't a particularly friendly scene description language. So I'm now using tolua to make a Lua package from the core of ray42, and it seems to work ok.
This code:
require("ray")
require("materials")
local s = nil
for x = -1, 1 do for y = -1, 1 do for z = -1, 1 do
local m
if x*y*z == 0 then m = gold else m = cyan end
local t = sphere3(m, 0.5):translate(v3(x,y,z)*1.5)
if s ~= nil then s = s + t else s = t end
end end end
s = s:transform(rotate3(0.3,1,2) * rotate3(0.3,0,2) * rotate3(0.3,0,1))
local l = Lights3:new(rgb(0.25,0.25,0.25))
l:add(v3(-3,0,0), rgb(0.5,0.5,0.5))
l:add(v3( 3,0,0), rgb(0.5,0.5,0.5))
l:add(v3(0,-3,0), rgb(0.5,0.5,0.5))
l:add(v3(0, 3,0), rgb(0.5,0.5,0.5))
l:add(v3(0,0,-3), rgb(0.5,0.5,0.5))
l:add(v3(0,0, 3), rgb(0.5,0.5,0.5))
render3(s, l, 788, 576, 4/3, 2)
generates this image:

One small tip when using tolua with recent versions of g++: activate the -Wno-write-strings flag to avoid drowning in a flood of:
warning: deprecated conversion from string constant to 'char*'
It is quite boring writing wrappers for ray42's C++ template classes because tolua doesn't seem to understand templates, maybe I should be using tolua++ or some other tool entirely.
I've been rewriting ray4 from scratch in C++, extending it to arbitrary dimensions, providing various Constructive Solid Geometry operations, trying out procedural textures, playing around in general. It's way too slow though, the ray tracing algorithm is completely naive and tests every object against every ray, no oct-tree optimisations here. But it seems to generate some pretty pictures, or even animations, if you're prepared to wait a while.
So far I've tested with 3D and 4D, and it seems to work to some extent.
Meanwhile, way back in 2006 I was trying to make a compound of five cubes, well it turned out my maths was wrong - instead of (Scheme):
(define A (* 90 (atan (* 2 (- 0.5 (/ (- (sqrt 5) 2) (- 3 (sqrt 5))))))))
I should have been using (C++):
double a(std::atan(2.0l / (1.0l + std::sqrt(5.0l))));
Now the corners line up perfectly:

Hooray!
Pd (aka Pure-data) is a real-time visual programming environment primarily used for multimedia processing. Lua is a powerful, fast, light-weight, embeddable scripting language. pdlua is a Lua embedding for Pd.
This release adds new features to interact with Pd's [value] and [table] and also better support Lua's require() functionality.
pdlua-0.5 (2008-06-18), changes since pdlua-0.4 (2008-03-26):
Note: if pdlua is compiled for pd >= 0.41 it won't load in pd < 0.41, and if pdlua is compiled for pd < 0.41 and is loaded in pd >= 0.41 it will exhibit table-related 64bit bugs.
Get a tarball here: pdlua-0.5
Or via SVN:
svn co https://devel.goto10.org/svn/maximus/releases/pdlua-0.5
Development version (may be broken at times):
svn co https://devel.goto10.org/svn/maximus/pdlua
buildtorrent is a simple command-line .torrent file creation tool.
Bug fixes in buildtorrent-0.7:
Download the release tarball: buildtorrent-0.7-1.tar.gz
Or check out the development sources from SVN:
svn checkout https://devel.goto10.org/svn/maximus/buildtorrent buildtorrent
See also: buildtorrent homepage.
Pd (aka Pure-data) is a real-time visual programming environment primarily used for multimedia processing. Lua is a powerful, fast, light-weight, embeddable scripting language. pdlua is a Lua embedding for Pd.
This is primarily a bug fix release, but also has some incompatible API changes (which should hopefully resolve some Pd vs Lua name clash issues in the long term).
pdlua-0.4 (2008-03-26), changes since pdlua-0.3 (2007-12-02):
Thanks to Frank Barknecht for the additional examples.
Get a tarball here: pdlua-0.4
Or via SVN:
svn co https://devel.goto10.org/svn/maximus/releases/pdlua-0.4
Development version (may be broken at times):
svn co https://devel.goto10.org/svn/maximus/pdlua
You might remember my project GraphGrow which started as a SVG plus ECMAScript system for designing Graph-Directed Iterated Function Systems, then developed into a comand-line video renderer written in C for higher performance.
The project has been dormant for some months, but today I resumed work on a new facet : a realtime preview system using Pd, Gem and Lua. It's currently rather rough/hardcoded - you have to make a new patch for each structure, and there is currently a key piece in the puzzle missing (conversion from [gemlist_info] to a format that the [graphgrow] scene exporter understands).
On the plus side, the realtime rendering (implemented with OpenGL texture feedback) makes it really quick to try out different ways of animating the fractals, and once the exporter is working it should be possible to record animations and later render high quality videos with graphgrow-engine.
Enough talking, some screenshots:


Patches are in my SVN under "2008/gg/", if you're curious.
UPDATE : I got the Gem->GraphGrow bridge working, apart from a tiny issue (GraphGrow output is upside down compared to Gem output) that should be easy to fix. Screenshot.
I'll be playing at the Linux Audio Conference Club Night this coming Friday, 8-til-late at Studio 672 in the basement of Stadtgarten.
UPDATE Two videos from my set are now online (download links are in the left sidebar):
External - the visuals I was projecting (nb: I made a typo in the filenames, oops).
Internal - what was on my screen (nb: probably useless to watch anything other than the MPEG2 due to tiny and important details in the image).
If someone knows any way to make multi-angle DVDs using a Free Software tool chain, please let me know!
Many thanks to the organisers of LAC, it was a great experience.
I uploaded some old videos I made during the last 3 years or so. Without further ado, here are the links:
The process:
Some notes:
There must be a better way to do this. Comments appreciated.
I stumbled across Susan Roberta Curtis' 1982 MSc thesis: Saturation and Luminance Control in Color Image Processing. This defines an LC1C2 colour space with some interesting properties that make it more useful than either RGB or YUV.
RGB is a pain at the best of times, but YUV isn't much better. The problem with YUV is that the "constant saturation curve" is not a circle, but a skew ellipse, which makes setting absolute saturation very tricky. This is generally shown best on a vector scope:

The constant saturation curves in the LC1C2 colour space seems to be more circular than in YUV, I haven't measured it yet but the results are pleasing. Here's a fragment of GLSL code that sets the saturation of an RGB colour:
// inputs
vec3 in;
float saturation;
// outputs
vec3 out;
// conversion matrices
mat3 rgb2lcc = mat3(
0.299, 0.621, 0.080,
0.498, -0.442, -0.056,
-0.162, -0.336, 0.498
);
mat3 lcc2rgb = mat3(
1.0, 1.407, 0.0,
1.0, -0.677, -0.236,
1.0, 0.0, 1.848
);
// saturation bashing
vec3 lcc1 = in * rgb2lcc;
float l = lcc1.x;
float c1 = lcc1.y;
float c2 = lcc1.z;
float sat = saturation/sqrt(c1*c1+c2*c2);
vec3 lcc2 = vec3(l, sat*c1, sat*c2);
vec3 out = lcc2 * lcc2rgb;
Next step is to investigate LC1C2 more scientifically.
Following on from hypercube (which renders a 4D cube, aka a tesseract), I've been working on hyperx, a generalisation to arbitrary dimensions and structures. To this end, I switched from (very slow) CPU based rendering to (very fast) GPU based rendering. Not all is accelerated so far, but the polygon rasterization is several orders of magnitude faster. To get the colours looking good, I'm using GLSL, with a fragment shader that manipulates the rendered image.
hexeract is a temporary branch of hyperx to experiment with, currently it renders a 6D cube. It's heavily based on the HelloGPGPU example (GLSL version) from GPGPU. Hopefully Pd's Gem package for OpenGL will be fixed so I can used shaders in it - just seems to be a matter of using GLEW in the right way, or not converting GLint to float and losing precision, or something.
Some example output is here: hexeract undergoing 3 orthogonal rotations (3.3MB)
Source code is in SVN:
svn co https://devel.goto10.org/svn/maximus/hyperx/hexeract hexeract
Undecidable :: some old tunes from 2001 that I found on a hard disk image.
Periodic two-dimensional image modulation. Scanlines extracted and used as wavetables for oscillators. Audiovisual drone.
Direct download links:
fbsetbg (a desktop background/wallpaper setter from the fluxbox project) has options for random wallpaper selection from a directory, and tiling wallpaper. Unfortunately it doesn't seem to support both at the same time.
I found a solution, however:
#!/bin/bash feh --bg-tile $1
wpsetters /home/claude/bin/wallpaper random|/home/claude/share/wallpapers/|:0.0 random|/home/claude/share/wallpapers/|:0.1
session.screen0.rootCommand: fbsetbg -l session.screen1.rootCommand: fbsetbg -l
And then enjoy your random tiled backgrounds. If you don't have a dual head setup, then just remove the stuff relating to the second display, I don't know if its harmless or not to leave it there.
Currently I'm using some created with GridFlow: Cycle Tile. Not quite perfectly seamless, however, need to fix that and rerender them. EDIT: should now be seamless, was a problem with dividing too soon creating rounding errors...
I got sick of having to mount my vfat USB flash drive stick as root, and chmod/chown files after moving them as root. So I investigated udev. Turns out I don't need to write a udev rule, but just add a line in /etc/fstab:
/dev/disk/by-id/usb-USB_DISK_Pro_AA04012700008623-part1 /media/pen/ vfat user,noauto,uid=claude,gid=claude,dmask=077,fmask=177 0 0
So I was toying with using Graphviz to render polytopes (higher-dimensional generalisations of polygons and polyhedra). I quickly got bored writing .dot files by hand, and switched to the Haskell programming language.
Here's some code that generates a .dot file containing the vertices and edges of a cube of arbitrary dimension:
> module Main where
>
> import System(getArgs)
>
> type Node = [Bool]
>
> edges node = filter (\(u,v) -> u /= v) $ zipWith (\n b -> (n, zipWith (||) n b)) (repeat node) bits
> where
> bits = map bit [0..(n-1)]
> bit b = map (== b) [0..(n-1)]
> n = length node
>
> nodes 0 = [[]]
> nodes d = concatMap (\n -> [False:n, True:n]) ns where ns = nodes (d-1)
>
> main = do
> args <- getArgs
> let d = read (head args) :: Int
> e = concatMap edges (nodes d)
> putStrLn ("strict graph Cube" ++ (show d) ++ "D {")
> putStrLn " node [label=\"\",shape=\"circle\",width=0.1,height=0.1,fixedsize=true,style=\"filled\"];"
> sequence (map printEdge e)
> putStrLn "}"
> where
> printEdge (u,v) = putStrLn (" " ++ showNode u ++ " -- " ++ showNode v ++ ";")
> showNode n = "p" ++ map showCoord n
> showCoord True = '1'
> showCoord False = '0'
And here's the output for a cube of 5 dimensions, rendered with neato from Graphviz:

I also wrote code for the cross polytope (in 3 dimensions it's an octahedron):
> module Main where
>
> import System(getArgs)
>
> type Node = Int
>
> edges d nodes node = filter (\(u,v) -> u < v && u /= (v + d) `mod` (2 * d)) $ zip (repeat node) nodes
>
> nodes d = [0..(2*d -1)]
>
> main = do
> args <- getArgs
> let d = read (head args) :: Int
> n = nodes d
> e = concatMap (edges d n) n
> putStrLn ("strict graph Cross" ++ (show d) ++ "D {")
> putStrLn " node [label=\"\",shape=\"circle\",width=0.1,height=0.1,fixedsize=true,style=\"filled\"];"
> sequence (map printEdge e)
> putStrLn "}"
> where
> printEdge (u,v) = putStrLn (" " ++ showNode u ++ " -- " ++ showNode v ++ ";")
> showNode n = "p" ++ show n
The output from neato is ugly for this structure, but with circo it looks pretty good:

The simplex is left as an exercise for the reader. These 3 (cube, cross, simplex) exist in all dimensions, when I refind my copy of Coxeter's opus I'll attempt code for the others that only exist in certain dimensions.
buildtorrent is a simple command-line .torrent file creation tool.
New features in buildtorrent-0.6:
Download the release tarball: buildtorrent-0.6-1.tar.gz
Or check out the development sources from SVN:
svn checkout https://devel.goto10.org/svn/maximus/buildtorrent buildtorrent
See also: buildtorrent homepage.
Once upon a time, in a land far far away, in a house, three intrepid adventurers disembarked from their longboat and set foot on strange territory. Some time later, archaelogists found an ancient platter that seemed to be inscribed using a primitive form of sound recording.
Improv musics.
pdlua is a Lua embedding for Pd, allowing you to write Pd classes/objects using the Lua scripting language.
New features in pdlua-0.3:
You can download the stable release tarball: pdlua-0.3
Or, check out the development version from SVN:
svn checkout https://devel.goto10.org/svn/maximus/pdlua pdlua