Sunday, 10 January 2010

Just a quick update

Four months without an update is too long, so I thought I would post a short summary of what I've been up to lately.

Land ahoy!
A few weeks ago I started toying with the idea of creating a terrain renderer, and started working on that. I managed to throw together a prototype in Python rather quickly.

This time I took advantage of OpenGL's vertex buffer objects to store the vertices. Calculation of normals happenes on the CPU, and proved rather costly, especially for Python. Per pixel lighting and texturing were done using shaders. My planned next step was to use pre-generated normal maps to achieve higher detail with less vertices. Quadtree based frustum culling was almost complete, before I lost interest in the project. If I pick it up again, I'll most likely fix the normal mapping and implement GeoMipMapping.


This weekend, I've been playing with Pickover attractors. Pickover's equation can create chaotic fractals with the right variables. The result of this is very fascinating. This application is written in C++ and for rendering it uses, you guessed it, OpenGL. Roughly speaking, it achieves the effect you see in the image below in three steps.

First, it calculates the vertices, about a million, of them on the CPU, uploading these to a vertex buffer. Second, it renders the fractal to a frame buffer with reduced size, then blurs the FBO with a gaussian blur filter. This done, it renders the FBO to the screen and superimposes the fractal on top of that. This creates a very nice glow effect.

Be sure to click the images and watch it in the resolution it deserves!

The source code for these projects will be released at some point in the future.

Monday, 21 September 2009

Dynamic 2D Soft Shadows

I decided to implement the technique discussed in the gamedev article written by Orangy Tang (See the article here).

My implementation is in Python and requires that you have a graphics card that supports shaders and framebuffer objects, as well as having the PyOpenGL library installed.

Since I'm not trying to write tutorials, I'll just explain a bit what i did differently and what obstacles I encountered.

The article by Mr. Tang uses textures for the penumbrae. Even though this works, I found that the edges from light to dark were too glaring for my liking. This was solved using a shader with a sigmoid function to smooth out the edges. Whilst this method might not be creating very realistic penumbrae, it looks a lot better than the texture!

The light itself is also rendered using a quad and a shader, creating a much smoother appearance than the triangle fan used in the article. This should also, in theory, make it faster since less vertices need to be pushed to the gpu.

Another issue was "popping" of the penumbrae, and I could not make the method in the article work properly. After a bit of discussion with a co-worker, the solution was obvious: Create shadowfins in either direction of the original boundary point where necessary. This in turn creates a very smooth transition between boundary points, taking the light radius into account.

Ok, enough of this chitchat. Here she is in all her glory:

The source code is available here.

You can add lights with the left mouse button, remove them with the right. The intensity of all the lights can also be changed with the + and - keys.

The implementation is currently rather slow (but hey, I can't give you _everything_ can I?).

Saturday, 19 September 2009

New blog

I made this blog, basically to have a place to dump source code for anyone to look at. Such as implementations of different (most likely) game related stuff.