The missing gap (light mapping)

Started by
0 comments, last by Vilem Otte 12 years, 11 months ago
Hi there, recently I have been learning to construct my own 3D engine using OpenTK and C#. Everything is going smooth as pie, I have a great system for using wavefront obj file's, and their material libraries. It correctly handles UV texture mapping / normal data for lighting, and I've even sorted out alpha blending (making sure to order faces correctly). The project uses immediate mode at the moment as VBO's can easily be implemented later, and I just want to focus on learning the theory.

Now it's time to move onto lighting and shadows, I've done a great deal of research into the matter already, and have decided that light maps are the way to go. From my
understanding and research, the following should be right (please correct me if i'm mistaken):



  • A texture providing light data need's to be produced for each mesh.
  • Each triangle on the mesh requires a separate set of coordinates to allow the lumel's provided by the texture to be mapped onto each triangle surface.
  • Shadow's can exhibit jagged edges if the light map is of small resolution, as lumel projection is determined by the pixel centre, not pixel edges.
  • light map coordinate data needs only to be calculated once.
  • When calculating light map coordinate data, the maths must be done using plane projection.


Those of you who are experienced in this area I'm sure already can spot the gap's in my knowledge, but I'm hoping that I am not too far away, and that someone may be able to nudge me in the right direction. Today I found a tutorial on flip code Light Mapping - Theory And Implementation , I think using it, I should be able to eventually understand the things I need to, though I have a few questions that I believe would help me learn a bit faster:



  • Are there any less pseudo OpenGL examples of plane projection that people use, I don't mind the language, as long as it's strong typed (not pseudo).
  • I'm a bit confused on how lights relate to a light map, does this process assume that light's are static, therefore the usage of the light map texture,
    this concept is part of what's confusing it for me.
  • Am I right in assuming that once I understand this process, I should be able to write a GLSL shader to map the lumel's based on the light map texture ID,
    and light UV via a uniform variable or something similar?
  • Finally (and this one is a bit off-topic at the moment), but taking into account a semi-transparent face would not cast such a dark shadow, how would you
    build this into this process? or would the colour information passed to the shader already account for the alpha channel.


Thanks for your time, I understand this is not the most straight forward question to answer, but I value your opinions, and very much look forward to some feedback.

Aimee.

We are now on Tumblr, so please come and check out our site!

http://xpod-games.com

Advertisement
Hello,

definitely implement VBOs as soon as you'll get some time, it is just a matter of few hours and it will save you a lot of pain :).

Lighting and shadows are quite huge area of rendering. Lighting can be divided to two main parts - direct lighting and indirect lighting. As indirect lighting methods are quite complicated I won't recommend learning them now, it will be time to learn them later. On the other hand direct lighting can be divided to again two parts - static lighting and dynamic lighting (as a matter of fact, indirect lighting can be also static and dynamic, but well ... lets forget indirect lighting for now and leave it to future).

Static lighting can be achieved using F.e. light maps, they're not as easy as they seem to be, they can begin to be overcomplicated when it comes to unwrapping mesh to texture. Try rather to do base dynamic lighting, it is a bit easier to do. Also light maps are a bit outdated right now and they're not so common in modern game engines.

Dynamic lighting can be computed using immediate mode lights, or shading languages (I recommend learning shaders, and trying to do lighting in them). Of course once you do your first dynamic light, you should continue and learn what is deferred shading and forward shading. How to work with them, try both of them, etc.

Shadows are another topic and they're much harder to achieve. There is no absolutely robust solution in rasterizers, you can use shadow volumes (but well... they're not so good), or better shadow mapping (that can be very robust). Both shadow mapping and shadow volumes can be extended to work properly with semi-transparent objects, to be soft shadows, or even properly physically plausible.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

This topic is closed to new replies.

Advertisement