I'm currently thinking hard about how to implement lighting in my game. The geometry is quite dynamic (fixed 3D grid with custom geometry in each cell) and needs some light to get more depth and in general look nicer.

A scene in my game always contains sunlight and local light sources like lamps (point lights). One can move underground, so sunlight must be able to illuminate as far as it can get.

Here's a render of a typical situation: The lamp is positioned behind the wall to the top, and in the hollow cube there's a hole in the back, so that light can shine through.

Example scene

(I don't want soft shadows, this is just for illustration)

While spending the whole day searching through Google, I stumbled on some keywords like deferred rendering, forward rendering, ambient occlusion, screen space ambient occlusion etc. Some articles/tutorials even refer to "normal shading", but to be honest I don't really have an idea to even do simple shading.

OpenGL of course has a fixed lighting pipeline with 8 possible light sources. However they just illuminate all vertices without checking for occluding geometry.

I'd be very thankful if someone could give me some pointers into the right direction. I don't need complete solutions or similar, just good sources with information understandable for someone with nearly no lighting experience (preferably with OpenGL).


1 Answer 1


It sounds what like you want is the standard OpenGL lighting pipeline plus shadow mapping.

In a nutshell, shadow mapping involves rendering the depth buffer from your light's point of view, and then projecting that texture onto your scene. It's a simple technique whose performance is unaffected by complex geometry (since it's an image-space algorithm) - I highly recommend it.

  • \$\begingroup\$ Thanks for the answer DangerOnTheRanger and welcome to GDSE. \$\endgroup\$
    – House
    Apr 13, 2012 at 21:08
  • \$\begingroup\$ Thanks. Like said I've got plenty of light sources, and shadow mapping requires to do a rendering pass to accumulate the depth buffer for each light source, is that right? I guess for the sunlight it somewhat makes sense, but I'm not sure how good the quality will be as it's quite far away to cover the whole viewing distance. For the point lights I was thinking about deferred rendering, because it's O(1). However these are just my random thoughts. ;-) \$\endgroup\$ Apr 13, 2012 at 21:47
  • \$\begingroup\$ There are some shadow mapping variants that are meant to work with directional lights/large outdoor areas: Cascaded Shadow Maps, Parallel-Split Shadow Maps, Trapezoidal Shadow Maps, and quite a few others. You can find info on all of them on the Wikipedia page I linked to. \$\endgroup\$ Apr 13, 2012 at 21:48
  • \$\begingroup\$ Especially CSMs and PSSMs seem to be perfect for me. Thanks! \$\endgroup\$ Apr 13, 2012 at 23:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .