Thursday, December 14, 2006

Going sloooow.

Since I just have a few hours a week to spare for engine coding, not much is happening atm. I simply have too much in school.

That said, at least I'm doing some progress:)
I have a nice and flexible GUI system up and running. It works pretty much like the usual winforms stuff (or any other GUI:)) and I have the most common controls implemented.
It's fully skinnable and easy to customize and extend. Since I'm too lazy for drawing my own skin, I "borrowed" a texture from this guy:)

I plan to add some more stuff (including 360-controller support) and polish the code and make this public with source and all. Probably some time after Christmas.

Hopefully they don't add GUI support to XNA too soon. Would make all this pretty pointless ;)

Thursday, November 09, 2006

I have begun coding on my new engine, entitled NebulaX.
Today I threw together a simple text rendering component and started working on a complete GUI library. Most stuff is directly ported from my old engine and altered to fit the pretty cool game component and content pipeline stuff in XNA.

I've also got myself a XBox 360 gamepad for my PC. Need that to test my input code.

A few days ago I found a cool open source project: Mono.XNA, witch is going to be an implementation of XNA using Mono and Tao.

So, all you "I-use-C++-instead-of-C#-since-I-want-platform-independence" people, stop whining and start using 21th century technology:)

Monday, October 23, 2006

Long time, no see.. erhm.. update.

I haven't worked on the engine for quite some time now. I've had lots of other stuff to do.
This semester I've taken a course in mobile computer graphics. A really great course that have given me a lot of useful knowledge about graphics hardware.

In course we had to do a mobile game project using the M3G (JSR-184) Java API, and once again I teamed up with Jesper Ek. We decided to do something different and we ended up doing a OpenGL accelerated J2SE implementation of M3G. There was a competition to award the greatest game. We obviously didn't win, since we didn't make a game:) We received a Technical Achievement Award, however. The jury consisted of people from the industry, including folks from Sony Ericsson, TAT and LUGG.

You can check out the project here, and the other game entries here (some are really cool!).

What about my engine then?

It's discontinued. Yep. Discontinued.

I have decided to not develop it any further and instead start on a completely new engine using Microsoft XNA!

My old engine was 100% graphics API independent and that's of course a good thing. However, being a single developer with very little spare time, that resulted in slowing down the project considerably. By selecting only one API, I will be able to speed up the development and focus on the cool stuff.

XNA is of course the obvious choice.
It still lacks some important functionality, but I'm very confident that that will be addressed when it's finally released. Micsosoft seems very serious about XNA and I think it has a bright future.

And yeah, I've "upgraded" to the new Blogger beta, so I changed to a new blog template. Sweet.

Saturday, June 17, 2006

Today I added refraction to the water. Pretty standard stuff where the reflection and refraction textures are blended together based on the fresnel term.

I've also improved the texturing a bit. If you look at the second image in my last post, you can see that the terrain at "medium" distance from the camera is blurry. I now use yet another detail texture in this region and the result is that the terrain appears to have detail at all distances.

Tuesday, June 13, 2006

Well, It has been a while since I had time to work on the engine, but today I had some time left.
A few days ago a found a tool called L3DT. It's a very cool and capable terrain generator and it inspired me to improve the texturing of the terrain.

Near the camera I use the same splatting technique as before but the textures are tiled at a much higher density so the ground look really highly detailed even if you look straight down. This ofcourse causes ugly repetition patterns further away. To hide this I blend in a large (1024x1024) color texture on terrain far from the camera.

I've also changed from vertex lighting to a normal map. This makes the lighting independent of the LOD and reduces popping artifacts. It also makes the distant terrain look more detailed.

I use L3DT to generate all texture data I need, since it does that a lot better than my own hack;)

Friday, May 26, 2006

Well, Jesper and I have finished the final assignment in the ASR course. This time it was about shadows.

We implemented both shadow mapping and z-fail shadow volumes. All done on the GPU. The geometry needs to be preprocessed for shadow volume extraction to work entirely on the GPU.

The shot shows "soft" shadow mapping with 3x3 PCF.

Nothing special, but I have to fill my blog with something when I don't have time to work on the engine:)

Btw, my lecturers got their paper "High Dynamic Range Texure Compression For Graphics Hardware" accepted to SIGGRAPH 2006. Really sweet stuff!

Tuesday, May 16, 2006

Well, I'm back from India. It was a great vacation and it feels a bit strange to be home, but I guess it's time to get back to normal life.

The image is a shot from an ocean water simulation I did for an assignment in the ASR course. It features two superpositioned Gerstner waves calculated in a vertex shader.

In the pixel shader I use three scrolling normal maps to add fine detail to the water. There's also cubemap reflection and refraction with fresnel terms. Finally there's a simple HDR hack to add some shininess to the highlights.

When I have time to work on the engine, I'll probably update the water with a similar approach.

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


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...

Tuesday, February 14, 2006

I have been working on the GUI system for a few days now. It's not complete, but I have what I need for now so I put it aside temporarily and started working on the terrain again.

I added simple multi texturing: one base texture stretched over the whole terrain and one tiled detail texture. The result is not as good as splatting but I think it looks suprisingly good. I guess I'll have a look at splatting when I have shaders implemented in the effect system.

I have a lot of stuff to do in school so guess I need to put the engine aside this week and get some 'real' work done ;)

Friday, February 10, 2006

The GUI system is slowly emerging and today I added panel controls. All controls are skinnable. They are composed of a set of pieces that are read from a skin texture. As you can see in the screenshot I can set alpha and color individually. The nice drop shadows are slimply an alpha channel in the texture.

Wednesday, February 08, 2006

I have begun coding a GUI system for the engine. The first thing to be completed is ofcourse text rendering. The fonts are simply textures created by this nice little tool and each character is rendered with a textured quad. Using a single font I can render texts in different color/alpha/size and use different aligning.

And yes, there are text in the old screenshots too but I cheated using D3DX fonts;)
I'm trying to keep things API independent, remember?

Monday, February 06, 2006

I like Perl.

Normally I'm an OO purist. I also favor the C-family-style syntax. This is why i love C# and dig C++. But perl is fun. Just fun. And also quite brilliant.

Consider the UNIX command cat. It reads from standard input OR from files specified as arguments and outputs the content to the console.

In perl you could implement a basic cut command like this:

foreach (<>) { print; }

That's it. Try to do the same in C/C#/Java/whatever and you'll end up writing quite a few lines of code. Another example: the UNIX command sort.

foreach (sort <>) { print; }

Bloody brilliant. The cool thing about perl is that it makes easy stuff really easy. I wouldn't use it to code larger programs but for simple suff it's amazing. Also the code tends to get quite hard to read so it's not something I would use in team development:)

Again, coding in perl is fun. When you have tried the basic stuff it almost becomes a sport to write as little code as possible. And as you can see, perl is good at doing a lot of stuff in few lines of code.

Sunday, February 05, 2006

I just added texturing to the effects system. Nothing fancy, but at least my test scene looks a bit nicer :)

At the moment I'm taking a course called Game Engine Technology. Game physics is a part of the course and today I and Jesper (who also is coding a nice engine called Milk) played around with ODE (Open Dynamics Engine). In the course we use a simple game engine written in Python and we used a wrapper for ODE called PyODE. I'll have a rant about my thoughts on Python in another post, but the short story is that I'm not very fond of it.
However, using ODE worked like a charm and we got some nice ridig body physics up and running in no time since most of the stuff were already there in the engine. It's amazingly fun to throw boxes around and watch them collide and respond in a realistic (well, more or less) manner :)

Thursday, February 02, 2006

Today I started working on an effect/material system. It's inspired by the most common effect formats, CgFX and DirectX Effects. Think of an effect as a kind of high level shader. It encapsluates the whole rendering process for a specific visual apperance. An effect is devided in a set of techniques. A technique is a way to render the desired visual effect. A technique is then devided into passes. This is indeed very flexible. For example, imagine a human skin effect. Close to the camera the effect uses a technique that renders using costly vertex and fragment shaders and/or multiple passes that gives a very high visual quality. Farther away, the effect uses a cheeper teqnique with a single pass and cheep shaders at the cost of visual quality. But since the camera is now far away from the object the loss of quality will not be noticeble. All this is encpsluated in the effect.

The screenshot shows a simple test of this effect system. The sphere is rendered with a single effect that uses a two-pass technique. The first pass just sets the diffuse color to red and fillmode to solid. The second pass uses a yellow color and wireframe fillmode and depthtesting disabled.

So far it's all very simple, but now I have something to build on =)

By the way, I downloaded the new IE7.0 beta and kind of liked it.
Until I tried to edit my blog that is. It simply won't work. Luckily there is firefox=)
But it's still in beta so I guess I shouldn't be to harsh...

Tuesday, January 31, 2006

Well, I think it's about time to write my first post on this blog!

There is much going on right now. My girldfriend is in India and doing her practice for her social work education. You can find her travel blog here (in swedish). I'm still in Lund and taking three courses at the university and I have started working on my C# 3D-engine 'Nebula' again.

The engine is written with 3D API independence in mind. Why, you might wonder. Most people tend to use Managed DirectX in the .NET world and that is ofcourse the most sane thing to do if you want to ever finnish your project :) However, I see this as a learning process and I don't want to constantly be temptated to take the easy road and use the goodies of D3DX utillity classes. By making it API independent I force myself to write everything myself! This ofcourse is not a philosophy I usually follow, but for learning stuff I think it's essential to do it all by yourself!

Up to this point, I have written a lot of boring plumming code like window management, scene graph management, resorce managment, vector and matrix math etc. The screenshot here is probably the first produced by this engine that is even a little bit intresting =). It features a heightmapped terrain with 1025 x 1025 vertices and simple Blinn-phong lightning. The terrain is divided in chunks of 65 x 65 vertices that are part of the scene grapth and culled against the view frustrum. I'm currently working on a GeoMipMapping implementation (LOD).

Well, thats about it for this time!