June 6, 2016

My Project has moved...

Hi all, After some years of silence, my project has been revived, but I will not use this blog any further. Please take a look at http://mlaban.home.xs4all.nl for a peek into the status of my ray tracer. See you there! Marinko

February 27, 2010

Sprint 4: Colour Spaces

Alas, another 4 months gone...too little time, too much to do...

Well, at least I have my Colour Space pretty much done, which now enables me to plot pixels in a neutral colour space.

My current colour space uses Floats to represent a spectrum, which is used to store an RGB triplet by default...nothing fancy here, I guess. But it enables me to extend it to non-RGB spectra in the future, in case I would like to do so. Also a function to map an RGB triplet onto an X11 colour parameter has been developed. Finally some supporting functions to construct a colour from 3 floats, add and multiply two RGB triplets.

In the future I exect to need a few more functions, like clamping and mapping RGB triplets as to support HDR and Tone Mapping in the future...I have prepared my Image Maps to allow for storage of the actual RGB triples as well to enable post-processing in some shape or form of all pixels.

The last bit I did was implement Kevin Suffern's example function to demonstrate aliasing. The function being sampled = (1 + sin(x^2 * y^2) / 2. The picture below shows this function in the range (x,y) in [0,4].



The picture below shows the function in the range (x,y) in [0,10]. Dramatic difference, huh? And you should also realized that I used 4 "samples" per pixel, so a single sample would even look worse...



So the next sprint will be focussing on an internal Object Data structure, as to store 3D objects. I will focus probably on a simple structure first, and hopefully doing some real ray tracing of spheres and planes...

Light makes right!
Marinko

November 1, 2009

Sprint 3: The basic 3D Math

Pffff...this sprint has taken way too long...Holidays, professional career (yes, I have to work for a living...) and a crashed development environment has slowed me down big time...So I had to rebuild my development environment from scratch...luckily, I could retreive a backup of my sources so far...but still, it delayed me big time...

Anyway, I have completed the utility data types & functions around vectors, points, normals and matrices. I based all the functions on the tables described in Kevin Suffern's book "Ray Tracing from the Ground Up",but I decided to make a Vector3D, Point3D and Normal3D as three different private types. Kevin Suffern uses a single object that can represent all three, but he indicates that that is actually badprogramming practice. I tend to agree with him on this, so I decided to follow good programming practice, and we'll see when we hit problems...sometimes bad programming is more efficient or easier...

Since Ada 2005 does not support overriding assignment, I will probably have to develop some additional utility functions to do something like:

Vec1 := Point1

This would be perfectly legal in Kevin Suffern's approach, but not in mine, since they are of a different type. So I would hav to write a function like:

function Point3D_to_Vector3D (pnt: in Point3D) return Vector3D is
Result: Vector3D;
begin
   Result.x := pnt.x;
   Result.y := pnt.y
   Result.z := pnt.z;
end Point3D_to_Vector3D;

Similar functions would have to be added for Point to Normal, Normal to Vector and alike...But I have not written these, as I am not sure if I would ever need them. I also wrote an Inverse function to calculate the inverse of a Matrix3D. Kevin Suffern uses the "create by inspection" method to build up the inverse out of the basic affine transformations. I decided to use the more mathematical approach. Furthermore, a lot of overrides have been written to allow vector & matrix manipulations like:

V1 := Inverse(M1 * M2) * V2;

Now I will start working on the color class, so I can plot pixels in a generic color space. This should be a fairly short sprint, I hope...

Until next time,
Marinko

July 18, 2009

Sprint 2: Plotting Pixels!

OK, 2nd sprint is basically done...the goal of this sprint is to have a very simple set of functions in which I could open a window and plot a pixel in any RGB colour. My requirements were very basic, as I do not want to "waste" time on a very fancy GUI. In fact, a ray tracer could write its result to an output file,and could do withhout any GUI at all. But that has a major drawback: There is something magical about looking at a screen and seeing your picture appeaing pixel by pixel...

It also allows you to stop a long-running trace when early in the picture you discover a mistake or bug, and you obviously want to correct it without waiting for the finalpixelto be finished.
Looking way into the future, I also wanted to allow for some multi-threading capabilities, and allow multiple pictures to be calculated in parallel. Hence the ray tracer should support multiple windows to be opened and painted to.

As an interface, I was looking for something very simple. Just opening a window, plot a poixel, and close the window. Obviously, any pixel needed to be stored in some kind of bitmap structure as well,since you want to save the picture at a later stage. I decided to use a separate bitmap for the calculated pixels and not use the one used by the window system. This allows me to stay away from any dependancy issues with the operating system, and avoids any requirements on the windows event handling and refreshing. As I said, I don't want to dwell on the GUI too much...

All in all, I decided to use a protected object type in my Ada 2005 sources. I would like to reference the book "Programming in Ada 2005" by John Barnes. I took all the stuff I used from there. For those interrested: This is the package specification of my Windows handler. It is based upon the X11ada library by Mitch Gart, with some modifications by Srini.

-- Package X11Windows
with X;
with X.Xlib;
with Interfaces.C;
with Ada.Text_IO;

package X11Windows is

MAX_XSIZE : constant Integer := 1280;
MAX_YSIZE : constant Integer := 1024;

type FrameBuffer is
array (Interfaces.C.unsigned range <>,
Interfaces.C.unsigned range <>)
of Interfaces.C.unsigned_long;

protected type X11Window (XS, YS : Interfaces.C.unsigned) is
procedure OpenWindow;
procedure CloseWindow;
procedure ProcessEvents;
procedure RedrawWindow;
procedure DrawPixel (Xc, Yc : in Integer; Colour : in Integer); private
XSize : Interfaces.C.unsigned := XS;
YSize : Interfaces.C.unsigned := YS;
PixelMap : FrameBuffer (1 .. XS, 1 .. YS);
GCon : X.Xlib.GC;
Screen : Interfaces.C.int;
Display : aliased X.Xlib.XDisplay_access;
Win : aliased X.Window;
GCon_Vals : aliased X.Xlib.XGCValues;
Event : aliased X.Xlib.XEvent;
end X11Window;

end X11Windows;


The next sprint will focus on the development of the basic mathematic functions around vectors and matrices. Of course, if you're interrested in the full code of the package above, let me know...I'll send you the sources...

C-Ya,Marinko

June 22, 2009

The 1st Sprint done!

3 weeks from starting the blog, I finally got something done...here's what happnened so far...


To kick off the project, I had to settle on 4 issues first. In no particular order, these were:


1. Name the project

It is always good to name your project, even a personal, single project. As other projects may appear on the horizon (I need a largel life span, I am afraid...), I can separate everything...


So guess what? For my master thesis at Delft University in 1989, I wrote a distributed ray tracer, and called it DART, as in "Distributed Accelerated Ray Tracer".I guess this name is a good start, and I have picked the project name to be M-Dart, where M is the first letter of my name...

2. Decide the project approach

I was going to use the word "Project Management", but that is silly...I am the only person working on the project, so what's to manage? And since there is no commitment in time, quality and costs, I don't need anything heavy. But what do I need then?

- to be able to set tangible goals and break it down in overseeable chunks
- to roughly keep track of progress and hours spent and planned
- a place to prioritize to-do items, future ideas and issues to tackle, so I don't forget them


Because of my participation in various projects using Scrum methodology, I decided to do something in the spirit of Scrum and Agile:


- Maintain a Product Backlog (PBL) with Items I need to do
- Plan PBL Items in a Sprint (but I am very flexible in the size & time for a sprint)
- Let each Sprint deliver something tangeable, if possible
- Execute the Sprint and review at the end
- Write something on the Blog about the sprint results so far

3. Decide the Programming Language

Now this was a tricky one...I have a great deal of experience with C and a bit with other languages, like Pascal, Fortran, Visual Studio (primarily VB) and some others...yes, I'm old school, I guess...But I really wanted to use a neat OO language, which would also help me in getting back on track in case I cannot work on the project for some time.


C would be out of the question, since it does not support OO. C++ seems to be mainstream OO language for ray tracing, but I don't like it...too much freedom to bypass stuff and error-prone, due to having its foundation in C...As I have followed lectures on Ada'83 a long time ago, I decided to investigate this a bit more. After doing quite a bit of reading up, I landed on Ada 2005 as my language of choice.

4. Decide the programming environment

This was an easy one...Since Adacore recently released a full Ada 2005 compiler (GNAT) and a nice IDE, called GPS, I decided to go for this one. GNAT and GPS is available under a GPL license from http://libre.adacore.com/libre and a professional version can be purchased at http://www.adacore.com/. As the project has little real budget, but spare time, a GPL-licensed development environment like this is just was I needed...


As I am old school, I decided to build a Linux environment and install GNAT 2009 in there. The Linux version is pretty arbitrary, but I decided to use OpenSUSE 11.1. Not for any particular reason though, as most Linux flavours would have done nicely as well...

So my 1st sprint was actually making all the above happen...I now have a development environment up & running and I can start doing something useful! Which is planning the next sprint...The main bits on this sprint would be:


- Getting more familiar with Ada 2005 and GPS
- Develop a simple GUI that allows me to open a window and draw pixels of any colour in it

Keep you posted,

Marinko

June 6, 2009

I finally started...

Ok, it has been quite some time that I have been thinking about writing a book on Ray Tracing...and I finally started !!!

I wrote my master thesis (Technical University Delft, 1989) on Distributed Ray Tracing, but my professional career moved me away from Computer Graphics and serious programming...But it always was present in the back of my mind and I couldn't resist trying to keep up with developments in the past. The Internet proved to be a massive source on that...

But it was the book "Ray Tracing from the Ground Up" by Kevin Suffern (see http://www.raytracegroundup.com for his web site) that finally pushed me over the edge to start my own project...

Do I want to be commercially succesful with it? No...
Do I want to publish the book? Maybe...if it is good enough...
Do I want to sell the software I will write? No...free for everyone to use it

So why doing this? Well, mainly just for the fun of it, but also to see if I can actually do this...I would like to leave this world with something tangeable that will help other people in having fun with ray tracing and computer graphics...

I decided to create this blog to keep everybody (anybody ???) up-to-date with the developments, although I expect it will take a couple of years...

Hopefully, it will also be a medium for people to comment, exchange idea's and check results...

We'll see...I hope to give some more details on the project this week, e.g. preliminary scope, development tools I plan to use and so on...

Have fun!
Marinko