Perlin Noise: The Internet Lies

Perlin Noise

Perlin Noise

A while back I started experimenting with some procedural techniques, more precisely I wanted to create a procedural terrain using Perlin Noise. I had never implemented Perlin Noise before so Google to the rescue. The first decent article I came across was this tutorial. Without going into too much detail, it explained how I should combine noise functions with different frequencies and amplitudes to produce “Perlin Noise”.

My first attempt failed, producing complete random noise. After confirming that I followed the tutorial accurately I set out to find more tutorials. Everything that I found seemed to be similar: combine noise at different frequencies and amplitudes. In the end I did indeed get some working “Perlin Noise”…or so I thought.

It was about a year later and I am in my Honours Graphics class at University one Friday night when my lecturer begins explaining the process that one follows to implement Perlin Noise. At first I thought I could sit back and relax, then I started to realise that I had no idea what my lecturer was talking about. The process was entirely different to what I had learnt! There was no talk of the octaves, frequencies and amplitudes and the methods of combining the noise like I had learnt – needless to say, I was completely confused. At this point I decided that I would take a detailed look into Ken Perlin’s online notes which is where my lecturer got all of his sources from. After wrapping my mind around the algorithm, I continue with Ken’s notes on different methods of applying the noise. One of the strategies that Ken Perlin mentions he calls Fractal Noise – this being the process of recombining the noise produced by the Perlin Noise function in different frequencies and amplitudes – just like I have read before!!

So!! – what many many people on the internet are calling Perlin Noise – is actually not Perlin Noise at all. It is instead the fractal recombination of noise. Furthurmore the noise function that everyone seems to be using is either some small custom random number function or just the programming language’s built-in random number function – meaning that once again that NONE OF IT can in any way be called Perlin Noise.

It seems that some of these tutorials and explanations have been on the internet so l

ong that it has actually convinced a large amount of the population that this fractal combination of noise is what Perlin Noise is – and thus more and more of these tutorials are appearing.

This blunder, this blatant lie is a dishonour to Ken Perlin and his work. The word needs to spread – so share this with everyone you know!!

The Whitted Scene

At last! My recent graphics practical has had me doing work in the realms of elementary ray tracing (ie: Whitted Ray Tracing). It is the first time I have ever worked with ray tracing concepts and I must admit that they are quite simple.

Recursively bouncing rays around a mathematically described scene is far simpler than the endless transformations and steps that one has to worry about with rasterisation…and the results complete with perfect reflections and refractions speak for themselves:

The Whitted Scene

The Whitted Scene

When this algorithm was developed some 30 odd years ago, it took the technology of the time 74 minutes to produce the above image. Today it takes less than a second 🙂

m2Work Challenge

I always love a good challenge. The latest is the m2Work challenge. It involves coming up with ideas for mobile microworkers focused in developing countries.
There were 944 ideas submitted and one of mine was chosen as a top six finalist (still not sure how I managed that)…of course Murphy had it that I should get the news in the last 5 minutes of an AI lecture – so as one would expect, I heard nothing of what my lecturer said in those last 5 minutes :-).

Now comes the real work. Slides, Elaboration and a video – all due in a shockingly short period of time, thus I will have to juggle this and my Honours work quite delicately … and my Tennis of course (I started playing Tennis with Divan and the rest of the Computer Scientists and Engineers that I am good friends with).

Now back to my graphics prac…

Honours – Full Steam Ahead

I have my honours project. It is in AI – can’t really say much more about it at this point. The lack of posts has been due to the insane amount of work I have (the entire year could easily be filled with AI and Graphics).

I am going to try and squeeze in a nice game project in collaboration with Divan Burger (see blogroll) – will post details soon 🙂

New Year, New Possibilities

It has been a while since my last post. Surprisingly I have had a fairly busy holiday. Been working on a project that I am keeping low-key for now. My web-design skills (or lack thereof) got some practice these past few weeks as I have developed a website for my parent’s business (see In the process I decided to play around a little with Microsoft Silverlight. I already had a little bit of experience with it from the perspective of Windows Phone 7 – but never developed a application from scratch with it. The results can also be seen on the website mentioned above (see Spec Query page).

This year (Happy New Year!) has the potential to become quite busy. I have already got queries from students asking when the weekend programming classes I give will be starting again (when they do, be sure to check back for some tutorials and challenges). I also have mentor duties this year at the university which should be interesting.

This is all of course happening over and above my honours studies. I am planning to choose an interesting and challenging syllabus made up of Artificial Intelligence, Computer Graphics, Computer Networks, Distributed Computing and Generic Programming. Can’t wait to start :-).

Cellular Automata and Swarm Intelligence

I have been playing around with HxCAS a little bit today in preparation for a demonstration the team and myself are giving tomorrow. For a while I have been wanting to write a small CA program that demonstrates some very simple swarm intelligence. Today I finally got it working 🙂

The program is quite simple. The goal of the swarm agents are to locate a beacon. So the agents will randomly roam about looking for any beacon. If they find a beacon or another agent which has reportedly found a beacon then they will stop and report the found beacon. (Thus they can tell any other agents in the vicinity that they found a beacon) While the agents roam about they have the potential to crash into each other (which will result in one of the agents being lost)

I have added the world (complete with rules and colour settings) to the newly created Downloads page. Feel free to play around with it. Note that you will need the latest version of HxCAS to run the compile the rules as I had to add a function the the standard library to get it all working nicely.

Google Analytics – There is always a price

I track the hit count of this Blog with Google Analytics. It is the first time I am personally using the service and so I will share my thoughts thus far about it.

Firstly it is simple enough to add to your website. Just register on the Analytics web site, add a bit of Javascript to your site and you’re off. There is a simple WordPress plugin that I have used for this site that adds it for you and thus all you have to do is specify the unique identifier that Google gives you when you register.

It seems to take a while to kick in but before you know it all the collected data can be viewed on the Google Analytics web site. When you log in you are confronted with a control panel (more like a reporting/statistics panel … thing). You are able to view all sorts of metrics – such as the location of your visitors and the time the spent on your site. You can track which other sites have provided the web traffic to your site. There is also a handy little tool (in beta at the time of writing) which allows you to view real-time statistics of your site.

There are however some things that I am unhappy with (which is expected – you can’t please everyone). First of all the default date range never seems to include the current day. You can of course select different pre-defined date ranges such as “today” but this is all unnecessary clicking that could have been avoided. Another problem is that there are many…and I mean many different metrics that can be customised and added and removed and changed – it is all a little overwhelming especially considering there are no clear guidelines on how to use some of the metrics or what they even mean. However the most irritating thing to date is trying to filter your own traffic from being logged. In some cases in can be simple, such as simply excluding an IP address. This is however South Africa – all us home internet users have dynamic IP addresses assigned to us by our ISP and this makes it very difficult to try and filter the traffic. Other methods include dabling with the Javascript and adding cookies to the machines that you expect to access the site from – not at all ideal.

Today however I had an idea and searched for a browser extension that could block Google Analytics scripts from running. First it was Hallelujah as Google makes there very own “Opt Out” plugin from Chrome. I never got round to installing it though since the most voiced complaint was that you cannot specify which sites you want to block – it is the all or nothing approach. I expected more from Google at this point. However I didn’t give up and continued the search. I quickly came across another plugin (Analytics Blocker) that did exactly the same but (drum-roll) – allows one to specify the sites. I had a little bit of trouble with the wild-card specifications since it didn’t always seem to work, but I think I have it sorted. I have been viewing my real-time statistics on Google Analytics and it now seems to work.

I think I have ranted enough now (feeling much better)

Use cases – Menace or Miracle

I am sure I can say that any programmer who has been involved in any sort of formal software engineering will agree with me when I say that the process of formalising a system in documentation is tedious and boring. In many cases it has been found that too many resources has been spent on documentation for the benefits it has brought about which is why agile development methodologies have become more and more popular.

However, it doesn’t matter what type of methodology you are using when developing a complex system, there is still some documentation that always seems to exist. The first is of course some sort of requirements specification. History has shown that incomplete requirements is one of the main reasons software projects fail. The next piece of documentation that seems to always exist in one form or another is some sort of behavioural overview of the system that depicts how users interact with the system. This is normally shows the goals that the system needs to accomplish. In agile these are normally user stories. Similar to user stories are use cases which are depicted using use case diagrams and explained using use case narratives. During this past year (with the final year project) I had become tired of use case diagrams, at one stage I was basically eating and breathing them.

I am currently developing a complex system. I am the only developer and I know what the system needs to do. I couldn’t believe my own surprise when I ended up drawing use case diagrams for the system on my whiteboard. They just seemed to capture the essence of what the system needs to do and how it interacts with the users. Normally I would start hacking away at a new software project of mine, but here with one that I hope to expand to sell one day I just felt more comfortable in formalising in what the system will do – it provides a measure of confidence. This sort of documentation has always accompanied a fear of “what if I forget something”, but now I see that this is forcing me to actually take some time to think and brainstorm of absolutely everything.

So, is all this planning and formalising a system a complete waste of time – probably not. There is an entire industry that will probably back me on that answer. I know how frustrating it can be sometimes, especially for those doing these sorts of projects at university for the first time – trust me when I say that it is all done for a reason.