Code Laboratorium

June 12, 2009

Sray raytracer under development

Filed under: projects — Nuclear @ 11:56 pm

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.

March 8, 2009

Raytracing Anamorphic Images

Filed under: hacks — Tags: , , — Nuclear @ 7:13 am

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):

January 11, 2009

Third OpenGL article

Filed under: articles — Nuclear @ 11:42 am

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.

November 5, 2008

Introductory OpenGL tutorials continued

Filed under: articles — Tags: , , , , , , , , — Nuclear @ 2:40 am

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.

September 3, 2008

Introductory OpenGL tutorials

Filed under: articles — Tags: , , , , , — Nuclear @ 8:12 pm

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.

August 15, 2008

Does vi rule or what?

Filed under: unix — Nuclear @ 1:52 am

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.
(more…)

March 23, 2008

Spacenav Project

Filed under: projects — Nuclear @ 4:54 pm

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.

February 3, 2008

3D VR Headtracking test

Filed under: hacks — Nuclear @ 2:53 am

After the first successful test of my webcam marker tracking algorithm, it’s now time for the real deal.

The purpose of my experiment, is to be able to detect the position of my head in 3D space, by processing the webcam-captured frames, locating the 2 markers, and then performing an inverse projection from 2D space to 3D space. That information can be used to set the view-point of a 3D environment to follow the motions of the user’s head, thus increasing the user’s immersion in the 3D world considerably. Simple, natural motions of the user’s head, are carried along in the virtual world, making the screen act as a window into that 3D environment.

Of course the point tracking code from my previous test is the same. However, I modified my tracking program to accept local connections from client programs that need to use that tracking information (x, y normalized position of each marker). Then I wrote a test program, that renders a simple OpenGL “world” (a bunch of balls and a couple of coordinate grids), and uses the marker positions from the other program, to calculate the user’s head 3D position, and set up the virtual camera to coincide with that.

Once again, you may watch the result at youtube. There’s still some way to go, and some details to be ironed out… I’ll keep you posted on anything new with this experiment :)

Oh, and of course, the code is always available at my subversion repository:

webcam marker tracking program (server): svn://nuclear.dnsalias.com/pub/compvis/cam_test
3D environment test (client): svn://nuclear.dnsalias.com/pub/compvis/vr_test
my webcam library (used by cam_test): svn://nuclear.dnsalias.com/pub/libwcam

January 21, 2008

First Headtracking Test

Filed under: hacks — Nuclear @ 2:05 pm

Finally, after some weeks of putting it off, I manged to sit down and write some code to talk to video4linux2 drivers, in order to get streaming video from a webcam.

My motivation for messing around with webcams and v4l ioctls, was a little experiment of mine. I wanted to write a program, that given video input from a webcam, is able to detect two “markers” attached to my head. This in turn is but a step in a slightly larger experiment I’m conducting, which I’m not going to go into right now.

So what this program does, is to detect the two markers in the video stream, and draw a blue rectangle around each marker. Check out this youtube video for a demonstration of my test program. Be warned: it’s rather silly :)

Also, I wrote a nice little v4l webcam library as part of this experiment. The code is available, as usual, in my subversion repository: svn://nuclear.dnsalias.com/pub/libwcam. The test program is also available here: svn://nuclear.dnsalias.com/pub/compvis/cam_test

December 13, 2007

Automatic Class Diagram Generation

Filed under: hacks — Nuclear @ 9:37 am

Some time ago, I needed a widget toolkit that would be able to draw widgets in an existing OpenGL window. However, I also needed it to be independent of the underlying graphics library, or event system, so I could use it in conjunction to both OpenGL, and another nameless 3D graphics API, that I was forced to use at the time for reasons I won’t go into right now. Anyhow, to cut the long story short, I started writing one such toolkit from scratch.

I opted for a fully object-oriented design, such as I rarely do lately, because OOP really makes sense for widget toolkits, and used C++ for the implementation.

Before long, I wanted to show what I was doing, to the rest of the team working on the project, for which I was writing the toolkit. And decided I should visualize the class hierarchy, as a quick overview of the widgets and their relations.
(more…)

Older Posts »

Blog at WordPress.com.