Saturday, April 22, 2006

As some might have noticed, I haven't updated the blog for some time now. The reason is that I'm on vacation in India with my girlfriend. I'll be staying here for three weeks so there will be no coding for a while:)

I just wanted to thank everybody who have left comments and sent me email. It's very encouraging and makes me want to keep on going!

In a few hours we're leaving for Kerala. It's supposed to be a real paradise and I think we'll have a great time!

Monday, April 10, 2006

Yesterday I did a quick test of grass rendering.
The grass waves slowly in the wind and is rendered as thousands of camera facing billboards. The nice thing is that everything is done on the GPU. The billboards are stored in one single static vertex buffer and the transformation to face the camera and the animation is done in a vertex shader.
I'm also using a neat trick to "fade" the grass out over distance without the need of alpha sorting.

It's not that good looking right now, but it's just a quick test. Putting it on real terrain with more variation of foliage and good texturing and lighting will hopefully make it look better.

Friday, April 07, 2006

I got stuck when trying to redesign my engine to better support materials that depend on multiple render passes. So I started working on a cloud system instead:)

The system if fully dynamic and the clouds move and deform. The lighting is a (rather) simple trick but looks quite nice. I got the basic idea from an article by Michael Gehling in last months GDMag. I just modified it to suit my needs. The main problem I have is that it's very hard to tweak the system to look good in all situations. Settings that look good at dawn look crap at noon and vice versa. But I think I can solve that by interpolating settings over the day-night cycle.

Another problem is that things are getting rather costly as you can see on the fps counter:) So far I've done no optimizations what so ever so I think I can squeeze quite a few more fps out of this baby.

Here's a few new screenshots:




Tuesday, April 04, 2006





I've added water to the engine. So far there's only reflections but refractions are coming up.

Now I need to render the scene multiple times per frame. The geometry that is going to show up in reflections is first rendered to a texture. This texure is then used in a second pass where the scene is rendered as normal but the reflection texture is projected onto the water plane. The same has to be done for refractions. The reflection pass is done with a lower LOD setting to increase speed, and the distortion of the water makes it very hard to notice the decreased LOD anyway.

I'm not totally happy with the way these multiple render passes are handled by the engine, so I think I have to redesign a bit. That's why I left out refractions for now.

Monday, April 03, 2006





For the second assignment in the ASR course we took a dive into the beautiful world of Global Illumination.

We had to write a Monte Carlo path tracer. The math is a bit involved but it all boils down to a very simple algorithm. Take a loot at this slide for more information.

What you gain in simplicity you loose in speed. Since we approximate the rendering equation with random sampling (Monte Carlo integration) we need to sample a lot to reduce noise. The first image was redered at a resolution of 1024 x 1024 with 625 samples per pixel. It took 72 minutes to complete. The second one uses 2304 samples per pixels and took about 6 hours to render:)

I really like the second image. Note the caustics formed by light passing through the glass objects. Quite pretty! Kudos to Jesper for setting up that scene!

Thursday, March 30, 2006

I've completed the atmospheric scattering implementation, and now the terrain is also affected by the scattering. Here's a few screenshots:




Wednesday, March 29, 2006

I'm working on a fully dynamic sky system. It's far from finished but I couldn't resist uploading a teaser screenshot:)

The system simulates atmospheric scattering, i.e. the effect of sun light scattering in different directions as it hits particles in the atmosphere.
This is what makes the sky blue at noon and red at dawn.
The method is described in this paper.

The sun in the picture is not a skybox or a billboard. It's a direct result of the scattering simulation!

I'll get back with more info as soon as I get this working perfeclty.

Tuesday, March 28, 2006






Good procedural terrain texturing is not easy to achieve. That I learned yesterday.

In the old screenshots I used only one big blurry color texture and one detail texture. This wasn't very realistic since all types of surfaces used the same detail, resulting in for example that grass did not look like grass if I used a rock texture.

Now I use one argb detail texture per surface type and blend them together using a blend controller texture in a pixel shader.

The hard thing is to generate the blend texture. I've made a small tool that generates the this texture based on parameters in the heightmap like elevation and slope. However the result is not as good as I would like. But post-processing the texture in photoshop yields acceptable results;)

Monday, March 27, 2006






Jesper and I have finished the first assignment in the "Advanced shading and rendering" course. We were given an unfinished raytracer and had to implement shading, shadows, reflections, refractions and super-sampling.

We had to implement at least one super-sampling scheme but we decided to make a comparision between a few schemes and ended up implementing uniform grid, stratified grid and adaptive. The latter is especially intresting since it tries to distribute the rays over the pixel area in a optimal way, resulting in good image quality and fast rendering.

The top screenshot shows the test scene rendered with 5x5 uniform grid super-sampling and the bottom shot is a close-up comparison between different sampling schemes.

Saturday, March 25, 2006

Today I extended the engine with support for vertex and pixel shaders.

Right now I have support for shaders written in HLSL but to the engine shaders is an abstract concept so there is nothing stopping me from adding support for other shading languages like Cg and GLSL transparently in the future.
Shaders are integrated into the effect/material system and I have a clean and simple interface for setting shader parameters from the engine. I intend to add support for automatic passing of common parameters like transform matrices to the shaders. Using shaders will be almost as easy as using the fixed function pipeline.

The terrain in the screenshot is rendered with per-pixel diffuse lighting and fog, using a pixel shader. In this kind of scene there is not much visual difference between per-vertex and per-pixel lighting, but when the sun is moving it's more apparent. Also the per-pixel fog is a lot smoother.
I use a slightly reddish sun color to give the impression of late afternoon lighting.

Now, with shader support in place, I can start doing some cool stuff :)

Thursday, March 23, 2006

I've done some minor improvments to the engine.
I added collision detection with the terrian so that the camera alywas stays on the ground.

I have also begun coding on a light management system. Until now I have hardcoded the sun into the renderer but now I have a more flexible system that handles unlimited (sort of) number of dynamic lights. Still need to add smarter culling of the lights though.

Wednesday, March 22, 2006

Since I have a lot less to do in school now, I've started working on the engine again.

Today I finished the terrain LOD system. I'm using the popular GeoMipMapping technique and it works very well. To the left you can see two screenshots taken from the same viewport. The top picture shows brute-force rendering of the terrain and ~2 million triangles are drawn. In the bottom picture the LOD is activated and only ~45k triangles are drawn. That's only ~2% of the original triangles!

It's pretty hard to see any difference in the pictures, but if you look at the distant mountains you are able to see that the bottom picture misses some of the detail.

When the camera is moving it's sometimes possible to notice some popping when the terrain patches changes LOD but still I think the result is quite good for such a simple technique.

Sunday, March 19, 2006

The last few days I've been writing a simple I/O library in x86 assembly for a course at uni.
We had to use the GNU assembler and debugger. It's not my idea of fun to use command line tools like that ;) It was a pain in the butt in the beginning but I got used to it quite quickly.

The GNU assembler is a bit different from other assemblers like MASM. It uses different directives and instruction syntax. The instruction parameters is reversed and you have to use the %-prefix for registers.

movl eax, ebx

becomes:

movl %ebx, %eax

A bit anoying at first, but the parameter order actually feels more natural to me since I used to do a lot of MC68000 coding.
It's been a long time since I did this much assembly coding and while it's fun to optimize small routines, it's mostly annoying to write longer programs ;)
It's a good thing that high level languages gives us enough speed nowadays.

Wednesday, March 15, 2006

The exams are finally over!
I haven't got the results of all of them yet, but I think I passed them all.

Today, I had the first lecture in Advanced shading and rendering. The lecturer is Tomas Akenine-Möller, one of the authors of the legendary Real-Time Rendering. That's pretty cool. I have high expertations of this course, and I don't think I'll be disappointed.

In this course we're using C++, so no more Python for a while! That's a good thing:)

Tuesday, February 28, 2006

We have released our Bomberman clone! One minute before deadline:) It's not fast, it's not perfect, and it's certanly not bug free. But considering that it was put together in more or less one weekend we're very happy with the result.

You can check it out and download it here.

You can take a look at the work of the other project groups here.

Monday, February 27, 2006







I've been working quite hard with the bomberman clone this weekend and we're getting there. I've done collision detection, physics (ODE), lighting, sound, and a some of the game play.

The engine we are using had some support for collisions with static geometry and ODE objects. But for dynamic objects like crates, bombs, players and powerups, I had to do it myself. I went for simple boundingspheres and sphere-sphere tests. For the bombs I'm using simple line segment-sphere tests. Simple and efficient.

Now there's only characters, AI and some game play left. But thats Jespers job so now I can focus on the other projects.

Friday, February 24, 2006







The bomberman clone have to be finished till next Wednesday. Way to little time. Especially since I have projects in the other courses to finish as well. And there is not even two weeks till the exams. I have no idea how I'm going to make this!

Anyway, I've done some more work on the particle system. Now it can do a lot of stuff. A lot more than we need for the game, so you could argue that I wasted some precious time there. The good news is that I can port it to my C# engine in no time.

The screens shows the system in action. Pretty nice explosions with fire and smoke.

Thursday, February 23, 2006

Tonight I enhanced my particle system in the Python engine we're using for the Bomberman clone we're making. In the screenshot you can see my first attempt to use it for the bomb explosions. One of the most important parts of the game:) Pretty neat!

Tuesday, February 21, 2006

I and Jesper are making a simple Bomberman clone in 3D as the mandatory project in the Game Engine Technology course. We put up a very simple project web page here (in swedish). You'll find a list of all this year's projects here.

Thursday, February 16, 2006

I threw together a lame particle system in Python for the Game engine tech course. I can't even count the number of times I ended a statement with ';'! Not that Python cares but it's not supposed to be there:)
I am using far to many programming languages in parallel right now. I wish they didn't try to teach us every damn language in the world at uni ;)

Game engine technology: Python
Web programming: Java, Perl (and the zillion markup languages that don't count)
Computer organization: MIPS and x86 assembly
...and ofcourse my engine: C#

I better improve my syntax switching skills...