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:)