Archive for the ‘Graphics’ Category


Wednesday, December 3rd, 2008

Blogging : Never before have so many people with so little to say said so much to so few

Never before have so many people
   with so little to say
      said so much
         to so few.

My desktop wallpaper

Friday, April 27th, 2007

I couldn’t resist! 🙂

Ohh, Shiny!

Saturday, January 27th, 2007

I have always had a strong interest in creating computer graphics. There are a couple of approaches to image generation. One approach is to create software that puts artist tools at the disposal of user, and relies on the artistic talents of the user to create a picture. The other approach applies mathematical modeling to how light propagates through a scene and the software crunches numbers until you get a picture out the other side of the processing pipeline.

The second approach, known as Raytracing is what Hollywood uses to create the photo-realistic special effects in movies. Raytracing involves creating mathematical models using simple geometric objects (spheres, planes, polynomial surfaces, triangles, etc) and building them up (like Lego bricks) to form a scene. You describe the materials all these primitive objects are made from, and how they reflect/absorb light, along with describing where all the lights in the scene are located. The software crunches light rays and voila you have a picture.

I was bored. I went back to a book that I bought in 1993 – “Photorealism and Raytracing in C” by Stephen B. Coy, Mark Finlay, Christopher D. Watkins. I pulled the mathematical formulae from there, whipped up some Java code. I would term this “version 0” of the software. It supports:

  • Ambient, diffuse and specular lighting models
  • Coloured lighting
  • Two primitives: spheres and planes
  • Basic procedural textures

Procedural textures are interesting: instead of the various materials that the primitives are made from being a flat base colour, you rely on some code to tell you what their colour should be at any given position. In the first example the procedural texture generated a checker-board pattern on the infinite plane, and in the second example a very basic implementation of Perlin noise was used to create the smoky effect. Not bad for a “version 0” piece of software!

There’s a lot left to do before the software is even in a state I would like for someone else to see or get their hands on. I am torn: the mathematical description of a sphere can be generalized and used to describe a cylinder and from there, a cone. More general still to the far more abstract “quadratic surface”; one reasonably simple change and I can support a whole class of new primitives! What the software doesn’t do yet is reflection or refraction – all the primitives are shiny plastic right now – what I want to do is model light bouncing around (metallic objects) and passing through (glassy objects).

Still, I am very happy. My physics class taught me that if you mix red and green lighting, and a surface reflects both, then you will see yellow. In the final screenshot you can clearly see the shiny silver ball now reflects both the colours, with a band of yellow at the top. So, upward and onward toward the goal of “version 0.1” where more primitives are supported. Then I’ll get to “version 0.2” where reflection and refraction are modeled. Watch this space!