RandI: Random Image Generation

In some ways I’m an artistic person.  I’m not saying I’m good at producing ‘art’; but I am driven to do it – often in bursts.  While I’ve felt that ‘need’ for a while now, lack of time and energy have meant I’ve been doing pretty much nothing about it.

Recently, however, I actually started on an idea that has been kicking around in my head for a long time, and is actually progressing in ways I’m happy with.  The result, so far, is a basic program I call RandI (Short for Random Image Generator – and with any double entendres you care to add).I’ve had trouble explaining the concepts behind the program to friends, but I’ll try again here.

The basic concept is to produce a random image.  I’ve been watching the amount of work that many people are putting into procedural generation of ‘known objects’, and at the same time, noticed how sometimes random things can turn out things that are pretty (if not recognisable).  Of course, random things can also turn out things that are an ugly mess.

So, the first concept is “random”.  The second concept is pretty much the opposite of that: control.  Once I’ve found something I like in the images, I want to be able to reproduce that.  Whether it’s an object, a pattern, a background or something more.  The good thing is, that I’m doing this on a computer, so I can use a property of many random number generators: they’re not really that random.

Random numbers generated by computers are often referred to as “pseudo random” numbers.  Since they’re generated by an algorithm, then if you start with the same input to that algorithm, you’ll get the same output.  A random number generator is often given a starting number/position called the “seed”, and if you use the same seed for the same algorithm, then you’ll get the same stream of numbers out of the generator.

The upshot of this, is that I get a stream of numbers that are random enough for my purpose (at least, so far), but I can start those numbers anywhere I want.  So if, for example, I find that with a seed of “803” that a pretty object is generated at the 20743th random number, then I can simply tell my program to start its numbers there, and regenerate that object.

I started playing with various ideas for how I produce the graphics, and quickly decided to use the POVRay ray tracer.  There are several reasons for this:

  • POVRay takes care of the ‘drawing’ side of things.  I tell it to place a certain object with a certain pattern at a certain position and lit by certain lights, and it produces a picture for me.
  • POVRay is driven by its own programming language, a language that describes the scene you wish to create.  This is perfect as the output of my program. My code generates POVRay code, which I then feed to POVRay.  I’m a coder, so this makes perfect sense to me.
  • The amount of things you can do within the POVRay scene language are incredibly large.  I can have all kinds of objects, with all kinds of patterns on them. I can make them look like metal, or glass, or wood, or plastic or … you get the idea.

The upshot of this is that I can focus on the balance between “random” and “control” and quickly get this project off the ground producing images (which is the whole point).  If I had stuck with my original idea of doing everything in the graphics myself, I’d probably still be coding up a very basic graphic “engine” and I’d give up because I wasn’t seeing anything “productive” yet.

Probably the next entry I’ll describe how this all works, and some of the other design decisions I’ve made.  Right now, I’ll leave you with a few pictures to give a rough idea of where the project is.

RandI: A collection of random objects. This has no explicit lights.

RandI: A random collection of objects, with a few random lights added.

RandI: A set of objects called Rainbows. Very much like the atmospheric rainbows we know, but with random colours and placements.

RandI: All of the objects, lights and rainbows in the same scene. Notice how they can be added or removed without disturbing the rest of the scene.

While I’m happy with where I am now  – and frankly amazed that I’m still going on this, given previous projects – I’m not anywhere near finished, and I’m not sure I know what I’m aiming for exactly.  I have a lot of vague ideas and directions in my head, but mostly I have to explain them with a lot of hand-waving and “you know”s.

About Lisa

A Geeky Gamergrrl who obsesses about the strangest things.
This entry was posted in Programming and tagged , , , , . Bookmark the permalink.