Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks for the answer DangerOnTheRanger and welcome to GDSE. –  Byte56 Apr 13 '12 at 21:08
    
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. ;-) –  Tank Apr 13 '12 at 21:47
    
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. –  DangerOnTheRanger Apr 13 '12 at 21:48
    
Especially CSMs and PSSMs seem to be perfect for me. Thanks! –  Tank Apr 13 '12 at 23:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.