Featured demo – Konami/Raze

Today’s featured demo is Konami/Raze by PlayPsyCo.

3 things about the demo download:

  • You need to work with RAR file, as opposed to a ZIP file. Try RarZilla.
  • Doesn’t work on Microsoft Vista
  • Your ATI graphics card renders only grayscale

Now that unpleasantries are out of the way, let’s get on with it. What do you mean you haven’t downloaded the demo yet? Do that now. It’s about 160 KB and 4 minutes in length.

3 points to take note while watching:

  • Constructive solid geometry or CSG
  • Cel shading or cartoon style rendering
  • Shadow rendering

At the start of the demo, there’s a note referring to CSG or constructive solid geometry. It’s a way to build 3D models. An example in the demo is the cube with a square hole in each side. Let me show you how it works. First you have a cube.

CSG cube

Then you stick in stuff, like cylinders (the demo used cuboids).

CSG cube with cylinders

Then imagine the cube having a positive trait, and the cylinders a negative trait. And the cylinders “cut” into the cube. Then you render only the positive parts (so the cylinders disappear). The result is this (I rotated the cube a little to better show off the result):

CSG cube without cylinders

Here’s one where a negative torus (that’s donut for the non-math people) cuts a positive cylinder. Can you see where the torus is?

CSG cylinder without torus

Basically you construct the 3D model by cutting basic geometric shapes such as cuboids, cylinders and spheres. You can also merge shapes together. For example, you can stick 2 half spheres to the ends of a cylinder to get a capsule.

Next up, you should have noticed the cartoony feel of the demo. This is brought to you by means of cel shading. There’s a web site dedicated to this. I’ll refer you to an article which can explain cel shading better than I do. And here’s the supporting source code.

The best use of this technique was in Okami, a Playstation 2 game. I was awed by the use in rendering brush strokes in a 3D scene. You have to check it out. That game was just beautiful, the music authentically ancient Japanese, and the dialogue funny.

Lastly, the use of shadows. You never really think about shadows until they’re not there because the sense of depth is missing. Real-time shadow calculation is very intensive. I haven’t implemented any technique before, so I can only point you to some resources. Simulation of natural phenomena doesn’t seem so easy now does it?

Have fun!

Featured demo – Concentrate

I’m starting a series featuring demos. If you don’t know what demos are, bring yourself up to speed with 5 of them.

Demos are multimedia applications combining programming, art, and music. There might be a storyline, an artistic direction, a showcase of physics concepts or even a statement by the creators. Plus they’re just fun to watch.

2 facts I’ve gleamed from watching demos. Sometimes, if there are text in the demo, and you want to read them, be prepared to watch the demo over and over again. Because the text will generally appear for split seconds. Second fact, “greets” or “greetz” refer to greetings or salutes by the creators to other demosceners (or sceners).

We’re not going to just watch demos. We’re also going to analyse them. Let me just give you the demo first. It’s “Concentrate” by Adapt. It was submitted to the Breakpoint 2008 demo event. Download it. It’s about 15.4 MB in size and about 5 minutes in length.

Keep these 2 points in mind while watching:

  • The sparks waterfall – collision detection, physics, gravity.
  • Texture in texture.

The technique used in the 2nd point goes like this. You render a scene onto a texture. Then you add an object, map that texture onto the object, and rerender the scene. Let me show you an example. Say I have this scene:

Texture scene

I render the scene onto a texture. In this case, I saved it into a bitmap. In the demo, it’s saved in memory. Then I created a cuboid and mapped the texture onto it, and then rerendered the scene.

Texture scene mapped

One characteristic of demos is that you usually have to watch them a few times to truly appreciate the beauty, the art and the skill used to produce it. Feel free to space your demo viewings.

Then tell me your experiences in the comments. What did the demo make you feel? What did you notice? Can you recreate a certain effect? Can you figure out how you can code certain parts? This is like an open homework project, so let’s discuss!

Reusable code not important

We’re moving faster. Technology advances. Businesses change. New services emerge. It’s not how much better you are at reusing code, but how much better you are at creating new code that’s of value.

It’s a new program, with new logic

Someone once said that his team seldom reuse code, because they almost certainly have to rewrite most of their existing code. Their new program will need new logic and a different way of optimisation.

I’m talking about demos. I can’t remember if it’s ASD, or Conspiracy who said that. Or maybe I read it in a Hugi magazine.

Once you get past the standard texture, music and 3D geometric mesh/object loading, it’s down to the new and creative code. And new and creative code doesn’t come from reusable code. Code used to create a special effect in one demo, might not be transferrable to another demo.

Businesses change

And so does the business logic. My users think of new ways to conduct business all the time. New services, new forms of price plans and new ways of interacting with data.

I develop .NET web applications for them. Like a good programmer, I separated web pages from business logic code. Then I realised that I’ve never used any function related to business logic more than a few times in an entire web application. That business function had a specific use, and so was inappropriate for code reuse, because you can’t reuse it!

To stay competitive, businesses have to change. They’ve got to keep innovating and keep providing more value to their customers. Programs written for one service might have to be rewritten to take advantage of better tools, or refactored to remove useless parts, or even replaced by a new program specifically written for a new service.

Innovation versus APIs, components and the like

Innovation means new ideas. So it means new code. Sure, you could come up with a new idea by combining two or more existing ideas. Existing code could still be used. Fair enough.

Then you come up with another new idea, based on that combo idea. And another based on existing ideas. Eventually, there comes a point where a new idea is better off being free from any parent idea. The new idea is so completely new that it looks nothing like existing ideas.

That’s innovation. So where’s the code going to come from? From scratch.

Application programming interfaces are meant to be reused. I’ve written custom web controls for reuse. I’ve written Javascript functions for reuse.

But unless you’re specifically writing code for reuse purposes, write code for the intended purpose first. If it’s easy to extend it to a more general form, then go ahead. Forget generalisation if any major reconstruction is needed to make it usable by an unknown number of applications for unknown uses.

I am the sole web developer in my team. I don’t have time to think into the future where I guess what my users might possibly want to do with my applications. By the time that imagined future arrives, my users might want a different feature. So what does that get me?

So should you reuse code or write reusable code?

As with many things, it depends. I want you to think for yourself. Decide for yourself if that piece of code is going to be useful in a generic form. Decide for yourself if your time is better used on writing a feature that provides value immediately.

This decision comes with experience. And programming experience isn’t measured in years, or months. It’s measured in the number of lines of code you write that never see the light of day. (which is an excellent topic for another day…)

In these current times, there are excellent code libraries that take out the drudgery of your work. Your time should be used on creating more valuable code on top of that. Reusable code is not important. Valuable code is.

If you don’t watch these 5 demos now, you’ll hate yourself later

Never heard of demos? Well, start. Because being a polymath programmer means you need to appreciate the expertise and knowledge in making one.

In simple terms, a demo is a multimedia program, where you just watch and listen. There’s usually visual effects. There’s music, usually playing in sync with the visual effects. There might be a story or an overall message. And everything is run in real time, so you’re better off with a speedy processor and an even speedier graphics card.

Why should you watch demos? They represent the coming together of different expertise such as

  • artistic direction
  • software design
  • music composition
  • graphics work
  • 3D modelling (of recent times)
  • programming skills

[Adapting a quote from one of my favourite movies]
Unfortunately, no one can be told what a demo is. You have to see it for yourself.

1. The product

Also known as fr08, this piece of work was created by farb-rausch. It’s actually an intro, a class of demos where the programs have a certain file size limit. In this case, 64 kilobytes. The constraint used to be caused by the platform, but now, it’s mainly to challenge the skills of the demogroup.

This was my first introduction to the demoscene. And I was amazed by how a 64 kilobyte program could generate close to 11 minutes of visual effects and music.

This was accomplished through procedural generation, where part of the code generates the image and music data in memory. Instead of image and music data files, the code instructions for generating them were stored in the program, thus saving executable size (or total bundled zip size). A similar concept to writing code to write code.

2. Heaven 7

Perhaps you’ve seen some 3D graphics movie, like Shrek. The basic technique in a 3D render software is ray tracing, a calculation intensive process.

If you’ve play computer games, you’ll know that superb clock speed and fast graphics cards are indispensable. You might even know how game programmers cut corners so as to deliver visuals that are stunning yet run smoothly on most computers.

Heaven 7, by Exceed, delivers an awesome visual and auditory experience, ray traced and in real time.

3. Instant Zen

Fly through scenes of space, metaballs and clouds. Follow wriggling paint worms and ephemeral ribbons over abstract landscapes and sparkling rivers. Experience instant Zen! Brought to you by Synesthetics.

4. Dream Child

The visuals in Dream Child are stunning. What impressed me more was the music. There’s a harmonious blending of human voices, computer generated sounds and electric guitars.

Look out for the ASD ambigram and unique 3D shark models in Andromeda Software Development‘s other productions.

5. Beyond

Conspiracy, the demogroup responsible for Beyond, invites the viewer to explore the uncharted galaxies. Starting out from behind a small comet hurtling through space, you then flew past nebulae, planets and Saturn’s rings. You’ll witness the scorching surface of a sun and cyclical movement of gases.

Near the end, it’s as if you’re dragged by the scruff of your neck and pulled backwards. You’ll then whisk outwards, away from gaseous bodies, pass more planets, out of galaxies, and finally reach … the part where you have to go download the demo and watch it to find out what happened!