S-ray goes public

S-ray is a photorealistic off-line renderer I’ve been writting on and off for the past few months. It’s basically a monte carlo ray tracer using the photon mapping algorithm to simulate global illumination effects, such as indirect diffuse lighting and caustics.

So, it’s time to open up the code and continue development in the open. The code is available only through subversion at the moment, no official “0.1” release shall be made until at least the most important outstanding bugs are fixed. However, feel free to checkout the code and play around all you want.

The project is hosted at googlecode, and you can find it at: http://code.google.com/p/sray
As always, ideas, comments, or bug fixes are more than welcome.

s-ray: caustics through photon mapping

The main feature set that I had planned for my new s-ray renderer is almost complete. The renderer is now capable of producing caustics, that is light being focused on surfaces by curved mirrors or lenses (or otherwise transmission through refractive objects).

Standard recursive ray tracing is incapable of producing caustics; instead a two-pass algorithm called photon mapping is used. Photon mapping works by tracing random photons as they leave the light sources and bounce around the scene, finally ending up on various surfaces. The second pass works just like regular ray tracing, with the difference that on every ray hit, the density of stored photons around that point is used to estimate the amount of light that has arrived there after being reflected or refracted.

Here are a couple of images produced by s-ray, showing both reflective and refractive caustics:

reflective caustics

reflective caustics

refractive caustics

refractive caustics

Spacenavd 0.4


I just released version 0.4 of my spacenavd user space driver for 6dof input devices, which fixes some long-standing reliability and ease of use issues.

First and foremost, I cleaned up the code, which started initially as a hack, and ended as an unmaintainable mess. I’ve split and isolated the linux specific parts so that I may add support for other operating systems in the future (specifically I’d like to find the chance to add freebsd support soon).

I’ve also dropped the dodgy 30sec polling cycle to aquire the device if it’s disconnected, which had the effect of being able to use the device at some seemingly random time after plugging it in, and started using the KOBJECT_UEVENT netlink socket to get asyncronous notification of hotplug events from the kernel. Now the device lights up and is ready to use immediatly upon plugging it in the USB port.

More importantly, I lifted the responsibility of notifying the daemon that X has started and it may connect and start listening for X11 clients from the user. By using the excellent inotify API to detect when the X server’s socket is created in /tmp/.X11-unix, the daemon is now able to wake up and connect to the X server automatically as soon as it’s started up.

And finally, now spacenavd actively grabs the device when it starts, which solves the problem of the X server trying to use it as a mouse, without having to resort to messing around with the user’s HAL config files, to make hald ignore it.

To celebrate this milestone release, the free spacenav project now has a newly redesigned web site, which may help attract more attention compared to the previous plain-text web page. Thanks go to cybernoid for the new web site.

Sray raytracer under development

My new ray tracer is starting to look good, even though there’s still quite a lot of work to do before its first public release.

Anyway, I was bored today, so I thought I’d upload a video of an early test. It’s a test of the keyframe animation system, and of the motion blur effect produced through monte carlo (distribution) ray tracing, when a non-zero shutter speed is selected.

sray motion blur test
Here’s a link to the video on youtube.

Raytracing Anamorphic Images

A long time ago, I stumbled upon a couple of strikingly odd images on Jim Arvo’s web site, which are apparently called “anamorphic”. The idea behind an anamorphic image, is that it’s distorted in such a way, that its true shape can be seen only when viewed in a particular manner. In the case of these images, you’re supposed to print the image and place a highly reflective cylindrical object, such as a chrome pipe, at a specific marked location in order to see the geometric shapes correctly.

I kept the images back then, with the purpose of either finding an appropriate cylindrical object, or raytracing them to see what they look like, but for some reason I’ve forgotten all about them until I accidentally found them again yesterday, in a dusty corner of my filesystem.

So I decided to hack some code to add perfect (x^2 + y^2 = r^2) cylinder primitives to my raytracer and do a couple of renderings with those images texture-mapped onto a ground quad (I could just do the same thing with another raytracer such as pov-ray but where’s the fun in that?).

So anyway here are the anamorphic images along with the renderings (click on the images for the full rendering):

Third OpenGL article

The third part of my OpenGL graphics programming series for the greek linux format magazine is available for a few days now. So make sure you don’t miss the January-February issue of linux format, if you wish to learn about texture mapping. A technique which, when used properly, can greatly increase the realism of our 3D objects, at virtually no extra processing cost on modern graphics hardware.

This time the accompanying source code for the examples is not included in the magazine’s dvd, so go grab a copy from my website.

Finally, I forgot to mention that the first of these articles is now available for download in PDF format.

Introductory OpenGL tutorials continued

Just a short notice, the second part of my “introduction to 3D graphics with OpenGL” series should be available as we speak. This time, we’ll perform the full set of transformations that we described while discussing the rendering pipeline in the previous issue. We’ll use the matrix stack to separate the model from the view parts of the modelview matrix, and render multiple objects properly. And finally we’re going to explain the mathematical model of shading and illumination, and we’ll apply lighting to our object in order to increase the realism of our simple 3D environment tremendously.

So, go and grab a copy of the november-december issue of the greek linux format magazine, and let me know what you think. As always I look forward to your comments, suggestions, corrections, etc.

By the way, due to popular demand, I will upload the first tutorial of the series in a couple of weeks, after the previous issue of linux format goes out of circulation.

Introductory OpenGL tutorials

I recently started writing a series of introductory tutorials about graphics programming with OpenGL, for the greek linux format magazine.

The articles are written for the complete begginer, who hasn’t had any previous exposure to graphics programming. However, familiarity with the C programming language is definitely required.

What I’m aiming for, is to thoroughly explain the underlying theory, in order to provide a stepping stone for someone who would like to eventually delve deeper into graphics algorithms, rather than just present raw examples for doing this and that with OpenGL.

In any case, the first article of the series will be published in the september-october issue of the greek linux format magazine, which should be available during the next few days. Any feedback, is greatly appreciated.

Does vi rule or what?

I get really excited each time my favourite development environment (UNIX + vi), lets me perform a task of insurmountable tediousness, in a split second. So much in fact, that I can’t hold myself from sharing it with others. And since updates on this blog are scarce anyway, I decided to write about it.
Read the rest of this entry »

Posted in unix. 2 Comments »

Spacenav Project

A few months ago, I bought a really nifty input device called “space navigator”. These devices, produced by “3dconnexion”, a logitech subsidiary, enable the user to intuitively manipulate a 3D object or viewport with 6 degrees of freedom (thus commonly refered to as 6dof devices). For instance, one could rotate around a 3D object while at the same time zooming in and slightly panning to the side to inspect a detail hidden there, all in simple fluid motions produced by manipulating a weird knob-looking thing.

3Dconnexion does provide a linux driver, called 3dxsrv, in the form of a user-space daemon. Applications talk to tha daemon and get motion, and button press events from the device, through an X11-based protocol. The problem is: it’s proprietary, and it doesn’t work. Either one of these is problematic in its own right, but the combination demands drastic measures. Thus, I decided to write a free drop-in replacement of the daemon myself. The daemon is called spacenavd, it’s compatible and transparent to any application that used to work with the 3dconnexion driver, and it also provides an alternative non-X11 interface through UNIX sockets.

3Dconnexion also provides a library, called magellan, which is supposed to make interfacing with the daemon easy. Unfortunately, the library is also proprietary (the code is there, but with nasty restrictions in the license text), and is utter crap API-wise. So, I decided to replace the library too, with a free library called libspnav. It’s got an orthogonal much easier to understand and use API, and supports both spacenavd, and the 3dconnexion driver. When working with spacenavd, it can optionally use the simpler alternative interface which doesn’t require an X server to be running or any Xlib code in the application. A magellan source-compatibility wrapper is also provided, to easily port existing applications to the free replacement library, thus freeing them from the shady licensing terms of magellan with zero effort.

The whole project is called “free spacenav”, not very imaginative really, and I just released version 0.2 of both the daemon and the library. You can find everything, and more details on the project itself, at the spacenav website. The daemon is released under the terms of the GNU GPLv3, while the library is available under the 3-clause BSD license.

Design a site like this with WordPress.com
Get started