Torch Experiments

I was experimenting with lighting effects in Amberfell today, trying to get my head around opengl lighting commands. I was playing with various light positions when I stumbled over one that looked a bit like the player was carrying a torch. A few adjustments gave the results in the first video here:

I quite like the idea of having a torch at night to light your way. However I wasn’t happy with the rendering of the light. Because the game is voxel based (cubes) the lighting looks chunky. Opengl calculates light on each vertex rather than across the objects, so the square face of a cube generally has the same light intensity all across it. To make it smoother I subdivided each top face of the terrain cubes into four smaller ones. The result is in this second video which you can see is a bit smoother.

Because the game is isometric and all the squares are skewed I wondered if dividing each cube’s top surface into triangles would give a better effect. I tried it and thought it looked worse than the previous method:

Finally I tried subdividing the top faces into 9 smaller squares. I did something wrong with the textures while doing this but even so you can see that the lighting looks a lot smoother.

However this comes at the expense of having 9 times as many vertices to render so that will have an impact on performance. The four subsquare method might be a good balance if I decide to stick with this kind of lighting.

Permalink: http://blog.iandavis.com/2012/04/torch-experiments/

Other posts tagged as amberfell, projects

Earlier Posts